I dunno. I built your code (-Os) and loaded the resulting dwarf-2 .elf file into the simulator and it works just fine. The struct is initialize properly and the correct values are passed into the uart_puts_hex() routine.
Maybe your problem is elsewhere? avr-gcc -g -Wall -Os -std=gnu99 -Wa,-adhlns=testcase.lst -Wstrict-prototypes -mmcu=atmega32 -gdwarf-2 -c -o testcase.o testcase.c avr-gcc -Wl -mmcu=atmega32 -dwarf-2 testcase.o -o testcase.elf Dwarf-2 and Astudio 4.12 is pretty good as a debug environment. ----------- Larry Barello www.barello.net | -----Original Message----- | From: Daniel O'Connor [mailto:[EMAIL PROTECTED] | Sent: Thursday, December 08, 2005 8:45 PM | To: Larry Barello | Cc: [email protected] | Subject: Re: [avr-chat] Strange struct problem | | 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 | | | -- | Daniel O'Connor software and network engineer | for Genesis Software - http://www.gsoft.com.au | "The nice thing about standards is that there | are so many of them to choose from." | -- Andrew Tanenbaum | GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C _______________________________________________ AVR-chat mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-chat
