** OpenOCD初始化失败**使用VS Code,platformio,stlink v2和stm32 f030r8t6

时间:2018-07-13 04:46:29

标签: visual-studio-code ubuntu-16.04 openocd platformio stm32f0

(我在问题中添加了链接,但我将详细解释我的问题是什么,以便您无需使用链接,它们仅供参考) 嗨,

我正在尝试遵循此youtube教程(https://www.youtube.com/watch?v=R6SstBoXjKc&list=PL6PplMTH29SHgRPDufZhfMRoFwRAIrzOp),但他使用的是coocox IDE和Windows。我正在使用VS Code和Ubuntu 16.04.4 LTS。我正在尝试将VS Code的platformio扩展与stlink-v2和裸露的stm32 f030r8t6微控制器(https://www.newbiehack.com/categories/newbiehack-microcontroller-ARM-stmicro-STM32F0R6-withBreadboardInterface)一起使用。要将笔记本电脑连接到板上,请使用st-util命令,该命令提供以下输出:

    st-util 1.4.0-40-g1ec89bf
2018-07-12T21:28:36 INFO common.c: Loading device parameters....
2018-07-12T21:28:36 WARN common.c: Invalid flash type, please check device declaration
2018-07-12T21:28:36 INFO gdb-server.c: Chip ID is 00000000, Core ID is  00000000.
2018-07-12T21:28:36 INFO gdb-server.c: Listening at *:4242...

我的platform.ini文件是:

[env:f030r8t6]
platform = ststm32
board = f030r8t6
framework = stm32cube

然后我创建了一个名为f030r8t6.json的自定义配置文件:

{
  "build": {
    "cpu": "cortex-m0",
    "extra_flags": "-DSTM32F030x8",
    "f_cpu": "48000000L",
    "mcu": "stm32f030r8t6"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "openocd_target": "stm32f0x",
    "svd_path": "STM32F030.svd"
  },
  "frameworks": [
    "mbed",
    "stm32cube"
  ],
  "name": "ST STM32F030r8t6",
  "upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 65536,
    "protocol": "stlink",
    "protocols": [
      "jlink",
      "stlink",
      "blackmagic"
    ]
  },
  "url": "http://www.st.com/en/evaluation-tools/32f0308discovery.html",
  "vendor": "ST"
}

构建项目时,一切正常,但是当我尝试上传时,得到以下信息:

Processing f030r8t6 (platform: ststm32; board: f030r8t6; framework: stm32cube)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 > ST STM32F030r8t6
SYSTEM: STM32F030R8T6 48MHz 8KB RAM (64KB Flash)
DEBUG: CURRENT(stlink) EXTERNAL(blackmagic, jlink, stlink)
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Checking size .pioenvs/f030r8t6/firmware.elf
DATA:    [          ]   0.3% (used 28 bytes from 8192 bytes)
PROGRAM: [          ]   0.7% (used 484 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, jlink, stlink
CURRENT: upload_protocol = stlink
Uploading .pioenvs/f030r8t6/firmware.elf
GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-14:56)
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
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
in procedure 'program'
in procedure 'init' called at file "embedded:startup.tcl", line 495
in procedure 'ocd_bouncer'
** OpenOCD init failed **
shutdown command invoked

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

Terminal will be reused by tasks, press any key to close it.

我已经坚持了好几个星期,真的很感谢您的帮助! 谢谢!

1 个答案:

答案 0 :(得分:0)

我猜您在gpio主重新映射时关闭了代码中的JTAG和SW。 当我使用libOpenCM3框架编写stm32时,代码如下: gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF, AFIO_MAPR_CAN1_REMAP_PORTB); 会引起像您一样的问题。