我最近购买了一个 STM32F7 发现板 [1],因此我尝试使用 openocd 对其进行闪存,因为该板具有嵌入式 st-link 调试器。我有我的工具链工作(我正在使用 makefile 和 arm-none-eabi-gcc),但我想使用 eclipse 刷新板,这样我就可以有一个图形调试器。
为此,我从他们的 git repo 安装了 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(例如 0xffffffffe 而不是 0x080004ac,这是重置处理程序的地址)。因此,CPU 将尝试执行一些甚至不存在的东西(在我的记忆之外)并且它失败了。
你知道什么可能是错的吗?一个小的精度:我在 Linux 上工作。
干杯,
安托万。
[1] : www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1848/PF261641?sc=stm32f7-discovery
[2] : vedder.se/2012/12/debugging-the-stm32f4-using-openocd-gdb-and-eclipse/
[3]:stackoverflow.com/questions/5535110/stm32-gdb-openocd-commands-and-initialization-for-flash-and-ram-debugging
[4]:stackoverflow.com/questions/17003519/stm32f4discovery-openocd-telnet-uploading-demo-program
[5]:github.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