Przemyslaw Marczak | a9efd63 | 2015-05-22 18:14:28 +0200 | [diff] [blame] | 1 | # This is an example file to generate boot.scr - a boot script for U-Boot |
| 2 | # Generate boot.scr: |
| 3 | # ./tools/mkimage -c none -A arm -T script -d autoboot.cmd boot.scr |
| 4 | # |
| 5 | # It requires a list of environment variables to be defined before load: |
| 6 | # platform dependent: boardname, fdtfile, console |
| 7 | # system dependent: mmcbootdev, mmcbootpart, mmcrootdev, mmcrootpart, rootfstype |
| 8 | # |
| 9 | setenv fdtaddr "40800000" |
| 10 | setenv initrdname "uInitrd" |
| 11 | setenv initrdaddr "42000000" |
| 12 | setenv loaddtb "load mmc ${mmcbootdev}:${mmcbootpart} ${fdtaddr} ${fdtfile}" |
| 13 | setenv loadinitrd "load mmc ${mmcbootdev}:${mmcbootpart} ${initrdaddr} ${initrdname}" |
| 14 | setenv loadkernel "load mmc ${mmcbootdev}:${mmcbootpart} '${kerneladdr}' '${kernelname}'" |
| 15 | setenv kernel_args "setenv bootargs ${console} root=/dev/mmcblk${mmcrootdev}p${mmcrootpart} rootfstype=${rootfstype} rootwait ${opts}" |
| 16 | |
| 17 | #### Routine: check_dtb - check that target.dtb exists on boot partition |
| 18 | setenv check_dtb " |
| 19 | if test -e mmc '${mmcbootdev}':'${mmcbootpart}' '${fdtfile}'; then |
| 20 | run loaddtb; |
| 21 | setenv fdt_addr ${fdtaddr}; |
| 22 | else |
| 23 | echo Warning! Booting without DTB: '${fdtfile}'!; |
| 24 | setenv fdt_addr; |
| 25 | fi;" |
| 26 | |
| 27 | #### Routine: check_ramdisk - check that uInitrd exists on boot partition |
| 28 | setenv check_ramdisk " |
| 29 | if test -e mmc '${mmcbootdev}':'${mmcbootpart}' '${initrdname}'; then |
| 30 | echo "Found ramdisk image."; |
| 31 | run loadinitrd; |
| 32 | setenv initrd_addr ${initrdaddr}; |
| 33 | else |
| 34 | echo Warning! Booting without RAMDISK: '${initrdname}'!; |
| 35 | setenv initrd_addr -; |
| 36 | fi;" |
| 37 | |
| 38 | #### Routine: boot_fit - check that env $boardname is set and boot proper config of ITB image |
| 39 | setenv setboot_fit " |
| 40 | if test -e '${boardname}'; then |
| 41 | setenv fdt_addr ; |
| 42 | setenv initrd_addr ; |
| 43 | setenv kerneladdr 0x42000000; |
| 44 | setenv kernelname Image.itb; |
Ćukasz Majewski | 286fd9d | 2015-06-17 12:49:23 +0200 | [diff] [blame] | 45 | setenv itbcfg "\"#${boardname}\""; |
Przemyslaw Marczak | a9efd63 | 2015-05-22 18:14:28 +0200 | [diff] [blame] | 46 | setenv imgbootcmd bootm; |
| 47 | else |
| 48 | echo Warning! Variable: \$boardname is undefined!; |
| 49 | fi" |
| 50 | |
| 51 | #### Routine: setboot_uimg - prepare env to boot uImage |
| 52 | setenv setboot_uimg " |
| 53 | setenv kerneladdr 0x40007FC0; |
| 54 | setenv kernelname uImage; |
| 55 | setenv itbcfg ; |
| 56 | setenv imgbootcmd bootm; |
| 57 | run check_dtb; |
| 58 | run check_ramdisk;" |
| 59 | |
| 60 | #### Routine: setboot_zimg - prepare env to boot zImage |
| 61 | setenv setboot_zimg " |
| 62 | setenv kerneladdr 0x40007FC0; |
| 63 | setenv kernelname zImage; |
| 64 | setenv itbcfg ; |
| 65 | setenv imgbootcmd bootz; |
| 66 | run check_dtb; |
| 67 | run check_ramdisk;" |
| 68 | |
| 69 | #### Routine: boot_img - boot the kernel after env setup |
| 70 | setenv boot_img " |
| 71 | run loadkernel; |
| 72 | run kernel_args; |
| 73 | '${imgbootcmd}' '${kerneladdr}${itbcfg}' '${initrd_addr}' '${fdt_addr}';" |
| 74 | |
| 75 | #### Routine: autoboot - choose proper boot path |
| 76 | setenv autoboot " |
| 77 | if test -e mmc 0:${mmcbootpart} Image.itb; then |
| 78 | echo Found kernel image: Image.itb; |
| 79 | run setboot_fit; |
| 80 | run boot_img; |
| 81 | elif test -e mmc 0:${mmcbootpart} zImage; then |
| 82 | echo Found kernel image: zImage; |
| 83 | run setboot_zimg; |
| 84 | run boot_img; |
| 85 | elif test -e mmc 0:${mmcbootpart} uImage; then |
| 86 | echo Found kernel image: uImage; |
| 87 | run setboot_uimg; |
| 88 | run boot_img; |
| 89 | fi;" |
| 90 | |
| 91 | #### Execute the defined autoboot macro |
| 92 | run autoboot |