Skip to contentSkip to conversation

arm writel in v2010.03-rc1 generate wrong code

U-Boot zzs213 4 participants 5 messages Feb 22, 2011

lore
Share & tools
lore

zzs213

author
#0 lore raw

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!!

#1 lore raw

Am 2011-02-22 09:06, schrieb zzs213:

Quoted 57 lines

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
Quoted 5 lines

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

#3 lore raw

Dear zzs213,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 4 lines

I think you need this patch

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

Is there any other smoothly solution?
This patch makes my code differ from the main line,So I think it's not good enough.

You can of course just wait until the patch has been accepted for mainline, or until another solution has been developed.

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
People have one thing in common: they are all different.
#4 lore raw

Le 22/02/2011 13:42, Wolfgang Denk a ?crit :

Quoted 6 lines

Dear zzs213,

Quoted 3 lines · In message<[email protected]> you wrote:
Quoted 3 lines

I think you need this patch

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

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

Is there any other smoothly solution?
This patch makes my code differ from the main line,So I think it's not good enough.

You can of course just wait until the patch has been accepted for mainline, or until another solution has been developed.

Meanwhile, one can maintain a local copy of the U-Boot git repository with a dedicated branch where this patch is added, and keep this branch rebased on master.

Quoted 3 lines

Best regards,

Wolfgang Denk

Amicalement,

Signature · 1 line
Albert.