blob: d66bcccf5d1cfc8015fc4cb4985154eb748d4534 [file] [log] [blame]
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +02001# 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:
Krzysztof Kozlowskif4befd42019-02-22 19:36:43 +01006# platform dependent: board_name, fdtfile, console
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +02007# system dependent: mmcbootdev, mmcbootpart, mmcrootdev, mmcrootpart, rootfstype
8#
9setenv fdtaddr "40800000"
10setenv initrdname "uInitrd"
11setenv initrdaddr "42000000"
12setenv loaddtb "load mmc ${mmcbootdev}:${mmcbootpart} ${fdtaddr} ${fdtfile}"
13setenv loadinitrd "load mmc ${mmcbootdev}:${mmcbootpart} ${initrdaddr} ${initrdname}"
14setenv loadkernel "load mmc ${mmcbootdev}:${mmcbootpart} '${kerneladdr}' '${kernelname}'"
15setenv 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
18setenv check_dtb "
19if test -e mmc '${mmcbootdev}':'${mmcbootpart}' '${fdtfile}'; then
20 run loaddtb;
21 setenv fdt_addr ${fdtaddr};
22else
23 echo Warning! Booting without DTB: '${fdtfile}'!;
24 setenv fdt_addr;
25fi;"
26
27#### Routine: check_ramdisk - check that uInitrd exists on boot partition
28setenv check_ramdisk "
29if test -e mmc '${mmcbootdev}':'${mmcbootpart}' '${initrdname}'; then
30 echo "Found ramdisk image.";
31 run loadinitrd;
32 setenv initrd_addr ${initrdaddr};
33else
34 echo Warning! Booting without RAMDISK: '${initrdname}'!;
35 setenv initrd_addr -;
36fi;"
37
Krzysztof Kozlowskif4befd42019-02-22 19:36:43 +010038#### Routine: boot_fit - check that env $board_name is set and boot proper config of ITB image
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +020039setenv setboot_fit "
Krzysztof Kozlowskif4befd42019-02-22 19:36:43 +010040if test -e '${board_name}'; then
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +020041 setenv fdt_addr ;
42 setenv initrd_addr ;
43 setenv kerneladdr 0x42000000;
44 setenv kernelname Image.itb;
Krzysztof Kozlowskif4befd42019-02-22 19:36:43 +010045 setenv itbcfg "\"#${board_name}\"";
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +020046 setenv imgbootcmd bootm;
47else
Krzysztof Kozlowskif4befd42019-02-22 19:36:43 +010048 echo Warning! Variable: \$board_name is undefined!;
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +020049fi"
50
51#### Routine: setboot_uimg - prepare env to boot uImage
52setenv 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
61setenv 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
70setenv 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
76setenv autoboot "
Lukasz Majewski42a4b142018-08-01 14:48:56 +020077if test -e mmc ${mmcbootdev}:${mmcbootpart} Image.itb; then
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +020078 echo Found kernel image: Image.itb;
79 run setboot_fit;
80 run boot_img;
Lukasz Majewski42a4b142018-08-01 14:48:56 +020081elif test -e mmc ${mmcbootdev}:${mmcbootpart} zImage; then
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +020082 echo Found kernel image: zImage;
83 run setboot_zimg;
84 run boot_img;
Lukasz Majewski42a4b142018-08-01 14:48:56 +020085elif test -e mmc ${mmcbootdev}:${mmcbootpart} uImage; then
Przemyslaw Marczaka9efd632015-05-22 18:14:28 +020086 echo Found kernel image: uImage;
87 run setboot_uimg;
88 run boot_img;
89fi;"
90
91#### Execute the defined autoboot macro
92run autoboot