platformIO上传程序到stm32失败,Warn : UNEXPECTED idcode: 0x2ba01477

  • 具体报错
Processing bluepill_f103c8 (platform: ststm32; board: bluepill_f103c8; framework: libopencm3)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8.html
PLATFORM: ST STM32 5.4.3 > BluePill F103C8
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES: tool-stm32duino 1.0.1, framework-libopencm3 1.1.0, toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), tool-openocd 2.1000.190422 (10.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
Checking size .pio/build/bluepill_f103c8/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   0.0% (used 0 bytes from 20480 bytes)
PROGRAM: [          ]   1.0% (used 684 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, dfu, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio/build/bluepill_f103c8/firmware.elf
GNU MCU Eclipse OpenOCD, 64-bitOpen On-Chip Debugger 0.10.0+dev-00593-g23ad80df4 (2019-04-22-20:18)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
hla_swd
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
none separate
Warn : UNEXPECTED idcode: 0x2ba01477
Error: expected 1 of 1: 0x1ba01477
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked

*** [upload] Error 1
================================================================================== [ERROR] Took 1.05 seconds ==================================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.
  • 问题核心:Warn : UNEXPECTED idcode: 0x2ba01477 Error: expected 1 of 1: 0x1ba01477
  • 原因:开发板用的芯片不是stm32f103c8,而是一个中国国产仿制版本 CS32F103C8T6。
  • 解决方法
    • 方案1:修改cfg文件
        编辑~/.platformio/packages/tool-openocd/scripts/target/stm32f1x.cfgset _CPUTAPID 0x1ba01477改为set _CPUTAPID 0x2ba01477
    • 方案2:修改工程配置文件
        在工程配置文件platformio.ini[env...]下添加upload_flags = -c set CPUTAPID 0x2ba01477
    • 方案3:
        stm32f1x.cfg在swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf 后添加-expected-id $_CPUTAPID -expected-id 0x2ba01477

你可能感兴趣的:(platformio,vscode,stm32)