Debug on STM8 not starting without errors

Hello everyone,

I’m trying to configure VSCode and PlatformIO to code on a STM8s003f3 micro-controller. I managed to make it build and upload the code (even though I had to manually indicate in platformio.ini where to find STM8S_StdPeriph_Driver for it to compile).

But now I have problems debugging.
When I go to the debug section and run PIO Debug, I don’t have any error but the debug does not occur. The little window with the start/stop/restart/… buttons is even appearing to disappear just afterwards.

In parallel, I managed to make it work with cosmic compiler and STVD IDE but I would really love to be able to make it work with VSCode and PlatformIO.

Thanks.

If that’s the case there must be error messages in the “DEBUG CONSOLE” Tab in VSCode. What does it say there?

Woah woah woah.

You are setting core_dir to… inside the ststm8spl package? That’s very weird and does not do what you want. It will move / reinstall the Arduino core in that folder Please remove that line.

I use this line otherwise it does not compile the stm8s and stm8s_gpio files I need in the main.

When it comes to the debug console that’s awesome it was there all along I never thought of checking it out … Here is what it says.

Ah yes, the DWARF error. As per Debugging not working with SPL examples · Issue #44 · platformio/platform-ststm8 · GitHub, debugging with SPL does not work correctly yet because of an SDCC bug on Windows. Per that issue it works on Linux.

I still have to check the newer SDCC version as to whether they finally fixed it or not.

This sounds extremely weird. Can you post the exact project code with which that occurs (through e.g. github)

Yes it sounded weird to me too and it took me a lot of time and frustration to go through it ^^
Here is the git repo of the code :
GitHub - frmarc/Blink_PIO_STM8

When it comes to the Dwarf error thanks for the information.
I guess I’ll wait for it to be fixed then and use STVD in the mean time.

I just downloaded your repo, took out the core_dir line and compiled. Works just fine.

>pio run
Processing debug (platform: ststm8; board: stm8s003f3; framework: spl)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm8/stm8s003f3.html
PLATFORM: ST STM8 (2.0.0) > ST STM8S003F3 chip
HARDWARE: STM8S003F3P6 16MHz, 1KB RAM, 8KB Flash
DEBUG: Current (stlink) External (stlink)
PACKAGES:
 - framework-ststm8spl 0.20301.181217 (2.3.1)
 - tool-stm8binutils 0.230.0 (2.30)
 - toolchain-sdcc 1.40100.12072 (4.1.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Compiling .pio\build\debug\SPL\stm8s_gpio.rel
Compiling .pio\build\debug\src\main.rel
Compiling .pio\build\debug\src\stm8s_it.rel
src\main.c:102: warning 85: in function assert_failed unreferenced function argument : 'file'
src\main.c:102: warning 85: in function assert_failed unreferenced function argument : 'line'
Linking .pio\build\debug\firmware.elf
Checking size .pio\build\debug\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.0% (used 0 bytes from 1024 bytes)
Flash: [=         ]   7.6% (used 620 bytes from 8192 bytes)
Building .pio\build\debug\firmware.hex
=============== [SUCCESS] Took 1.97 seconds ===============

What does the full build output look for you when you hit “build” and don’t set core_dir?

Btw, I just tested whether the SDCC people have fixed the bug after they said the issue was likely fixed, but they let me down. Not fixed.

https://sourceforge.net/p/sdcc/bugs/3200/#9c9d/a2ce

When I don’t set core_dir, the terminal output this, and nothing is outputted in the “Output” window

   > Executing task: C:\Users\marc\.platformio\penv\Scripts\platformio.exe run <
    legacy Click
    Processing debug (platform: ststm8; board: stm8s003f3; framework: spl)
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boards/ststm8/stm8s003f3.html
    PLATFORM: ST STM8 (2.0.0) > ST STM8S003F3 chip  
    HARDWARE: STM8S003F3P6 16MHz, 1KB RAM, 8KB Flash
    DEBUG: Current (stlink) External (stlink)       
    PACKAGES:
     - framework-ststm8spl 0.20301.181217 (2.3.1)   
     - tool-stm8binutils 0.230.0 (2.30)
     - toolchain-sdcc 1.40100.12072 (4.1.0)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies...
    No dependencies
    Building in debug mode
    Linking .pio\build\debug\firmware.elf

    ?ASlink-Warning-Undefined Global '_GPIO_Init' referenced by module 'main'        

    ?ASlink-Warning-Undefined Global '_GPIO_WriteReverse' referenced by module 'main'
    *** [.pio\build\debug\firmware.elf] Error 1
    =================================================================================== [FAILED] Took 1.36 seconds ===================================================================================
The terminal process "C:\Users\marc\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.

    Terminal will be reused by tasks, press any key to close it.

Also I don’t know if it is linked but when I start VSCode in output it says
[14/10/2021, 12:06:44] Unable to resolve configuration with compilerPath "C:/Users/marc/.platformio/packages/toolchain-sdcc/bin/sdcc.exe". Using "cl.exe" instead.
The thing is that the file is there so I don’t really know what happens here …

Can you

  • Remove / comment out the core_dir line
  • Remove the entire C:\Users\<user>\.platformio\packages\framework-ststm8spl folder
  • Use the project task “General → Clean”
  • And then Advanced → Verbose Build

and post that output?

It worked !

I guess I might have done something wrong with the stm8 framework ?

Thanks a lot !


legacy Click
Processing debug (build_type: debug; debug_tool: stlink; platform: ststm8; board: stm8s003f3; framework: spl; upload_protocol: stlinkv2)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/ststm8/stm8s003f3.html
PLATFORM: ST STM8 (2.0.0) > ST STM8S003F3 chip  
HARDWARE: STM8S003F3P6 16MHz, 1KB RAM, 8KB Flash
DEBUG: Current (stlink) External (stlink)       
PACKAGES:
 - framework-ststm8spl 0.20301.181217 (2.3.1)   
 - tool-stm8binutils 0.230.0 (2.30)
 - toolchain-sdcc 1.40100.12072 (4.1.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
MethodWrapper(["checkprogsize"], [".pio\build\debug\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.0% (used 0 bytes from 1024 bytes)
Flash: [=         ]   7.6% (used 620 bytes from 8192 bytes)
.pio\build\debug\firmware.elf  :

section           size    addr

HOME               111   32768

GSINIT              26   32879

GSFINAL              3   32905

CONST              105   32908

CODE               480   33013

.debug_line       1660       0

.debug_loc        1608       0

.debug_abbrev      268       0

.debug_info       2090       0

.debug_pubnames    785       0

.debug_frame      1906       0

SSEG                 1   33493

Total             9043
================================================================================== [SUCCESS] Took 1.19 seconds ==================================================================================

Terminal will be reused by tasks, press any key to close it.

Probably a partly corrupted package download for SPL, not sure. But this is how it’s supposed to work normally – no setting core_dir inside a package.

As for the SDCC bug, I’ve notified the developers again and hopefully this can get resolved for Windows. You might want to try a Linux VM and pass through the STLink adapter to get it work in the meantime.

1 Like