simulavr icon indicating copy to clipboard operation
simulavr copied to clipboard

do not work with cpp

Open pat1 opened this issue 12 years ago • 2 comments

in example/simple_serial rename .c in .c++ modify Maefile.am to compile with avr-g++

with avr-g++ I have to add -fpermissive options

Make do

avr-g++ -fpermissive -g -O2 -mmcu=atmega644 -DF_CPU=20000000 -Wl,--section-start=.siminfo=0x900000 -c -o serial.o serial. serial.c serial.h serial.o
[root@asus-pat1 simple_serial]# avr-g++ -fpermissive -g -O2 -mmcu=atmega644 -DF_CPU=20000000 -Wl,--section-start=.siminfo=0x900000 -c -o serial.o serial. serial.c serial.h serial.o
[root@asus-pat1 simple_serial]# avr-g++ -fpermissive -g -O2 -mmcu=atmega644 -DF_CPU=20000000 -Wl,--section-start=.siminfo=0x900000 -c -o serial.o serial.c [root@asus-pat1 simple_serial]# avr-gcc -g -O2 -mmcu=atmega644 -DF_CPU=20000000 -Wl,--section-start=.siminfo=0x900000 -o simple_serial.elf main.o serial.o [root@asus-pat1 simple_serial]# avr-objcopy -j .text -j .data -O ihex -R .eeprom -R .fuse -R .lock simple_serial.elf simple_serial.hex

simulavr --file simple_serial.elf

FATAL: file avrfactory.cpp: line 57: Device type not specified, use -d | --device TYPE or insert a SIMINFO_DEVICE(name) macro into your source to specify the device name

readelf -p .siminfo simple_serial.elf readelf: Warning: Section '.siminfo' was not dumped because it does not exist!

in a different project I get: readelf -p .siminfo .build/uno/firmware.elf

Dump delle stringhe della sezione ".siminfo": [ 5] $ [ a] D0 [ e] % [ 13] D1 [ 17] %

[pat1@asus-pat1 jsonrpc-mqtt]$ simulavr --file .build/uno/firmware.elf WARNING: file avrreadelf.cpp: line 396: signature for device '' not found

FATAL: file avrfactory.cpp: line 60: Invalid device specification:

pat1 avatar Dec 19 '13 16:12 pat1

While C++ is no longer a superset of C, so simply renaming a file can break things, I think this is a linking problem.

Off the top of my head, this flag to the command line might help:

-Wl,--no-gc-sections

Trying without -O2 could give a hint, too. What about "extern C { ... }" ? It's also possible to put these macros into a separate file. I had quite a journey until I could convince the linker to keep the siminfo section in all the cases I tried. Mostly a matter of experimenting and reading linker man pages.

Traumflug avatar Dec 20 '13 00:12 Traumflug

This one might help: https://github.com/Traumflug/Teacup_Firmware/issues/103

Traumflug avatar Oct 28 '14 20:10 Traumflug