avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] string initialization


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] string initialization
Date: Wed, 9 Jul 2003 22:08:56 +0200 (MET DST)

In article <address@hidden> you write:

>char test[] = "Hello!";
>
>If this string is initialized as global, the linker
>put it in the flash and the string has undefined values.

Here you err.  test[] itself will be put into the .data
section which is in RAM.  You can easily change its value
later on.

>I have used the watch-window.

Well, you should write on top that your problems are related
to AVR Studio. ;-)  It's something very different from running
it on a real chip...

>If I put this line in the main() the linker put it in
>the SRAM.

In that case, it's not the linker but the compiler who puts
the variable into the function's local stack frame (which is
obviously in SRAM, of course).

>Is the initialization a bug of avr-gcc?

No, it's an interaction bug between the way avr-gcc initializes
its .data and how AVR Studio by default evaluates the COFF file.

See the README for the new COFF translator, close to the end.
Atmel's current AVR Studio sources already have a fix for this,
but there's still no official version containing that fix.

>How can I avoid an allocation of the string to the flash memory?

Just the opposite: if you want it in ROM, you need to explicitly
declare it and handle that manually.  See the documentation for
<avr/pgmspace.h>.
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]