Commit 73e9db22abf5d6ee9db88efa4a1b404f972b8e24

Authored by Hannes Schmelzer
Committed by Tom Rini
1 parent d63f7130ce

board/BuR/brppt1: implement more flexible boot process

With this commit we do:

- set the bootdelay in all brppt1 defconfigs to 0, this makes
development easier, since we can break into serial console.

- move CONFIG_BOOTCOMMAND from header file to defconfig

- introduce b_mode variable for selecting the final boot-target.
This b_mode represents the boot-switch, which can found on most b&r
targets. On the brppt1 this boot-switch is derived from some gpio and
the bootcounter within the RTC block, making it so possible to force
a boot-target (as example for repair-case).

- refactor the environment for booting new flexible way
primary we want to get some bootscr.img within the mass-storage,
this script then loads everything needed for the boot.
For legacy reason we implement the t30lgcy#x boot targets, booting the
already delivered linux-images.

- make space for the cfgscr within mtdparts on brppt1_nand

Signed-off-by: Hannes Schmelzer <oe5hpm@oevsv.at>

Showing 5 changed files with 102 additions and 85 deletions Side-by-side Diff

board/BuR/brppt1/board.c
... ... @@ -140,11 +140,33 @@
140 140 }
141 141  
142 142 #ifdef CONFIG_BOARD_LATE_INIT
  143 +static char *bootmodeascii[16] = {
  144 + "BOOT", "reserved", "reserved", "reserved",
  145 + "RUN", "reserved", "reserved", "reserved",
  146 + "reserved", "reserved", "reserved", "reserved",
  147 + "PME", "reserved", "reserved", "DIAG",
  148 +};
  149 +
143 150 int board_late_init(void)
144 151 {
145   - if (0 == gpio_get_value(REPSWITCH)) {
146   - env_set("bootcmd", "run netconsole");
147   - }
  152 + unsigned char bmode = 0;
  153 + ulong bootcount = 0;
  154 +
  155 + bootcount = bootcount_load() & 0xF;
  156 +
  157 + if (gpio_get_value(REPSWITCH) == 0 || bootcount == 12)
  158 + bmode = 12;
  159 + else if (bootcount > 0)
  160 + bmode = 0;
  161 + else
  162 + bmode = 4;
  163 +
  164 + printf("Mode: %s\n", bootmodeascii[bmode & 0x0F]);
  165 + env_set_ulong("b_mode", bmode);
  166 +
  167 + /* get sure that bootcmd isn't affected by any bootcount value */
  168 + env_set_ulong("bootlimit", 0);
  169 +
148 170 return 0;
149 171 }
150 172 #endif /* CONFIG_BOARD_LATE_INIT */
configs/brppt1_mmc_defconfig
... ... @@ -10,7 +10,9 @@
10 10 CONFIG_SPL=y
11 11 CONFIG_OF_BOARD_SETUP=y
12 12 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1,EMMC_BOOT"
13   -CONFIG_BOOTDELAY=-2
  13 +CONFIG_BOOTDELAY=0
  14 +CONFIG_USE_BOOTCOMMAND=y
  15 +CONFIG_BOOTCOMMAND="run b_default"
14 16 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
15 17 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
16 18 CONFIG_SYS_CONSOLE_INFO_QUIET=y
configs/brppt1_nand_defconfig
... ... @@ -9,7 +9,9 @@
9 9 CONFIG_SPL=y
10 10 CONFIG_OF_BOARD_SETUP=y
11 11 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1"
12   -CONFIG_BOOTDELAY=-2
  12 +CONFIG_BOOTDELAY=0
  13 +CONFIG_USE_BOOTCOMMAND=y
  14 +CONFIG_BOOTCOMMAND="run b_default"
13 15 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
14 16 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
15 17 CONFIG_SYS_CONSOLE_INFO_QUIET=y
... ... @@ -46,7 +48,7 @@
46 48 CONFIG_CMD_FS_GENERIC=y
47 49 CONFIG_CMD_MTDPARTS=y
48 50 CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0"
49   -CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:128k(MLO),128k(MLO.backup),128k(dtb),128k(u-boot-env),512k(u-boot),4m(kernel),128m(rootfs),-(user)"
  51 +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:128k(MLO),128k(cfgscr),128k(dtb),128k(u-boot-env),512k(u-boot),4m(kernel),128m(rootfs),-(user)"
50 52 CONFIG_ENV_IS_IN_NAND=y
51 53 CONFIG_NETCONSOLE=y
52 54 CONFIG_BOOTCOUNT_LIMIT=y
configs/brppt1_spi_defconfig
... ... @@ -13,7 +13,9 @@
13 13 CONFIG_OF_BOARD_SETUP=y
14 14 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1,SPI_BOOT,EMMC_BOOT"
15 15 CONFIG_SPI_BOOT=y
16   -CONFIG_BOOTDELAY=-2
  16 +CONFIG_BOOTDELAY=0
  17 +CONFIG_USE_BOOTCOMMAND=y
  18 +CONFIG_BOOTCOMMAND="run b_default"
17 19 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
18 20 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
19 21 CONFIG_SYS_CONSOLE_INFO_QUIET=y
include/configs/brppt1.h
... ... @@ -16,6 +16,7 @@
16 16 /* ------------------------------------------------------------------------- */
17 17 /* memory */
18 18 #define CONFIG_SYS_MALLOC_LEN (5 * 1024 * 1024)
  19 +#define CONFIG_SYS_BOOTM_LEN SZ_32M
19 20  
20 21 /* Clock Defines */
21 22 #define V_OSCK 26000000 /* Clock output from T2 */
22 23  
23 24  
24 25  
25 26  
26 27  
27 28  
28 29  
29 30  
... ... @@ -56,99 +57,87 @@
56 57 #define CONFIG_ENV_SIZE (64 << 10)
57 58  
58 59 #ifdef CONFIG_NAND
59   -#define NANDARGS \
60   - "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \
61   - "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
62   - "nandargs=setenv bootargs console=${console} " \
63   - "${optargs} " \
64   - "${optargs_rot} " \
65   - "root=mtd6 " \
66   - "rootfstype=jffs2\0" \
67   - "kernelsize=0x400000\0" \
68   - "nandboot=echo booting from nand ...; " \
69   - "run nandargs; " \
70   - "nand read ${loadaddr} kernel ${kernelsize}; " \
71   - "bootz ${loadaddr} - ${dtbaddr}\0" \
72   - "defboot=run nandboot\0" \
73   - "bootlimit=1\0" \
74   - "simplefb=1\0 " \
75   - "altbootcmd=run usbscript\0"
  60 +#define NANDTGTS \
  61 +"mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \
  62 +"mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
  63 +"cfgscr=nand read ${cfgaddr} cfgscr && source ${cfgaddr}\0" \
  64 +"nandargs=setenv bootargs console=${console} ${optargs} ${optargs_rot} " \
  65 + "root=mtd6 rootfstype=jffs2 b_mode=${b_mode}\0" \
  66 +"b_nand=nand read ${loadaddr} kernel; nand read ${dtbaddr} dtb; " \
  67 + "run nandargs; run cfgscr; bootz ${loadaddr} - ${dtbaddr}\0" \
  68 +"b_tgts_std=usb0 nand net\0" \
  69 +"b_tgts_rcy=net usb0 nand\0" \
  70 +"b_tgts_pme=usb0 nand net\0"
76 71 #else
77   -#define NANDARGS ""
  72 +#define NANDTGTS ""
78 73 #endif /* CONFIG_NAND */
79 74  
  75 +#define MMCSPI_TGTS \
  76 +"t30args#0=setenv bootargs ${optargs_rot} ${optargs} console=${console} " \
  77 + "b_mode=${b_mode} root=/dev/mmcblk0p2 rootfstype=ext4\0" \
  78 +"b_t30lgcy#0=" \
  79 + "load ${loaddev}:2 ${loadaddr} /boot/PPTImage.md5 && " \
  80 + "load ${loaddev}:2 ${loadaddr} /boot/zImage && " \
  81 + "load ${loaddev}:2 ${dtbaddr} /boot/am335x-ppt30.dtb || " \
  82 + "load ${loaddev}:1 ${dtbaddr} am335x-ppt30-legacy.dtb; "\
  83 + "run t30args#0; run cfgscr; bootz ${loadaddr} - ${dtbaddr}\0" \
  84 +"t30args#1=setenv bootargs ${optargs_rot} ${optargs} console=${console} " \
  85 + "b_mode=${b_mode}\0" \
  86 +"b_t30lgcy#1=" \
  87 + "load ${loaddev}:1 ${loadaddr} zImage && " \
  88 + "load ${loaddev}:1 ${dtbaddr} am335x-ppt30.dtb && " \
  89 + "load ${loaddev}:1 ${ramaddr} rootfsPPT30.uboot && " \
  90 + "run t30args#1; run cfgscr; bootz ${loadaddr} ${ramaddr} ${dtbaddr}\0" \
  91 +"b_mmc0=load ${loaddev}:1 ${scraddr} bootscr.img && source ${scraddr}\0" \
  92 +"b_mmc1=load ${loaddev}:1 ${scraddr} /boot/bootscr.img && source ${scraddr}\0" \
  93 +"b_tgts_std=mmc0 mmc1 t30lgcy#0 t30lgcy#1 usb0 net\0" \
  94 +"b_tgts_rcy=t30lgcy#1 usb0 net\0" \
  95 +"b_tgts_pme=net usb0 mmc0 mmc1\0" \
  96 +"loaddev=mmc 1\0"
  97 +
80 98 #ifdef CONFIG_MMC
81   -#define MMCARGS \
82   -"dtbdev=mmc\0" \
83   -"dtbpart=1:1\0" \
84   -"mmcroot0=setenv bootargs ${optargs_rot} ${optargs} console=${console}\0" \
85   -"mmcroot1=setenv bootargs ${optargs_rot} ${optargs} console=${console} " \
86   - "root=/dev/mmcblk0p2 rootfstype=ext4\0" \
87   -"mmcboot0=echo booting Updatesystem from mmc (ext4-fs) ...; " \
88   - "setenv simplefb 1; " \
89   - "ext4load mmc 1:1 ${loadaddr} /${kernel}; " \
90   - "ext4load mmc 1:1 ${ramaddr} /${ramdisk}; " \
91   - "run mmcroot0; bootz ${loadaddr} ${ramaddr} ${dtbaddr};\0" \
92   -"mmcboot1=echo booting PPT-OS from mmc (ext4-fs) ...; " \
93   - "setenv simplefb 0; " \
94   - "ext4load mmc 1:2 ${loadaddr} /boot/${kernel}; " \
95   - "run mmcroot1; bootz ${loadaddr} - ${dtbaddr};\0" \
96   -"defboot=ext4load mmc 1:2 ${loadaddr} /boot/PPTImage.md5 && run mmcboot1; " \
97   - "ext4load mmc 1:1 ${dtbaddr} /$dtb && run mmcboot0; " \
98   - "run ramboot; run usbscript;\0" \
99   -"bootlimit=1\0" \
100   -"altbootcmd=mmc dev 1; run mmcboot0;\0" \
101   -"upduboot=dhcp; " \
102   - "tftp ${loadaddr} MLO && mmc write ${loadaddr} 100 100; " \
103   - "tftp ${loadaddr} u-boot.img && mmc write ${loadaddr} 300 400;\0"
  99 +#define MMCTGTS \
  100 +MMCSPI_TGTS \
  101 +"cfgscr=mmc dev 1; mmc read ${cfgaddr} 200 80; source ${cfgaddr}\0"
104 102 #else
105   -#define MMCARGS ""
  103 +#define MMCTGTS ""
106 104 #endif /* CONFIG_MMC */
107 105  
  106 +#ifdef CONFIG_SPI
  107 +#define SPITGTS \
  108 +MMCSPI_TGTS \
  109 +"cfgscr=sf probe; sf read ${cfgaddr} 0xC0000 10000; source ${cfgaddr}\0"
  110 +#else
  111 +#define SPITGTS ""
  112 +#endif /* CONFIG_SPI */
  113 +
  114 +#define LOAD_OFFSET(x) 0x8##x
  115 +
108 116 #ifndef CONFIG_SPL_BUILD
109 117 #define CONFIG_EXTRA_ENV_SETTINGS \
110 118 BUR_COMMON_ENV \
111 119 "verify=no\0" \
112 120 "autoload=0\0" \
113   -"dtb=bur-ppt-ts30.dtb\0" \
114   -"dtbaddr=0x80100000\0" \
115   -"loadaddr=0x80200000\0" \
116   -"ramaddr=0x80A00000\0" \
117   -"kernel=zImage\0" \
118   -"ramdisk=rootfs.cpio.uboot\0" \
  121 +"scraddr=" __stringify(LOAD_OFFSET(0000000)) "\0" \
  122 +"cfgaddr=" __stringify(LOAD_OFFSET(0020000)) "\0" \
  123 +"dtbaddr=" __stringify(LOAD_OFFSET(0040000)) "\0" \
  124 +"loadaddr=" __stringify(LOAD_OFFSET(0100000)) "\0" \
  125 +"ramaddr=" __stringify(LOAD_OFFSET(2000000)) "\0" \
119 126 "console=ttyO0,115200n8\0" \
120 127 "optargs=consoleblank=0 quiet panic=2\0" \
121   -"nfsroot=/tftpboot/tseries/rootfs-small\0" \
122   -"nfsopts=nolock\0" \
123   -"ramargs=setenv bootargs ${optargs} console=${console} root=/dev/ram0\0" \
124   -"netargs=setenv bootargs console=${console} " \
125   - "${optargs} " \
126   - "root=/dev/nfs " \
127   - "nfsroot=${serverip}:${nfsroot},${nfsopts} rw " \
128   - "ip=dhcp\0" \
129   -"netboot=echo Booting from network ...; " \
130   - "dhcp; " \
131   - "tftp ${loadaddr} ${kernel}; " \
132   - "tftp ${dtbaddr} ${dtb}; " \
133   - "run netargs; " \
134   - "bootz ${loadaddr} - ${dtbaddr}\0" \
135   -"ramboot=echo Booting from network into RAM ...; "\
136   - "if dhcp; then; " \
137   - "tftp ${loadaddr} ${kernel}; " \
138   - "tftp ${ramaddr} ${ramdisk}; " \
139   - "if ext4load ${dtbdev} ${dtbpart} ${dtbaddr} /${dtb}; " \
140   - "then; else tftp ${dtbaddr} ${dtb}; fi;" \
141   - "run mmcroot0; " \
142   - "bootz ${loadaddr} ${ramaddr} ${dtbaddr}; fi;\0" \
143   -"netupdate=echo Updating UBOOT from Network (TFTP) ...; " \
144   - "setenv autoload 0; " \
145   - "dhcp && tftp 0x80000000 updateUBOOT.img && source;\0" \
146   -NANDARGS \
147   -MMCARGS
  128 +"b_break=0\0" \
  129 +"b_usb0=usb start && load usb 0 ${scraddr} bootscr.img && source ${scraddr}\0" \
  130 +"b_net=tftp ${scraddr} netscript.img && source ${scraddr}\0" \
  131 +MMCTGTS \
  132 +SPITGTS \
  133 +NANDTGTS \
  134 +"b_deftgts=if test ${b_mode} = 12; then setenv b_tgts ${b_tgts_pme};" \
  135 +" elif test ${b_mode} = 0; then setenv b_tgts ${b_tgts_rcy};" \
  136 +" else setenv b_tgts ${b_tgts_std}; fi\0" \
  137 +"b_default=run b_deftgts; for target in ${b_tgts};"\
  138 +" do echo \"### booting ${target} ###\"; run b_${target};" \
  139 +" if test ${b_break} = 1; then; exit; fi; done\0"
148 140 #endif /* !CONFIG_SPL_BUILD*/
149   -
150   -#define CONFIG_BOOTCOMMAND \
151   - "mmc dev 1; run defboot;"
152 141  
153 142 #ifdef CONFIG_NAND
154 143 /*