[U-Boot] [PATCH v3 01/10] fw_env.c: Switch get_config to use '%ms' in sscanf

We currently limit ourself to 16 characters for the device name to read the environment from. This is insufficient for /dev/mmcblk0boot1 to work for example. Switch to '%ms' which gives us a dynamically allocated buffer instead. We're short lived enough to not bother free()ing the buffer.
Signed-off-by: Tom Rini trini@ti.com
--- Changes in v2: - Rework to use '%ms' in get_config per Wolfgang
Signed-off-by: Tom Rini trini@ti.com --- tools/env/fw_env.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index d228cc3..f5cd521 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -40,7 +40,7 @@ _min1 < _min2 ? _min1 : _min2; })
struct envdev_s { - char devname[16]; /* Device name */ + const char *devname; /* Device name */ ulong devoff; /* Device offset */ ulong env_size; /* environment size */ ulong erase_size; /* device erase size */ @@ -1243,7 +1243,7 @@ static int parse_config () return -1; } #else - strcpy (DEVNAME (0), DEVICE1_NAME); + DEVNAME (0) = DEVICE1_NAME; DEVOFFSET (0) = DEVICE1_OFFSET; ENVSIZE (0) = ENV1_SIZE; /* Default values are: erase-size=env-size */ @@ -1258,7 +1258,7 @@ static int parse_config () #endif
#ifdef HAVE_REDUND - strcpy (DEVNAME (1), DEVICE2_NAME); + DEVNAME (1) = DEVICE2_NAME; DEVOFFSET (1) = DEVICE2_OFFSET; ENVSIZE (1) = ENV2_SIZE; /* Default values are: erase-size=env-size */ @@ -1297,6 +1297,7 @@ static int get_config (char *fname) int i = 0; int rc; char dump[128]; + char *devname;
fp = fopen (fname, "r"); if (fp == NULL) @@ -1307,8 +1308,8 @@ static int get_config (char *fname) if (dump[0] == '#') continue;
- rc = sscanf (dump, "%s %lx %lx %lx %lx", - DEVNAME (i), + rc = sscanf (dump, "%ms %lx %lx %lx %lx", + &devname, &DEVOFFSET (i), &ENVSIZE (i), &DEVESIZE (i), @@ -1317,6 +1318,8 @@ static int get_config (char *fname) if (rc < 3) continue;
+ DEVNAME(i) = devname; + if (rc < 4) /* Assume the erase size is the same as the env-size */ DEVESIZE(i) = ENVSIZE(i);

Inside of SPL we only concern ourself with one MMC device, so instead of being able to use CONFIG_SYS_MMC_ENV_DEV we need to use 0 in SPL. Switch the code to use a 'dev' variable to facilitate this.
Signed-off-by: Tom Rini trini@ti.com --- common/env_mmc.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-)
diff --git a/common/env_mmc.c b/common/env_mmc.c index 045428c..d42168b 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -64,6 +64,14 @@ int env_init(void)
static int init_mmc_for_env(struct mmc *mmc) { +#ifdef CONFIG_SYS_MMC_ENV_PART + int dev = CONFIG_SYS_MMC_ENV_DEV; + +#ifdef CONFIG_SPL_BUILD + dev = 0; +#endif +#endif + if (!mmc) { puts("No MMC card found\n"); return -1; @@ -76,8 +84,7 @@ static int init_mmc_for_env(struct mmc *mmc)
#ifdef CONFIG_SYS_MMC_ENV_PART if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) { - if (mmc_switch_part(CONFIG_SYS_MMC_ENV_DEV, - CONFIG_SYS_MMC_ENV_PART)) { + if (mmc_switch_part(dev, CONFIG_SYS_MMC_ENV_PART)) { puts("MMC partition switch failed\n"); return -1; } @@ -90,9 +97,13 @@ static int init_mmc_for_env(struct mmc *mmc) static void fini_mmc_for_env(struct mmc *mmc) { #ifdef CONFIG_SYS_MMC_ENV_PART + int dev = CONFIG_SYS_MMC_ENV_DEV; + +#ifdef CONFIG_SPL_BUILD + dev = 0; +#endif if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) - mmc_switch_part(CONFIG_SYS_MMC_ENV_DEV, - mmc->part_num); + mmc_switch_part(dev, mmc->part_num); #endif }
@@ -174,12 +185,16 @@ static inline int read_env(struct mmc *mmc, unsigned long size, unsigned long offset, const void *buffer) { uint blk_start, blk_cnt, n; + int dev = CONFIG_SYS_MMC_ENV_DEV; + +#ifdef CONFIG_SPL_BUILD + dev = 0; +#endif
blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len; blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len;
- n = mmc->block_dev.block_read(CONFIG_SYS_MMC_ENV_DEV, blk_start, - blk_cnt, (uchar *)buffer); + n = mmc->block_dev.block_read(dev, blk_start, blk_cnt, (uchar *)buffer);
return (n == blk_cnt) ? 0 : -1; } @@ -188,16 +203,23 @@ static inline int read_env(struct mmc *mmc, unsigned long size, void env_relocate_spec(void) { #if !defined(ENV_IS_EMBEDDED) - struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); + struct mmc *mmc; u32 offset1, offset2; int read1_fail = 0, read2_fail = 0; int crc1_ok = 0, crc2_ok = 0; env_t *ep; int ret; + int dev = CONFIG_SYS_MMC_ENV_DEV;
ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1); ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env2, 1);
+#ifdef CONFIG_SPL_BUILD + dev = 0; +#endif + + mmc = find_mmc_device(dev); + if (tmp_env1 == NULL || tmp_env2 == NULL) { puts("Can't allocate buffers for environment\n"); ret = 1; @@ -274,9 +296,16 @@ void env_relocate_spec(void) { #if !defined(ENV_IS_EMBEDDED) ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE); - struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); + struct mmc *mmc; u32 offset; int ret; + int dev = CONFIG_SYS_MMC_ENV_DEV; + +#ifdef CONFIG_SPL_BUILD + dev = 0; +#endif + + mmc = find_mmc_device(dev);
if (init_mmc_for_env(mmc)) { ret = 1;

On Fri, Mar 28, 2014 at 12:03:34PM -0400, Tom Rini wrote:
Inside of SPL we only concern ourself with one MMC device, so instead of being able to use CONFIG_SYS_MMC_ENV_DEV we need to use 0 in SPL. Switch the code to use a 'dev' variable to facilitate this.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

With 452a272 we moved to allocating these variables on the stack. So they will never now be NULL so remove these checks.
Signed-off-by: Tom Rini trini@ti.com --- common/env_mmc.c | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/common/env_mmc.c b/common/env_mmc.c index d42168b..f47bd77 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -220,12 +220,6 @@ void env_relocate_spec(void)
mmc = find_mmc_device(dev);
- if (tmp_env1 == NULL || tmp_env2 == NULL) { - puts("Can't allocate buffers for environment\n"); - ret = 1; - goto err; - } - if (init_mmc_for_env(mmc)) { ret = 1; goto err;

On Fri, Mar 28, 2014 at 12:03:35PM -0400, Tom Rini wrote:
With 452a272 we moved to allocating these variables on the stack. So they will never now be NULL so remove these checks.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

This mainly converts the am335x_spl_bch driver to the "normal" format which means a slight change to nand_info within the driver.
Acked-by: Scott Wood scottwood@freescale.com Signed-off-by: Tom Rini trini@ti.com --- Changes in v2: - Document CONFIG_SPL_MTD_SUPPORT in the README --- README | 4 +++ drivers/mtd/nand/am335x_spl_bch.c | 54 ++++++++++++++++++------------------- include/configs/ti_armv7_common.h | 1 + spl/Makefile | 1 + 4 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/README b/README index 216f0c7..b035033 100644 --- a/README +++ b/README @@ -3314,6 +3314,10 @@ FIT uImage format: Support for NAND boot using simple NAND drivers that expose the cmd_ctrl() interface.
+ CONFIG_SPL_MTD_SUPPORT + Support for the MTD subsystem within SPL. Useful for + environment on NAND support within SPL. + CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT Set for the SPL on PPC mpc8xxx targets, support for drivers/ddr/fsl/libddr.o in SPL binary. diff --git a/drivers/mtd/nand/am335x_spl_bch.c b/drivers/mtd/nand/am335x_spl_bch.c index c84851b..bd89b06 100644 --- a/drivers/mtd/nand/am335x_spl_bch.c +++ b/drivers/mtd/nand/am335x_spl_bch.c @@ -16,7 +16,7 @@ #include <linux/mtd/nand_ecc.h>
static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS; -static nand_info_t mtd; +nand_info_t nand_info[1]; static struct nand_chip nand_chip;
#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ @@ -30,12 +30,12 @@ static struct nand_chip nand_chip; static int nand_command(int block, int page, uint32_t offs, u8 cmd) { - struct nand_chip *this = mtd.priv; + struct nand_chip *this = nand_info[0].priv; int page_addr = page + block * CONFIG_SYS_NAND_PAGE_COUNT; void (*hwctrl)(struct mtd_info *mtd, int cmd, unsigned int ctrl) = this->cmd_ctrl;
- while (!this->dev_ready(&mtd)) + while (!this->dev_ready(&nand_info[0])) ;
/* Emulate NAND_CMD_READOOB */ @@ -45,11 +45,11 @@ static int nand_command(int block, int page, uint32_t offs, }
/* Begin command latch cycle */ - hwctrl(&mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE); + hwctrl(&nand_info[0], cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE);
if (cmd == NAND_CMD_RESET) { - hwctrl(&mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); - while (!this->dev_ready(&mtd)) + hwctrl(&nand_info[0], NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + while (!this->dev_ready(&nand_info[0])) ; return 0; } @@ -60,35 +60,35 @@ static int nand_command(int block, int page, uint32_t offs,
/* Set ALE and clear CLE to start address cycle */ /* Column address */ - hwctrl(&mtd, offs & 0xff, + hwctrl(&nand_info[0], offs & 0xff, NAND_CTRL_ALE | NAND_CTRL_CHANGE); /* A[7:0] */ - hwctrl(&mtd, (offs >> 8) & 0xff, NAND_CTRL_ALE); /* A[11:9] */ + hwctrl(&nand_info[0], (offs >> 8) & 0xff, NAND_CTRL_ALE); /* A[11:9] */ /* Row address */ - hwctrl(&mtd, (page_addr & 0xff), NAND_CTRL_ALE); /* A[19:12] */ - hwctrl(&mtd, ((page_addr >> 8) & 0xff), + hwctrl(&nand_info[0], (page_addr & 0xff), NAND_CTRL_ALE); /* A[19:12] */ + hwctrl(&nand_info[0], ((page_addr >> 8) & 0xff), NAND_CTRL_ALE); /* A[27:20] */ #ifdef CONFIG_SYS_NAND_5_ADDR_CYCLE /* One more address cycle for devices > 128MiB */ - hwctrl(&mtd, (page_addr >> 16) & 0x0f, + hwctrl(&nand_info[0], (page_addr >> 16) & 0x0f, NAND_CTRL_ALE); /* A[31:28] */ #endif - hwctrl(&mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + hwctrl(&nand_info[0], NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
if (cmd == NAND_CMD_READ0) { /* Latch in address */ - hwctrl(&mtd, NAND_CMD_READSTART, + hwctrl(&nand_info[0], NAND_CMD_READSTART, NAND_CTRL_CLE | NAND_CTRL_CHANGE); - hwctrl(&mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + hwctrl(&nand_info[0], NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
/* * Wait a while for the data to be ready */ - while (!this->dev_ready(&mtd)) + while (!this->dev_ready(&nand_info[0])) ; } else if (cmd == NAND_CMD_RNDOUT) { - hwctrl(&mtd, NAND_CMD_RNDOUTSTART, NAND_CTRL_CLE | + hwctrl(&nand_info[0], NAND_CMD_RNDOUTSTART, NAND_CTRL_CLE | NAND_CTRL_CHANGE); - hwctrl(&mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + hwctrl(&nand_info[0], NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); }
return 0; @@ -96,7 +96,7 @@ static int nand_command(int block, int page, uint32_t offs,
static int nand_is_bad_block(int block) { - struct nand_chip *this = mtd.priv; + struct nand_chip *this = nand_info[0].priv;
nand_command(block, 0, CONFIG_SYS_NAND_BAD_BLOCK_POS, NAND_CMD_READOOB); @@ -117,7 +117,7 @@ static int nand_is_bad_block(int block)
static int nand_read_page(int block, int page, void *dst) { - struct nand_chip *this = mtd.priv; + struct nand_chip *this = nand_info[0].priv; u_char ecc_calc[ECCTOTAL]; u_char ecc_code[ECCTOTAL]; u_char oob_data[CONFIG_SYS_NAND_OOBSIZE]; @@ -133,15 +133,15 @@ static int nand_read_page(int block, int page, void *dst) nand_command(block, page, 0, NAND_CMD_READ0);
for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { - this->ecc.hwctl(&mtd, NAND_ECC_READ); + this->ecc.hwctl(&nand_info[0], NAND_ECC_READ); nand_command(block, page, data_pos, NAND_CMD_RNDOUT);
- this->read_buf(&mtd, p, eccsize); + this->read_buf(&nand_info[0], p, eccsize);
nand_command(block, page, oob_pos, NAND_CMD_RNDOUT);
- this->read_buf(&mtd, oob, eccbytes); - this->ecc.calculate(&mtd, p, &ecc_calc[i]); + this->read_buf(&nand_info[0], oob, eccbytes); + this->ecc.calculate(&nand_info[0], p, &ecc_calc[i]);
data_pos += eccsize; oob_pos += eccbytes; @@ -160,7 +160,7 @@ static int nand_read_page(int block, int page, void *dst) * from correct_data(). We just hope that all possible errors * are corrected by this routine. */ - this->ecc.correct(&mtd, p, &ecc_code[i], &ecc_calc[i]); + this->ecc.correct(&nand_info[0], p, &ecc_code[i], &ecc_calc[i]); }
return 0; @@ -206,13 +206,13 @@ void nand_init(void) /* * Init board specific nand support */ - mtd.priv = &nand_chip; + nand_info[0].priv = &nand_chip; nand_chip.IO_ADDR_R = nand_chip.IO_ADDR_W = (void __iomem *)CONFIG_SYS_NAND_BASE; board_nand_init(&nand_chip);
if (nand_chip.select_chip) - nand_chip.select_chip(&mtd, 0); + nand_chip.select_chip(&nand_info[0], 0);
/* NAND chip may require reset after power-on */ nand_command(0, 0, 0, NAND_CMD_RESET); @@ -222,5 +222,5 @@ void nand_init(void) void nand_deselect(void) { if (nand_chip.select_chip) - nand_chip.select_chip(&mtd, -1); + nand_chip.select_chip(&nand_info[0], -1); } diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h index cb972f4..c45c691 100644 --- a/include/configs/ti_armv7_common.h +++ b/include/configs/ti_armv7_common.h @@ -247,6 +247,7 @@ #define CONFIG_SPL_NAND_BASE #define CONFIG_SPL_NAND_DRIVERS #define CONFIG_SPL_NAND_ECC +#define CONFIG_SPL_MTD_SUPPORT #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000 #endif diff --git a/spl/Makefile b/spl/Makefile index be5fd3b..ce2e55e 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -104,6 +104,7 @@ libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/ libs-y += fs/ libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ drivers/power/pmic/ +libs-$(CONFIG_SPL_MTD_SUPPORT) += drivers/mtd/ libs-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/ libs-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/ libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/

On Fri, Mar 28, 2014 at 12:03:36PM -0400, Tom Rini wrote:
This mainly converts the am335x_spl_bch driver to the "normal" format which means a slight change to nand_info within the driver.
Acked-by: Scott Wood scottwood@freescale.com Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

Acked-by: Scott Wood scottwood@freescale.com Signed-off-by: Tom Rini trini@ti.com --- Changes in v2: - Surround adding nand_util.o with CONFIG_SPL_ENV_SUPPORT test --- drivers/mtd/nand/Makefile | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 02b149c..4eb354d 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -18,6 +18,9 @@ obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o obj-$(CONFIG_SPL_NAND_INIT) += nand.o +ifeq ($(CONFIG_SPL_ENV_SUPPORT),y) +obj-$(CONFIG_ENV_IS_IN_NAND) += nand_util.o +endif
else # not spl

On Fri, Mar 28, 2014 at 12:03:37PM -0400, Tom Rini wrote:
Acked-by: Scott Wood scottwood@freescale.com Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

We use the same variable as a3m071 in the environment to determine if we should boot into Linux or U-Boot. This is useful on boards like Beaglebone Black or AM335x GP EVM where we have persistent storage for the environment.
Signed-off-by: Tom Rini trini@ti.com --- board/ti/am335x/board.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index 554398f..ce7a8b0 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -30,6 +30,7 @@ #include <power/tps65910.h> #include <environment.h> #include <watchdog.h> +#include <environment.h> #include "board.h"
DECLARE_GLOBAL_DATA_PTR; @@ -219,7 +220,17 @@ static struct emif_regs ddr3_evm_emif_reg_data = { int spl_start_uboot(void) { /* break into full u-boot on 'c' */ - return (serial_tstc() && serial_getc() == 'c'); + if (serial_tstc() && serial_getc() == 'c') + return 1; + +#ifdef CONFIG_SPL_ENV_SUPPORT + env_init(); + env_relocate_spec(); + if (getenv_yesno("boot_os") != 1) + return 1; +#endif + + return 0; } #endif

On Fri, Mar 28, 2014 at 12:03:38PM -0400, Tom Rini wrote:
We use the same variable as a3m071 in the environment to determine if we should boot into Linux or U-Boot. This is useful on boards like Beaglebone Black or AM335x GP EVM where we have persistent storage for the environment.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

Signed-off-by: Tom Rini trini@ti.com --- README | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/README b/README index b035033..56ecaa1 100644 --- a/README +++ b/README @@ -3242,6 +3242,10 @@ FIT uImage format: supports MMC, NAND and YMODEM loading of U-Boot and NAND NAND loading of the Linux Kernel.
+ CONFIG_SPL_OS_BOOT + Enable booting directly to an OS from SPL. + See also: doc/README.falcon + CONFIG_SPL_DISPLAY_PRINT For ARM, enable an optional function to print more information about the running system.

On Fri, Mar 28, 2014 at 12:03:39PM -0400, Tom Rini wrote:
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

Signed-off-by: Tom Rini trini@ti.com --- doc/README.falcon | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/doc/README.falcon b/doc/README.falcon index 6357b1e..bccf6c9 100644 --- a/doc/README.falcon +++ b/doc/README.falcon @@ -80,6 +80,15 @@ spl_start_uboot() : required Returns "0" if SPL should start the kernel, "1" if U-Boot must be started.
+Environment variables +--------------------- + +A board may chose to look at the environment for decisions about falcon +mode. In this case the following variables may be supported: + +boot_os : Set to yes/Yes/true/True/1 to enable booting to OS, + any other value to fall back to U-Boot (including + unset)
Using spl command -----------------

On Fri, Mar 28, 2014 at 12:03:40PM -0400, Tom Rini wrote:
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

This change makes the behaviour slightly more rebust and will match other implementations which can use getenv_yesno directly.
Acked-by: Stefan Roese sr@denx.de Signed-off-by: Tom Rini trini@ti.com --- board/a3m071/a3m071.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/board/a3m071/a3m071.c b/board/a3m071/a3m071.c index 7aeefb2..b96ba81 100644 --- a/board/a3m071/a3m071.c +++ b/board/a3m071/a3m071.c @@ -412,7 +412,8 @@ int spl_start_uboot(void)
env_init(); getenv_f("boot_os", s, sizeof(s)); - if ((s != NULL) && (strcmp(s, "yes") == 0)) + if ((s != NULL) && (*s == '1' || *s == 'y' || *s == 'Y' || + *s == 't' || *s == 'T')) return 0;
return 1;

On Fri, Mar 28, 2014 at 12:03:41PM -0400, Tom Rini wrote:
This change makes the behaviour slightly more rebust and will match other implementations which can use getenv_yesno directly.
Acked-by: Stefan Roese sr@denx.de Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

We add two new environment variables, falcon_args_file and falcon_image_file, which when set will override the compiled in default values for falcon mode.
Signed-off-by: Tom Rini trini@ti.com --- common/spl/spl_fat.c | 27 +++++++++++++++++++++++++++ doc/README.falcon | 4 ++++ 2 files changed, 31 insertions(+)
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index 1e532d5..56be943 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -74,11 +74,38 @@ end: int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition) { int err; + __maybe_unused char *file;
err = spl_register_fat_device(block_dev, partition); if (err) return err;
+#if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT) + file = getenv("falcon_args_file"); + if (file) { + err = file_fat_read(file, (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0); + if (err <= 0) { + printf("spl: error reading image %s, err - %d, falling back to default\n", + file, err); + goto defaults; + } + file = getenv("falcon_image_file"); + if (file) { + err = spl_load_image_fat(block_dev, partition, file); + if (err != 0) { + puts("spl: falling back to default\n"); + goto defaults; + } + + return 0; + } else + puts("spl: falcon_image_file not set in environment, falling back to default\n"); + } else + puts("spl: falcon_args_file not set in environment, falling back to default\n"); + +defaults: +#endif + err = file_fat_read(CONFIG_SPL_FAT_LOAD_ARGS_NAME, (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0); if (err <= 0) { diff --git a/doc/README.falcon b/doc/README.falcon index bccf6c9..82a254b 100644 --- a/doc/README.falcon +++ b/doc/README.falcon @@ -89,6 +89,10 @@ mode. In this case the following variables may be supported: boot_os : Set to yes/Yes/true/True/1 to enable booting to OS, any other value to fall back to U-Boot (including unset) +falcon_args_file : Filename to load as the 'args' portion of falcon mode + rather than the hard-coded value. +falcon_image_file : Filename to load as the OS image portion of falcon + mode rather than the hard-coded value.
Using spl command -----------------

On Fri, Mar 28, 2014 at 12:03:42PM -0400, Tom Rini wrote:
We add two new environment variables, falcon_args_file and falcon_image_file, which when set will override the compiled in default values for falcon mode.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!

On Fri, Mar 28, 2014 at 12:03:33PM -0400, Tom Rini wrote:
We currently limit ourself to 16 characters for the device name to read the environment from. This is insufficient for /dev/mmcblk0boot1 to work for example. Switch to '%ms' which gives us a dynamically allocated buffer instead. We're short lived enough to not bother free()ing the buffer.
Signed-off-by: Tom Rini trini@ti.com
Applied to u-boot-ti/master, thanks!
participants (1)
-
Tom Rini