Forum: ARM programming with GCC/GNU tools About SAM7 remapping

von Martin Thomas (Guest)

Rate this post
0 useful
not useful
I have received a question about the remapping code in my
AT91SAM7-"gamma" example (at
). I think it is interesting for others or maybe others can give better
or more detailed information so I have copied the question and my answer
into the forum.


>I have a question with regard to the SAM7 remap.
>Here is some assembler code you wrote from the following project
>AT91SAM7 SWI, Remap, GPIO, PIT and stdio Example ("Gamma") (last Updated
>4.Sept. 2006)

[mthomas: from the gamma-examle/Cstartup.S:]

/*- Remapping
                        .print "RCR setting for remapping enabled"
                        .equ    MC_BASE,0xFFFFFF00  /* MC Base Address
                        .equ    MC_RCR, 0x00        /* MC_RCR Offset */
                        /* store first word in RAM into r4 */
                        ldr r0,=__FIRST_IN_RAM
                        ldr r4,[r0]
                        /* load value at address 0 into R2 */
                        ldr r1,=0x00000000
                        ldr r2,[r1]
                        /* xor value from address 0 (flip all bits),
                        store in R3 */
                        ldr r3,=0xffffffff
                        eor r3, r2, r3
                        /* write xored value to first word in RAM
                        if already remapped this will also change
                        the value at 0 */
                        str r3,[r0]
                        /* load from address 0 again into R3 */
                        ldr r3,[r1]
                        /* restore first value in RAM */
                        str r4,[r0]
                        /* compare */
                        cmp r3, r2
                        bne already_remapped
                        /* if both values have been equal the change of
                        RAM-value had no effect on the value at
                        so we are not remapping yet -> remap now: */
                        LDR     R0, =MC_BASE
                        MOV     R1, #1
                        STR     R1, [R0, #MC_RCR]

[mthomas: end of "cited" code]

>First I assume that the above code is executing from flash and not from RAM.

Yes, I have wrapped this code between .if/.endif and it is ment to be
used for the "ROM_RUN" (=flash) target. Remap for target RAM_RUN is
usualy done by the debugging-software by writing directly into the
processor-registers so there is no option for remapping and "RAM_RUN" in
this example.

>After the remap instruction in red [mthomas: the lines
>LDR R0, =MC_BASE, MOV R1, #1 STR R1, [R0, #MC_RCR] ] above you don


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.