If you're doing a bunch of experimentation with a SheevaPlug, you may find yourself wanting to boot from multiple sources at different times (NAND, USB, SD, Network), and it would be nice to be able to switch between these boot sources without having to manually fiddle with u-boot every time.
As a way to make things easier, you can configure u-boot to try multiple boot sources in sequence until one succeeds. This allows you to normally boot from NAND but occasionally boot from SD or USB by plugging in the SD/USB device; if the device is missing, it will fall back to the NAND boot.
Note added by CqCn: [per restamp] This method will not work if the kernel is in nand, and you want to start from your rootfs from one of two or more places. This works when the kernel is in the same place along with the rootfs.
Note to Admins: Please track down the User who tried redirecting everyone from here to a malicious website. Thank you.
--alex9113 05:26 P.M. EST, 27 November 2010
Syntax: I'm not quite sure what this page's syntax conforms to. Looking at the first command in the first example below, from U-Boot, I would enter the command in U-Boot as:
setenv bootargs_sd 'console=ttyS0,115200 ro root=/dev/mmcblk0p1 rootdelay=1'
--Rektide 04:47, 17 August 2009 (UTC)
SD and NAND
Here's my set up for choosing between SD and NAND:
bootargs_sd=console=ttyS0,115200 ro root=/dev/mmcblk0p1 rootdelay=1 bootcmd_sd=setenv bootargs $(bootargs_sd); mmcinit; ext2load mmc 0 0x800000 /boot/uImage; bootm 0x800000
bootargs_nand=console=ttyS0,115200 rw root=/dev/mtdblock2 rootfstype=jffs2 bootcmd_nand=setenv bootargs $(bootargs_nand); nand read.e 0x800000 0x100000 0x400000; bootm 0x800000
bootcmd=run bootcmd_sd; run bootcmd_nand
u-boot doesn't support conditional scripting, but if the load operations fail, the bootm call will also fail when it doesn't see a proper kernel image. At that point, it will continue to run the next bootcmd. And if you want to, you can have a longer chain by inserting a USB bootcmd before or after SD.
setenv bootargs_nand 'console=ttyS0,115200 video=dovefb:lcd0:1920x1080-16@60,lcd1:1024x768-16@60-edid clcd.lcd0_enable=1 clcd.lcd1_enable=1 usb0Mode=host usb1Mode=device root=/dev/mmcblk0p2 rootwait' setenv bootcmd_nand 'setenv bootargs $bootargs_nand; mmcinfo; fatload mmc 0:1 0x2000000 uImage.d2plug; bootm 0x2000000'
setenv bootargs_sd 'console=ttyS0,115200 video=dovefb:lcd0:1920x1080-16@60,lcd1:1024x768-16@60-edid clcd.lcd0_enable=1 clcd.lcd1_enable=1 usb0Mode=host usb1Mode=device root=/dev/sdb2 rootwait' setenv bootcmd_sd 'setenv bootargs $bootargs_sd; usb start; fatload usb 1:1 20000000 uImage.d2plug; bootm 0x2000000'
setenv bootcmd 'run bootcmd_sd; run bootcmd_nand'
Other Boot sources
bootargs_usb=console=ttyS0,115200 ro root=/dev/sda1 rootdelay=10 bootcmd_usb=setenv bootargs $(bootargs_usb); usb start; ext2load usb 0:1 0x800000 /boot/uImage; bootm 0x800000
Your kernel can rely on initrd to load modules needed for booting. This technique is adapted from [md].
Initrd off of USB
bootargs_usb=console=ttyS0,115200 root=/dev/sda1 ro panic=10 rootdelay=10 bootcmd_usb1=setenv bootargs $(bootusb_args); usb start; ext2load usb 0:1 0x00200000 /boot/uImage bootcmd_usb2=ext2load usb 0:1 0x01100000 /boot/uInitrd; bootm 0x00200000 0x01100000 bootcmd=run bootcmd_usb1; run bootcmd_usb2; run bootcmd_nand
- This works because you can physical remove the SD or USB device to ensure the bootcmd fails - that means NAND has to be your final choice as it will never fail. If you want NAND to have a higher priority, you're out of luck.
- ** Too many args (max. 16) ** If you get this message while making a long setenv, split your setenv into multiple examples. See #Initrd for an example. Trying Initrd with a single bootcmd_usb will generate this error.
Boot from SD support
The default u-boot included with the plug doesn't support boot from SD (the mmcinit command doesn't exist). If you upgrade to the u-boot provided with the SheevaPlug Installer, you will gain this support. Note the caveats on that page - some cards may not work.