Debugging LSM100A (NUCLEO WL55JC like) with STLINK V2

Hi,

I’m trying to set up a full environment to program a LSM100A (ST NUCLEO WL55JC like) board.
I succeeded to add the STM32cube WL framework thanks to this:

I added a main.h and a main.c that make a led blink, launched the debugger and got this error:

Function “main” not defined

Processing nucleo_wl55jc (platform: ststm32; board: nucleo_wl55jc; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_wl55jc.html
PLATFORM: ST STM32 (17.0.0) > ST Nucleo WL55JC
HARDWARE: STM32WL55JC 48MHz, 64KB RAM, 256KB Flash
DEBUG: Current (stlink) On-board (stlink) External (cmsis-dap, jlink)
PACKAGES:
 - framework-stm32cubewl @ 1.3.0
 - tool-ldscripts-ststm32 @ 0.2.0
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
Warning! Cannot find the default startup file for `stm32wl55jc`. Ignore this warning if the startup code is part of your project.
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Checking size .pio\build\nucleo_wl55jc\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.0% (used 28 bytes from 65536 bytes)
Flash: [          ]   0.0% (used 88 bytes from 262144 bytes)
========================= [SUCCESS] Took 1.20 seconds =========================
Reading symbols from c:\Users\Cyrille\Documents\PlatformIO\Projects\tot\.pio\build\nucleo_wl55jc\firmware.elf...
(no debugging symbols found)...done.
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = stlink
PlatformIO: Initializing remote target...
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate

adapter speed: 480 kHz

Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 480 kHz
Info : STLINK V2J42S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.191704
Info : [stm32wlx.cpu0] Cortex-M4 r0p1 processor detected
Info : [stm32wlx.cpu0] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32wlx.cpu0 on pipe
Info : accepting 'gdb' connection from pipe
[stm32wlx.cpu0] halted due to debug-request, current mode: Handler HardFault
xPSR: 0x00000003 pc: 0xf3af4804 msp: 0x4c05b4f0
Info : device idcode = 0x10016497 (STM32WLE/WL5x - Rev 'unknown' : 0x1001)
Info : RDP level 0 (0xAA)
Info : flash size = 256 KiB
Info : flash mode : single-bank
Info : device idcode = 0x10016497 (STM32WLE/WL5x - Rev 'unknown' : 0x1001)
Info : RDP level 0 (0xAA)
Info : OTP size is 1024 bytes, base address is 0x1fff7000
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1012 ms). Workaround: increase "set remotetimeout" in GDB
0xf3af4804 in ?? ()
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
[stm32wlx.cpu0] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xb9337822 msp: 0x4c05b510
Loading section .text, size 0x58 lma 0x8000000
Loading section .init_array, size 0x4 lma 0x8000058
Loading section .fini_array, size 0x4 lma 0x800005c
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
[stm32wlx.cpu0] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xb9337822 msp: 0x4c05b510
Start address 0x8000000, load size 96
Transfer rate: 539 bytes/sec, 32 bytes/write.
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
[stm32wlx.cpu0] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xb9337822 msp: 0x4c05b510
[stm32wlx.cpu0] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xb9337822 msp: 0x4c05b510
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> https://bit.ly/pio-debug

Any ideas?

Can you upload the whole PlatformIO project? There may be multiple things wrong with it. E.g., the .text section that’s supposed to have all the code is only 0x58 bytes, which is hard to believe when there’s supposed to be at least an interrupt vector and the STM32HAL base functions in there. Plus there is no .rodata or data section for (constant) variables or their initial values. That could be a problem in the linkerscript, but hard to say without the full project.

The stm32cube builder script fails to select any startup assembly file at all. You need to copy-paste the contents startup_stm32wl55xx_cm4.s file as src/startup_stm32wl55xx_cm4.S (mind the uppercase “.S!”) and rebuild.

1 Like