几年来,我一直在使用mbed在线编译器创建.bin文件,然后像这样在命令行中使用ST-LINK/V2 USB小型设备进行烧录,一切都无缝运行:
st-flash write 01_blink.NUCLEO_F103RB.bin 0x8000000
今天我下载了适用于Linux(Fedora 30)的STM32CubeIDE,并开始按照这个教程使用枫叶迷你(STM32F103CBT6)。
在构建项目并启动调试运行后,我得到了以下输出:
STMicroelectronics ST-LINK GDB server. Version 5.3.2
Copyright (c) 2019, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 1
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
Waiting for debugger connection...
Debugger connected
-------------------------------------------------------------------
STM32CubeProgrammer v2.2.0
-------------------------------------------------------------------
Log output file: /tmp/STM32CubeProgrammer_2ZxzGk.log
ST-LINK SN : 34006B063058373138650943
ST-LINK FW : V2J34S7
Voltage : 3.21V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x410
Device name : STM32F101/F102/F103 Medium-density
Flash size : 64 KBytes
Device type : MCU
Device CPU : Cortex-M3
Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_Q2zZSF.srec
File : ST-LINK_GDB_server_Q2zZSF.srec
Size : 4648 Bytes
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 4]
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:00.595
Verifying ...
Download verified successfully
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Error! Failed to read target status
Debugger connection lost.
Shutting down...
之后我无法启动调试会话,因为我收到了这个错误信息:
我可以看到LED如预期地闪烁,所以我知道程序已经成功地烧录到了板子上。但是我不能在STM32CubeIDE中进一步操作,当我尝试像之前那样通过命令行进行烧录时,现在也不起作用了:
[root@localhost Downloads]# st-flash write 01_blink.NUCLEO_F103RB.bin 0x8000000
st-flash 1.5.1-38-gc3577b5
2020-03-24T13:51:09 INFO common.c: Loading device parameters....
2020-03-24T13:51:09 WARN common.c: Invalid flash type, please check device declaration
core status: unknown
Unknown memory region
幸运的是,我可以使用ST-Link UTILITY(在Windows上)并在连接之前按住复位按钮,然后进行完全擦除,从而回到起点,如此处所述:
http://www.kerrywong.com/2012/08/02/the-dreaded-cannot-connect-to-st-link-error-message/
但显然这不是进行任何产品开发的可行情况。我做错了什么吗?
在“调试配置”对话框的“调试器”选项卡中,我尝试将“接口”设置为SWD(实际上已经是),并且我也尝试了所有“复位行为”的选项,但结果没有改变。