Fish On, Fish Off: Part 2
In ELJ's January/February 2001 issue, I described the installation of an open-source home automation CGI Sparkler, a home-automation product, on a desktop Linux machine. This article describes installing Sparkler on an embedded system using the popular embedded Linux distribution, Hard Hat Linux (HHL). Given the diversity of embedded boards available today, I chose to make the article as useful as possible by giving detailed information about the principles involved in setting up an embedded system. This should prove useful regardless of which embedded system you select.
In order to keep the implementation applicable to the greatest number of embedded systems, I chose to limit the size of installation to 1.44MB, so it will fit on a floppy disk. This requirement will accommodate embedded systems with severe resource limitations.
Booting from the floppy disk is akin to booting from the EEPROM in a diskless embedded system. The main difference is the logistics of moving the prepared image to permanent memory in the particular device and instructing the device to boot from that image. Though it may seem like a logistical nightmare to move a Linux installation image to an embedded system that does not have a hard disk drive or a floppy drive, most embedded systems contain the necessary utilities and software programs to facilitate the installation onto the device of choice. Usually, this consists of a device boot-time utility that facilitates loading the image to the device via TFTP to the necessary memory location of the EEPROM.
Since we are trying to run Sparkler on an embedded device, it is necessary to use a CGI-capable web server with minimal memory and disk-space requirements. For this purpose, I chose thttpd (see Resources), a popular low-resource, high-speed web server. It is necessary to configure and compile the thttpd package to create a binary for inclusion into the RAM disk image.
Since the lightweight C library included with HHL does not support the C library getpwnam function, thttpd cannot verify that the user ``nobody'' is present when it runs, causing thttpd to fail. I worked around this limitation by looking up the uid and gid for the user ``nobody'' in the HHL /etc/passwd and /etc/group files. Then I commented out lines 264-273 in thttpd.c and hard-coded the uid and gid values in the source code at line 275:
uid=99; gid=99;
I'm sure that many C wizards out there could have come up with a better workaround. After making this change, a simple ./configure and make will build the program.
Sparkler and BottleRocket software are also necessary. In my previous article, I assume the use of the Apache web server, and I mention using ScriptAlias to create a /sparkler server path. Since thttpd does not contain as many fancy features as Apache, I chose to place Sparkler at the /cgi-bin/sparkler server path. This requires a change to a CGI form parameter in the Sparkler source. Find lines 86 and 96 in the Sparkler source and change /sparkler to /cgi-bin/sparkler. A better solution will be implemented in a future version of Sparkler. Once this change is made, Sparkler can be compiled, as described in the previous article, using a simple make. BottleRocket can be compiled with a simple ./configure and make similar to that of thttpd.
The first step to getting an embedded Linux system up and running is to prepare a kernel that contains the drivers for the peripherals available on the particular device. I started working from the Linux/demos/Microwindows directory on the Hard Hat Linux distribution CD. This directory provides the necessary scripts to create new images and to create a working boot floppy disk. The kernel provided contains just enough device support to demonstrate the Microwindows graphical user interface. Since a CGI application such as Sparkler requires additional functionality, I found it necessary to compile my own kernel for the system I was working on.
The Hard Hat Linux distribution CD contains a sample Linux kernel with minimal device drivers. In order to get Sparkler running, I decided that I would need both Ethernet and serial device support, which are not provided by the demonstration Hard Hat Linux kernel. I chose the latest stable Linux kernel, version 2.2.18, and configured it for functionality that includes support for serial, Ethernet and a few other necessities. See the Linux Kernel HOWTO for information on compiling a Linux kernel.
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |





40 min 1 sec ago
51 min 25 sec ago
5 hours 54 min ago
6 hours 17 min ago
6 hours 20 min ago
8 hours 43 min ago
10 hours 12 min ago
13 hours 12 min ago
15 hours 2 min ago
15 hours 12 min ago