NAND/MMC environment in SPL, Falcon Mode enhancements
Subsystems (2)
cover NAND/MMC environment in SPL, Falcon Mode enhancements
Hey all,
This series fixes a few bugs / issues, and then sets things up so that we can use MMC (or NAND) for environment in SPL, in addition to NOR flash or simply built-in. The end result is that Falcon Mode becomes much more configurable via the environment, and thus from within Linux.
Signature · 1 line
Tom
PATCH 1/11 fw_env.c: Increase max dev path to 32
Currently our limit is too small to allow for /dev/mmcblk0boot0 to work, for example. Expand to 32 for future needs.
--- tools/env/fw_env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/env/fw_env.c +1 -1
@@ -40,7 +40,7 @@ _min1 < _min2 ? _min1 : _min2; })struct envdev_s { -char devname[16 ];/* Device name */ +char devname[32 ];/* Device name */ ulong devoff;/* Device offset */ ulong env_size;/* environment size */ ulong erase_size;/* device erase size */
Signature · 1 line
1.7.9.5
PATCH 1/11 fw_env.c: Increase max dev path to 32
Dear Tom Rini,
Quoted 13 lines · In message <[email protected]> you wrote:
Currently our limit is too small to allow for
/dev/mmcblk0boot0to work, for example. Expand to 32 for future needs.Signed-off-by Tom Rini <[email protected]>--- tools/env/fw_env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/env/fw_env.c +0
-0
tools/env/fw_env.c line 43
Quoted 5 lines
tools/env/fw_env.c +1
-1@@ -40,7 +40,7 @@ _min1 < _min2 ? _min1 : _min2; })struct envdev_s { -char devname[16 ];/* Device name */ +char devname[32 ];/* Device name */
Do we really need a static size here? Can we not auto-adjust to the needed size, say by dynamically allocating the buffer?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The speed of time is one second per second.
PATCH 1/11 fw_env.c: Increase max dev path to 32
Quoted 18 lines · Wolfgang Denk
Dear Tom Rini,
Quoted 15 lines · In message <[email protected]> you wrote:
Currently our limit is too small to allow for
/dev/mmcblk0boot0to work, for example. Expand to 32 for future needs.Signed-off-by Tom Rini <[email protected]>--- tools/env/fw_env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/env/fw_env.c +0
-0@@ -40,7 +40,7 @@ _min1 < _min2 ? _min1 : _min2; })
Quoted 6 lines
tools/env/fw_env.c line 43
Quoted 3 lines
tools/env/fw_env.c +1
-1struct envdev_s { -char devname[16 ];/* Device name */ +char devname[32 ];/* Device name */ Do we really need a static size here? Can we not auto-adjust to the needed size, say by dynamically allocating the buffer?
Doesn't look like it, without a big change to the parsing code.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131006/9efb8269/attachment.pgp>
PATCH 1/11 fw_env.c: Increase max dev path to 32
Dear Tom,
Quoted 5 lines · In message <20131006205527.GP15917@bill-the-cat> you wrote:
Quoted 3 lines
Do we really need a static size here? Can we not auto-adjust to the needed size, say by dynamically allocating the buffer?
Doesn't look like it, without a big change to the parsing code.
I don't think this requires a big change. Eventually all it takes is changing the sscanf() call in get_config() to use a format "%ms" instead of plain "%s"; form the sscanf() man page:
? An optional 'm' character. This is used with string
conversions (%s, %c, %[), and relieves the caller of the need to allocate a corresponding buffer to hold the input:
instead, scanf() allocates a buffer of sufficient size, and assigns the address of this buffer to the corresponding pointer argument, which should be a pointer to a char * variable (this variable does not need to be initialized before the call). The caller should subsequently free(3) this buffer when it is no longer required.
OK, the struct should then of course contain a const char pointer instead of the buffer itself, but that's also a trivial change.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"An open mind has but one disadvantage: it collects dirt."
- a saying at RPIPATCH 1/11 fw_env.c: Increase max dev path to 32
Quoted 23 lines · Wolfgang Denk
Dear Tom,
Quoted 5 lines · In message <20131006205527.GP15917@bill-the-cat> you wrote:
Quoted 3 lines
Do we really need a static size here? Can we not auto-adjust to the needed size, say by dynamically allocating the buffer?
Doesn't look like it, without a big change to the parsing code.
I don't think this requires a big change. Eventually all it takes is changing the
sscanf()call inget_config()to use a format "%ms" instead of plain "%s"; form thesscanf()man page:?? An optional 'm' character. This is used with string
conversions (%s, %c, %[), and relieves the caller of the need to allocate a corresponding buffer to hold the input:
instead,scanf()allocates a buffer of sufficient size, and assigns the address of this buffer to the corresponding pointer argument, which should be a pointer to a char * variable (this variable does not need to be initialized before the call). The caller should subsequently free(3) this buffer when it is no longer required.
Quoted 2 lines
OK, the struct should then of course contain a const char pointer instead of the buffer itself, but that's also a trivial change.
Well, that's what I get for looking at the code, and not checking man pages. Agreed, I'll re-work this part.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131007/9df4ef1e/attachment.pgp>
PATCH 2/11 env_mmc.c: Make the non-redundant env_relocate_spec use malloc not stack
In reply to Tom RiniSwitch the case of non-redundant non-embedded environment to use malloc to allocate buffers, rather than place them on the stack, like the redundant case does.
--- common/env_mmc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
common/env_mmc.c +12 -3
@@ -274,11 +274,18 @@ err: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 ); +env_t *ep;u32 offset;int ret; + ep = (env_t *)malloc (CONFIG_ENV_SIZE ); +if (ep ==NULL ) { +puts ("Can't allocate buffers for environment\n" ); + ret =1 ; + goto err; + } +if (init_mmc_for_env (mmc)) { ret =1 ; goto err;
@@ -289,12 +296,12 @@ void env_relocate_spec(void) goto fini; } -if (read_env (mmc,CONFIG_ENV_SIZE , offset, buf)) { +if (read_env (mmc,CONFIG_ENV_SIZE , offset, ep)) { ret =1 ; goto fini; } -env_import (buf,1 ); +env_import ((char *)ep,1 ); ret =0 ; fini:
@@ -302,6 +309,8 @@ fini: err:if (ret)set_default_env (NULL ); + +free (ep); #endif }#endif /* CONFIG_ENV_OFFSET_REDUND */
Signature · 1 line
1.7.9.5
PATCH 2/11 env_mmc.c: Make the non-redundant env_relocate_spec use malloc not stack
Dear Tom Rini,
Quoted 3 lines · In message <[email protected]> you wrote:
Switch the case of non-redundant non-embedded environment to use malloc to allocate buffers, rather than place them on the stack, like the redundant case does.
What exactly would be the benefit of this change? It just adds code size and execution time and makes the code more complex, without any appearent advanteages?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Never face facts; if you do, you'll never get up in the morning." - Marlo Thomas
PATCH 2/11 env_mmc.c: Make the non-redundant env_relocate_spec use malloc not stack
Quoted 10 lines · Wolfgang Denk
Dear Tom Rini,
Quoted 3 lines · In message <[email protected]> you wrote:
Switch the case of non-redundant non-embedded environment to use malloc to allocate buffers, rather than place them on the stack, like the redundant case does.
What exactly would be the benefit of this change? It just adds code size and execution time and makes the code more complex, without any appearent advanteages?
The main advantage is that we can use this code in environments with less than CONFIG_ENV_SIZE worth of stack available. Arguably it makes the behaviour and code paths similar for redundant and non-redundant cases (but someone posted a patch to make the redundant case use the stack).
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131006/709d66b3/attachment.pgp>
PATCH 2/11 env_mmc.c: Make the non-redundant env_relocate_spec use malloc not stack
Dear Tom,
Quoted 10 lines · In message <20131006204046.GN15917@bill-the-cat> you wrote:
Quoted 9 lines
Quoted 3 lines · In message <[email protected]> you wrote:
Switch the case of non-redundant non-embedded environment to use malloc to allocate buffers, rather than place them on the stack, like the redundant case does.
What exactly would be the benefit of this change? It just adds code size and execution time and makes the code more complex, without any appearent advanteages?
Quoted 5 lines
The main advantage is that we can use this code in environments with less than
CONFIG_ENV_SIZEworth of stack available. Arguably it makes the behaviour and code paths similar for redundant and non-redundant cases (but someone posted a patch to make the redundant case use the stack).
Instead of stack size you pay for that with additional size of the malloc() arena. As I just explained in the other mail [1], this is even worse to deal with and will result in less memoy available for other purposes.
And yes, we definitely should use the stack for the redundant case as well. Do you want me to submit such a patch?
[1] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/171217
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Anyone can count the seeds in an apple. No one can count the apples in a seed.
PATCH 3/11 env_mmc.c: Allow environment to be used within SPL
In reply to Tom RiniInside 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.
--- common/env_mmc.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)
common/env_mmc.c +30 -7
@@ -64,6 +64,13 @@ 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 +83,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 +96,12 @@ 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,11 +183,15 @@ 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, + n = mmc->block_dev.block_read (dev, blk_start, blk_cnt, (uchar *)buffer);return (n == blk_cnt) ?0 :-1 ;
@@ -188,13 +201,18 @@ 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, *tmp_env1, *tmp_env2;int ret; +int dev =CONFIG_SYS_MMC_ENV_DEV ; +#ifdef CONFIG_SPL_BUILD + dev =0 ; +#endif + mmc =find_mmc_device (dev); tmp_env1 = (env_t *)malloc (CONFIG_ENV_SIZE ); tmp_env2 = (env_t *)malloc (CONFIG_ENV_SIZE );if (tmp_env1 ==NULL || tmp_env2 ==NULL ) {
@@ -274,11 +292,16 @@ err:void env_relocate_spec (void ) {#if !defined(ENV_IS_EMBEDDED ) -struct mmc *mmc =find_mmc_device (CONFIG_SYS_MMC_ENV_DEV ); +struct mmc *mmc;env_t *ep;u32 offset;int ret; +int dev =CONFIG_SYS_MMC_ENV_DEV ; +#ifdef CONFIG_SPL_BUILD + dev =0 ; +#endif + mmc =find_mmc_device (dev); ep = (env_t *)malloc (CONFIG_ENV_SIZE );if (ep ==NULL ) {puts ("Can't allocate buffers for environment\n" );
Signature · 1 line
1.7.9.5
PATCH 4/11 mtd: Add a CONFIG_SPL_MTD_SUPPORT for a more full NAND subsystem in SPL
In reply to Tom RiniThis mainly converts the am335x_spl_bch driver to the "normal" format which means a slight change to nand_info within the driver.
--- drivers/mtd/nand/am335x_spl_bch.c | 54 ++++++++++++++++++------------------- include/configs/ti_armv7_common.h | 1 + spl/Makefile | 1 + 3 files changed, 29 insertions(+), 27 deletions(-)
drivers/mtd/nand/am335x_spl_bch.c +27 -27
@@ -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 ); }
include/configs/ti_armv7_common.h +1 -0
@@ -244,6 +244,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
spl/Makefile +1 -0
@@ -89,6 +89,7 @@ LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o +LIBS-$(CONFIG_SPL_MTD_SUPPORT) += drivers/mtd/libmtd.o LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
Signature · 1 line
1.7.9.5
PATCH 4/11 mtd: Add a CONFIG_SPL_MTD_SUPPORT for a more full NAND subsystem in SPL
Quoted 10 lines · Tom Rini
This mainly converts the
am335x_spl_bchdriver to the "normal" format which means a slight change tonand_infowithin the driver.Cc Scott Wood <[email protected]>Signed-off-by Tom Rini <[email protected]>--- drivers/mtd/nand/am335x_spl_bch.c | 54 ++++++++++++++++++------------------- include/configs/ti_armv7_common.h | 1 + spl/Makefile | 1 + 3 files changed, 29 insertions(+), 27 deletions(-)
with one caveat:
Quoted 17 lines
include/configs/ti_armv7_common.h +1
-0@@ -244,6 +244,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 spl/Makefile +0
-0
spl/Makefile LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o · line 95
Quoted 7 lines
spl/Makefile +1
-0@@ -89,6 +89,7 @@ LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o +LIBS-$(CONFIG_SPL_MTD_SUPPORT) += drivers/mtd/libmtd.o LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
This needs to be documented in the README.
-Scott
PATCH 5/11 mtd: Build nand_util.o for CONFIG_ENV_IS_IN_NAND in SPL
In reply to Tom Rini--- drivers/mtd/nand/Makefile | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/Makefile +1 -0
@@ -24,6 +24,7 @@ COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o COBJS-$(CONFIG_SPL_NAND_BASE) += nand_base.o COBJS-$(CONFIG_SPL_NAND_INIT) += nand.o +COBJS-$(CONFIG_ENV_IS_IN_NAND) += nand_util.o else # not spl
Signature · 1 line
1.7.9.5
PATCH 5/11 mtd: Build nand_util.o for CONFIG_ENV_IS_IN_NAND in SPL
Quoted 11 lines · Tom Rini
Cc Scott Wood <[email protected]>Signed-off-by Tom Rini <[email protected]>--- drivers/mtd/nand/Makefile | 1 + 1 file changed, 1 insertion(+)drivers/mtd/nand/Makefile +0
-0
drivers/mtd/nand/Makefile COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o · line 27
Quoted 4 lines
drivers/mtd/nand/Makefile +1
-0@@ -24,6 +24,7 @@ COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o COBJS-$(CONFIG_SPL_NAND_BASE) += nand_base.o COBJS-$(CONFIG_SPL_NAND_INIT) += nand.o +COBJS-$(CONFIG_ENV_IS_IN_NAND) += nand_util.o
Not all NAND SPLs will want this. Define a new CONFIG_SPL_* symbol, or perhaps it could just use CONFIG_SPL_NAND_BASE.
-Scott
PATCH 5/11 mtd: Build nand_util.o for CONFIG_ENV_IS_IN_NAND in SPL
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 7 lines · Scott Wood
Quoted 6 lines · Tom Rini
Cc Scott Wood <[email protected]>Signed-off-by Tom Rini <[email protected]>--- drivers/mtd/nand/Makefile | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
drivers/mtd/nand/Makefile COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o · line 27
Quoted 9 lines
drivers/mtd/nand/Makefile +1
-0@@ -24,6 +24,7 @@ COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o COBJS-$(CONFIG_SPL_NAND_BASE) += nand_base.o COBJS-$(CONFIG_SPL_NAND_INIT) += nand.o +COBJS-$(CONFIG_ENV_IS_IN_NAND) += nand_util.oNot all NAND SPLs will want this. Define a new CONFIG_SPL_* symbol, or perhaps it could just use
CONFIG_SPL_NAND_BASE.
Then they won't get it. Without CONFIG_SPL_ENV_SUPPORT that all gets discarded. And talked about before adding CONFIG_SPL_ENV_... and I didn't want to go down that path. If you feel strongly about not building the object we can guard this with CONFIG_SPL_ENV_SUPPORT checks perhaps?
- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBAgAGBQJSRJz4AAoJENk4IS6UOR1WMfAP/RkD0fqs0QMaS+rXwrFtVSuk D3wH9KmvehSgY8AL1rq/gpNxFSj/t3/yqdMP6uE1RIJQjlcMsAhXalsy9+QSzDeq TInAA3gebJVOIJzvJlPEkaR4ybEdQOgtMzcWXqV0mrV626SXfNo6PQ8ZtGxBxAm3 oDBbJw0xkmkqnVgOy+jNDgoPoR8aNl1bbpB0UTb2Iz5rRghf0GYPVeR3J88+Fgtq cm0sQdklkl28ZnbJFU9uhL7Sdws23QuZBihIwiEwmMqwT1pI17nF/YGm3WaayGd3 Pb4wb+FyesDHIcTwl4fDDN+QMNFQ6oz/3lden6X7a/rPHJWxxxUFQtKFykIfExk3 YnPMud20TDlEHeRvoI4vqqvtBd2/nCjyw/R2UhMgyc0Uk+43lJUbXhiq9XbLk88t m5RZjsfLGTUl12Uxe5OIh+s8O1BkrmY+knyZSwy8uw0JZcnuuV11A15vNoCMNQzc vzzXCke8r0rS5Ci3ai2R6XGJX8Thh3QD3+ZYED899B2TwPxHH6wo6saLnNNf4nYt s41rExlhzCMDRSl3Kd1pnFIFu7butiRZWuRldTY/ASwAZKtvvUOibq9U23HtWwKY JSLlkkTjIOEsJPZcvPgooMHdJA1Kyt5Lb9SHpgkozqd1Dy0WPA/JOSfgoGoSRhKh tM0XMWkMuUYt1oNToTkl
=n9Vw
-----END PGP SIGNATURE-----
PATCH 5/11 mtd: Build nand_util.o for CONFIG_ENV_IS_IN_NAND in SPL
Quoted 21 lines · Tom Rini
Quoted 7 lines · Scott Wood
Quoted 6 lines · Tom Rini
Cc Scott Wood <[email protected]>Signed-off-by Tom Rini <[email protected]>--- drivers/mtd/nand/Makefile | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
drivers/mtd/nand/Makefile COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o · line 27
Quoted 9 lines
drivers/mtd/nand/Makefile +1
-0@@ -24,6 +24,7 @@ COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o COBJS-$(CONFIG_SPL_NAND_BASE) += nand_base.o COBJS-$(CONFIG_SPL_NAND_INIT) += nand.o +COBJS-$(CONFIG_ENV_IS_IN_NAND) += nand_util.oNot all NAND SPLs will want this. Define a new CONFIG_SPL_* symbol, or perhaps it could just use
CONFIG_SPL_NAND_BASE.
Quoted 2 lines
Then they won't get it. Without
CONFIG_SPL_ENV_SUPPORTthat all gets discarded.
Anonymous strings won't.
Quoted 4 lines
And talked about before adding
CONFIG_SPL_ENV_... and I didn't want to go down that path. If you feel strongly about not building the object we can guard this withCONFIG_SPL_ENV_SUPPORTchecks perhaps?
And then we get a bigger mess if something wants nand_util for some other reason...
I think the entire way SPL has been structured is a mistake, and it should have been viewed as just multiple U-Boot configs that happen to be automatically built and concatenated together under one user-visible target name. Then, if existing config mechanisms are not fine grained enough, make them finer grained. Bring in kconfig to sort out the dependency mess.
-Scott
PATCH 5/11 mtd: Build nand_util.o for CONFIG_ENV_IS_IN_NAND in SPL
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 22 lines · Scott Wood
Quoted 21 lines · Tom Rini
Quoted 19 lines · Scott Wood
Quoted 11 lines · Tom Rini
Cc Scott Wood <[email protected]>Signed-off-by Tom Rini <[email protected]>--- drivers/mtd/nand/Makefile | 1 + 1 file changed, 1 insertion(+)drivers/mtd/nand/Makefile +0
-0drivers/mtd/nand/Makefile COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o · line 27
Quoted 4 lines
drivers/mtd/nand/Makefile +1
-0@@ -24,6 +24,7 @@ COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o COBJS-$(CONFIG_SPL_NAND_BASE) += nand_base.o COBJS-$(CONFIG_SPL_NAND_INIT) += nand.o +COBJS-$(CONFIG_ENV_IS_IN_NAND) += nand_util.oNot all NAND SPLs will want this. Define a new CONFIG_SPL_* symbol, or perhaps it could just use
CONFIG_SPL_NAND_BASE.
Quoted 4 lines
Quoted 2 lines
Then they won't get it. Without
CONFIG_SPL_ENV_SUPPORTthat all gets discarded.Anonymous strings won't.
Ah that's right, curses...
Quoted 8 lines
Quoted 4 lines
And talked about before adding
CONFIG_SPL_ENV_... and I didn't want to go down that path. If you feel strongly about not building the object we can guard this withCONFIG_SPL_ENV_SUPPORTchecks perhaps?And then we get a bigger mess if something wants
nand_utilfor some other reason...
Quoted 6 lines
I think the entire way SPL has been structured is a mistake, and it should have been viewed as just multiple U-Boot configs that happen to be automatically built and concatenated together under one user-visible target name. Then, if existing config mechanisms are not fine grained enough, make them finer grained. Bring in kconfig to sort out the dependency mess.
Mid-term, yes. I would like to talk about Kconfig more at ELC-E and get a feel from the community on how much time people have to devote to such big efforts.
- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBAgAGBQJSRKO+AAoJENk4IS6UOR1WMW8QAKUU8ZT2/W8EefntM4lQJ/iY /2PjdCPOA+KotWGPPCGyg6EjFFeNw03ruhnsDmtNduw2tWU6sq9WXZZoR3sw4kVP ZOax+kqxBrd8XBiqGzM5+3CD2W3KAiEYBwCbF2q9weG1U/Pl14rQEfAZ7RaXt7da Hz0mAhIKP+IyTJ94/SOvRCVziwJPNUYc1FL4hKnvA5knqkfmd36Jael1++1UxK15 eYp6o2Xdliz28mPL+It1UVUK9gn+3SDTOuG+KNNkCW+NSmB8hFMnVVTipZWc4u0H hQXquHVDGIUieZ7d1zbpcOkz5OVWcd+CjwvvbKPrMwvOHDNq9UbZo8QDtFFsnqZJ eSOOG6CVMdJ0t9TB6R1CKQaphtb6XQvKO6fStlQI07nXmDzdx9qHZjPeX8rH2aV0 xX7dAkIUpc5knpnb1r8SFVdawXqlveNgzYOEHCNVMk6kpsO1U0F53d7nzBXSOz6h d1zTR4xV91rWr1n9bp1YC9HML7c1InNo1gelKMNSjlUMWkg6mKEc+r9X70P0Qgx3 1kZ5GmR0HkvV1NnlYpgq09UvI+tWXIYcH4alEPge88JHEcEQHVhqzp9j5ErWt0ei 1VcIEA/s1Vj0RyBDolPeomnWv+liOm9RQaghBMwF7rDkd9pGbEytIfoyOb56cf3E WDs/54voOqB61z9+5c5f
=ODSN
-----END PGP SIGNATURE-----
PATCH 6/11 spl: Make CONFIG_SPL_ENV_SUPPORT have to be set by all users of env in SPL
In reply to Tom RiniPreviously, we forced a "no environment" choice on network using SPL. Now we allow all users to set where they want to look for their environment. This means we have to set CONFIG_SPL_ENV_SUPPORT now for ti_armv7_common.h.
--- common/Makefile | 4 +--- include/configs/ti_armv7_common.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-)
common/Makefile +1 -3
@@ -197,17 +197,15 @@ COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o # environment +ifeq ($(CONFIG_SPL_ENV_SUPPORT),y) COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_attr.o COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_flags.o COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_callback.o -ifneq ($(CONFIG_SPL_NET_SUPPORT),y) COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o COBJS-$(CONFIG_ENV_IS_IN_MMC) += env_mmc.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o -else -COBJS-y += env_nowhere.o endif endif # core command
include/configs/ti_armv7_common.h +1 -0
@@ -202,6 +202,7 @@#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME "u-boot.img"#ifdef CONFIG_SPL_OS_BOOT +#define CONFIG_SPL_ENV_SUPPORT /* For 'boot_os' and similar */ #define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + 0x100)/* FAT */
Signature · 1 line
1.7.9.5
PATCH 7/11 am335x_evm: Make SPL_OS also check the boot_os variable for falcon mode
In reply to Tom RiniWe 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.
--- board/ti/am335x/board.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
board/ti/am335x/board.c +12 -1
@@ -26,6 +26,7 @@#include <i2c.h> #include <miiphy.h> #include <cpsw.h> +#include <environment.h> #include "board.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -232,7 +233,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
Signature · 1 line
1.7.9.5
PATCH 8/11 README: Add CONFIG_SPL_OS_BOOT to README
In reply to Tom Rini--- README | 4 ++++ 1 file changed, 4 insertions(+)
README +4 -0
@@ -3031,6 +3031,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.
Signature · 1 line
1.7.9.5
PATCH 9/11 README.falcon: Document environment variables for falcon mode
In reply to Tom Rini--- doc/README.falcon | 9 +++++++++ 1 file changed, 9 insertions(+)
doc/README.falcon +9 -0
@@ -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 -----------------
Signature · 1 line
1.7.9.5
PATCH 10/11 a3m071: Make spl_start_uboot test like getenv_yesno does
In reply to Tom RiniThis change makes the behaviour slightly more rebust and will match other implementations which can use getenv_yesno directly.
--- board/a3m071/a3m071.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
board/a3m071/a3m071.c +2 -1
@@ -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 ;
Signature · 1 line
1.7.9.5
PATCH 10/11 a3m071: Make spl_start_uboot test like getenv_yesno does
Quoted 5 lines · Tom Rini
This change makes the behaviour slightly more rebust and will match other implementations which can use
getenv_yesnodirectly.Cc Stefan Roese <[email protected]>Signed-off-by Tom Rini <[email protected]>
I see the benefit by this generalization. So:
Thanks,
Stefan
PATCH 11/11 spl_mmc/CONFIG_SPL_OS_BOOT: Allow environment to determine what to boot
In reply to Tom RiniWe 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.
--- common/spl/spl_mmc.c | 28 +++++++++++++++++++++++++++- doc/README.falcon | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-)
common/spl/spl_mmc.c +27 -1
@@ -100,7 +100,33 @@ end:static int mmc_load_image_fat_os (struct mmc *mmc) {int err; - +#if defined(CONFIG_SPL_ENV_SUPPORT ) && defined(CONFIG_SPL_OS_BOOT ) +char *file; + + 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 =mmc_load_image_fat (mmc, 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 ) {
doc/README.falcon +4 -0
@@ -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 -----------------
Signature · 1 line
1.7.9.5