# # boot.scr # # Boot script for Beagle Hybrid / Panda Hybrid / GTA04 # # Author: H. Nikolaus Schaller # Copyright Golden Delicious Computers 2010-2013 # licensed under GPL 2.0 # # # NAND Flash addresses (@ 256 MByte/2 GBit) # # 0x0000 0000 0x0007 ffff 08 0000 512 KB X-Loader (flash image) - note the loader must fit into 64k SRAM! # 0x0008 0000 0x001c ffff 15 0000 1.3 MB U-Boot (flash image) # 0x001d 0000 0x0020 ffff 04 0000 256 KB splash.rgb16z # 0x0021 0000 0x0024 ffff 04 0000 256 KB menu.rgb16z # 0x0025 0000 0x0025 ffff 01 0000 64 KB boot.scr # 0x0026 0000 0x0027 ffff 02 0000 128 KB U-Boot parameters written by saveenv # 0x0028 0000 0x0067 ffff 40 0000 4 MB Kernel (flash image loaded by nandboot) # 0x0068 0000 0x0fff ffff 250 MB (or more) file system (e.g. jffs) # # To flash into NAND from command line: # # 1. break into U-Boot command line # 2. flash=yes # 3. boot # # booting tries to load: # boot script /boot.scr (FAT) from partition 1, then /boot/boot.scr (EXT) from partition 1, then NAND # splash images /image.rgb16 (FAT) from partition 1, then /boot/image.rgb16 (EXT) partition 1, then NAND # kernel on up to 4 partitions /boot/uImage (EXT) or /uImage (FAT) or if none found then NAND # bootargs.scr on the same paritions /boot/bootargs.scr (EXT) or /bootargs.scr (FAT) -- default is initialized to NAND or SD (if kernel is found) # VERSION=0123456789 # incremented by build script so that we re-initialize the boot environment or reflash x-loader and u-boot echo "*** if you boot from NAND don-t worry about error messages when U-Boot tries to read a non-existing MMC ***" i2c dev 0 status init status set 8 # give fast feedback that U-Boot did start (red power led) # we have to add an "x" because the test command treats empty string as equal to anything if test "x${scriptversion}" != "x${VERSION}" then # set up default environment # this setting boots from MMC if available and falls back to NAND # (except for MLO/X-Loader which is located depending on the AUX button) echo *** initializing GTA04 environment *** setenv bootdelay 1 setenv imgtempaddr 0x80800000 # address where we load compressed splash image setenv bootaddr 0x81800000 # address where we load the boot script setenv loadaddr 0x82000000 # address where we load the kernel # setenv console ttyS2,115200n8 # for newer kernels with OMAP console (unfortunately U-Boot can't find out) setenv console ttyO2,115200n8 setenv defaultdisplay lcd setenv bootorder "1 2 3 4" setenv nand 4 # mtd4 is nand setenv vram 12M setenv omapfbvram 0:8M,1:4M # load boot script from mmc (first FAT partition only) or nand wherever we find it # i2c dev 0 # mmc rescan 0 # if load mmc 0 ${bootaddr} boot.scr # then # echo did load bootscript from mmc # elif nand read ${bootaddr} 250000 10000 # then # echo did load bootscript from nand # fi setenv loadbootscript 'i2c dev 0; mmc rescan 0; if load mmc 0 ${bootaddr} boot.scr; then echo did load bootscript from mmc; elif nand read ${bootaddr} 250000 10000; then echo did load bootscript from nand; fi' # load zipped/uncompressed image from mmc (first FAT partition only) or nand wherever we find it # i2c dev 0 # mmc rescan 0 # if load mmc 0 ${imgaddr} ${imgfile}.rgb16 # then # ; # elif load mmc 0 ${imgtempaddr} ${imgfile}.rgb16z # then # unzip ${imgtempaddr} ${imgaddr} # elif nand read ${imgtempaddr} ${imgnandaddr} 40000 # then # unzip ${imgtempaddr} ${imgaddr} # fi setenv loadimg 'i2c dev 0; mmc rescan 0; if load mmc 0 ${imgaddr} ${imgfile}.rgb16; then; elif load mmc 0 ${imgtempaddr} ${imgfile}.rgb16z; then unzip ${imgtempaddr} ${imgaddr}; elif nand read ${imgtempaddr} ${imgnandaddr} 40000; then unzip ${imgtempaddr} ${imgaddr}; fi' setenv showimg 'run loadimg; lcm fb ${imgaddr};' # predefine default boot arguments (unless overwritten by bootargs.scr) setenv mmcargs 'setenv bootargs console=${console} mpurate=${mpurate} mux=${mux} vram=${vram} omapfb.vram=${omapfbvram} omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} ubi.mtd=${nand} root=${mmcroot} rootfstype=${mmcrootfstype}' setenv mmcroot '/dev/mmcblk0p2 rw' setenv mmcrootfstype 'ext4,ext3,btrfs rootwait' setenv nandargs 'setenv bootargs console=${console} mpurate=${mpurate} mux=${mux} vram=${vram} omapfb.vram=${omapfbvram} omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} ubi.mtd=${nand} root=${nandroot} rootfstype=${nandrootfstype}' setenv nandroot 'ubi0:gta04-rootfs' setenv nandrootfstype 'ubifs' # load kernel and boot script from mmc (any of 4 partitions FAT or ext) or nand wherever we find it setenv kernelloading 'status set 18' # orange setenv kernelloaded 'status set 10' # green # run kernelloading # i2c dev 0 # mmc rescan 0 # DONE=0 # KERNEL=0 # run nandargs # start with default arguments for rootfs in NAND # for p in $bootorder # do # if itest $DONE == 0 # then # if load mmc 0:${p} ${loadaddr} uImage # then # echo found kernel /uImage on partition $p # run mmcargs # start with default mmc args # KERNEL=1 # DONE=1 # elif load mmc 0:${p} ${loadaddr} /boot/uImage # then # echo found kernel /boot/uImage on partition $p # setenv mmcroot "/dev/mmcblk0p${p} rw" # run mmcargs # start with default mmc args # KERNEL=1 # DONE=1 # fi # if load mmc 0:${p} ${imgtempaddr} bootargs.scr # then # setenv PARTITION $p # setenv PARTITIONTYPE FAT # source ${imgtempaddr} # DONE=1 # elif load mmc 0:${p} ${imgtempaddr} /boot/bootargs.scr # then # setenv PARTITION $p # setenv PARTITIONTYPE EXT # source ${imgtempaddr} # DONE=1 # fi # fi # done # if itest $KERNEL == 0 # then # if nand read ${loadaddr} 280000 400000 # then # echo fallback to NAND kernel # else # status blink # fi # fi # run kernelloaded setenv loadkernel 'run kernelloading;i2c dev 0;mmc rescan 0;DONE=0;KERNEL=0;run nandargs;echo trying partitions $bootorder;for p in $bootorder;do;if itest $DONE == 0;then;if load mmc 0:${p} ${loadaddr} uImage;then;echo found kernel on partition $p;run mmcargs;KERNEL=1;DONE=1;elif load mmc 0:${p} ${loadaddr} /boot/uImage;then;echo found kernel on EXT partition $p;setenv mmcroot "/dev/mmcblk0p${p} rw";run mmcargs;KERNEL=1;DONE=1;fi;if load mmc 0:${p} ${imgtempaddr} bootargs.scr;then;setenv PARTITION $p;setenv PARTITIONTYPE FAT;source ${imgtempaddr};DONE=1;elif load mmc 0:${p} ${imgtempaddr} /boot/bootargs.scr;then;setenv PARTITION $p;setenv PARTITIONTYPE EXT;source ${imgtempaddr};DONE=1;fi;fi;done;if itest $KERNEL == 0;then;if nand read ${loadaddr} 280000 400000;then;echo fallback to NAND kernel;else;status blink;fi;fi;run kernelloaded' # boot with kernel/rootfs from specified source setenv mmcboot 'if run loadkernel; then bootm ${loadaddr}; fi;' setenv nandboot 'run kernelloading; if nand read ${loadaddr} 280000 400000; then run nandargs; run kernelloaded; bootm ${loadaddr}; fi;' # run the boot script - and fall back to direct kernel boot setenv bootcmd 'if run loadbootscript; then run bootscript; elif run loadkernel; then bootm ${loadaddr}; fi;' setenv bootscript 'echo Running bootscript ...; source ${bootaddr}' # write script version number permanently setenv scriptversion "${VERSION}" flash=yes # trigger flashing fi echo *** initializing LCM *** if lcm start || test "${flash}" = "yes" then if test "x${flash}" = "xyes" then lcm color ff0000 # will flash - turn screen red else echo *** loading splash from MMC *** setenv imgaddr 80400000 setenv imgfile splash setenv imgnandaddr 1d0000 run showimg fi if test "x${flash}" = "xyes" || test "x${forcemenu}" = "xyes" || status check 1 # we want to flash or AUX button is (still) pressed then if test "x${forcemenu}" = "xyes" then # reset setenv forcemenu saveenv fi echo *** initializing TSC for boot menu *** tsc init # tsc selection will be 0 while true do if test "x${flash}" != "xyes" then echo *** loading boot menu image *** setenv imgaddr 80600000 setenv imgfile menu setenv imgnandaddr 210000 run showimg tsc choose 3 3 # 3 columns 3 rows -> value 1 .. 9 # restore boot image # setenv imgaddr 80400000 # setenv imgfile splash # setenv imgnandaddr 1d0000 # run showimg fi if tsc selection 7 then lcm color 00ff00 # turn screen green (feedback to touch press) lcm fb 0 echo *** LED mirror *** status mirror elif tsc selection 8 then lcm color 0000ff # turn screen blue lcm fb 0 echo *** LED blink *** # systest all status blink elif tsc selection 9 then echo *** TSC test *** tsc gloop elif tsc selection 99 then lcm color 00ff00 # turn screen green (feedback to touch press) lcm fb 0 echo *** LCD boot *** setenv defaultdisplay lcd if run loadkernel; then bootm ${loadaddr}; fi elif tsc selection 5 then lcm color 00ff00 # turn screen green (feedback to touch press) lcm fb 0 setenv bootorder "" echo *** NAND boot *** setenv defaultdisplay lcd saveenv run mmcboot elif tsc selection 6 then lcm color 555555 # turn screen green (feedback to touch press) lcm fb 0 sleep 1 poweroff # OLD echo *** DVI boot *** if run loadkernel then setenv bootdelay 10 setenv defaultdisplay dvi # this is not made persistent! setenv dvimode 1024x768MR-16@60 lcm backlight 0 lcm off lcm power 0 bootm ${loadaddr} fi elif tsc selection 1 then lcm color 00ff00 # turn screen green (feedback to touch press) lcm fb 0 echo *** MMC boot partition 1*** setenv bootorder "1 2 3 4" echo new boot order $bootorder setenv defaultdisplay lcd saveenv run mmcboot elif tsc selection 2 then lcm color 55ff00 # turn screen green (feedback to touch press) lcm fb 0 echo *** MMC boot partition 1*** setenv bootorder "2 3 4 1" echo new boot order $bootorder setenv defaultdisplay lcd saveenv run mmcboot elif tsc selection 3 then lcm color 00ff55 # turn screen green (feedback to touch press) lcm fb 0 echo *** MMC boot partition 1*** setenv bootorder "3 4 1 2" echo new boot order $bootorder setenv defaultdisplay lcd saveenv run mmcboot elif tsc selection 4 then lcm color 55ff55 # turn screen green (feedback to touch press) lcm fb 0 echo *** MMC boot partition 1*** setenv bootorder "4 1 2 3" echo new boot order $bootorder setenv defaultdisplay lcd saveenv run mmcboot elif test "x${flash}" = "xyes" || tsc selection 99 then echo *** NAND flash *** # note: MLO is configured to load U-Boot from MMC # while X-Loader is loading U-Boot from NAND status set 10 i2c dev 0 if fatload mmc 0 0x80200000 x-load.flash then status set 18 echo *** flashing Xloader *** # nand unlock nandecc hw # write some copies nand erase 0 80000 nand write 0x80200000 0 20000 nand write 0x80200000 20000 20000 nand write 0x80200000 40000 20000 nand write 0x80200000 60000 20000 echo *** Xloader flashed *** fi status set 10 # the official u-boot partition goes from 0x80000 to 0x27ffff i.e. 2 MByte if fatload mmc 0 0x80300000 u-boot.flash then echo *** flashing U-Boot *** status set 18 nandecc sw nand erase 80000 1e0000 nand write 0x80300000 80000 150000 echo *** write our new environment *** saveenv # read&write compressed splash image to nand # there is just room for 614 kByte # since u-boot is approx 260 kByte status set 10 if fatload mmc 0 0x80300000 splash.rgb16z then echo *** flashing splash *** status set 18 nandecc sw nand write 0x80300000 1d0000 40000 status set 10 fi status set 10 if fatload mmc 0 0x80300000 menu.rgb16z then echo *** flashing menu *** status set 18 nandecc sw nand write 0x80300000 210000 40000 status set 18 fi status set 10 if fatload mmc 0 0x80300000 boot.scr then echo *** flashing boot.scr *** status set 18 nandecc sw nand write 0x80300000 250000 10000 fi echo *** U-Boot flashed *** fi # please flash kernel and rootfs from Linux status set 8 flash=no # don't flash again echo echo ********************************* echo *** Flashing Done *** echo *** Device will reboot *** echo ********************************* echo run mmcboot # reset # resets CPU only but not BootROM boot order! # we simply show the menu else echo *** Could not decode *** status blink fi done else # default boot w/o menu echo *** booting Linux *** if run loadkernel then # lcm backlight 0 # switch off before booting (?) printenv lcm power 0 lcm off # avoid wash-out bootm ${loadaddr} fi fi else # LCM did not init (e.g. we run without display) echo *** DVI boot *** if run loadkernel then setenv bootdelay 10 setenv defaultdisplay dvi setenv dvimode 1024x768MR-16@60 bootm ${loadaddr} fi fi echo *** Could not run *** lcm color ff0000 lcm fb 0 status blink