[U-Boot] [PATCH] post, memorytest: fix if vstart is not = 0x0

Signed-off-by: Heiko Schocher hs@denx.de --- post/drivers/memory.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/post/drivers/memory.c b/post/drivers/memory.c index 3f47449..b7943ef 100644 --- a/post/drivers/memory.c +++ b/post/drivers/memory.c @@ -500,9 +500,10 @@ int memory_post_test(int flags) unsigned long i; for (i = 0; i < (memsize >> 20) && ret == 0; i++) { if (ret == 0) - ret = memory_post_tests(i << 20, 0x800); + ret = memory_post_tests(vstart + + (i << 20), 0x800); if (ret == 0) - ret = memory_post_tests( + ret = memory_post_tests(vstart + (i << 20) + 0xff800, 0x800); } }

Signed-off-by: Heiko Schocher hs@denx.de --- post/drivers/memory.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/post/drivers/memory.c b/post/drivers/memory.c index b7943ef..47b312d 100644 --- a/post/drivers/memory.c +++ b/post/drivers/memory.c @@ -455,10 +455,30 @@ static int memory_post_tests (unsigned long start, unsigned long size) __attribute__((weak)) int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset) { +#if defined(CONFIG_ARM) + bd_t *bd = gd->bd; + int i; + + *size = 0; + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + if (i == 0) { + *vstart = bd->bi_dram[0].start; + *size += bd->bi_dram[i].size; + } else { + if (bd->bi_dram[i].start == + (bd->bi_dram[i - 1].start + bd->bi_dram[i - 1].size)) { + *size += bd->bi_dram[i].size; + } else { + break; + } + } + } +#else bd_t *bd = gd->bd; *vstart = CONFIG_SYS_SDRAM_BASE; *size = (bd->bi_memsize >= 256 << 20 ? 256 << 20 : bd->bi_memsize) - (1 << 20); +#endif
/* Limit area to be tested with the board info struct */ if ((*vstart) + (*size) > (ulong)bd)

Dear Heiko Schocher,
In message 1306909447-19603-2-git-send-email-hs@denx.de you wrote:
Signed-off-by: Heiko Schocher hs@denx.de
post/drivers/memory.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/post/drivers/memory.c b/post/drivers/memory.c index b7943ef..47b312d 100644 --- a/post/drivers/memory.c +++ b/post/drivers/memory.c @@ -455,10 +455,30 @@ static int memory_post_tests (unsigned long start, unsigned long size) __attribute__((weak)) int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset) { +#if defined(CONFIG_ARM)
This is a weak function, so there should be no need to have #ifdef's in there.
Just define your own code as you need it.
- bd_t *bd = gd->bd;
- int i;
- *size = 0;
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
if (i == 0) {
*vstart = bd->bi_dram[0].start;
*size += bd->bi_dram[i].size;
This is a constant part and should be moved out of the loop. Then you can also get rid of th if...else clause.
} else {
if (bd->bi_dram[i].start ==
(bd->bi_dram[i - 1].start + bd->bi_dram[i - 1].size)) {
*size += bd->bi_dram[i].size;
} else {
break;
So how do you handle non-contiguous memory banks? It appears these are quite frequent on ARM these days.
Best regards,
Wolfgang Denk

Hello Wolfgang,
Wolfgang Denk wrote:
Dear Heiko Schocher,
In message 1306909447-19603-2-git-send-email-hs@denx.de you wrote:
Signed-off-by: Heiko Schocher hs@denx.de
post/drivers/memory.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/post/drivers/memory.c b/post/drivers/memory.c index b7943ef..47b312d 100644 --- a/post/drivers/memory.c +++ b/post/drivers/memory.c @@ -455,10 +455,30 @@ static int memory_post_tests (unsigned long start, unsigned long size) __attribute__((weak)) int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset) { +#if defined(CONFIG_ARM)
This is a weak function, so there should be no need to have #ifdef's in there.
Just define your own code as you need it.
Yes (I did this for my case, as I use it in nand_spl code, and therefore I need a "own" function, because there I have no bd ) ... but, for arm there is no bd->bi_memsize! ... so this file fails compiling. Independent, if it gets replaced by another function.
- bd_t *bd = gd->bd;
- int i;
- *size = 0;
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
if (i == 0) {
*vstart = bd->bi_dram[0].start;
*size += bd->bi_dram[i].size;
This is a constant part and should be moved out of the loop. Then you can also get rid of th if...else clause.
Yep, you are right! Change this.
} else {
if (bd->bi_dram[i].start ==
(bd->bi_dram[i - 1].start + bd->bi_dram[i - 1].size)) {
*size += bd->bi_dram[i].size;
} else {
break;
So how do you handle non-contiguous memory banks? It appears these are quite frequent on ARM these days.
Actually, I could not handle this. Ok, I add a comment, that this function is actually only valid for contiguous mem banks.
Thanks!
bye, Heiko

On Wednesday, June 01, 2011 02:54:30 Heiko Schocher wrote:
Wolfgang Denk wrote:
Heiko Schocher wrote:
--- a/post/drivers/memory.c +++ b/post/drivers/memory.c @@ -455,10 +455,30 @@ static int memory_post_tests (unsigned long start, unsigned long size)
__attribute__((weak)) int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset) {
+#if defined(CONFIG_ARM)
This is a weak function, so there should be no need to have #ifdef's in there.
Just define your own code as you need it.
Yes (I did this for my case, as I use it in nand_spl code, and therefore I need a "own" function, because there I have no bd ) ... but, for arm there is no bd->bi_memsize! ... so this file fails compiling. Independent, if it gets replaced by another function.
so add bi_memsize to arm ? it's the only arch that lacks it. -mike

Hello Mike,
Mike Frysinger wrote:
On Wednesday, June 01, 2011 02:54:30 Heiko Schocher wrote:
Wolfgang Denk wrote:
Heiko Schocher wrote:
--- a/post/drivers/memory.c +++ b/post/drivers/memory.c @@ -455,10 +455,30 @@ static int memory_post_tests (unsigned long start, unsigned long size)
__attribute__((weak)) int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset) {
+#if defined(CONFIG_ARM)
This is a weak function, so there should be no need to have #ifdef's in there.
Just define your own code as you need it.
Yes (I did this for my case, as I use it in nand_spl code, and therefore I need a "own" function, because there I have no bd ) ... but, for arm there is no bd->bi_memsize! ... so this file fails compiling. Independent, if it gets replaced by another function.
so add bi_memsize to arm ? it's the only arch that lacks it.
Hmm.. I thought of that too, but wouldn;t it be better to use gd->ram_size in post/drivers/memory.c, as this is defined in global_data for all archs?
bye, Heiko

Dear Heiko Schocher,
In message 4DE72566.9040008@denx.de you wrote:
Hmm.. I thought of that too, but wouldn;t it be better to use gd->ram_size in post/drivers/memory.c, as this is defined in global_data for all archs?
Indeed. Can you do this, please?
Best regards,
Wolfgang Denk

On Thursday, June 02, 2011 01:53:42 Heiko Schocher wrote:
Mike Frysinger wrote:
so add bi_memsize to arm ? it's the only arch that lacks it.
Hmm.. I thought of that too, but wouldn;t it be better to use gd->ram_size in post/drivers/memory.c, as this is defined in global_data for all archs?
makes me wonder why we have bd->bi_memsize in the first place.
and how can this possibly work ? arch/arm/lib/board.c: sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram); -mike

Hello Mike,
Mike Frysinger wrote:
On Thursday, June 02, 2011 01:53:42 Heiko Schocher wrote:
Mike Frysinger wrote:
so add bi_memsize to arm ? it's the only arch that lacks it.
Hmm.. I thought of that too, but wouldn;t it be better to use gd->ram_size in post/drivers/memory.c, as this is defined in global_data for all archs?
makes me wonder why we have bd->bi_memsize in the first place.
and how can this possibly work ? arch/arm/lib/board.c: sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram); -mike
Yep, good question ... maybe, no arm based board has defined
"#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)"
?
I can make a fix and change this to gd->ram_size?
bye, Heiko

Dear Heiko Schocher,
In message 4DE8739D.2040400@denx.de you wrote:
Yep, good question ... maybe, no arm based board has defined
"#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)"
That's actually very likely. ARM systems tended to be simple and not use any such fancy features.
I can make a fix and change this to gd->ram_size?
Please do!
Best regards,
Wolfgang Denk

This include is needed, if this memory test is used "outside" from post code, for example booting with nand_spl, and using this memory test before copying u-boot code to RAM and jumping to it.
Signed-off-by: Heiko Schocher hs@denx.de --- include/post.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/post.h b/include/post.h index 519cef1..cda6e76 100644 --- a/include/post.h +++ b/include/post.h @@ -187,6 +187,7 @@ extern int post_hotkeys_pressed(void); #define CONFIG_SYS_POST_CODEC 0x00200000 #define CONFIG_SYS_POST_COPROC 0x00400000
+int memory_post_test(int flags); #endif /* CONFIG_POST */
#endif /* _POST_H */

Dear Heiko Schocher,
In message 1306909447-19603-3-git-send-email-hs@denx.de you wrote:
This include is needed, if this memory test is used "outside" from post code, for example booting with nand_spl, and using this memory test before copying u-boot code to RAM and jumping to it.
Signed-off-by: Heiko Schocher hs@denx.de
include/post.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Dear Heiko,
In message 1306909447-19603-3-git-send-email-hs@denx.de you wrote:
This include is needed, if this memory test is used "outside" from post code, for example booting with nand_spl, and using this memory test before copying u-boot code to RAM and jumping to it.
Signed-off-by: Heiko Schocher hs@denx.de
include/post.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
This got applied as commit f18714d, but obviously this patch has not been tested before as it is breaking a ton of boards:
... Configuring for NETTA_ISDN - Board: NETTA, Options: NETTA_ISDN=1 include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [lib_powerpc/libpostpowerpc.o] Error 2 make: *** [libpost.o] Error 2 ppc_6xx-size: 'u-boot': No such file Configuring for NETTA_ISDN_6412 - Board: NETTA, Options: NETTA_ISDN=1,NETTA_6412=1 include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [lib_powerpc/libpostpowerpc.o] Error 2 make: *** [libpost.o] Error 2 ppc_6xx-size: 'u-boot': No such file Configuring for NETTA_ISDN_6412_SWAPHOOK - Board: NETTA, Options: NETTA_ISDN=1,NETTA_6412=1,NETTA_SWAPHOOK=1 include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [lib_powerpc/libpostpowerpc.o] Error 2 make: *** [libpost.o] Error 2 ppc_6xx-size: 'u-boot': No such file Configuring for NETTA_ISDN_SWAPHOOK - Board: NETTA, Options: NETTA_ISDN=1,NETTA_SWAPHOOK=1 include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [lib_powerpc/libpostpowerpc.o] Error 2 make: *** [libpost.o] Error 2 ppc_6xx-size: 'u-boot': No such file Configuring for NETTA_SWAPHOOK - Board: NETTA, Options: NETTA_SWAPHOOK=1 include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [lib_powerpc/libpostpowerpc.o] Error 2 make: *** [libpost.o] Error 2 ppc_6xx-size: 'u-boot': No such file ... Configuring for KUP4X board... include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' make[2]: *** [lib_powerpc/asm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... include/post.h: Assembler messages: include/post.h:190: Error: Unrecognized opcode: `int' ...
Please fix!!
Best regards,
Wolfgang Denk

Dear Heiko,
In message 20110726082651.F2CE3138EED4@gemini.denx.de I wrote:
In message 1306909447-19603-3-git-send-email-hs@denx.de you wrote:
This include is needed, if this memory test is used "outside" from post code, for example booting with nand_spl, and using this memory test before copying u-boot code to RAM and jumping to it.
Signed-off-by: Heiko Schocher hs@denx.de
include/post.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
This got applied as commit f18714d, but obviously this patch has not been tested before as it is breaking a ton of boards:
...
Please fix!!
To keep the number of non-compiling commits small and being able to apply more patches now I decided not to wait for your fix, but to revert the broken commit.
Please resubmit the (fixed) patch.
Best regards,
Wolfgang Denk

Hello Wolfgang,
Wolfgang Denk wrote:
Dear Heiko,
In message 20110726082651.F2CE3138EED4@gemini.denx.de I wrote:
In message 1306909447-19603-3-git-send-email-hs@denx.de you wrote:
This include is needed, if this memory test is used "outside" from post code, for example booting with nand_spl, and using this memory test before copying u-boot code to RAM and jumping to it.
Signed-off-by: Heiko Schocher hs@denx.de
include/post.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
This got applied as commit f18714d, but obviously this patch has not been tested before as it is breaking a ton of boards:
...
Please fix!!
To keep the number of non-compiling commits small and being able to apply more patches now I decided not to wait for your fix, but to revert the broken commit.
Please resubmit the (fixed) patch.
Argh, did a "MAKEALL arm" only ... Sorry for the inconvinience! I look at this ASAP.
bye, Heiko

This include is needed, if this memory test is used "outside" from post code, for example booting with nand_spl, and using this memory test before copying u-boot code to RAM and jumping to it.
Signed-off-by: Heiko Schocher hs@denx.de
--- changes for v2: - make MAKEALL clean as Wolfgang Denk suggested - rebased against 7130a579fdba5dd1bf99508fb0b1d13317542109
include/post.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/post.h b/include/post.h index 3f259b7..3d23d22 100644 --- a/include/post.h +++ b/include/post.h @@ -147,6 +147,7 @@ unsigned long post_time_ms (unsigned long base); extern struct post_test post_list[]; extern unsigned int post_list_size; extern int post_hotkeys_pressed(void); +extern int memory_post_test(int flags);
/* * If GCC is configured to use a version of GAS that supports

Dear Heiko Schocher,
In message 1311748268-14521-1-git-send-email-hs@denx.de you wrote:
This include is needed, if this memory test is used "outside" from post code, for example booting with nand_spl, and using this memory test before copying u-boot code to RAM and jumping to it.
Signed-off-by: Heiko Schocher hs@denx.de
changes for v2:
- make MAKEALL clean as Wolfgang Denk suggested
- rebased against 7130a579fdba5dd1bf99508fb0b1d13317542109
include/post.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Dear Heiko Schocher,
In message 1306909447-19603-1-git-send-email-hs@denx.de you wrote:
Signed-off-by: Heiko Schocher hs@denx.de
post/drivers/memory.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
participants (3)
-
Heiko Schocher
-
Mike Frysinger
-
Wolfgang Denk