使用 openocd 闪存和调试 STM32F7 发现

Flash and debug STM32F7 discovery with openocd

我最近买了一块 STM32F7 发现板 [1],因此我尝试使用 openocd 对其进行闪存,因为该板具有嵌入式 st-link 调试器。我有我的工具链工作(我正在使用 makefiles 和 arm-none-eabi-gcc),但我想使用 eclipse 刷新电路板,这样我就可以有一个图形调试器。

为此,我从他们的 git 仓库安装了 openocd,并使用以下配置文件启动它:

source [find board/stm32f7discovery.cfg]

然后我在 eclipse 中使用以下命令和 arm-none-eabi-gdb 刷写板子:

target remote localhost:3333
monitor flash protect 0 0 11 off
monitor flash erase_address 0x08000000 0x100000
monitor flash write_image erase "/absolute/path/hello-world.hex" 0 ihex
monitor reset halt

我尝试了不同的命令列表,包括我用来在 eclipse [2] 上设置调试链的教程或其他 SO 帖子 [3][4] 中的命令。有时写入操作会失败,如果没有失败,我会得到一台错误的 PC(例如,0xfffffffe 而不是 0x080004ac,这是重置处理程序的地址)。因此 CPU 将尝试执行一些甚至不存在的东西(在我的记忆之外)并且它失败了。

你知道哪里出了问题吗?一个小的精度:我正在研究 Linux。

干杯,

安托万。

[1] : www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1848/PF261641?sc=stm32f7-发现

[2] : 维德.se/2012/12/debugging-the-stm32f4-using-openocd-gdb-and-eclipse/

[3]:计算器。com/questions/5535110/stm32-gdb-openocd-commands-and-initialization-for-flash-and-ram-debugging

[4]:计算器。com/questions/17003519/stm32f4discovery-openocd-telnet-uploading-demo-program

[5] : git中心.com/texane/stlink

[编辑]

我还尝试使用来自 github [5] 的 st-link 程序并使用 gdb 加载,我得到了类似的错误:

2016-03-23T09:22:22 INFO src/stlink-common.c: Attempting to write 32768 (0x8000) bytes to stm32 address: 134217728 (0x8000000)
2016-03-23T09:22:22 WARN src/stlink-common.c: Failed to unlock flash!
EraseFlash - Sector:0x0 Size:0x8000
Flash page at addr: 0x08000000 erased
2016-03-23T09:22:22 INFO src/stlink-common.c: Finished erasing 1 pages of 32768 (0x8000) bytes
2016-03-23T09:22:22 INFO src/stlink-common.c: Starting Flash write for F2/F4/L4
2016-03-23T09:22:22 INFO src/stlink-common.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 32768
2016-03-23T09:22:23 INFO src/stlink-common.c: Starting verification of write complete
2016-03-23T09:22:23 ERROR src/stlink-common.c: Verification of flash failed at offset: 0

我设法解决了问题。事实证明,我一定是修改了内部选项字节,这在我尝试刷新电路板时阻碍了我。

我使用 st-link 实用程序 将它们设置回默认值,现在一切正常!可能可以使用 openocd 代替,但我还没有尝试过。如果有人知道该怎么做,他会很高兴分享它。

有关选项字节的更多详细信息,您可以查看参考手册 [1],第 80 至 83 页。

[1] : http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/DM00124865.pdf