[U-Boot] Most ARM CPU's have buggy clear_bss?

Darius Augulis
2010-10-27T18:11:51Z

Hi Eric,

On 10/27/2010 06:12 PM, Eric Cooper wrote:
> On Wed, Oct 27, 2010 at 10:26:06AM +0300, Darius Augulis wrote:
>> Maybe it could be reason why I'm facing strange problem, when after
>> relocating uboot with nand_spl no one command is not working. I
>> debugged that command table is empty.
>
> Maybe this is the same problem I reported here (commands not found):
> http://lists.denx.de/pipermail/u-boot/2010-October/080198.html
>

looks similar, but not exactly the same. Mine output:

U-Boot 2010.09-00560-g5b4d583-dirty (Oct 27 2010 - 21:00:13) for MINI6410

U-Boot code: 57E00000 -> 57E2BDE4 BSS: -> 57E31680

CPU: S3C6400 at 532MHz
Fclk = 532MHz, Hclk = 133MHz, Pclk = 66MHz (SYNC Mode)
Board: MINI6410
monitor len: 00031680
ramsize: 08000000
TLB table at: 57ff0000
Top of RAM usable for U-Boot at: 57ff0000
Reserving 197k for U-Boot at: 57fbe000
Reserving 1280k for malloc() at: 57e7e000
Reserving 24 Bytes for Board Info at: 57e7dfe8
Reserving 92 Bytes for Global Data at: 57e7df8c
New Stack Pointer is: 57e7df88
RAM Configuration:
Bank #0: 50000000 128 MiB
relocation Offset is: 001be000
monitor flash len: 0002BDE4
Now running in RAM - U-Boot at: 57fbe000
NAND: raise: Signal # 8 caught
raise: Signal # 8 caught
raise: Signal # 8 caught
256 MiB
Using default environment

Destroy Hash Table: 57e31568 table = (null)
Create Hash Table: N=79
INSERT: table 57e31568, filled 1/79 rv 57e7f42c ==> name="bootargs"
value="console=ttySAC,115200"
INSERT: table 57e31568, filled 2/79 rv 57e7f348 ==> name="bootcmd"
value="nand read 0x50018000 0x60000 0x1c0000;bootm 0x50018000"
INSERT: table 57e31568, filled 3/79 rv 57e7f438 ==> name="bootdelay"
value="3"
INSERT: table 57e31568, filled 4/79 rv 57e7f378 ==> name="baudrate"
value="115200"
INSERT: free(data = 57e7f2a0)
INSERT: done
In: serial
Out: serial
Err: serial
Net: dm9000
### main_loop entered: bootdelay=3

### main_loop: bootcmd="nand read 0x50018000 0x60000 0x1c0000;bootm
0x50018000"
Hit any key to stop autoboot: 0
MINI6410 # help
Unknown command 'help' - try 'help'
MINI6410 #

I'm doing support for new board, so there could be some bugs in its
config. But I still thinking that clear_bss code is buggy, because uboot
reboots is DEBUG if defined and following simple patch isn't applied:

diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S
index 7f32db7..8337c4b 100644
--- a/arch/arm/cpu/arm1176/start.S
+++ b/arch/arm/cpu/arm1176/start.S
@@ -379,13 +379,16 @@ clear_bss:
#ifndef CONFIG_PRELOADER
ldr r0, _bss_start_ofs
ldr r1, _bss_end_ofs
- ldr r3, _TEXT_BASE /* Text base */
+#ifdef CONFIG_SKIP_RELOCATE_UBOOT
+ ldr r4, _TEXT_BASE /* Text base */
+#else
mov r4, r7 /* reloc addr */
+#endif
add r0, r0, r4
add r1, r1, r4
- mov r2, #0x00000000 /* clear
*/
+ mov r2, #0x00000000 /* clear */

-clbss_l:str r2, [r0] /* clear loop...
*/
+clbss_l:str r2, [r0] /* clear loop */
add r0, r0, #4
cmp r0, r1
bne clbss_l

If DEBUG isn't defined then it does not reboot, but commands are missing
in both cases. Unfortunately this patch does not solve this problem.
I've calculated bss start and end addresses with and without '#ifdef
CONFIG_SKIP_RELOCATE_UBOOT' and they are wrong without it.

Darius.