Using CompactFlash Cards in Your Embedded Linux System
For this application I chose the tiny-turbo web server. This web server is very small and takes up very little memory. It also allows CGI programs, so you can write web programs. This would let you write a web application as the user interface to your devices. The web server is installed in the /usr/httpd directory. The configuration file is in /etc/thttpd.conf file and is listed as:
dir=/usr/heepd/html chroot cgipat=/cgi-bin/*
Now that the partitions are made, the filesystem created and the kernel built, you need to install a boot loader. The BIOS in PC hardware will load the first sector of the first hard drive when the system boots. You need to have software on your system that will load your Linux kernel from the code in this first sector of the hard drive. I used the LILO boot loader because I've been using this loader for years. It can do so much more than just load a single Linux kernel, but it can do our simple task also.
I had problems making it load the boot-loader software on the CompactFlash card in my development system because the card was addressed at /dev/hdc in my development box. The card will be located at /dev/hda in the target system. Fortunately, there is a way to do it. I found instructions in the LILO mini-HOWTO. See Listing 3 for the contents of the /etc/lilo.conf file. Assuming that you have mounted your CompactFlash card as /mnt/hda1 on your development system, the command to load the boot loader on your CompactFlash card is:
/mnt/hda1/sbin/lilo -r /mnt/hda1 -C etc/lilo.conf
Be very careful with this command. It is possible to replace the boot loader on your development system by mistake. It could cause your development system not to boot properly. It's always a good idea to keep a boot floppy around just in case.
You should now be ready to test your CompactFlash boot device. Shut down your development system and remove the CompactFlash card. Install the card in your target system and turn it on. For testing purposes, it is best to have a display adapter in your target system. If this isn't possible, you can configure the kernel to use a serial port as the console device. If you have a display connected to your target, you should see the kernel messages as the kernel boots. When the kernel is finished booting, it will prompt you to press Enter to start a shell.
Congratulations! You have built a Linux operating system for an embedded device from scratch. You can now test the web server. You can check the web server from another computer. Go to the URL http://18.104.22.168/ in a browser on another computer. Make sure to substitute your IP address in the URL. If you get a welcome screen, it worked. There is a very simple CGI program on the embedded system at http://22.214.171.124/cgi-bin/test.cgi that you can try.
As you can see, installing an embedded Linux system isn't very difficult. Now that the OS is installed and working, you just need to write the code for your embedded system and copy it to the CompactFlash card. This is something that anyone with a little knowledge of Linux can accomplish. Good luck building your embedded system!
Jay Sissom is a systems analyst in the computing department at Indiana University in Bloomington, Indiana. He is very busy finishing an Electrical Engineering degree. Amateur radio and playing the piano are two of his hobbies. He likes building electronic things in what little spare time he has between work and school. You can send him e-mail at email@example.com.
- Hacking a Safe with Bash
- Django Models and Migrations
- Secure Server Deployments in Hostile Territory, Part II
- The Controversy Behind Canonical's Intellectual Property Policy
- Huge Package Overhaul for Debian and Ubuntu
- Home Automation with Raspberry Pi
- Shashlik - a Tasty New Android Simulator
- Embed Linux in Monitoring and Control Systems
- KDE Reveals Plasma Mobile
- diff -u: What's New in Kernel Development