Hi I have been using Arduino IDE to program bluepill (STM32F103) using Roger Clarke’s repo GitHub - rogerclarkmelbourne/Arduino_STM32: Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards and it compiles, program fine with a ST-Link V2 dongle.
However when I switch to PlatformIO I cannot get the program to work, it saids upload is fine but the program appears not working in the MCU. (It is just a blinking sketch). Here is the output that saids it successfully programmed with openocd
Checking size .pio\build\genericSTM32F103CB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 5.3% (used 1076 bytes from 20480 bytes)
Flash: [= ] 5.4% (used 7032 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\genericSTM32F103CB\firmware.elf
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
debug_level: 1
hla_swd
[stm32f1x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080001a4 msp: 0x20005000
** Programming Started **
Warn : Adding extra erase range, 0x08001c9c .. 0x08001fff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked
I tried both configurations, the first one is - from what I heard - is official ST STM32duino library.
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
upload_protocol = stlink
board_build.core = maple
The second one is Roger Clarke’s implementation.
[env:genericSTM32F103CB]
platform = ststm32
board = genericSTM32F103CB
framework = arduino
;build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC -Os
debug_tool = stlink
upload_protocol = stlink
;upload_flags = -c set CPUTAPID 0x2ba01477
Both does not work. Going back to Arduino IDE it programs fine. For example in Arduino IDE:
Sketch uses 12916 bytes (19%) of program storage space. Maximum is 65536 bytes.
Global variables use 2064 bytes (10%) of dynamic memory, leaving 18416 bytes for local variables. Maximum is 20480 bytes.
STM32 ST-LINK CLI v3.3.0.0
STM32 ST-LINK Command Line Interface
ST-LINK SN: XXXXXXXXXXXXXXXXXXX
ST-LINK Firmware version: V2J37S7 (Need Update)
Connected via SWD.
SWD Frequency = 4000K.
Target voltage = 3.3 V
Connection mode: Normal
Reset mode: Software reset
Device ID: 0x410
Device flash Size: 64 Kbytes
Device family: STM32F10xx Medium-density
Loading file...
Flash Programming:
File : C:\XXXXXXXXXX\arduino-sketch-91D7BEE80E204XXXXXXXXXXXXXX\sketch_jul11a.ino.bin
Address : 0x08000000
Memory programming...
�������������������������������������������������� 0%
0%����������������������������� 59%��������������������� 100%
Memory programmed in 1s and 0ms.
Programming Complete.
MCU Reset.
Application started.
What else can I do to help diagnose the cause? I am complete noob on bootloader and flashing to flash/ram but i am willing to learn.
Thanks




