User guide

HEAP +0 UNINIT ; The heap is not zero-initialized.
; The +0 specification means that the heap
{ ; starts immediately after RW and ZI regions.
heap.o (+ZI) ; A symbol in heap.o is used set the heap base.
}
STACKS 0x40000 UNINIT ; The stack is not zero-initialized.
{ ; The top of stack address is set absolutely.
stack.o (+ZI) ; A symbol in stack.o is used to set the
} ; top of stack.
UART0 0x16000000 UNINIT ; The UART is not zero-initialized.
{ ; The address is specified absolutely.
uart.o (+ZI) ; The symbols in uart.o are used to reserve the
} ; memory-mapped I/O.
}
The program code and data is placed in Flash that resides at 0x24000000. On reset, an aliased copy of Flash is
remapped by hardware to address 0x0. Program execution starts at AREA Init in init.s. The +First option is
used to place this code first in the image. After reset the first few instructions of init.s remap 32-bit RAM to
address 0x0. The ARM Integrator Board remaps its Flash in this way.
Most of the RO code executes from Flash. The RO execution address is the same as its load address
(0x24000000), so it does not have to be moved.
32bitRAM might be fast on-chip 32-bit SSRAM. Fast RAM is typically used for the stack, and for code that must be
executed quickly. The exception vectors (AREA Vect in vectors.s) are relocated from Flash to the 32bitRAM
execution region at address 0x0 for speed. The Vect code is placed first in the region. The RW data is relocated
from Flash to the 32bitRAM execution region after the vector code. The ZI data will be created above the RW data.
6.6.3 Initialization code
Example 6-8 illustrates the code in init.s that performs ROM/RAM remapping.
Example 6-8 ROM/RAM remapping
; --- Set up if ROM/RAM remapping required
GBLL ROM_RAM_REMAP
ROM_RAM_REMAP SETL {TRUE} ; change to {FALSE} if remapping not required
...
; --- Perform ROM/RAM remapping, if required
IF :DEF: ROM_RAM_REMAP
; On reset, an aliased copy of ROM is at 0x0.
; Continue execution from 'real' ROM rather than aliased copy
LDR pc, =Instruct_2
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 (in vectors.s) must be copied from ROM to the RAM
; The copying is done later by the C library code inside __main
The initialization code in the C library copies the RO and RW execution regions from their load addresses to their
execution addresses before creating any zero-initialized areas. See also Loading the ROM image at address 0.
6.6.4 Building the example
To build the example, either:
open the supplied embed.mcp project with the CodeWarrior IDE and select the EmbeddedScatterRemap
build target.
use the build_c.bat batch file or a makefile containing the following (the indented lines are a continuation of
the single line above):
Writing Code for ROM
Copyright ?1999 2001 ARM Limited 6-16