Traumflug / simulavr

A fork of SimulAVR (http://www.nongnu.org/simulavr/) for handling contributions. The practical SIMINFO mechanism implemented here wasn't accepted upstream, but is crucial for Teacup Firmware simulations, so this fork will stay ... and follow upstream. Default branch is 'traumflug', master here matches master on nongnu.org.
GNU General Public License v2.0
40 stars 26 forks source link

do not work with cpp #1

Open pat1 opened 10 years ago

pat1 commented 10 years ago

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: 

Traumflug commented 10 years ago

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 commented 9 years ago

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