Commit 3ef5f6714ab1501247b227ffdcb5f37fd13c0bce

Authored by Christopher Spinrath
Committed by Stefano Babic
1 parent 6b79f71c8e

ARM: imx: cm_fx6: env: support distro boot command

The current default environment of the cm_fx6 is not suitable for
booting modern distributions.

Instead of extending the custom environment, let's use the distro
boot command, which has been developed for precisely this use case.

If the distro boot command fails, fall back to the old behavior
(except for USB drives where the old behaviour is completely covered
by the distro boot command). That way it is still possible to create
"rescue SD cards" for old installations (e.g. if one messes up the
on-flash environment).

Signed-off-by: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>

Showing 2 changed files with 30 additions and 20 deletions Side-by-side Diff

configs/cm_fx6_defconfig
... ... @@ -12,9 +12,11 @@
12 12 # CONFIG_CMD_BMODE is not set
13 13 CONFIG_DEFAULT_DEVICE_TREE="imx6q-cm-fx6"
14 14 CONFIG_AHCI=y
  15 +CONFIG_DISTRO_DEFAULTS=y
15 16 CONFIG_OF_BOARD_SETUP=y
16 17 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
17 18 CONFIG_BOOTDELAY=3
  19 +CONFIG_BOOTCOMMAND="run distro_bootcmd; run legacy_bootcmd"
18 20 CONFIG_SPL=y
19 21 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x80
20 22 CONFIG_SPL_I2C_SUPPORT=y
include/configs/cm_fx6.h
... ... @@ -13,6 +13,10 @@
13 13  
14 14 #include "mx6_common.h"
15 15  
  16 +#ifndef CONFIG_SPL_BUILD
  17 +#include <config_distro_defaults.h>
  18 +#endif
  19 +
16 20 /* Machine config */
17 21 #define CONFIG_SYS_LITTLE_ENDIAN
18 22 #define CONFIG_MACH_TYPE 4273
... ... @@ -62,6 +66,7 @@
62 66 #define CONFIG_ENV_SIZE (8 * 1024)
63 67 #define CONFIG_ENV_OFFSET (768 * 1024)
64 68  
  69 +#ifndef CONFIG_SPL_BUILD
65 70 #define CONFIG_EXTRA_ENV_SETTINGS \
66 71 "fdt_high=0xffffffff\0" \
67 72 "initrd_high=0xffffffff\0" \
... ... @@ -126,7 +131,6 @@
126 131 "setupmmcboot=setenv storagetype mmc; setenv storagedev 2;\0" \
127 132 "setupsataboot=setenv storagetype sata; setenv storagedev 0;\0" \
128 133 "setupnandboot=setenv storagetype nand;\0" \
129   - "setupusbboot=setenv storagetype usb; setenv storagedev 0;\0" \
130 134 "storagebootcmd=echo Booting from ${storagetype} ...;" \
131 135 "run ${storagetype}args; run doboot;\0" \
132 136 "trybootk=if run loadkernel; then " \
133 137  
134 138  
... ... @@ -141,28 +145,32 @@
141 145 "run setboottypem;" \
142 146 "run trybootk;" \
143 147 "run setboottypez;" \
144   - "run trybootk;\0"
145   -
146   -#define CONFIG_BOOTCOMMAND \
147   - "run setupmmcboot;" \
148   - "mmc dev ${storagedev};" \
149   - "if mmc rescan; then " \
150   - "run trybootsmz;" \
151   - "fi;" \
152   - "run setupusbboot;" \
153   - "if usb start; then "\
154   - "if run loadscript; then " \
155   - "run bootscript;" \
  148 + "run trybootk;\0" \
  149 + "legacy_bootcmd=" \
  150 + "run setupmmcboot;" \
  151 + "mmc dev ${storagedev};" \
  152 + "if mmc rescan; then " \
  153 + "run trybootsmz;" \
156 154 "fi;" \
157   - "fi;" \
158   - "run setupsataboot;" \
159   - "if sata init; then " \
160   - "run trybootsmz;" \
161   - "fi;" \
162   - "run setupnandboot;" \
163   - "run nandboot;"
  155 + "run setupsataboot;" \
  156 + "if sata init; then " \
  157 + "run trybootsmz;" \
  158 + "fi;" \
  159 + "run setupnandboot;" \
  160 + "run nandboot;\0" \
  161 + BOOTENV
164 162  
165 163 #define CONFIG_PREBOOT "usb start;sf probe"
  164 +
  165 +#define BOOT_TARGET_DEVICES(func) \
  166 + func(USB, usb, 0) \
  167 + func(MMC, mmc, 2) \
  168 + func(SATA, sata, 0)
  169 +
  170 +#include <config_distro_bootcmd.h>
  171 +#else
  172 +#define CONFIG_EXTRA_ENV_SETTINGS
  173 +#endif
166 174  
167 175 /* SPI */
168 176 #define CONFIG_SPI