Embedded System Project:

Booting Linux from a DiskOnChip Device

There are several things you will learn doing this lab. The main thing you will learn is how a computing system boots, from a “CMOS” through the BIOS, followed by a boot loader, kernel, and operating system. You will learn where each of these pieces reside, and how to configure and modify them. Along the way, you will also learn how to install a linux operating system. You will learn how to compile a kernel, modifying it for your own use. You will learn about patch files, modules, and device drivers. You will learn where how to manipulate the boot process to fit your needs.

The goal of this project is to install a minimal version of linux to boot from an M-systems DiskOnChip 2000 device. This documentation overviews the steps you should take. Along the way, this documentation references several other sources. Depending on your background and experience, you may need to access additional sources (for example, if you are not already comfortable with a shell or the gcc compiler, that is beyond the scope of this documentation).

  1. The first step is to setup the working environment. Install Red Hat 7.0 from the available CDs (it comes on 2 CDs) onto your team’s assigned hard drive. It is recommended that you install all development packages and the X window environment. However, other packages such as network support and printing services should be skipped. This will make your hard drive boot faster.
  1. You will have to connect both your hard drive and a CD-ROM to the system. You may need to set master/slave flags on the drives so both are recognized (you should see both recognized during BIOS initialization).
  2. You will have to change the CMOS to allow the machine to boot from the CD-ROM. Also in the CMOS, make sure the DiskOnChip device is turned OFF.
  3. During Red Hat setup, choose custom install. Packages such as networking, printing services, and whatever else you choose can be disabled to allow the system to boot faster since you won’t be needing them. You WILL need to select the Development package, which will include tools needed to compile the kernel. It is also recommended that you include the X window environment for a future lab exercise.
  4. When Disk Druid asks you to partition the drive you will need a small swap partition of type “Linux Swap”, and a root (/) partition of type “Linux Native”. Linux uses the swap partition as extra system memory, and the root partition as the mount point for the main file system.
  5. After Red Hat install is finished, reboot and switch the CMOS to boot from the hard drive.
  6. If you are unsure about a setting, use the default value. Extensive documentation and a Red Hat installation manual can be found at
  1. The version of Red Hat that you just installed uses the Linux 2.2.16 kernel. The kernel version that we want to install on the DiskOnChip device is 2.2.14. You must copy the source code for the 2.14 kernel to your hard drive, and prepare it for compilation.
  1. Connect a CD-ROM drive, concurrently with your hard drive, to the system. You may need to set master/slave flags on the drives so both are recognized. Boot your system from the hard drive.
  2. All of the lab systems do not have a CMOS battery, causing the system time to be incorrect. You can use the “date” command to set the time each time you boot, so that you do not see clock skew errors. Clock skew errors can also be ignored, but you must be careful when compiling because the make program uses dates to decide which files to recompile.
  3. Insert the ECE468 CD (includes MSystems files, kernel files, Ampro files, an some stuff for a future lab exercise). If the CD-ROM drive does not auto-mount, you may need to mount it manually. See the “mount” command (e.g. man mount).
  4. Locate the kernel file linux-2.2.14.tar.gz. The kernel (linux-2.2.14.tar.gz) can also be obtained from but we have already burned it to the CD. Copy the file to a working directory on your hard drive and untar it.
  5. The ECE468 CD also contains files you will need to modify the kernel before compiling (a kernel patch) and a new version of lilo designed to work with the DiskOnChip. These files are stored in the DOC/ folder on the CD. Copy these files to your hard drive. These files can also be found on M-Systems website.
  1. To compile the kernel you need to use the kgcc compiler, which is a variation of gcc designed specifically for kernels. If you did not already install it to your hard drive (during initial setup), you will need to use a package manager to install it now. Red Hat uses a package management utility called RPM.
  1. Find the rpm directory on the Red Hat 7.0 Installation CD.
  2. Find the .rpm file that contains kgcc.
  3. Use the rpm command to install kgcc (consult Linux man pages on rpm).
  1. This version of the Linux kernel (2.14) does not already contain drivers to access a DiskOnChip device, so you will apply a patch and make some other changes to add this functionality, then compile the new kernel. Find the MSystems documentation in the manual, turn to page 9, and begin following those instructions with the following notes:
  1. You will apply two patches to the kernel. It is very important that you apply each patch ONLY ONCE. Running the patch adds or changes lines of code in different files and doing it twice will only add the code again which can change the flow control of the program. Find the patch files among the files you copied over from the floppy, and run the following command using first the patch file “linux-2_2-patch”, and then the patch file“driver-patch”:

patch –d <your linux dir> -pl < <patch-filename>

  1. To access devices, Linux uses device nodes. To create device nodes for the DiskOnChip, run mknod-fl as explained in the M-Systems installation manual. You can look at that file to see that it is only using the Linux mknod command to create these device nodes. (man mknod for more information). The file mknod-fl is a script file, and may not run properly if the initial line in the file is corrupted (for example, it must use the appropriate newline byte). If the file does not run properly, make a copy of the file, delete the first line, and then retype it exactly as you saw it (this deletes unseen bytes). Run this new version of the file.
  2. Find the Makefile in the root directory of your Linux 2.14 kernel source. This file needs to be changed in two places to use kgcc instead of gcc.
  3. Continue following the M-Systems installation manual through step 10 to configure and compile the kernel. You may wish to use make xconfig as an alternative to make menuconfig if you are using Xwindows. Either way, be sure to include the M-Systems drivers found under Block Devices as a part of the kernel and NOT as a module.
  4. Since we are compiling the drivers into the kernel and not as a module, you can skip step 11 in the manual.
  5. Lilo is a boot loader commonly used to load linux. It can be configured to give multiple kernel choices at boot time as well as to load other operating systems. Follow step 12 to add your new kernel to lilo, and step 13 to install it. You will probably need to read documentation on lilo (e.g. man lilo and man lilo.conf) to properly configure your boot loader.
  6. Reboot the machine and choose your new kernel from the lilo prompt. While running, you can type “uname –a” at the shell to see which kernel you are running.
  1. If the DiskOnChip device is turned on in the CMOS, its firmware conflicts with the lilo boot loader and you cannot boot. To solve this problem, you will need to follow instructions in Section 6 of the M-Systems installation manual in order to install a patched version of lilo using the files you copied from the CD.
  2. It is highly recommended that you rename the original files, so that you retain access to them, before replacing them with the copied files.
  3. After doing this, reboot the machine, enabling the DiskOnChip in the CMOS and verifying that the new lilo boot loader works.
  1. The DiskOnChip may have anything on it, including work done by another team. You will need to reformat the DiskOnChip each time you move to a new workstation, or start over.
  2. To remove any existing partition and create a Linux Native (ext2) file system, follow the instructions in the M-Systems manual under Section 3.
  3. After rebooting, initialize this file system as shown in step 1 of Section 3.1 in the manual.
  1. Now you will populate the DiskOnChip with a minimal working Linux system. In this step, you are not given exact instructions. It is up to you to show some initiative to figure out which files you need to run a bare system, keeping space constraints in mind. However, some guidelines are given in the M-Systems manual Section 4.1.3. Some information will also be given in class. Copy what is needed to the DiskOnChip and modify files as necessary. Note:
  1. the only devices needed are /dev/ttya* , /dev/msys/* , and /dev/hda* .
  2. remove the rc system and just use inittab to execute shell.
  3. do not use gettys or login.
  4. the system does not need to do anything except boot to a shell
  1. Modify /etc/lilo.conf as in step 11 (Section 4.1.3), but also making changes to allow for booting from the hard drive as an alternate. Run the lilo program to update the boot map. In this step you should also show some initiative. You should try to modify the boot loader you install to the DiskOnChip so that one of its options is to load a kernel from your hard drive. This way, you do not need to re-flash the BIOS every time you want to go back to booting from your hard drive.
  1. Because the flash device we are using is made by a company other than M-Systems, you will use a different update utility to access the device, so stop following the M-Systems manual at this point. There is some documentation labeled “CM/P5e” in the manual that can be consulted for the following steps.
  1. Boot from the ECE468 CD to the DOS operating system. You will be accessing the files in the Ampro/ folder. Note however that these are DOS excecutables; you cannot run them from linux.
  2. Include CD-ROM support.
  3. Switch to the drive containing the P5e Utilities. (e.g. D:, depending on how you booted).
  4. Run the p5update command as shown. This updates the firmware on the DiskOnChip so it will be selected as the first drive in the system, allowing us to boot from it.

P5update /win:e000 /S:DOC110.exb /FIRST

  1. If all is well, you should be able to reboot the system and boot from the DiskOnChip device. Since it is unlikely that this will happen smoothly your first time, proceed in one of two ways:
  1. If the boot hangs and the bootmap is corrupted you will not be able to boot from the DiskOnChip again. You should redo the command in Step 9 omitting the /FIRST flag.

P5update /win:e000 /S:DOC110.exb

You can now boot from the hard drive and go back to Step 7 to make changes to your system, continuing from there.

  1. If there are errors during boot, but the bootmap is not corrupted, you should be able to reboot the DiskOnChip, selecting the hard drive kernel image at the lilo prompt. You can then make changes to your system and try to boot from the DiskOnChip again (Step 10).