Hi there,
I’m currently starting to work with an STM32F303CCT6 microcontroller on an older SP Racing F3 flight controller board. To save some time, I use CubeMX for general configuration and the STM32 HAL Library.
Here is my platform.ini
:
[env:genericSTM32F303CB]
platform = ststm32
board = genericSTM32F303CB
build_flags =
-I include/Drivers/CMSIS
-I include/Drivers/CMSIS/Device/ST/STM32F3xx/include
-I include/Drivers/STM32F3xx_HAL_Driver
-I include/Drivers/STM32F3xx_HAL_Driver/Legacy
upload_protocol = custom
upload_command = ${platformio.packages_dir}/tool-stlink/st-flash write $SOURCE 0x8000000
debug_tool = stlink
My test program to turn on the onboard LED didn’t work, so I hooked up an ST-Link V2 (one of the small USB Dongles). When I now try to start debugging with the IDE, it just ends without any feedback. So I tried the command line debugger using piodebuggdb -x .pioinit
This gives me the following result:
Reading symbols from e:\TUBcloud\Office\Projekte\2022\TestProgramSpracingF3\.pio\build\genericSTM32F303CB\firmware.elf...done.
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = stlink
PlatformIO: Initializing remote target...
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:19)
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
Info : DEPRECATED target event trace-config; use TPIU events {pre,post}-{enable,disable}
Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 1000 kHz
Info : STLINK V2J39S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.237062
Info : stm32f3x.cpu: Cortex-M4 r0p1 processor detected
Info : stm32f3x.cpu: target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f3x.cpu on pipe
Info : accepting 'gdb' connection from pipe
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x00000003 pc: 0x2100b508 msp: 0xbf00b5d8
Info : device id = 0x10036422
Info : flash size = 256kbytes
0x2100b508 in ?? ()
Loading section .init, size 0xc lma 0x8000
Loading section .text, size 0x11b8 lma 0x800c
.pioinit:15: Error in sourced command file:
Load failed
I couldn’t figure out what the .pioinit
does, so I dont know what failed to load.
I also tried to the st-link debugging server st-util
from here: GitHub - stlink-org/stlink: Open source STM32 MCU programming toolset
On VScode, this gives me the following output:
Preparing firmware for debugging...
Processing genericSTM32F303CB (platform: ststm32; board: genericSTM32F303CB)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F303CB.html
PLATFORM: ST STM32 (15.4.1) > STM32F303CB (32k RAM. 128k Flash)
HARDWARE: STM32F303CBT6 72MHz, 32KB RAM, 128KB Flash
DEBUG: Current (custom) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
- toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_cortex.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_dma.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_exti.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_flash.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_flash_ex.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_gpio.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_i2c.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_i2c_ex.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_pwr.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_pwr_ex.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_rcc.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_rcc_ex.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_spi.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_spi_ex.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_tim.o
Compiling .pio\build\genericSTM32F303CB\src\Drivers\STM32F3xx_HAL_Driver\stm32f3xx_hal_tim_ex.o
Compiling .pio\build\genericSTM32F303CB\src\Startup\startup_stm32f303cctx.o
Compiling .pio\build\genericSTM32F303CB\src\main.o
Compiling .pio\build\genericSTM32F303CB\src\stm32f3xx_hal_msp.o
Compiling .pio\build\genericSTM32F303CB\src\stm32f3xx_it.o
Compiling .pio\build\genericSTM32F303CB\src\syscalls.o
Compiling .pio\build\genericSTM32F303CB\src\sysmem.o
Compiling .pio\build\genericSTM32F303CB\src\system_stm32f3xx.o
Linking .pio\build\genericSTM32F303CB\firmware.elf
Checking size .pio\build\genericSTM32F303CB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 3.8% (used 1252 bytes from 32768 bytes)
Flash: [ ] 4.3% (used 5680 bytes from 131072 bytes)
Building .pio\build\genericSTM32F303CB\firmware.bin
========================================================================== [SUCCESS] Took 1.31 seconds ==========================================================================Reading symbols from e:\TUBcloud\Office\Projekte\2022\TestProgramSpracingF3\.pio\build\genericSTM32F303CB\firmware.elf...done.
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = custom
PlatformIO: Initializing remote target...
0x2100b508 in ?? ()
.pioinit:14: Error in sourced command file:
Target does not support this command.
Meanwhile, the debugging server says the following:
2022-10-18T09:23:05 WARN common.c: NRST is not connected
2022-10-18T09:23:05 INFO common.c: F3xx: 40 KiB SRAM, 256 KiB flash in at least 2 KiB pages.
2022-10-18T09:23:05 INFO gdb-server.c: Listening at *:4242...
2022-10-18T09:23:15 WARN common.c: NRST is not connected
2022-10-18T09:23:15 INFO common.c: F3xx: 40 KiB SRAM, 256 KiB flash in at least 2 KiB pages.
2022-10-18T09:23:15 INFO gdb-server.c: Found 6 hw breakpoint registers
2022-10-18T09:23:15 INFO gdb-server.c: GDB connected.
2022-10-18T09:23:15 ERROR gdb-server.c: cannot recv: -2
2022-10-18T09:23:15 INFO common.c: Go to Thumb mode
2022-10-18T09:23:15 INFO gdb-server.c: Listening at *:4242...
This is weird, because the NRST port on the board is connected to the RST port on the STlink.
I also used STM32CubeProgrammer to inspect the microcontroller and this seems to work fine. So does someone know what the problem could be?
Thanks in advance!