I’m attempting to upload the cmsis-blink example to a Blue Pill board using ST-Link, as a quick sanity check to make sure I know what I’m doing before I move on to more complicated things. (And apparently I don’t know what I’m doing.)
I’m using PlatformIO 5.1.1 on Ubuntu 20.04, and I tried uploading to the board like this:
ppelleti@patrick64:~/src/platform-ststm32/examples/cmsis-blink$ pio run -e 'bluepill f103c8' --target upload
Processing bluepill f103c8 (platform: ststm32; framework: cmsis; board: bluepill_f103c8)
--------------------------------------------------------------------------------
Tool Manager: Installing platformio/tool-stm32duino @ ~1.0.1
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-stm32duino @ 1.0.1 has been installed!
Tool Manager: Installing platformio/tool-openocd @ ~2.1000.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-openocd @ 2.1000.200630 has been installed!
Tool Manager: Installing platformio/tool-dfuutil @ ~1.9.190708
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-dfuutil @ 1.9.200310 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8.html
PLATFORM: ST STM32 (12.1.1) > BluePill F103C8
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
- framework-cmsis 2.50501.200527 (5.5.1)
- framework-cmsis-stm32f1 4.3.1
- tool-dfuutil 1.9.200310
- tool-ldscripts-ststm32 0.1.0
- tool-openocd 2.1000.200630 (10.0)
- tool-stm32duino 1.0.1
- toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
Warning! Cannot find a linker script for the required board! An auto-generated script will be used to link firmware!
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 release mode
Checking size .pio/build/bluepill f103c8/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 0.1% (used 28 bytes from 20480 bytes)
Flash: [ ] 0.6% (used 396 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio/build/bluepill f103c8/firmware.elf
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-09:27)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
hla_swd
none separate
Error: init mode failed (unable to connect to the target)
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
*** [upload] Error 1
========================= [FAILED] Took 12.23 seconds =========================
Environment Status Duration
--------------- -------- ------------
bluepill f103c8 FAILED 00:00:12.235
==================== 1 failed, 0 succeeded in 00:00:12.235 ====================
I’m unclear exactly what “unable to connect to the target” means. Does it mean that it could not connect to the ST-Link probe? Or does it mean that the ST-Link probe could not connect to the Blue Pill board?
I wondered if this could be a udev
problem, but it doesn’t look like it is. Here is how my probe shows up:
ppelleti@patrick64:/etc/udev/rules.d$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 0483:3748 STMicroelectronics ST-LINK/V2
Bus 004 Device 002: ID 04f2:0939 Chicony Electronics Co., Ltd USB Optical Mouse
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 058f:6363 Alcor Micro Corp. Mass Storage Device
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 04ca:002f Lite-On Technology Corp. USB Multimedia Keyboard
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
and it looks like that is covered by a udev
rule:
ppelleti@patrick64:/etc/udev/rules.d$ fgrep 3748 99-platformio-udev.rules
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0666"
What is the next thing I should try?