Network booting a Gumstix OveroLast Updated on Monday, 03 May 2010 14:16 Here's an article I wrote for the Gumstix User Wiki on how to setup a workstation and u-boot to network boot a gumstix. OverviewNetwork booting can be very convenient during the development cycle for an embedded device. Current Gumstix Overos have a bootloader and kernel ready for network booting if you have an expansion board with an ethernet connector. Older Gumstix Overos can upgrade their version of u-boot to get support for network booting. The procedures that follow are for setting up a workstation to act as both the tftp server and the nfs server to host the root file system. The procedure described does not require a dhcp server. Setup The following procedure assumes a Linux workstation to host all the services. The workstation for the example is running Ubuntu 10.04 (9.10 also). There are multiple ways to configure the nfs server and the tftpd server and you could use dhcp, but I was trying to keep things as simple as possible. The names of the packages will be different if you are using another Linux distribution. The example uses the following network configuration. Workstation IP: 192.168.4.4 You will also need a rootfs for the Overo available on the workstation. You can either build one yourself or download one here. I'll assume an omap3-console-image custom built with OE located in the standard location. Any image will work though. PackagesInstall the following Ubuntu packages on the workstation
Create a root filesystemCreate and populate the /exports directory with a kernel and a root filesystem sudo mkdir -p /exports/overo Configure the tftp serverDisable inetd control of tftpd which is the default for Ubuntu. Either comment the line in /etc/inetd.conf that references tftpd by adding a # to the start of the tftp line # tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/int.tftpd -s /var/lib/tftpboot or if you don't need inetd for any other service, which a Ubuntu desktop install typically doesn't, disable inetd completely this way sudo mv /etc/rc2.d/S20openbsd-inetd /etc/rc2.d/K20openbsd-inetd See the NOTES section. The tftpd-hpa configuration file format changed between Ubuntu 9.10 and 10.04 so use the appropriate example. Edit /etc/default/tftpd-hpa (9.10) RUN_DAEMON="yes" OPTIONS="-l -s /exports/overo/boot" Edit /etc/default/tftpd-hpa (10.04) TFTP_USERNAME="tftp" TFTP_DIRECTORY="/exports/overo/boot" TFTP_ADDRESS="192.168.4.4:69" TFTP_OPTIONS="-s" What we are doing here is pointing the tftp daemon at the Gumstix root filesystem we created above because our uImage kernel sits here. $ ls -all /exports/overo/boot/* Configure the nfs serverAdd the following line to /etc/exports /exports/overo 192.168.4.50(rw,no_root_squash,no_subtree_check) This tells the nfs server what directories to export as an nfs mountpoint and what machines have access to it. Use the exports man page to get the documentation for /etc/exports. Restart the serverssudo /etc/init.d/tftpd-hpa restart Configure u-bootEstablish a serial console connection with the gumstix. Power the gumstix unit and hit a key to stop the process in uboot. Add some environment variables to u-boot. Overo # setenv ipaddr 192.168.4.50 Save what you've entered in the u-boot environment so far. None of these variables are used by the default boot process so there will be no booting behavior changes yet. Overo # saveenv TestingThe next step is to test the network boot by running each step manually. Later we will modify u-boot to run this automatically. 1. First tftp load the kernel into the overo memory Overo # print loadaddr Overo # tftp ${loadaddr} uImage
If you get the following error Overo # tftp ${loadaddr} uImage
see Note 11 below for a fix. Okay, if that worked, make sure the loadnfskernel variable we created doesn't have a typo by running the same process again using the u-boot run command. Overo # run loadnfskernel You should get the same results, a kernel tftp loaded into memory. If it did not work, use a network monitoring tool like tcpdump or wireshark to see if you are getting any traffic. See the Notes section for some troubleshooting tips.
Overo # print bootargs Make sure that bootargs looks correct.
With a kernel of the correct format loaded into memory, the u-boot command bootm will transfer control of the processor to this kernel. Overo # bootm ${loadaddr}
...normal kernel boot messages here, then... Making it automaticSo if everything worked and you want to boot this way every time you need to modify the bootcmd u-boot variable. Reboot the gumstix and hit a key to stop it in u-boot again. Overo # print bootcmd You may want to save this for the future or see the Notes section for where it is defined in the build. Make a new bootcmd using the u-boot environment variables that we created. Overo # setenv bootcmd echo Booting nfs ...\; run loadnfskernel\; run nfsargs\; bootm \${loadaddr}
Overo # saveenv Now reboot and the gumstix should nfsboot by default. Overo # reset Notes1. tftp and inetd. You can use inetd to run tftp if you want. Just edit the -s option for tftp appropriately in /etc/inetd.conf tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /exports/overo/boot and instead of this restart command sudo /etc/init.d/tftpd-hpa restart use this one sudo /etc/init.d/openbsd-inetd restart And finally, prevent tftpd-hpa from starting by sudo mv /etc/rc2.d/S20tftpd-hpa /etc/rc2.d/s20tftpd-hpa though that's not really necessary since inetd beats him to the socket. TIMTOWTDI
2. The default u-boot environment variables are defined in the u-boot source tree under include/configs/omap3-overo.h
3. The documentation for linux kernel parameters for nfs booting can be found in the linux source tree under Documentation/filesystems/nfsroot.txt and Documentation/kernel-parameters.txt.
4. tftp listens over udp on port 69 $ grep tftp /etc/services You can check if it is listening with the following command. $ netstat -an | grep udp
5. nfs listens on port 2049 both tcp and udp. The nfs root process uses only udp. $ grep nfs /etc/services
6. The following is a tcpdump command for watching the gumstix boot traffic. Choose the appropriate interface for your workstation. $ sudo tcpdump -i eth1 -l -n udp
7. A cross-over ethernet cable connected between the workstation and the gumstix works well if you can't host services on your regular network. You may want to check before starting a tftp server on a shared network. A dedicated switch/hub will also work to keep things isolated.
8. You can check for running firewall rules with this command $ sudo iptables --list If you get output different then this (nothing running) and you are having problems booting, then you should ensure you are not blocking any of the required traffic.
9. I removed the kernel parameters for the kernel display configuration for wiki formatting reasons. You should add the settings you require to the bootcmd variable in the example.
10. There is a patch to u-boot in the current gumstix overo-oe tree that improves the ethernet network speeds on the overos. You can save about 10 seconds on an nfs boot using a u-boot built with this patch as well as get better ethernet performance after booting. When you do a network boot without a microSD card, you are using the u-boot on the NAND flash which was probably built without this patch. Build a newer version of u-boot following the standard build procedures. (U-boot is built whenever you build an image.) Then copy it to NAND using the instructions here.
11. Older gumstix ethernet boards did not come with an EEPROM specifying a MAC address and so the ethernet controller's reset value of FF:FF:FF:FF:FF:FF was being used by U-Boot. Older versions of U-Boot didn't complain about this, but newer versions do. So if you are in the situation with an older gumstix ethernet board running a newer U-Boot, you must specify an ethaddr U-Boot environment variable manually if you want to tftp boot. Newer U-Boot still allows FF:FF:FF:FF:FF:FF when set from the environment, though that's just an oversight that might get fixed anytime. This works for now. setenv ethaddr FF:FF:FF:FF:FF:FF If U-Boot starts checking more thoroughly, you may have to use another value. This is not a problem once Linux is booted. The Linux driver will assign a random MAC if it detects FF:FF:FF:FF:FF:FF. Again this is a problem that is going away and shouldn't affect any new gumstix owners. |
Gumstix network boot