New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simavr fails to run on ELF, but not on HEX #462
Comments
I think that the immediate problem is that a different modification to the build is needed. Try removing the previous changes and adding this line from Makefile.common: -Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000 The first part stops ld from discarding .mmcu and the second places it at an address meaningless to simavr. Without that, .mmcu is placed between .text and .data, using Flash space. Worse, simavr discards it during loading and then loads .data at the wrong address. Then the startup code copies uninitialised Flash into RAM and things go rapidly downhill. That might fix the problem, but there is a bigger underlying issue: simavr loads only the .text, .data, .eeprom, .fuse and .lock sections and assumes the first two are contiguous. I think code will fail if any statically allocated C++ objects are defined, introducing .ctor and .dtor sections. I believe the way to fix this would be to use the Program Header Table for loading, as the ELF specification suggests. It seems the Section Table is intended for linkers. Add a helpful warning if .mmcu is included in Flash. |
Note you appear to be using standard GDB. It is not directly compatible with AVR-GDB and cannot interpret ELFs correctly for AVR-style executables. I get all kinds of odd issues if I attempt to use it with SimAVR and atmel ELFs. I haven't had issues loading ELFs from arduino directly with MK404 (just grabbed 'em from the tmp build dir) so I'm inclined to agree this is related to how the ELF is assembled in your case 👍 |
I'm using my host GDB to watch the execution of
Thanks, I'll try these options. |
D'oh... sorry. I'll crawl back under my rock now 😁 |
This absolutely fixes the problem, and I don't even need to leave out the [env:uno]
platform = atmelavr
board = uno
framework = arduino
build_flags = -Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000 produces a
and it even runs nicely, although the Arduino code uses
so it works just out. Closing as solved, thanks @gatk555! |
After making adjustments to the build process as per #378 (comment), I now have a
.elf
file with the needed ELF section.mmcu
, however simavr crashes on it.Running it unde GDB reveals
That it ends in
avr_sadly_crashed
.simavr
has no problem running the hex file created from that ELF file...Firmware files are attached.
firmwares.zip
The text was updated successfully, but these errors were encountered: