2.5.3. ROM/RAM remapping

You must consider what sort of memory your system has at address 0x0000, the address of the first instruction executed.


This section assumes that the ARM core begins fetching instructions at 0x0000. This is the norm for systems based on ARM cores. However, some ARM cores can be configured to begin fetching instructions from 0xFFFF0000.

There has to be a valid instruction at 0x0000 at startup, so you must have non-volatile memory located at 0x0000 at the moment of reset.

One way to achieve this is to have ROM located at 0x0000. However, there are some drawbacks to this configuration. Access speeds to ROM are generally slower than to RAM, and your system might suffer if there is too great a performance penalty when branching to exception handlers. Also, locating the vector table in ROM does not enable you to modify it at runtime.

Another solution is shown in Figure 2.13. ROM is located at address 0x10000, but this memory is aliased to zero by the memory controller at reset. Following reset, code in the reset handler branches to the real address of ROM. The memory controller then removes the aliased ROM, so that RAM is shown at address 0x0000. In __main, the vector table is copied into RAM at 0x0000, so that exceptions can be serviced.

Figure 2.13. ROM/RAM remapping

Example 2.8 shows how you might implement ROM/RAM remapping in an ARM assembler module. The constants shown here are specific to the Integrator platform, but the same method is applicable to any platform that implements ROM/RAM remapping in a similar way.

Example 2.8. ROM/RAM remapping

; --- Integrator CM control reg
CM_ctl_reg     EQU  0x1000000C     ; Address of CM Control Register
Remap_bit      EQU  0x04           ; Bit 2 is remap bit of CM_ctl


; Code execution starts here on reset
; On reset, an alias of ROM is at 0x0, so jump to 'real' ROM.
        LDR     pc, =Instruct_2

; Remap by setting Remap bit of the CM_ctl register
        LDR     r1, =CM_ctl_reg
        LDR     r0, [r1]
        ORR     r0, r0, #Remap_bit
        STR     r0, [r1]

; RAM is now at 0x0.
; The exception vectors must be copied from ROM to RAM (in __main)

; Reset_Handler follows on from here

The first instruction is a jump from aliased ROM to real ROM. This can be done because the label Instruct_2 is located at the real ROM address.

After this step, the alias of ROM is removed by inverting the remap bit of the Integrator Core Module control register.

This code is normally executed immediately after system reset. Remapping must be completed before C library initialization code can be executed.


In systems with MMUs, remapping can be implemented through MMU configuration at system startup.

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G