From: Jens Scharsig <esw@bus-elektronik.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] arm writel in v2010.03-rc1 generate wrong code
Date: Tue, 22 Feb 2011 11:10:34 +0100 [thread overview]
Message-ID: <ik022q$fnf$1@dough.gmane.org> (raw)
In-Reply-To: <5e692249.14e54.12e4c68127b.Coremail.zzs213@126.com>
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
next prev parent reply other threads:[~2011-02-22 10:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-22 8:06 [U-Boot] arm writel in v2010.03-rc1 generate wrong code zzs213
2011-02-22 10:10 ` Jens Scharsig [this message]
2011-02-22 11:19 ` zzs213
2011-02-22 12:42 ` Wolfgang Denk
2011-02-22 12:46 ` Albert ARIBAUD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='ik022q$fnf$1@dough.gmane.org' \
--to=esw@bus-elektronik.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.