nand_spl_simple: store ecc data on the stack
Subsystems (2)
PATCH 1/1 nand_spl_simple: store ecc data on the stack
Currently nand_spl_simple puts it's temp data at 0x10000 offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.
---
Note: Ilya has already submitted a patch to fix this issue:
http://patchwork.ozlabs.org/patch/128018/
after discussing on ML about booting linux from SPL, we agree about putting the data on the stack.
drivers/mtd/nand/nand_spl_simple.c | 27 ++++++---------------------
1 files changed, 6 insertions(+), 21 deletions(-)
drivers/mtd/nand/nand_spl_simple.c +6 -21
@@ -145,9 +145,9 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,uchar *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ]; +u_char ecc_code[CONFIG_SYS_NAND_ECCTOTAL ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ;
@@ -155,14 +155,6 @@ static int nand_read_page(int block, int page, uchar *dst)uint8_t *p = dst;int stat; -/* -* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -nand_command (block, page,0 ,NAND_CMD_READOOB ); this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );nand_command (block, page,0 ,NAND_CMD_READ0 );
@@ -185,9 +177,9 @@ static int nand_read_page(int block, int page, uchar *dst)static int nand_read_page (int block,int page,void *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ]; +u_char ecc_code[CONFIG_SYS_NAND_ECCTOTAL ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ;
@@ -197,13 +189,6 @@ static int nand_read_page(int block, int page, void *dst)nand_command (block, page,0 ,NAND_CMD_READ0 ); -/* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {if (this->ecc.mode !=NAND_ECC_SOFT ) this->ecc.hwctl (&mtd,NAND_ECC_READ );
Signature · 1 line
1.7.5.4
PATCH 1/1 nand_spl_simple: store ecc data on the stack
Hi Stefano,
thanks for posting this. There is a couple of comments below.
drivers/mtd/nand/nand_spl_simple.c static int nand_is_bad_block(int block) · line 149
Quoted 13 lines · Stefano Babic
drivers/mtd/nand/nand_spl_simple.c +2
-3@@ -145,9 +145,9 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,uchar *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ]; +u_char ecc_code[CONFIG_SYS_NAND_ECCTOTAL ];
Doesn't ECCTOTAL always equal to ECCSTEPS * ECCBYTES?
drivers/mtd/nand/nand_spl_simple.c static int nand_is_bad_block(int block) · line 150
Quoted 1 line
drivers/mtd/nand/nand_spl_simple.c +1
-0+u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];
I think we can save a few bytes by placing ecc_code and oob_data into a union. We only need oob_data to get ecc_code...
Regards, Ilya.
PATCH 1/1 nand_spl_simple: store ecc data on the stack
Quoted 5 lines · Ilya Yanok
Hi Stefano,
thanks for posting this. There is a couple of comments below.
On 11.12.2011 21:22, Stefano Babic wrote:
Quoted 15 lines
drivers/mtd/nand/nand_spl_simple.c static int nand_is_bad_block(int block) · line 149
Quoted 13 lines
drivers/mtd/nand/nand_spl_simple.c +2
-3@@ -145,9 +145,9 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,uchar *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ]; +u_char ecc_code[CONFIG_SYS_NAND_ECCTOTAL ];Doesn't ECCTOTAL always equal to ECCSTEPS * ECCBYTES?
I see. Then we can also remove CONFIG_SYS_NAND_ECCTOTAL from the configuration files, because it is not useful. I will do in V2.
By grepping the code, the same issue is present in nand_spl/nand_boot.c, too. This is part of the old spl code, I do not know if we have also to fix this one. IMHO we can only fix nand_spl_simple.c, because the other one will become obsolete and there is not probelms with current boards.
Quoted 5 lines
drivers/mtd/nand/nand_spl_simple.c static int nand_is_bad_block(int block) · line 150
Quoted 2 lines
drivers/mtd/nand/nand_spl_simple.c +1
-0+u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];I think we can save a few bytes by placing
ecc_codeandoob_datainto a union. We only needoob_datato getecc_code...
Checking the real values I see that ECCTOTAL is small - 8 bytes on the TI we are currently testing, and it has not a big value on other architectures. So I think we can avoid the union, also because this can generate overlapping when the oob data is copied: I mean in case nand_ecc_pos[i] is smaller as CONFIG_SYS_NAND_ECCTOTAL at:
for (i = 0; i < CONFIG_SYS_NAND_ECCTOTAL; i++)
ecc_code[i] = oob_data[nand_ecc_pos[i]];
Regards,
Stefano
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-0 Fax: +49-8142-66989-80 Email: [email protected] =====================================================================
PATCH v2 1/1 nand_spl_simple: store ecc data on the stack
In reply to Stefano BabicCurrently nand_spl_simple puts it's temp data at 0x10000 offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.
---
V2:
- CONFIG_SYS_NAND_ECCTOTAL can always be computed (Ilya Yanok)
- drop all CONFIG_SYS_NAND_ECCTOTAL in arm boards using nand_simple.c
drivers/mtd/nand/nand_spl_simple.c | 33 +++++++++---------------------- include/configs/am3517_crane.h | 2 - include/configs/am3517_evm.h | 2 - include/configs/devkit8000.h | 2 - include/configs/hawkboard.h | 3 +- include/configs/omap3_beagle.h | 2 - include/configs/omap3_evm.h | 2 - include/configs/omap3_evm_quick_nand.h | 2 - 8 files changed, 11 insertions(+), 37 deletions(-)
drivers/mtd/nand/nand_spl_simple.c +10 -23
@@ -145,9 +145,9 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,uchar *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ]; +u_char ecc_code[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ;
@@ -155,20 +155,13 @@ static int nand_read_page(int block, int page, uchar *dst)uint8_t *p = dst;int stat; -/* -* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -nand_command (block, page,0 ,NAND_CMD_READOOB ); this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );nand_command (block, page,0 ,NAND_CMD_READ0 );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; + i < (CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ); i++) ecc_code[i] = oob_data[nand_ecc_pos[i]];
@@ -185,9 +178,9 @@ static int nand_read_page(int block, int page, uchar *dst)static int nand_read_page (int block,int page,void *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ]; +u_char ecc_code[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ;
@@ -197,13 +190,6 @@ static int nand_read_page(int block, int page, void *dst)nand_command (block, page,0 ,NAND_CMD_READ0 ); -/* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {if (this->ecc.mode !=NAND_ECC_SOFT ) this->ecc.hwctl (&mtd,NAND_ECC_READ );
@@ -213,7 +199,8 @@ static int nand_read_page(int block, int page, void *dst) this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; + i < (CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES ); i++) ecc_code[i] = oob_data[nand_ecc_pos[i]]; eccsteps =CONFIG_SYS_NAND_ECCSTEPS ;
include/configs/am3517_crane.h +0 -2
@@ -361,8 +361,6 @@#define CONFIG_SYS_NAND_ECCBYTES 3#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/am3517_evm.h +0 -2
@@ -362,8 +362,6 @@#define CONFIG_SYS_NAND_ECCBYTES 3#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/devkit8000.h +0 -2
@@ -346,8 +346,6 @@#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
include/configs/hawkboard.h +1 -2
@@ -141,8 +141,7 @@#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ CONFIG_SYS_NAND_ECCSIZE)#define CONFIG_SYS_NAND_OOBSIZE 64 -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS) +#endif /* CONFIG_SYS_USE_NAND */ /*
include/configs/omap3_beagle.h +0 -2
@@ -428,8 +428,6 @@#define CONFIG_SYS_NAND_ECCBYTES 3#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm.h +0 -2
@@ -123,8 +123,6 @@#define CONFIG_SYS_NAND_ECCBYTES 3#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm_quick_nand.h +0 -2
@@ -93,8 +93,6 @@#define CONFIG_SYS_NAND_ECCBYTES 3#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
Signature · 1 line
1.7.5.4
PATCH v2 1/1 nand_spl_simple: store ecc data on the stack
Quoted 4 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.
OK, I think we need some convenience defines in nand_spl_simple.c:
Quoted 1 line
+ ? ? ?
u_charecc_calc[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES];
This is long and used in a lot of places. Furthermore...
Quoted 2 lines
?#define
CONFIG_SYS_NAND_ECCSTEPS? ? ? (CONFIG_SYS_NAND_PAGE_SIZE/ \
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CONFIG_SYS_NAND_ECCSIZE)
Is what everyone does. So if we replace ECCSTEPS with (PAGE_SIZE/ECCSIZE) it gets eve longer. We should probably #define SYS_NAND_ECCSTEPS, SYS_NAND_ECCTOTAL up top and go with it.
Signature · 1 line
Tom
PATCH v2 1/1 nand_spl_simple: store ecc data on the stack
Quoted 8 lines · Tom Rini
Quoted 4 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.OK, I think we need some convenience defines in
nand_spl_simple.c:
Quoted 8 lines
Quoted 1 line
+
u_charecc_calc[CONFIG_SYS_NAND_ECCSTEPS *CONFIG_SYS_NAND_ECCBYTES];This is long and used in a lot of places. Furthermore...
Quoted 2 lines
#define
CONFIG_SYS_NAND_ECCSTEPS(CONFIG_SYS_NAND_PAGE_SIZE/ \
CONFIG_SYS_NAND_ECCSIZE)Is what everyone does.
Right, I've missed this one - we can then drop CONFIG_SYS_NAND_ECCSTEPS also from configuration files.
Quoted 3 lines
So if we replace ECCSTEPS with
(PAGE_SIZE/ECCSIZE) it gets eve longer. We should probably #defineSYS_NAND_ECCSTEPS,SYS_NAND_ECCTOTALup top and go with it.
I'll do in V3.
Regards,
Stefano
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-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
In reply to Stefano BabicCurrently nand_spl_simple puts it's temp data at 0x10000 offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.
---
V3:
- use local defines for CONFIG_SYS_NAND_ECCSTEPS and CONFIG_SYS_NAND_ECCTOTAL (Tom Rini)
- drop CONFIG_SYS_NAND_ECCSTEPS from board config files
V2:
- CONFIG_SYS_NAND_ECCTOTAL can always be computed (Ilya Yanok)
- drop all CONFIG_SYS_NAND_ECCTOTAL in arm boards using nand_simple.c
drivers/mtd/nand/nand_spl_simple.c | 42 ++++++++++++------------------- include/configs/am3517_crane.h | 4 --- include/configs/am3517_evm.h | 4 --- include/configs/devkit8000.h | 5 ---- include/configs/hawkboard.h | 5 +--- include/configs/omap3_beagle.h | 4 --- include/configs/omap3_evm.h | 4 --- include/configs/omap3_evm_quick_nand.h | 4 --- 8 files changed, 17 insertions(+), 55 deletions(-)
drivers/mtd/nand/nand_spl_simple.c +16 -26
@@ -27,6 +27,11 @@ static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;static nand_info_t mtd;static struct nand_chip nand_chip; +#define SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ + CONFIG_SYS_NAND_ECCSIZE) +#define SYS_NAND_ECCTOTAL (SYS_NAND_ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES) + +#if (CONFIG_SYS_NAND_PAGE_SIZE <=512 )/* * NAND command for small page NAND devices (512)
@@ -145,30 +150,22 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,uchar *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[SYS_NAND_ECCTOTAL ]; +u_char ecc_code[SYS_NAND_ECCTOTAL ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ; -int eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; +int eccsteps =SYS_NAND_ECCSTEPS ;uint8_t *p = dst;int stat; -/* -* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -nand_command (block, page,0 ,NAND_CMD_READOOB ); this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );nand_command (block, page,0 ,NAND_CMD_READ0 );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; i < (SYS_NAND_ECCTOTAL ); i++) ecc_code[i] = oob_data[nand_ecc_pos[i]];
@@ -185,25 +182,18 @@ static int nand_read_page(int block, int page, uchar *dst)static int nand_read_page (int block,int page,void *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[SYS_NAND_ECCTOTAL ]; +u_char ecc_code[SYS_NAND_ECCTOTAL ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ; -int eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; +int eccsteps =SYS_NAND_ECCSTEPS ;uint8_t *p = dst;int stat;nand_command (block, page,0 ,NAND_CMD_READ0 ); -/* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {if (this->ecc.mode !=NAND_ECC_SOFT ) this->ecc.hwctl (&mtd,NAND_ECC_READ );
@@ -213,10 +203,10 @@ static int nand_read_page(int block, int page, void *dst) this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; i < (SYS_NAND_ECCTOTAL ); i++) ecc_code[i] = oob_data[nand_ecc_pos[i]]; - eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; + eccsteps =SYS_NAND_ECCSTEPS ; p = dst;for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
include/configs/am3517_crane.h +0 -4
@@ -359,10 +359,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/am3517_evm.h +0 -4
@@ -360,10 +360,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/devkit8000.h +0 -5
@@ -344,11 +344,6 @@#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS) -#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/hawkboard.h +1 -4
@@ -138,11 +138,8 @@#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 10 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE)#define CONFIG_SYS_NAND_OOBSIZE 64 -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS) +#endif /* CONFIG_SYS_USE_NAND */ /*
include/configs/omap3_beagle.h +0 -4
@@ -426,10 +426,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm.h +0 -4
@@ -121,10 +121,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm_quick_nand.h +0 -4
@@ -91,10 +91,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
Signature · 1 line
1.7.5.4
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
Quoted 11 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic <[email protected]>CC Ilya Yanok <[email protected]>CC Scott Wood <[email protected]>CC Tom Rini <[email protected]>CC Simon Schwarz <[email protected]>CC Wolfgang Denk <[email protected]>
Which covers the omap config file changes. Assuming Wolfgang doesn't see a problem with using SYS_... in defines, Scott, do you want this via your tree (in /next) since it's NAND or in mine since it's TI boards? Assuming you don't see any problems of course. Thanks!
Signature · 1 line
Tom
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
Dear Tom,
Quoted 5 lines · In message <CA+M6bX=j+=UBkZ-VGoAJgFtfap+sLp4i2JypDSjJ_z-bCbw6sQ@mail.gmail.com>…
Which covers the omap config file changes. Assuming Wolfgang doesn't see a problem with using
SYS_... in defines, Scott, do you want this via your tree (in /next) since it's NAND or in mine since it's TI boards? Assuming you don't see any problems of course. Thanks!
Indeed.
Stefano, what is this SYS_NAND_* supposed to mean? Either it is a config option, then you should name it CONFIG_SYS_NAND_* (or CONFIG_NAND_), or it is something else, in which case the "SYS_" is difficult to swallow for me (unless you have a really good explanation?)
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 Real computer scientists don't comment their code. The identifiers are so long they can't afford the disk space.
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
Quoted 9 lines · Wolfgang Denk
Dear Tom,
Quoted 5 lines · In message <CA+M6bX=j+=UBkZ-VGoAJgFtfap+sLp4i2JypDSjJ_z-bCbw6sQ@mail.gmail.com>…
Which covers the omap config file changes. ?Assuming Wolfgang doesn't see a problem with using
SYS_... in defines, Scott, do you want this via your tree (in /next) since it's NAND or in mine since it's TI boards? ?Assuming you don't see any problems of course. ?Thanks!
Quoted 7 lines
Indeed.
Stefano, what is this SYS_NAND_* supposed to mean? ?Either it is a config option, then you should name it CONFIG_SYS_NAND_* (or
CONFIG_NAND_), or it is something else, in which case the "SYS_" is difficult to swallow for me (unless you have a really good explanation?)
So, we have various characteristics of the NAND chip that need to be described for SPL. Today we do CONFIG_SYS_NAND... but they're unchanged in every implementation and are calculated from other per-board values. So to avoid duplication in each config file, we drop them from there and use them only locally #define calculate them in the file that needs them. Since they're still system specific values, I had suggested calling them SYS_... but I wasn't sure what the right namespace is. I had a recollection that using CONFIG_ outside of config files was a bad idea.
Signature · 1 line
Tom
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
Quoted 9 lines · Tom Rini
So, we have various characteristics of the NAND chip that need to be described for SPL. Today we do
CONFIG_SYS_NAND... but they're unchanged in every implementation and are calculated from other per-board values. So to avoid duplication in each config file, we drop them from there and use them only locally #define calculate them in the file that needs them. Since they're still system specific values, I had suggested calling themSYS_... but I wasn't sure what the right namespace is. I had a recollection that usingCONFIG_outside of config files was a bad idea.
These symbols are not in a header file -- how about just plain ECCSTEPS and ECCTOTAL?
-Scott
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
Quoted 11 lines · Scott Wood
Quoted 9 lines · Tom Rini
So, we have various characteristics of the NAND chip that need to be described for SPL. ?Today we do
CONFIG_SYS_NAND... but they're unchanged in every implementation and are calculated from other per-board values. ?So to avoid duplication in each config file, we drop them from there and use them only locally #define calculate them in the file that needs them. ?Since they're still system specific values, I had suggested calling themSYS_... but I wasn't sure what the right namespace is. ?I had a recollection that usingCONFIG_outside of config files was a bad idea.
Quoted 2 lines
These symbols are not in a header file -- how about just plain ECCSTEPS and ECCTOTAL?
Works for me and Wolfgang (on IRC) so lets go there for a hopefully last v4 (along with what Scott said in the other email)
Signature · 1 line
Tom
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
In reply to Scott WoodQuoted 11 lines · Scott Wood
Quoted 9 lines · Tom Rini
So, we have various characteristics of the NAND chip that need to be described for SPL. Today we do
CONFIG_SYS_NAND... but they're unchanged in every implementation and are calculated from other per-board values. So to avoid duplication in each config file, we drop them from there and use them only locally #define calculate them in the file that needs them. Since they're still system specific values, I had suggested calling themSYS_... but I wasn't sure what the right namespace is. I had a recollection that usingCONFIG_outside of config files was a bad idea.
Quoted 2 lines
These symbols are not in a header file -- how about just plain ECCSTEPS and ECCTOTAL?
Ok, agree - done in V4.
Regards,
Stefano
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-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
In reply to Wolfgang DenkAm 13/12/2011 19:18, schrieb Wolfgang Denk:
Quoted 9 lines
Dear Tom,
Quoted 5 lines · In message <CA+M6bX=j+=UBkZ-VGoAJgFtfap+sLp4i2JypDSjJ_z-bCbw6sQ@mail.gmail.com>…
Which covers the omap config file changes. Assuming Wolfgang doesn't see a problem with using
SYS_... in defines, Scott, do you want this via your tree (in /next) since it's NAND or in mine since it's TI boards? Assuming you don't see any problems of course. Thanks!
Quoted 7 lines
Indeed.
Stefano, what is this SYS_NAND_* supposed to mean? Either it is a config option, then you should name it CONFIG_SYS_NAND_* (or
CONFIG_NAND_), or it is something else, in which case the "SYS_" is difficult to swallow for me (unless you have a really good explanation?)
As already explained by Tom: we switch to local defines instead of CONFIG_SYS, and we get rid of CONFIG_SYS_ in board configuration files. Inside the single file, we have some freedom to use names, and the names suggested by Tom tells us that they are system specific, but because the CONFIG_SYS_ is missing, they cannot be confused with U-Boot general configuration settings. I find the names (for me) quite self explaining, but if there is some possibility to misunderstand their meaning we can drop the SYS_ prefix.
Best regards,
Stefano Babic
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-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
In reply to Tom RiniQuoted 13 lines · Tom Rini
Quoted 11 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic <[email protected]>CC Ilya Yanok <[email protected]>CC Scott Wood <[email protected]>CC Tom Rini <[email protected]>CC Simon Schwarz <[email protected]>CC Wolfgang Denk <[email protected]>
Quoted 6 lines
Acked-by Tom Rini <[email protected]>Which covers the omap config file changes. Assuming Wolfgang doesn't see a problem with using
SYS_... in defines, Scott, do you want this via your tree (in /next) since it's NAND or in mine since it's TI boards? Assuming you don't see any problems of course. Thanks!
The board-specific stuff is just removing unneeded NAND config items, and isn't depending on other non-NAND patches, so I can take it through my tree -- but if you want me to ACK it (once the minor issues are fixed) to go via your tree so you can build on top of it sooner, that's fine...
-Scott
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
Quoted 21 lines · Scott Wood
Quoted 13 lines · Tom Rini
Quoted 11 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic <[email protected]>CC Ilya Yanok <[email protected]>CC Scott Wood <[email protected]>CC Tom Rini <[email protected]>CC Simon Schwarz <[email protected]>CC Wolfgang Denk <[email protected]>Quoted 6 lines
Acked-by Tom Rini <[email protected]>Which covers the omap config file changes. ?Assuming Wolfgang doesn't see a problem with using
SYS_... in defines, Scott, do you want this via your tree (in /next) since it's NAND or in mine since it's TI boards? ?Assuming you don't see any problems of course. ?Thanks!
Quoted 5 lines
The board-specific stuff is just removing unneeded NAND config items, and isn't depending on other non-NAND patches, so I can take it through my tree -- but if you want me to ACK it (once the minor issues are fixed) to go via your tree so you can build on top of it sooner, that's fine...
Just building up my /next tree and don't want this to get lost, so if you can take v4 once it's out and you're happy, I'd appreciate it. Thanks!
Signature · 1 line
Tom
PATCH v3 1/1 nand_spl_simple: store ecc data on the stack
In reply to Stefano BabicQuoted 4 lines · Stefano Babic
drivers/mtd/nand/nand_spl_simple.c +1
-1/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; i < (SYS_NAND_ECCTOTAL ); i++) ecc_code[i] = oob_data[nand_ecc_pos[i]];
[snip]
drivers/mtd/nand/nand_spl_simple.c static int nand_read_page(int block, int page, void *dst) · line 206
Quoted 6 lines
drivers/mtd/nand/nand_spl_simple.c +1
-1@@ -213,10 +203,10 @@ static int nand_read_page(int block, int page, void *dst) this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; i < (SYS_NAND_ECCTOTAL ); i++)
No need for parens around SYS_NAND_ECCTOTAL.
-Scott
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
In reply to Stefano BabicCurrently nand_spl_simple puts it's temp data at 0x10000 offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.
---
V4:
- Drop SYS_ from local defines (Wolfgang Denk, Scott Wood)
- drop parenthesis around defines (Scott Wood)
V3:
- use local defines for CONFIG_SYS_NAND_ECCSTEPS and CONFIG_SYS_NAND_ECCTOTAL (Tom Rini)
- drop CONFIG_SYS_NAND_ECCSTEPS from board config files
V2:
- CONFIG_SYS_NAND_ECCTOTAL can always be computed (Ilya Yanok)
- drop all CONFIG_SYS_NAND_ECCTOTAL in arm boards using nand_simple.c
drivers/mtd/nand/nand_spl_simple.c | 42 ++++++++++++------------------- include/configs/am3517_crane.h | 4 --- include/configs/am3517_evm.h | 4 --- include/configs/devkit8000.h | 5 ---- include/configs/hawkboard.h | 5 +--- include/configs/omap3_beagle.h | 4 --- include/configs/omap3_evm.h | 4 --- include/configs/omap3_evm_quick_nand.h | 4 --- 8 files changed, 17 insertions(+), 55 deletions(-)
drivers/mtd/nand/nand_spl_simple.c +16 -26
@@ -27,6 +27,11 @@ static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;static nand_info_t mtd;static struct nand_chip nand_chip; +#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ + CONFIG_SYS_NAND_ECCSIZE) +#define ECCTOTAL (ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES) + +#if (CONFIG_SYS_NAND_PAGE_SIZE <=512 )/* * NAND command for small page NAND devices (512)
@@ -145,30 +150,22 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,uchar *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[ECCTOTAL ]; +u_char ecc_code[ECCTOTAL ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ; -int eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; +int eccsteps =ECCSTEPS ;uint8_t *p = dst;int stat; -/* -* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -nand_command (block, page,0 ,NAND_CMD_READOOB ); this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );nand_command (block, page,0 ,NAND_CMD_READ0 );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; i <ECCTOTAL ; i++) ecc_code[i] = oob_data[nand_ecc_pos[i]];
@@ -185,25 +182,18 @@ static int nand_read_page(int block, int page, uchar *dst)static int nand_read_page (int block,int page,void *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[ECCTOTAL ]; +u_char ecc_code[ECCTOTAL ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ; -int eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; +int eccsteps =ECCSTEPS ;uint8_t *p = dst;int stat;nand_command (block, page,0 ,NAND_CMD_READ0 ); -/* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {if (this->ecc.mode !=NAND_ECC_SOFT ) this->ecc.hwctl (&mtd,NAND_ECC_READ );
@@ -213,10 +203,10 @@ static int nand_read_page(int block, int page, void *dst) this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; i <ECCTOTAL ; i++) ecc_code[i] = oob_data[nand_ecc_pos[i]]; - eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; + eccsteps =ECCSTEPS ; p = dst;for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
include/configs/am3517_crane.h +0 -4
@@ -359,10 +359,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/am3517_evm.h +0 -4
@@ -360,10 +360,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/devkit8000.h +0 -5
@@ -344,11 +344,6 @@#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS) -#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/hawkboard.h +1 -4
@@ -138,11 +138,8 @@#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 10 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE)#define CONFIG_SYS_NAND_OOBSIZE 64 -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS) +#endif /* CONFIG_SYS_USE_NAND */ /*
include/configs/omap3_beagle.h +0 -4
@@ -426,10 +426,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm.h +0 -4
@@ -121,10 +121,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm_quick_nand.h +0 -4
@@ -91,10 +91,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
Signature · 1 line
1.7.5.4
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
Quoted 11 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic <[email protected]>CC Ilya Yanok <[email protected]>CC Scott Wood <[email protected]>CC Tom Rini <[email protected]>CC Simon Schwarz <[email protected]>CC Wolfgang Denk <[email protected]>
Quoted 230 lines
---
V4:
?- DropSYS_from local defines (Wolfgang Denk, Scott Wood) ?- drop parenthesis around defines (Scott Wood)V3:
?- use local defines forCONFIG_SYS_NAND_ECCSTEPSand ?CONFIG_SYS_NAND_ECCTOTAL(Tom Rini)
?- dropCONFIG_SYS_NAND_ECCSTEPSfrom board config filesV2:
?-CONFIG_SYS_NAND_ECCTOTALcan always be computed (Ilya Yanok) ?- drop allCONFIG_SYS_NAND_ECCTOTALin arm boards usingnand_simple.c?drivers/mtd/nand/nand_spl_simple.c ? ? | ? 42 ++++++++++++------------------- ?include/configs/am3517_crane.h ? ? ? ? | ? ?4 --- ?include/configs/am3517_evm.h ? ? ? ? ? | ? ?4 --- ?include/configs/devkit8000.h ? ? ? ? ? | ? ?5 ---- ?include/configs/hawkboard.h ? ? ? ? ? ?| ? ?5 +--- ?include/configs/omap3_beagle.h ? ? ? ? | ? ?4 --- ?include/configs/omap3_evm.h ? ? ? ? ? ?| ? ?4 --- ?include/configs/omap3_evm_quick_nand.h | ? ?4 ---?8 files changed, 17 insertions(+), 55 deletions(-)
drivers/mtd/nand/nand_spl_simple.c +5
-0@@ -27,6 +27,11 @@ static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS; ?static nand_info_t mtd; ?static struct nand_chip nand_chip; +#define ECCSTEPS ? ? ? (CONFIG_SYS_NAND_PAGE_SIZE / \ + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSIZE) +#define ECCTOTAL ? ? ? (ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES) + + ?#if (CONFIG_SYS_NAND_PAGE_SIZE <= 512)?/*
?* NAND command for small page NAND devices (512)drivers/mtd/nand/nand_spl_simple.c +4
-12@@ -145,30 +150,22 @@ static int nand_is_bad_block(int block) ?static int nand_read_page(int block, int page, uchar *dst) ?{ ? ? ? ?struct nand_chip *this = mtd.priv; - ? ? ? u_char *ecc_calc; - ? ? ? u_char *ecc_code; - ? ? ? u_char *oob_data; + ? ? ? u_char ecc_calc[ECCTOTAL]; + ? ? ? u_char ecc_code[ECCTOTAL]; + ? ? ? u_char oob_data[CONFIG_SYS_NAND_OOBSIZE]; ? ? ? ?int i; ? ? ? ?int eccsize = CONFIG_SYS_NAND_ECCSIZE; ? ? ? ?int eccbytes = CONFIG_SYS_NAND_ECCBYTES; - ? ? ? int eccsteps = CONFIG_SYS_NAND_ECCSTEPS; + ? ? ? int eccsteps = ECCSTEPS; ? ? ? ?uint8_t *p = dst; ? ? ? ?int stat; - ? ? ? /* - ? ? ? ?* No malloc available for now, just use some temporary locations - ? ? ? ?* in SDRAM - ? ? ? ?*/ - ? ? ? ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000); - ? ? ? ecc_code = ecc_calc + 0x100; - ? ? ? oob_data = ecc_calc + 0x200; - ? ? ? ?nand_command(block, page, 0, NAND_CMD_READOOB); ? ? ? ?this->read_buf(&mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE); ? ? ? ?nand_command(block, page, 0, NAND_CMD_READ0);? ? ? ?/* Pick the ECC bytes out of the oob data */
- ? ? ? for (i = 0; i <CONFIG_SYS_NAND_ECCTOTAL; i++)
+ ? ? ? for (i = 0; i < ECCTOTAL; i++)
? ? ? ? ? ? ? ?ecc_code[i] = oob_data[nand_ecc_pos[i]];drivers/mtd/nand/nand_spl_simple.c +4
-11@@ -185,25 +182,18 @@ static int nand_read_page(int block, int page, uchar *dst) ?static int nand_read_page(int block, int page, void *dst) ?{ ? ? ? ?struct nand_chip *this = mtd.priv; - ? ? ? u_char *ecc_calc; - ? ? ? u_char *ecc_code; - ? ? ? u_char *oob_data; + ? ? ? u_char ecc_calc[ECCTOTAL]; + ? ? ? u_char ecc_code[ECCTOTAL]; + ? ? ? u_char oob_data[CONFIG_SYS_NAND_OOBSIZE]; ? ? ? ?int i; ? ? ? ?int eccsize = CONFIG_SYS_NAND_ECCSIZE; ? ? ? ?int eccbytes = CONFIG_SYS_NAND_ECCBYTES; - ? ? ? int eccsteps = CONFIG_SYS_NAND_ECCSTEPS; + ? ? ? int eccsteps = ECCSTEPS; ? ? ? ?uint8_t *p = dst; ? ? ? ?int stat; ? ? ? ?nand_command(block, page, 0, NAND_CMD_READ0); - ? ? ? /* No malloc available for now, just use some temporary locations - ? ? ? ?* in SDRAM - ? ? ? ?*/ - ? ? ? ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000); - ? ? ? ecc_code = ecc_calc + 0x100; - ? ? ? oob_data = ecc_calc + 0x200; - ? ? ? ?for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { ? ? ? ? ? ? ? ?if (this->ecc.mode != NAND_ECC_SOFT) ? ? ? ? ? ? ? ? ? ? ? ?this->ecc.hwctl(&mtd, NAND_ECC_READ);@@ -213,10 +203,10 @@ static int nand_read_page(int block, int page, void *dst) ? ? ? ?this->read_buf(&mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);? ? ? ?/* Pick the ECC bytes out of the oob data */
- ? ? ? for (i = 0; i <CONFIG_SYS_NAND_ECCTOTAL; i++)
+ ? ? ? for (i = 0; i < ECCTOTAL; i++)
? ? ? ? ? ? ? ?ecc_code[i] = oob_data[nand_ecc_pos[i]];- ? ? ? eccsteps =
CONFIG_SYS_NAND_ECCSTEPS;
+ ? ? ? eccsteps = ECCSTEPS;
? ? ? ?p = dst;? ? ? ?for (i = 0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
include/configs/am3517_crane.h +0
-0@@ -359,10 +359,6 @@ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?10, 11, 12, 13}?#define
CONFIG_SYS_NAND_ECCSIZE? ? ? ? ? ? ? ?512 ?#defineCONFIG_SYS_NAND_ECCBYTES? ? ? 3include/configs/am3517_crane.h +0
-4-#define CONFIG_SYS_NAND_ECCSTEPS ? ? ? (CONFIG_SYS_NAND_PAGE_SIZE / \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL ? ? ? (CONFIG_SYS_NAND_ECCBYTES * \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSTEPS)?#define
CONFIG_SYS_NAND_U_BOOT_START?CONFIG_SYS_TEXT_BASE?#defineCONFIG_SYS_NAND_U_BOOT_OFFS? ?0x80000include/configs/am3517_evm.h +0
-0@@ -360,10 +360,6 @@ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?10, 11, 12, 13}?#define
CONFIG_SYS_NAND_ECCSIZE? ? ? ? ? ? ? ?512 ?#defineCONFIG_SYS_NAND_ECCBYTES? ? ? 3include/configs/am3517_evm.h +0
-4-#define CONFIG_SYS_NAND_ECCSTEPS ? ? ? (CONFIG_SYS_NAND_PAGE_SIZE / \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL ? ? ? (CONFIG_SYS_NAND_ECCBYTES * \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSTEPS)?#define
CONFIG_SYS_NAND_U_BOOT_START?CONFIG_SYS_TEXT_BASE?#defineCONFIG_SYS_NAND_U_BOOT_OFFS? ?0x80000include/configs/devkit8000.h +0
-0@@ -344,11 +344,6 @@?#define
CONFIG_SYS_NAND_ECCSIZE? ? ? ? ? ? ? ?512 ?#defineCONFIG_SYS_NAND_ECCBYTES? ? ? 3include/configs/devkit8000.h +0
-5-#define CONFIG_SYS_NAND_ECCSTEPS ? ? ? (CONFIG_SYS_NAND_PAGE_SIZE / \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL ? ? ? (CONFIG_SYS_NAND_ECCBYTES * \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSTEPS) -?#define
CONFIG_SYS_NAND_U_BOOT_START?CONFIG_SYS_TEXT_BASE?#define
CONFIG_SYS_NAND_U_BOOT_OFFS? ?0x80000include/configs/hawkboard.h +0
-0@@ -138,11 +138,8 @@?#define
CONFIG_SYS_NAND_BAD_BLOCK_POS?0
?#defineCONFIG_SYS_NAND_ECCSIZE? ? ? ? ? ? ? ?512
?#defineCONFIG_SYS_NAND_ECCBYTES? ? ? 10
-#defineCONFIG_SYS_NAND_ECCSTEPS? ? ? (CONFIG_SYS_NAND_PAGE_SIZE/ ? ? \
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CONFIG_SYS_NAND_ECCSIZE) ?#defineCONFIG_SYS_NAND_OOBSIZE? ? ? ? ? ? ? ?64include/configs/hawkboard.h +1
-2-#define CONFIG_SYS_NAND_ECCTOTAL ? ? ? (CONFIG_SYS_NAND_ECCBYTES * ? ? \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSTEPS) +?#endif /*
CONFIG_SYS_USE_NAND*/?/*
include/configs/omap3_beagle.h +0
-0@@ -426,10 +426,6 @@ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?10, 11, 12, 13}?#define
CONFIG_SYS_NAND_ECCSIZE? ? ? ? ? ? ? ?512 ?#defineCONFIG_SYS_NAND_ECCBYTES? ? ? 3include/configs/omap3_beagle.h +0
-4-#define CONFIG_SYS_NAND_ECCSTEPS ? ? ? (CONFIG_SYS_NAND_PAGE_SIZE / \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL ? ? ? (CONFIG_SYS_NAND_ECCBYTES * \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSTEPS)?#define
CONFIG_SYS_NAND_U_BOOT_START?CONFIG_SYS_TEXT_BASE?#defineCONFIG_SYS_NAND_U_BOOT_OFFS? ?0x80000include/configs/omap3_evm.h +0
-0@@ -121,10 +121,6 @@ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?10, 11, 12, 13}?#define
CONFIG_SYS_NAND_ECCSIZE? ? ? ? ? ? ? ?512 ?#defineCONFIG_SYS_NAND_ECCBYTES? ? ? 3include/configs/omap3_evm.h +0
-4-#define CONFIG_SYS_NAND_ECCSTEPS ? ? ? (CONFIG_SYS_NAND_PAGE_SIZE / \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL ? ? ? (CONFIG_SYS_NAND_ECCBYTES * \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSTEPS)?#define
CONFIG_SYS_NAND_U_BOOT_START?CONFIG_SYS_TEXT_BASE?#defineCONFIG_SYS_NAND_U_BOOT_OFFS? ?0x80000include/configs/omap3_evm_quick_nand.h +0
-0@@ -91,10 +91,6 @@ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?10, 11, 12, 13}?#define
CONFIG_SYS_NAND_ECCSIZE? ? ? ? ? ? ? ?512 ?#defineCONFIG_SYS_NAND_ECCBYTES? ? ? 3include/configs/omap3_evm_quick_nand.h +0
-4-#define CONFIG_SYS_NAND_ECCSTEPS ? ? ? (CONFIG_SYS_NAND_PAGE_SIZE / \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL ? ? ? (CONFIG_SYS_NAND_ECCBYTES * \ - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_NAND_ECCSTEPS)?#define
CONFIG_SYS_NAND_U_BOOT_START?CONFIG_SYS_TEXT_BASE?#defineCONFIG_SYS_NAND_U_BOOT_OFFS? ?0x80000--
1.7.5.4
Signature · 1 line
Tom
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
In reply to Stefano BabicQuoted 16 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic<[email protected]>CC Ilya Yanok<[email protected]>CC Scott Wood<[email protected]>CC Tom Rini<[email protected]>CC Simon Schwarz<[email protected]>CC Wolfgang Denk<[email protected]>---
V4:
- DropSYS_from local defines (Wolfgang Denk, Scott Wood)
- drop parenthesis around defines (Scott Wood)
Quoted 9 lines
V3:
- use local defines forCONFIG_SYS_NAND_ECCSTEPSandCONFIG_SYS_NAND_ECCTOTAL(Tom Rini)
- dropCONFIG_SYS_NAND_ECCSTEPSfrom board config filesV2:
-CONFIG_SYS_NAND_ECCTOTALcan always be computed (Ilya Yanok)
- drop allCONFIG_SYS_NAND_ECCTOTALin arm boards usingnand_simple.c
[SNIP]
Hi Stefano,
on which repo is this patch based? I tried to test it on u-boot but the patch does not apply.
Regards
Simon
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
Quoted 26 lines · Simon Schwarz
Quoted 16 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic<[email protected]>CC Ilya Yanok<[email protected]>CC Scott Wood<[email protected]>CC Tom Rini<[email protected]>CC Simon Schwarz<[email protected]>CC Wolfgang Denk<[email protected]>---
V4:
- DropSYS_from local defines (Wolfgang Denk, Scott Wood)
- drop parenthesis around defines (Scott Wood)Quoted 9 lines
V3:
- use local defines forCONFIG_SYS_NAND_ECCSTEPSandCONFIG_SYS_NAND_ECCTOTAL(Tom Rini)
- dropCONFIG_SYS_NAND_ECCSTEPSfrom board config filesV2:
-CONFIG_SYS_NAND_ECCTOTALcan always be computed (Ilya Yanok)
- drop allCONFIG_SYS_NAND_ECCTOTALin arm boards usingnand_simple.c
Quoted 6 lines
[SNIP]
Hi Stefano,
on which repo is this patch based? I tried to test it on u-boot but the patch does not apply.
Because I thought that the patch will be merged by Tom, I rebased the patch on u-boot-ti. This is also because there is Ilya's patch:
nand_spl_simple: add support for software ECC
that modifies the same file. The patch can be applied flawlessy on top of u-boot-ti, I have checked now again.
For testing I have then applied your SPL Linux patches, and tried to boot linux, as I know there is a conflict with the ECC area.
Tom, it is surely better (I forget to mention) that you merge the patch into u-boot-ti, because you have already merged Ilya's patch.
Regards,
Stefano
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-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
Quoted 18 lines · Simon Schwarz
Hi Stefano,
On 12/14/2011 09:49 AM, Stefano Babic wrote:
[SNIP]Quoted 14 lines
Because I thought that the patch will be merged by Tom, I rebased the patch on u-boot-ti. This is also because there is Ilya's patch:
nand_spl_simple: add support for software ECCthat modifies the same file. The patch can be applied flawlessy on top of u-boot-ti, I have checked now again.
For testing I have then applied your SPL Linux patches, and tried to boot linux, as I know there is a conflict with the ECC area.
Tom, it is surely better (I forget to mention) that you merge the patch into u-boot-ti, because you have already merged Ilya's patch.
Quoted 8 lines
Quoted 3 lines
Regards,
Stefanohmm. I tried it on u-boot-ti (master and next) and it didn't apply.
The problem was with
drivers/mtd/nand/nand_spl_simple.c:145. The last commit touching the file was from Anatolij on 3th december.
I see, maybe it was not already merged when I tested. I send a rebased patch.
Stefano
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-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
In reply to Stefano BabicQuoted 25 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic <[email protected]>CC Ilya Yanok <[email protected]>CC Scott Wood <[email protected]>CC Tom Rini <[email protected]>CC Simon Schwarz <[email protected]>CC Wolfgang Denk <[email protected]>---
V4:
- DropSYS_from local defines (Wolfgang Denk, Scott Wood)
- drop parenthesis around defines (Scott Wood)V3:
- use local defines forCONFIG_SYS_NAND_ECCSTEPSandCONFIG_SYS_NAND_ECCTOTAL(Tom Rini)
- dropCONFIG_SYS_NAND_ECCSTEPSfrom board config filesV2:
-CONFIG_SYS_NAND_ECCTOTALcan always be computed (Ilya Yanok)
- drop allCONFIG_SYS_NAND_ECCTOTALin arm boards usingnand_simple.c
Quoted 9 lines
drivers/mtd/nand/nand_spl_simple.c | 42 ++++++++++++------------------- include/configs/am3517_crane.h | 4 --- include/configs/am3517_evm.h | 4 --- include/configs/devkit8000.h | 5 ---- include/configs/hawkboard.h | 5 +--- include/configs/omap3_beagle.h | 4 --- include/configs/omap3_evm.h | 4 --- include/configs/omap3_evm_quick_nand.h | 4 --- 8 files changed, 17 insertions(+), 55 deletions(-)
After this patch a hawkboard_nand build gives this:
Quoted 8 lines
Configuring for
hawkboard_nand- Board: hawkboard, Options:NAND_U_BOOT/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.c: In function 'nand_read_page':/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.c:148:17: error: 'CONFIG_SYS_NAND_ECCSTEPS' undeclared (first use in this function)/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.c:148:17: note: each undeclared identifier is reported only once for each function it appears in/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.c:164:18: error: 'CONFIG_SYS_NAND_ECCTOTAL' undeclared (first use in this function) make[1]: *** [/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.o] Error 1
make: *** [nand_spl] Error 2
make: *** Waiting for unfinished jobs....
Should I drop hawkboard from this patch, or add the change to nand_spl/nand_boot.c? Is a hawkboard conversion to the new SPL pending in some other tree?
-Scott
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
Quoted 47 lines · Scott Wood
Quoted 33 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic <[email protected]>CC Ilya Yanok <[email protected]>CC Scott Wood <[email protected]>CC Tom Rini <[email protected]>CC Simon Schwarz <[email protected]>CC Wolfgang Denk <[email protected]>---
V4:
?- DropSYS_from local defines (Wolfgang Denk, Scott Wood) ?- drop parenthesis around defines (Scott Wood)V3:
?- use local defines forCONFIG_SYS_NAND_ECCSTEPSand ? ?CONFIG_SYS_NAND_ECCTOTAL (Tom Rini)
?- dropCONFIG_SYS_NAND_ECCSTEPSfrom board config filesV2:
?-CONFIG_SYS_NAND_ECCTOTALcan always be computed (Ilya Yanok) ?- drop allCONFIG_SYS_NAND_ECCTOTALin arm boards usingnand_simple.c?drivers/mtd/nand/nand_spl_simple.c ? ? | ? 42 ++++++++++++------------------- ?include/configs/am3517_crane.h ? ? ? ? | ? ?4 --- ?include/configs/am3517_evm.h ? ? ? ? ? | ? ?4 --- ?include/configs/devkit8000.h ? ? ? ? ? | ? ?5 ---- ?include/configs/hawkboard.h ? ? ? ? ? ?| ? ?5 +--- ?include/configs/omap3_beagle.h ? ? ? ? | ? ?4 --- ?include/configs/omap3_evm.h ? ? ? ? ? ?| ? ?4 --- ?include/configs/omap3_evm_quick_nand.h | ? ?4 ---Quoted 1 line
?8 files changed, 17 insertions(+), 55 deletions(-)
After this patch a
hawkboard_nandbuild gives this:Quoted 8 lines
Configuring for
hawkboard_nand- Board: hawkboard, Options:NAND_U_BOOT/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.c: In function 'nand_read_page':/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.c:148:17: error: 'CONFIG_SYS_NAND_ECCSTEPS' undeclared (first use in this function)/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.c:148:17: note: each undeclared identifier is reported only once for each function it appears in/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.c:164:18: error: 'CONFIG_SYS_NAND_ECCTOTAL' undeclared (first use in this function) make[1]: *** [/tmp/u-boot-arm/nand_spl/board/davinci/da8xxevm/nand_boot.o] Error 1
make: *** [nand_spl] Error 2
make: *** Waiting for unfinished jobs....
Quoted 3 lines
Should I drop hawkboard from this patch, or add the change to
nand_spl/nand_boot.c? ?Is a hawkboard conversion to the new SPL pending in some other tree?
A hawkboard conversion is pending Albert ack'ing/commenting on a generic ARM fixup.
Signature · 1 line
Tom
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
Hi,
I am slowly catching up on my e-mail, so...
Le 11/01/2012 00:24, Tom Rini a ?crit :
Quoted 2 lines
A hawkboard conversion is pending Albert ack'ing/commenting on a generic ARM fixup.
Can you point me to this patch series? I'll look it up as soon as possible.
Amicalement,
Signature · 1 line
Albert.
PATCH v4 1/1 nand_spl_simple: store ecc data on the stack
Quoted 11 lines · Albert ARIBAUD
Hi,
I am slowly catching up on my e-mail, so...
Le 11/01/2012 00:24, Tom Rini a ?crit :
Quoted 3 lines
A hawkboard conversion is pending Albert ack'ing/commenting on a generic ARM fixup.
Can you point me to this patch series? I'll look it up as soon as possible.
Latest version starts at http://patchwork.ozlabs.org/patch/139114/ and is in my queue for Monday, assuming there's no further feedback.
Signature · 1 line
Tom
PATCH v5 1/1 nand_spl_simple: store ecc data on the stack
In reply to Stefano BabicCurrently nand_spl_simple puts it's temp data at 0x10000 offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.
---
V5:
- no changes, rebased on current u-boot-ti
V4:
- Drop SYS_ from local defines (Wolfgang Denk, Scott Wood)
- drop parenthesis around defines (Scott Wood)
V3:
- use local defines for CONFIG_SYS_NAND_ECCSTEPS and CONFIG_SYS_NAND_ECCTOTAL (Tom Rini)
- drop CONFIG_SYS_NAND_ECCSTEPS from board config files
V2:
- CONFIG_SYS_NAND_ECCTOTAL can always be computed (Ilya Yanok)
- drop all CONFIG_SYS_NAND_ECCTOTAL in arm boards using nand_simple.c
drivers/mtd/nand/nand_spl_simple.c | 42 ++++++++++++------------------- include/configs/am3517_crane.h | 4 --- include/configs/am3517_evm.h | 4 --- include/configs/devkit8000.h | 5 ---- include/configs/hawkboard.h | 5 +--- include/configs/omap3_beagle.h | 4 --- include/configs/omap3_evm.h | 4 --- include/configs/omap3_evm_quick_nand.h | 4 --- 8 files changed, 17 insertions(+), 55 deletions(-)
drivers/mtd/nand/nand_spl_simple.c +16 -26
@@ -27,6 +27,11 @@ static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;static nand_info_t mtd;static struct nand_chip nand_chip; +#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ + CONFIG_SYS_NAND_ECCSIZE) +#define ECCTOTAL (ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES) + +#if (CONFIG_SYS_NAND_PAGE_SIZE <=512 )/* * NAND command for small page NAND devices (512)
@@ -145,29 +150,21 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,uchar *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[ECCTOTAL ]; +u_char ecc_code[ECCTOTAL ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ; -int eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; +int eccsteps =ECCSTEPS ;uint8_t *p = dst; -/* -* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -nand_command (block, page,0 ,NAND_CMD_READOOB ); this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );nand_command (block, page,0 ,NAND_CMD_READ0 );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; i <ECCTOTAL ; i++) ecc_code[i] = oob_data[nand_ecc_pos[i]];
@@ -184,24 +181,17 @@ static int nand_read_page(int block, int page, uchar *dst)static int nand_read_page (int block,int page,void *dst) {struct nand_chip *this = mtd.priv; -u_char *ecc_calc; -u_char *ecc_code; -u_char *oob_data; +u_char ecc_calc[ECCTOTAL ]; +u_char ecc_code[ECCTOTAL ]; +u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];int i;int eccsize =CONFIG_SYS_NAND_ECCSIZE ;int eccbytes =CONFIG_SYS_NAND_ECCBYTES ; -int eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; +int eccsteps =ECCSTEPS ;uint8_t *p = dst;nand_command (block, page,0 ,NAND_CMD_READ0 ); -/* No malloc available for now, just use some temporary locations -* in SDRAM -*/ - ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE +0x10000 ); - ecc_code = ecc_calc +0x100 ; - oob_data = ecc_calc +0x200 ; -for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {if (this->ecc.mode !=NAND_ECC_SOFT ) this->ecc.hwctl (&mtd,NAND_ECC_READ );
@@ -211,10 +201,10 @@ static int nand_read_page(int block, int page, void *dst) this->read_buf (&mtd, oob_data,CONFIG_SYS_NAND_OOBSIZE );/* Pick the ECC bytes out of the oob data */ -for (i =0 ; i <CONFIG_SYS_NAND_ECCTOTAL ; i++) +for (i =0 ; i <ECCTOTAL ; i++) ecc_code[i] = oob_data[nand_ecc_pos[i]]; - eccsteps =CONFIG_SYS_NAND_ECCSTEPS ; + eccsteps =ECCSTEPS ; p = dst;for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
include/configs/am3517_crane.h +0 -4
@@ -359,10 +359,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/am3517_evm.h +0 -4
@@ -360,10 +360,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/devkit8000.h +0 -5
@@ -343,11 +343,6 @@#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS) -#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/hawkboard.h +1 -4
@@ -138,11 +138,8 @@#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 10 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE)#define CONFIG_SYS_NAND_OOBSIZE 64 -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS) +#endif /* CONFIG_SYS_USE_NAND */ /*
include/configs/omap3_beagle.h +0 -4
@@ -418,10 +418,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm.h +0 -4
@@ -121,10 +121,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm_quick_nand.h +0 -4
@@ -91,10 +91,6 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 -#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ - CONFIG_SYS_NAND_ECCSIZE) -#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ - CONFIG_SYS_NAND_ECCSTEPS)#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
Signature · 1 line
1.7.5.4
PATCH v5 1/1 nand_spl_simple: store ecc data on the stack
Quoted 5 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.
Quoted 7 lines
Signed-off-by Stefano Babic <[email protected]>CC Ilya Yanok <[email protected]>CC Scott Wood <[email protected]>CC Tom Rini <[email protected]>CC Simon Schwarz <[email protected]>CC Wolfgang Denk <[email protected]>---
-Scott
PATCH v5 1/1 nand_spl_simple: store ecc data on the stack
In reply to Stefano BabicQuoted 11 lines · Stefano Babic
Currently
nand_spl_simpleputs it's temp data at0x10000offset in SDRAM which is likely to contain already loaded data.
The patch saves the oob data and the ecc on the stack replacing the fixed address in RAM.Signed-off-by Stefano Babic <[email protected]>CC Ilya Yanok <[email protected]>CC Scott Wood <[email protected]>CC Tom Rini <[email protected]>CC Simon Schwarz <[email protected]>CC Wolfgang Denk <[email protected]>
Applied to u-boot-nand-flash
-Scott