14.01.2015 Views

RealView Compilation Tools Developer Guide - ARM Information ...

RealView Compilation Tools Developer Guide - ARM Information ...

RealView Compilation Tools Developer Guide - ARM Information ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Embedded Software Development<br />

2.5 Reset and initialization<br />

This chapter has so far assumed that execution begins at __main, the entry point to the C<br />

library initialization routine. In fact, any embedded application on your target hardware<br />

performs some system-level initialization at startup. This section describes this in more<br />

detail.<br />

2.5.1 Initialization sequence<br />

Figure 2-11 shows a possible initialization sequence for an embedded system based on<br />

an <strong>ARM</strong> architecture.<br />

__main<br />

.<br />

C Library<br />

__scatterload<br />

copy/decompress RW data<br />

copy non-root code<br />

zero uninitialized data<br />

.<br />

.<br />

__rt_entry<br />

3<br />

4<br />

initialize library<br />

functions<br />

call top-level<br />

constructors (C++)<br />

Exit from application<br />

2<br />

5<br />

6<br />

8<br />

.<br />

USER CODE<br />

reset handler<br />

initialize stack pointers<br />

configure MMU/MPU<br />

. setup cache/enable<br />

TCM<br />

.<br />

__user_initial_stackheap()<br />

set up application stack<br />

and heap<br />

.<br />

$Sub$$main()<br />

enable caches and<br />

interrupts<br />

.<br />

main()<br />

causes the linker to link<br />

in library initialization<br />

code<br />

1<br />

Image<br />

entry point<br />

7<br />

Figure 2-11 Initialization sequence<br />

The reset handler executes immediately on system startup. The block of code labeled<br />

$Sub$$main() executes immediately before entering the main application.<br />

The reset handler is a short module coded in assembler that is executed on system reset.<br />

As a minimum, your reset handler initializes stack pointers for the modes that your<br />

application is running in. For cores with local memory systems, such as caches, Tightly<br />

Coupled Memories (TCMs), Memory Management Units (MMUs), and Memory<br />

2-26 Copyright © 2002-2007 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DUI 0203H<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!