.ELF file created by PlatformIO does not contain degub symbol

I’ve made a discovery. If you use PlatformIO, rename the src/main.cpp file to src/main.ino. The file will then show in Proteus.

[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
build_type = debug

It seems to me that Proteus does some extra logic or different handling when creating an Arduino project and it looks for .ino files from the Arduino IDE.

Because it actually shouldn’t be looking for user_main.ino. This file is not compiled. The .ino is converted to a .ino.cpp file which then gets compiled. But Proteus probably wants to show the user-friendly version.

Please contact the Proteus support regarding this isse – as I said, I don’t see an issue with the ELF file, seems they’re looing for the .ino file.

I am very glad that there is one person who is ready to understand the problem. Together, the path is more reliable, as it allows you to combine knowledge and skills.
This is not a feature of Proteus. Proteus just works with the elf file. I previously tried elf from AVR studio. Everything works there, although there are no *.ino files.
I believe this is a feature of the Arduino build system in PlatformIO.
For example, in Eclipse, the problem is also missing. Eclipse uses a make-like system. There, the build system first builds itself sloeber.ino.cpp

It is possible that the build system does not correctly identify the main file.

Proteus has some problem with path handling. The symptom: it receives the .elf file, simulation is working, but the source view window is empty. The reason that the .elf file doesn’t include the source code, it just points to the source files with relative paths. In some cases Proteus fails with the path. There is a workaround:
When you double click on the uC in Proteus, and browse for the .elf file, the path in the box looks something like this:

..\..\..\..\0work\bubuws\bubu\Debug\bubu.elf

Proteus somehow fails with these

..\..\..\

Replace it with the absolute path, for example c:\0work\bubuws\bubu\Debug\bubu.elf
I didn’t tried with PIO, but it is working with the .elf from STM32CubeIde.
With the .elf from Keil one more step required: copy the .elf one folder up. For example copy it from c:\0work\bubuws\bubu\Debug\bubu.elf to c:\0work\bubuws\bubu\bubu.elf and pick it from here with Proteus.
One more thing: the .elf has to include dwarf2 debug information. In case of the GCC toolset use
-gdwarf-2,
in Keil use
–gdwarf2.

1 Like

For main.ino:

Processing nanoatmega328 (platform: atmelavr; board: nanoatmega328new; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328new.html
PLATFORM: Atmel AVR (3.2.0) > Arduino Nano ATmega328 (New Bootloader)
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
Converting main.ino
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 8 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ArduinoRS485> 1.0.0
|-- <ArduinoModbus> 1.0.3
|   |-- <ArduinoRS485> 1.0.0
|-- <TimerOne> 1.1.0
|-- <SPI> 1.0
Building in debug mode

For main.cpp

Processing nanoatmega328 (platform: atmelavr; board: nanoatmega328new; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328new.html
PLATFORM: Atmel AVR (3.2.0) > Arduino Nano ATmega328 (New Bootloader)
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 7 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ArduinoModbus> 1.0.3
|   |-- <ArduinoRS485> 1.0.0
|-- <SPI> 1.0
Building in debug mode

Difference in line “Converting main.ino”. Perhaps this process does additional work that makes the files visible.

The Arduino IDE does the same – the ino file is preprocessed to include function prototypes to make it a valid C++ file, then that file is compiled and linked into the firmware.

Generating function prototypes...
"C:\\Users\\Max\\Desktop\\Programming Stuff\\arduino-1.8.13\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\Max\\Desktop\\Programming Stuff\\arduino-1.8.13\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Users\\Max\\Desktop\\Programming Stuff\\arduino-1.8.13\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "C:\\Users\\Max\\AppData\\Local\\Temp\\arduino_build_340961\\sketch\\blinky_nano.ino.cpp" -o "C:\\Users\\Max\\AppData\\Local\\Temp\\arduino_build_340961\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Users\\Max\\Desktop\\Programming Stuff\\arduino-1.8.13\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\Max\\AppData\\Local\\Temp\\arduino_build_340961\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Sketch wird kompiliert...
"C:\\Users\\Max\\Desktop\\Programming Stuff\\arduino-1.8.13\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\Max\\Desktop\\Programming Stuff\\arduino-1.8.13\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Users\\Max\\Desktop\\Programming Stuff\\arduino-1.8.13\\hardware\\arduino\\avr\\variants\\eightanaloginputs" "C:\\Users\\Max\\AppData\\Local\\Temp\\arduino_build_340961\\sketch\\blinky_nano.ino.cpp" -o "C:\\Users\\Max\\AppData\\Local\\Temp\\arduino_build_340961\\sketch\\blinky_nano.ino.cpp.o"

Absolute paths are used. The-gdwarf-2 key is used.

I never use this website. I just made an account to tell you THANKS