[U-Boot] arm writel in v2010.03-rc1 generate wrong code

Jens Scharsig
2011-02-22T10:10:34Z

Am 2011-02-22 09:06, schrieb zzs213:
> My board is very similar to at91rm9200ek. I have a function to init nor flash bus, like this :
>
> void gfd3000cdb_nor_hw_init(void)
> {
> at91_mc_t *mc = (at91_mc_t *)AT91_MC_BASE;
>
> writel(CONFIG_SYS_EBI_CFGR_VAL, &(mc->ebi.cfgr));
> writel(CONFIG_SYS_SMC_CSR0_VAL, &mc->smc.csr[0]);
> }
>
> Which render to the fllowing asm code :
>
> 20120f0c <gfd3000cdb_nor_hw_init>:
> 20120f0c: e3a01000 mov r1, #0 ; 0x0
> 20120f10: e3e0309b mvn r3, #155 ; 0x9b
> 20120f14: e5831000 str r1, [r3]
> 20120f18: e283309b add r3, r3, #155 ; 0x9b
> 20120f1c: e553208f ldrb r2, [r3, #-143]
> 20120f20: e3e0207b mvn r2, #123 ; 0x7b
> 20120f24: e543208f strb r2, [r3, #-143]
> 20120f28: e553208e ldrb r2, [r3, #-142]
> 20120f2c: e3a02032 mov r2, #50 ; 0x32
> 20120f30: e543208e strb r2, [r3, #-142]
> 20120f34: e553208d ldrb r2, [r3, #-141]
> 20120f38: e543108d strb r1, [r3, #-141]
> 20120f3c: e553208c ldrb r2, [r3, #-140]
> 20120f40: e543108c strb r1, [r3, #-140]
> 20120f44: e1a0f00e mov pc, lr
>
> It can't work very obviously because it use the target address as four byte address, but my idea is write a 4bytes word
> to the target address.
>
> And the cpu dead when I download this code to the board.
>
>
> Then I change the function to the flowwing form:
>
> void gfd3000cdb_nor_hw_init(void)
> {
> at91_mc_t *mc = (at91_mc_t *)AT91_MC_BASE;
>
> writel(CONFIG_SYS_EBI_CFGR_VAL, &(mc->ebi.cfgr));
> writel(CONFIG_SYS_SMC_CSR0_VAL, (unsigned int)(&mc->smc.csr[0]));
> }
>
> It's asm code is :
>
> 20120f0c <gfd3000cdb_nor_hw_init>:
> 20120f0c: e3a02000 mov r2, #0 ; 0x0
> 20120f10: e3e0309b mvn r3, #155 ; 0x9b
> 20120f14: e5832000 str r2, [r3]
> 20120f18: e59f2008 ldr r2, [pc, #8] ; 20120f28 <gfd3000cdb_nor_hw_init+0x1c>
> 20120f1c: e283300c add r3, r3, #12 ; 0xc
> 20120f20: e5832000 str r2, [r3]
> 20120f24: e1a0f00e mov pc, lr
> 20120f28: 00003284 .word 0x00003284
>
> It's ok. And the board say OK too.
>
> My toolchain is eldk4.2
>
> anybody help me!!

I think you need this patch

http://lists.denx.de/pipermail/u-boot/2010-December/084133.html

regards

Jens Scharsig