You need to log in to create posts and topics.

Cooperation with an external editor and debugger (e.g. Platformio)

PreviousPage 2 of 3Next

Sorry, I think that I confused your blink with another one...
Let me have a look.

Ok, please, try to download the zip here again. Below you can see my compilation output: it is a simple blink program for arduino nano compiled with avr-toolchain 7.3.0. But I admit that the firmware.lst file in the hidden directory: .pio/build/nanoatmega328 probably won't fit your requirements. If you have some information how to setup avr-toolchain to produce the right .lst file, please tell me. I can try to set it the same way.

 

Processing nanoatmega328 (platform: atmelavr; board: nanoatmega328; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328.html
PLATFORM: Atmel AVR (5.0.0) > Arduino Nano ATmega328
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.2.0 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Current CLI targets []
Current Build targets [<SCons.Node.Alias.Alias object at 0x7fef44bab4d0>, <SCons.Node.Alias.Alias object at 0x7fef44bab650>]
Checking size .pio/build/nanoatmega328/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   3.0% (used 924 bytes from 30720 bytes)
============================================================ [SUCCESS] Took 0.46 seconds ============================================================
 *  Terminal will be reused by tasks, press any key to close it. 

 

Thanks, but the the problem was in my side.
I had another blink.zip in my download folder and I used the wrong one.

I'm pretty sure that it will be possible to debug it in Simulide.
Indeed in this case we can probably use the elf file if we can trick the debugger to think that it is using avr-gcc.
I'm trying to find an easy way to do it.

Perfect, thank you!

The elf file does not seem to contain information about main.cpp and other Arduino files, only about: gcc/libgcc/config/avr/lib1funcs.S

Maybe it should be compiled for debug, I think with -g -Og.

.lst file does not contain information about the sources, so not usable.

Well, I tried again. The result is here. Now, also the lst file looks better.

Thanks, that elf contains all the info we need.

I can't debug because paths are absolute, so they match your filesystem, not mine.
There are some other issues to solve about filenames: that toolchaing is using a different name for firmware than the source file.
But maybe you can do a test to see if it is possible at all, later we can try to make it easier:

1- Add a "fake" compiler with name avrgcc-2.xml at simulide/data/codeeditor/compilers/compilers/
with this content:

<compiler name="Avrgcc-2" type="avrgcc" buildPath="" >
    <step 
        command="avr-gcc"
        arguments=" -v"
    />
</compiler>

 

2- Copy Test_blink/.pio/build/nanoatmega328/firmware.hex and firmware.elf
To Test_blink/src/main.hex and main.elf

3- Open main.cpp in the Editor and choose compiler: Avrgcc-2
If avr-gcc is not in $PATH, configure Compiler_Settings->Tool_Path
Simulide will search for avr binaries at toolPath and toolPath+avr/bin/
avr-objdump, avr-readelf, avr-size, avr-addr2line.

4- Open the circuit.

5- Click on debug.
At the Editor console you should see something like this:

Searching for variables... 3 variables found

Searching for Functions... 10 functions found

Mapping Flash to Source... 455 lines mapped

Debugger Started

Source line numbers in loop() should be dark gray.

I tried you procedure and it looks that it works! I can debug my source file main.cpp. Is it possible to step into functions during debugging?

Great! the tricky part will be to make it work without renaming and moving hex and elf files.

I'm thinking that an easy option would be to use firmware.cpp instead of main.cpp
And add a build path in avrgcc-2.xml:

<compiler name="Avrgcc-2" type="avrgcc" buildPath="../.pio/build/nanoatmega328" >
    <step 
        command="avr-gcc"
        arguments=" -v"
    />
</compiler>

Not sure if relative path will work here, but you can try if you wish.

 

Is it possible to step into functions during debugging?

In Simulide 1.1.0 is not possible to step into other files than the main source file.
Development version can do it (still very experimental).

Also development version doesn't need a "dummy" command like avr-gcc -v to work.
But the one available at Tester builds is not very usable at this point.

I assume that you are using 1.1.0, isn't it?

Yes, I use Simulide 1.1.0 R1912 (installed from Debian repositories). By the way, moving and renaming hex/elf file can be probably done using the python script, which is in the top directory ("extra_script.py"). The script can be configured to run post-compiled actions. In my case it creates the .lst file, I hope that the renaming can be done similarly.

PreviousPage 2 of 3Next