STM32CubeIDE只能闪烁一次,没有SWD调试

问题描述 投票:1回答:1

几年来,我一直在使用mbed在线编译器来创建.bin文件,然后使用ST-LINK / V2 USB软件狗在这样的命令行中将它们刷新,并且所有内容都可以正常工作:

st-flash write 01_blink.NUCLEO_F103RB.bin 0x8000000

[今天,我下载了适用于Linux的STM32CubeIDE(Fedora 30),并使用maple mini(STM32F103CBT6)开始学习本教程。

https://www.digikey.co.nz/en/maker/projects/getting-started-with-stm32-introduction-to-stm32cubeide/6a6c60a670c447abb90fd0fd78008697

构建项目并开始调试运行后,我得到输出:

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...

此后,我不能再启动调试会话,因为得到了这个:

enter image description here

我可以看到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(实际上已经),并且还尝试了“重置行为”的所有选项,但结果没有改变。

stm32 gdbserver swd
1个回答
2
投票

为什么总是这样?我花了几个小时苦苦挣扎,然后又花了20分钟用截图等方式使问题尽可能简洁明了,然后在发布后两分钟我找到了答案,通常是在另一个SO答案中,我以某种方式在数小时内从未见过搜索。我认为关于SO的问题大约有一半是通过这种方式结束的。

问题似乎是,除非您声明要使用SWD以及在哪些引脚上使用,否则默认情况下不会启用它。因此,一旦刷新了新程序,SWD连接就会中断。我猜mbed程序默认情况下会保留在标准引脚上使用SWD,所以那里从来就不是问题。

无论如何要避免这种情况,请返回引脚排列和配置(在项目资源管理器中双击.ioc文件)。设置适当的SWD引脚(在我的情况下为PA13,PA14),然后在“系统核心”下单击SYS,并将“调试”选项设置为“串行线”。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.