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#
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
38#### Routine: boot_fit - check that env $boardname is set and boot proper config of ITB image
39setenv setboot_fit "
40if test -e '${boardname}'; then
41	setenv fdt_addr ;
42	setenv initrd_addr ;
43	setenv kerneladdr  0x42000000;
44	setenv kernelname  Image.itb;
45	setenv itbcfg      "\"#${boardname}\"";
46	setenv imgbootcmd  bootm;
47else
48	echo Warning! Variable: \$boardname is undefined!;
49fi"
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 "
77if test -e mmc 0:${mmcbootpart} Image.itb; then
78	echo Found kernel image: Image.itb;
79	run setboot_fit;
80	run boot_img;
81elif test -e mmc 0:${mmcbootpart} zImage; then
82	echo Found kernel image: zImage;
83	run setboot_zimg;
84	run boot_img;
85elif test -e mmc 0:${mmcbootpart} uImage; then
86	echo Found kernel image: uImage;
87	run setboot_uimg;
88	run boot_img;
89fi;"
90
91#### Execute the defined autoboot macro
92run autoboot
93