# # boot.scr # # Boot script for Beagle Hybrid / Panda Hybrid / GTA04 # # Author: H. Nikolaus Schaller # Copyright Golden Delicious Computers 2010-2012 # 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. run bootcmd # 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 ***" status init status set 8 # give fast feedback that U-Boot did start (red power led) if test "${gta04}" != "${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 mmcdev 0 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 # load zipped/uncompressed image from mmc or nand wherever we find it setenv loadimg 'i2c dev 0; mmc rescan ${mmcdev}; if fatload mmc ${mmcdev} ${imgaddr} ${imgfile}.rgb16; then; elif fatload mmc ${mmcdev} ${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};' # load kernel and boot script from mmc or nand wherever we find it setenv kernelloading 'status set 18' # orange setenv kernelloaded 'status set 10' # green setenv loadbootscript 'i2c dev 0; mmc rescan ${mmcdev}; if fatload mmc ${mmcdev} ${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 loadkernel 'run kernelloading; i2c dev 0; mmc rescan ${mmcdev}; if fatload mmc ${mmcdev} ${loadaddr} uImage; then run mmcargs; elif ext2load mmc 0:2 ${loadaddr} /boot/uImage; then run mmcargs; else nand read ${loadaddr} 280000 400000; run nandargs; fi; run kernelloaded' # set boot arguments setenv mmcargs 'setenv bootargs console=${console} mpurate=${mpurate} vram=${vram} omapfb.vram='0:8M,1:4M' omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} root=${mmcroot} rootfstype=${mmcrootfstype}; echo using mmc rootfs; if fatload mmc ${mmcdev} ${imgtempaddr} bootargs.scr; then source ${imgtempaddr}; elif ext2load mmc 0:2 ${imgtempaddr} /boot/bootargs.scr; ; then source ${imgtempaddr}; fi' setenv mmcroot '/dev/mmcblk0p2 rw' setenv mmcrootfstype 'ext4,ext3,btrfs rootwait' setenv nandargs 'setenv bootargs console=${console} mpurate=${mpurate} vram=${vram} omapfb.vram='0:8M,1:4M' omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} root=${nandroot} rootfstype=${nandrootfstype}; echo using nand rootfs' setenv nandroot '/dev/mtdblock4 rw' setenv nandrootfstype 'jffs2' # as soon as we can use UBIFS, change this to # setenv nandroot 'ubi0:om-gta04-rootfs' # setenv nandrootfstype 'ubifs ubi.mtd=4,2048' # boot with kernel/rootfs from specified source (fallback to NAND for kernel; may call mmcargs twice) setenv mmcboot 'if run loadkernel; then run mmcargs; 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 (but only once) setenv gta04 "${VERSION}" # saveenv flash=yes fi echo *** initializing LCM *** if lcm start || test "x${flash}" = "xyes" then if test "x${flash}" != "xyes" then echo *** loading splash from MMC *** setenv imgaddr 80400000 setenv imgfile splash setenv imgnandaddr 1d0000 run showimg fi if test "x${flash}" = "xyes" || status check 1 # we want to flash or AUX button is (still) pressed then echo *** initializing TSC for boot menu *** tsc init 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 2 3 # 2 columns 3 rows -> value 1 .. 6 # restore boot image setenv imgaddr 80400000 setenv imgfile splash setenv imgnandaddr 1d0000 run showimg fi if tsc selection 1 then echo *** LED mirror *** status mirror elif tsc selection 2 then echo *** LED blink *** systest all elif tsc selection 3 then echo *** LCD boot *** setenv defaultdisplay lcd if run loadkernel; then bootm ${loadaddr}; fi elif tsc selection 4 then 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 5 then echo *** NAND boot *** run nandboot elif tsc selection 6 then echo *** - *** run mmcboot ## this was intended to be a demo while true do setenv imgfile img1 run showimg sleep 3 setenv imgfile img2 run showimg sleep 3 setenv imgfile img3 run showimg sleep 3 setenv imgfile img4 run showimg sleep 3 setenv imgfile img5 run showimg sleep 3 done elif tsc selection 7 then ; elif test "x${flash}" = "xyes" || tsc selection 8 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.bin then echo *** flashing U-Boot *** status set 18 nandecc sw nand erase 80000 1e0000 nand write 0x80300000 80000 150000 echo *** write our 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 if false # don't overwrite the kernel just because we have modified the boot script version then status set 10 if fatload mmc 0 0x80300000 uImage then echo *** flashing Kernel (max. 4 MByte) *** nandecc sw nand erase 280000 400000 nand write 0x80300000 280000 400000 status set 18 fi fi # can we flash a rootfs from MMC? # currently no # we would need jffs2 and tar/cp -R support status set 8 flash=no # don't flash again echo echo ********************************* echo *** Flashing Done *** echo *** Device will boot from MMC *** echo ********************************* echo run mmcboot # if u-boot had a "reboot" command we should use it here... 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 *** status blink