In this section we show how to configure several boot loaders and environments for booting MaRTE OS. We start with environments mostly used at the application implementation phase, and then we show the typical final environments.
This configuration is very used in the development phase of an embedded system. While we are implementing a new application for MaRTE OS we will probably need to do a lot of tests, changes in our application and resets. If we store our mprogram in a hard disk we would have to rewrite it every time, then reset... a lot of time wasted. A Network environment consists of two computers, the host and the target. The host is the PC with Linux+GNAT+MaRTE_OS, where we program and generate the mprogram application. The target is the computer where mprogram must be executed. For instance, the CPU of a Robot, a PC-104 computer, or another PC. Therefore, the target needs to download mprogram from the host. This can be done by connecting both computers through an Ethernet network and using some magic :). The following picture shows you this environment. The RS-232 line can be used for debugging but we leave this for another tutorial.
Ok, suppose you have your host with Linux connected to the target. You have installed MaRTE OS, compiled an application (i.e. /marte/examples/hello_world.c) and generated your mprogram. What's left? Oh, yeah, the magic I told you about. The magic you will need to use depends on the target capabilities (i.e. if it has a floppy, a compactflash, a PXE built-in motherboard). When the target computer starts or is reset it will do exactly the same steps I mentioned before. The Bios will look for a device to boot from in a certain order. This order is set in the Bios setup program. Depending on the options for booting of your target computer the configuration needed is different.
This configuration consists of a diskette with GRUB installed and a network loader called Netboot. Netboot loader is included in MaRTE OS (/marte/netboot) for several network cards. An script, mkbootfloppy, has been also included for recording netboot with grub on a diskette. If you want to install it on other device like a hard disk, a compactflash, etc.. the structure is almost the same. You will have to install GRUB and then add the netboot file.
In this configuration, when the target starts it executes GRUB loader. GRUB will load the netboot file (with built-in drivers for our specific NIC) in RAM and run it. Netboot will ask the network two questions through the DHCP protocol:
What file do I have to download?
Where is it?
Therefore, we have to answer those questions from our host. This is done by installing a DHCP daemon and configuring it:
/etc/dhcpd.conf: host mov1 { option host-name "mov1.ctr.unican.es"; hardware ethernet 00:0B:AB:05:BB:B0; fixed-address 193.144.198.55; server-name "soc1.ctr.unican.es"; next-server 193.144.198.98; filename "/home/user/export/mprogram"; option root-path "/home/user/export"; }} |
After that, the Netboot code will start downloading mprogram through the NFS protocol. We have to install an NFS server in our Linux and configure it:
/etc/exports: /home/tucuenta/export 193.144.198.55(ro,sync) |
One of the main problems of using Netboot is that there is compatibility only for a few ethernet cards. Etherboot is another network loader that solves this problem because it supports a wide range of ethernet cards. You just have to go to its webpage at [7] and make a floppy bootable ROM image compatible with your card and the DHCP/NFS protocols. Then, record it on your floppy:
$ cat eb-5.4.2-3c509.zdsk > /dev/fd0 |
If you want to use another disk (like a hard disk or a compactflash for example) you can make a GRUB compatible ROM image (i.e. eb-5.4.2-3c509.zlilo) instead of a floppy one. The configuration for the host is the same as the Netboot case.
So far, we have used a diskette (or other disk) to load first a network boot loader in charge of loading the mprogram file. This can be a problem when our target doesn't have a solid state memory available. Nowadays, a lot of computers have a built-in protocol called Preboot Execution Environment (PXE) [8]. When you select the option LAN in the BIOS setup utility, the motherboard will try to download a kernel through the network using this protocol.
PXE will start using DHCP in order to get an answer for the same questions needed to resolve. After that it will download the so called Network Bootstrap Program via another protocol, TFTP. In our case, this program will be an Etherboot image in PXE format (you can select it while making your ROM at [7]). Then, Etherboot will be in charge of booting mprogram as we have explained before. We need to install a TFTP server, configure it and put our PXE Etherboot image available.
You may have noticed that both PXE and Etherboot use DHCP at the begining of their processes so they can conflict. We need to difference them in our DHCP server in order to tell them the correct files. This is done with this configuration lines:
if substring (option vendor-class-identifier,0,9) = "PXEClient" {filename "/eb-5.0.8-rtl8139.lzpxe";} else if substring(option vendor-class-identifier,0,9)="Etherboot" {filename "/home/dsl/export/mprogram"; option root-path "/home/dsl/export";} |
You can download the configuration files here: /etc/dhcpd.conf, tftp, /etc/exports.
This is the preferred method for booting in the final embedded system. It consists on installing GRUB in any device in the target. For example, a CompacthFlash, USB, hard disk, floppy, etc.. (I haven't tried booting from a cd-rom yet):
Create a partition in your device (i.e. CompactFlash) with fdisk or cfdisk. For instance, if if your device is /dev/hdc (the Secondary master):
fdisk /dev/hdc |
In the menu, create a partition with 'n', toggle the boot flag to true, and set the filesystem to FAT16 (for example).
Format the created partition with the desired filesystem with mkfs, mkdosfs, ... For example:
mkdosfs -F 16 /dev/hdc1 |
Mount the partition ('sudo mount /dev/hdc1 /mnt') and copy the GRUB loader files to your device. You can get them from your own linux at /boot/grub. For example:
cp -R /boot/grub /mnt |
Unmount the partition again and install GRUB stages on the partition with the grub command. Note that so far you just copied the files, you need to write the MBR of your partition. WARNING: be careful now because you must do the following operation as root and you could damage your Linux partition if you don't choose the right device. In GRUB the equivalence with Linux naming of disk devices is: hda, hdb, hdc, hdd ==> hd0, hd1, hd2, hd3 And for each partition of the disk the equivalence is: hda1, hda2, hda3.. ==> (hd0,0), (hd0,1), (hd0,2)...
# grub >> root (hd1,0) <-- click on TAB to see the options Now you should get a message indicating the type of filesystem. If you formatted the partition with FAT you will see a message saying this is a FAT disk. >> setup (hd1) <-- WARNING: be careful you are using your device >> quit |
Mount the new partition and copy your mprogram to it.
Finally, edit the GRUB configuration file /boot/grub/grub.conf:
title MaRTE OS root (hd0,0) kernel /mprogram |