Linux Embedded Frequently Asked Question

V0.3 September, 1999


Submit your article


Introduction
1 Linux as embedded operating system (EOS)
1.1 Why Linux ?
1.2 Minimal configuration ?
2 Linux as real time operating system (RTOS)
2.1 RT-Linux
3 Linux & flash Cards, flash eproms
3.1 Pcmcia flash cards
3.2 DiskOnChip
3.3 Flash Limited write cycles
3.3.1 solutions
References

Introduction.

This faq has been made from discussions on different linux embedded and related mailing list and from several articles about linux as embedded os. You, reader, may find some of your words or explanations in this document. If you don't complain with this, please send mail to describing the part you are claiming , other comments may also be sent at the same mail address.

1 Linux as embedded operating system (EOS)

The choice between EOS depends on what you have to do. If you are writing the firmware for a coffee maker, it will be silly to use a unix like OS.

1.1 Why Linux ?

Linux is freely available , includes a TCP/IP stack, runs over a multitude of architecture, and provides drivers for almost all devices.

1.2 Minimal configuration ?

On a i386 architecture, the minimal needs are 386sx16 with 1Mb hard or flashdisk, and 4 Mb of ram

authors: Zivkov Ivo, Ingo Cyliax

2 Linux as real time operating system (RTOS)

A real time operating system is an operating system whose correctness depends not only on the logic result, but also on the time that the result is produced. RTOSs are used in a variety of applications, especially embedded systems, and are becoming increasingly important. These types of systems usually involve the control of robots or machinery, telecommunications, air traffic control and military command and control.

2.1 RT-Linux

RT-Linux follows the model of Linux: open source code and a cooperative development environment mainly through the Internet. This results in fast bug detection and fixing, as well as good user support through mailing lists and newsgroups. The RT-Linux approach to the design of a real-time module to the Linux kernel differs from that of traditional RTOSs like VxWorks and QNX. Instead of having a real-time kernel that provides all the OS features as real-time features, RT-Linux tries to separate the real-time services and non real-time services. It leaves all the major OS features like networking, device access (drivers), GUI system to the Linux kernel, and provides very basic features for
real-time processing.

authors: Bernard Nahas

links to Linux & Real Time may be found there.

3 Linux & flash Cards, flash eproms

 

3.1 Pcmcia flash cards


Pcmcia flash cards are seen as standard hard disk, while using the pcmcia package.
 

3.2 DiskOnChip


M-Systems provides DiskOnChip, this is a flash eprom pluggable on most single board computer or PC/104. There is drivers for most DiskOnChips products ( 2000, Millenium ). Drivers are a binary patch, no source available, over 2.03x kernels. Please contact Esther Spanjer <> for last info on m-sys & linux products.
Memory Technology Device (MTD) Subsystem for Linux David Woodhouse is working on a generic Linux subsystem for memory devices, especially Flash devices. The aim of the system is to make it simple to provide a driver for new hardware, by providing a generic interface between the hardware drivers and the upper layers of the system a gpl driver now works with DiskOnChip

authors: Spanjer Esther
 

3.3 Flash Limited write cycles


Flash have limited write cycles capabilities from 200 000 to 400 000. Using swap on such device is dangerous. 300 000 writes gives you 200 days at 1 write / minute and 83 hours at 1 write / second. More, If you interrupt power at arbitrary times while the device is writing,
you can lose the integrity of the file system being modified. The loss is not limited to the 512 byte sector being modified, as it generally
is with rotating disks; you can lose an entire erase block, maybe 64K at once. The risk goes up as the "disk" approaches full, because erase rewrite cycles happen more often in this condition. Un*x file systems spread their super block tables around the "disk", in the hope that at least one will survive a head crash. Create one file, then /bin/sync: what percentage of the device's erase blocks get hit?
 

3.3.1 solutions


* Two partitions

Nicolas uses a Sandisk 4 MB flash disk to hold the whole system in a read-only partition and a read write partition is used to save some data. The partition are set to be on flash block boundaries so if a crash occurs, only the second partition must be rebuild. And there might be no need to install a file system on the writable partition so the application may check for some magic number and reset the structure in this partition by itself if needed. The trick is to access /dev/hda2 as any regular file for example. Now to be safe from power crash, we have made the power state be controlled by software. So if the user turns off the power switch (which is only wired to one of the parallel port pins), the application then takes the time needed to write its data to the flash, to sync the buffers and only then drop the power by dropping a line again on the parallel port. Since his device is made to be used on batteries, the AC power can be unplugged and everything still goes on. Of course, another line on the parallel port is used to monitor the batteries's charge and force a power down if the charge goes too low. So the flash is written only during the shutdown procedure which limits write cycles and there is very very little possibility it can crash due to power failure.

* Loading contents of system into a ram disk

Paul Moody's mini-HOWTO gives one approach to using a Flash memory drive with Linux, by loading the contents into a ram disk at boot time. One of the good point is that RAM is cheaper than Flash.

* Mounting root file system read-only

If you're stuck with less RAM than Flash, or if you're using a real hard drive, you may mount the root file system from the drive read-only. This retains many of the benefits of resisting corruption of the drive and avoiding write cycles (which would quickly wear out a flash drive), because no data is ever written to the root file system. Even with a real hard drive, the root file system is not corrupted (and fsck is not run on reboot) if the power is cycled. Of course, it's complicated by the fact that Linux usually wants/needs to write data to its root file system. This problem can be solved principally by modifying /etc/rc.sysinit to create and mount a ramdisk on the read-only root file system, instead of remounting the root file system in read write mode. This technique takes advantage of the fact that a read write device can be mounted on the file system of a read-only device, to create a read write directory subtree within an otherwise read-only hierarchy. Note that mounting a new device merely stores an entry in a kernel table and does not write to the device holding the file system upon which the new device is being mounted. Here's a sketch of the places on the root file system
where Linux traditionally wants to write, and how to cope with them:


authors: Paul Moody, Carry O'Brien, Nicolas Pitres, Graham Stoney, Steven Work.
 

References

Ingo Cyliax
Bernard Nahas, May 15, 1998 University of Ottawa <http://aix2.uottawa.ca/~s997014/rtos.html>
Sebastien Huet
Paul Moody <http://users.bigpond.com/paulmoody/Mhow11c.html>
Carry O'Brien
Nicolas Pitres
Esther Spanjer
Graham Stoney
Steven Work
Ivo Zivkov
 
 



© 1998-2000 ,
last update April 18, 2000.
main site
Linux is a registred trademark of Dr Linus Torvalds