Forum: ARM programming with GCC/GNU tools static initialization does not work with arm-none-eabi

von Pawel (Guest)

Rate this post
0 useful
not useful
Hello, I moved from arm-elf- to arm-none-eabi- and noticed that a static 
variable inside a function would not initialize. A piece of code like:

static uint8_t Config[3] = { 0x87, 0x44, 0x00 } ;

would yield Config[] being { 0x00, 0x00, 0x00 }

That worked with arm-elf ... am I doing something wrong ?

Thank you for help or hints.


von (prx) A. K. (prx)

Rate this post
0 useful
not useful
And data not explicitly initialized is not set to 0, I assume.

Those initializations are part of the startup code linked into the 
executable. arm-none-eabi usually implies that there is no operating 
system provided program loader (which normally does this job) and that 
initialized static data is part of the program data segment, to be 
copied from ROM to RAM by some startup code which is provided either by 
the development environment or has to be provided by you.

The initialization code depends on definitions within the linker script, 
so replacing only of them usually fails.

von Pawel (Guest)

Rate this post
0 useful
not useful
The data appears to be initialized with zeros.

Do you mean the arm-none-eabi- compiler does not generate such startup 
code while the arm-elf compiler would generate it ?
Shall I write such code myself ?

von Martin T. (mthomas) (Moderator)

Rate this post
0 useful
not useful
I don't think the problem is related to EABI or "old ABI". Are both 
toolchains based on the same version of the gcc sources? Let the linker 
create a map-file and checked the assigend addresses for the array and 
the start and end of the .data output-section? If there are still 
problems please create a minimal but full example with source-code incl. 
startup-code, linker-script, compiler- & linker-options (pref. in a 


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]
  • [avrasm]AVR assembler code[/avrasm]
  • [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.