avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] Strange struct problem


From: Ian Caddy
Subject: Re: [avr-chat] Strange struct problem
Date: Fri, 09 Dec 2005 13:37:25 +0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050923 Thunderbird/1.0.7 Mnenhy/0.7.2.0

Hi Daniel,

Your problem is that you need to also include your initialised data section in your hex file. The initialised data will be copied to your data section by the startup code, but only if you include it in your hex file which you are not.

> avr-objcopy -j .text -O ihex testcase.elf testcase.hex

You are only including the .text section.

Because of this, the initilised data section is empty (0xFF) and these values are copied to the data section on startup.

> avr-objcopy -O ihex testcase.elf testcase.hex

should work for you as it will copy the sections that it thinks it should rather than you telling it to just use the .text section with the -j field.

I hope this helps,

Ian Caddy


Daniel O'Connor wrote:
On Fri, 9 Dec 2005 14:49, Larry Barello wrote:

Which version of the compiler are you using?  I find it hard to believe
that something this fundamental (a static array of five chars) would go
unnoticed until now.


Yeah, me too :)
The .lst file shows buffer and abc are in the data section..

The data section ends up in SRAM, right?


I took your test case, stripped it down and it appears that GCC does the
right thing: Because the data is initialized it sticks the struct onto the
stack then initializes the values.

The version of GCC I am using is 3.4.3 (WinAvr)


[inchoate 15:11] ~ >avr-gcc -v
Reading specs from /usr/local/lib/gcc/avr/3.4.4/specs
Configured with: ./configure --target=avr --disable-nls --prefix=/usr/local 
i386-portbld-freebsd7.0
Thread model: single
gcc version 3.4.4


Are you using some hacked version of the C runtime, or startup that isn't
initializing the SRAM data?  Or is it possible you application is > 64k and
the initialized data segment is beyond the reach of the LPM command (IIRC
gcc can't access data > 64k, although the code can go that high)


If you take my testcase.c file and do..
avr-gcc -O2 -fno-strict-aliasing -pipe  -g -Wall -Wunreachable-code 
-DF_CPU=16000000 -mmcu=atmega32 -Wa,-adhlmsn=testcase.lst -c testcase.c -o 
testcase.o
avr-gcc -O2 -fno-strict-aliasing -pipe -g -Wall -Wunreachable-code -DF_CPU=16000000 -mmcu=atmega32 -Wl,-Map=testcase.map,--cref -g testcase.o -o testcase.elf avr-objcopy -j .text -O ihex testcase.elf testcase.hex
avr-objdump -S testcase.elf > testcase.dmp

You will get the code I am shoving into my micro, which I do with..

avrdude -U flash:w:testcase.hex -p m32 -c alf -E vcc,noreset -q




------------------------------------------------------------------------

_______________________________________________
AVR-chat mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-chat

--
Ian Caddy
Goanna Technologies Pty Ltd
+61 8 9221 1860





reply via email to

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