Davide | 16 May 14:43 2011

alternative uboot environment

I did a little fiddling with jeff's uboot environment setup and changed it so that it looks for a bootable
partition in the firs 7 usb drives.
This allows you to have your linux install on different partitions.
Just 3 conditions must be met:
1) the linux install partition must have everything needed to boot in it (kernel initrd /etc /bin /sbin)
2) uImage and uinitrd must be in the same place (whether it be in / or in /boot)
3) /etc must live in your linux install or the detection of valid linux partition will fail and pass on

If you have more then one valid boot partition present amongst your usb drives the first valid partition
will be used (scan is done in reverse order so that last scanned will be firs in bus).

Take care for the really long usb_scan ... it must be all in one line untill I find out how to put packslashes
without mangling it up for uboor setenv.

#set ethaddr to the mac address you want to use or to match what's on your label
#set arcNumber to match your hardware
#set mtdparts to match your flash partitioning scheme
#all the things below are only relative to when usb booting fails
#set flash_root_fs to where you want root to be mounted if usb booting fails (default is /dev/mtdblock3)
#set flash_root_fstype to what sort of filesystem is used on the above root_fs mtd partition (default is jffs2)
#set flash_kernel_offest to where the kernel is to be gotten from flash (default is 0x200000)
#set flash_kernel_size to the size of the partition where your kernel resides in flash (default is 300000)
#set flash_kernel_load_addr to where kernel is to be loaded to if usb boot fails (default is 0x6400000)

setenv bootdelay 3
setenv baudrate 115200
setenv console console=ttyS0,115200
setenv stdin serial
setenv stdout serial
setenv stderr serial
setenv mtdparts mtdparts=orion_nand:1M(u-boot),1M <at> 1M(second_stage_u-boot),3M <at> 2M(kernel),32M <at> 5M(rootfs),219M <at> 37M(data)
setenv mtdids nand0=orion_nand
setenv partition nand0,2
setenv led_init green blinking
setenv led_exit green off
setenv led_error orange blinking
setenv ethact egiga0
setenv ethaddr 00:10:75:1A:1C:7E
setenv arcNumber 2998
setenv usb_boot_0 'setenv root_fs root=/dev/sda${usb_dev_part}'; setenv usb_boot_1 'setenv root_fs
root=/dev/sdb${usb_dev_part}'; setenv usb_boot_2 'setenv root_fs root=/dev/sdc${usb_dev_part}'
setenv usb_boot_3 'setenv root_fs root=/dev/sdd${usb_dev_part}'; setenv usb_boot_4 'setenv root_fs
root=/dev/sde${usb_dev_part}'; setenv usb_boot_5 'setenv root_fs root=/dev/sdf${usb_dev_part}'
setenv usb_boot_6 'setenv root_fs root=/dev/sdg${usb_dev_part}'
setenv usb_dev_list 6 5 4 3 2 1 0
setenv usb_dev_part 1
setenv set_usb_bootargs 'setenv bootargs ${console} ${mtdparts} ${root_fs} ro ${root_fstype}'

setenv usb_scan 'usb start; setenv usb_boot_dev none; for dev in  $usb_dev_list; do for part in
$usb_part_list; do if ext2ls usb ${dev}:$part /etc; then setenv usb_boot_dir; ext2ls usb ${dev}:$part
/boot && seten
v usb_boot_dir /boot; if ext2load usb ${dev}:$part 0x800000 ${usb_boot_dir}/uImage; then setenv
usb_dev_part $part; setenv usb_boot_dev $dev; setenv usb_boot_address 0x800000; setenv root_fstype rootfstype=ext2;
run usb_boot_$dev ; run set_usb_bootargs; fi; ext2load usb ${dev}:$usb_dev_part 0x1100000
${usb_boot_dir}/uinitrd; && setenv usb_boot_address 0x800000 0x1100000; fi; done; done; if test
"$usb_boot_dev" = "none";
then echo "No USB bootable device found"; else echo "USB device ${usb_boot_dev}:$usb_dev_part is
bootable"; bootm $usb_boot_address; fi;'

setenv flash_root_fs root=/dev/mtdblock3
setenv flash_root_fstype rootfstype=jffs2
setenv flash_kernel_offest 0x200000
setenv flash_kernel_size 0x300000
setenv flash_kernel_load_addr 0x6400000
setenv set_flash_bootargs 'setenv bootargs ${console} ${mtdparts} ${flash_root_fs} ro ${flash_root_fstype}'
setenv boot_flash_kernel 'nand read $flash_kernel_load_addr $flash_kernel_offest
$flash_kernel_size; bootm $flash_kernel_load_addr'
setenv bootcmd 'run usb_scan; run set_flash_bootargs; run boot_flash_kernel'