我想使用 gdb 将二进制文件闪存到我的 ARM MCU 闪存中。
目前我可以像这样加载精灵:
# arm-none-eabi-gdb --command=flash.gdb "myfirmware.elf"
# cat flash.gdb
set confirm off
target remote 127.0.0.1:7224
monitor reset
load
detach
quit
基本上是load
命令擅长将 elf 部分加载到正确的地址。
然而,要将多个固件放入 MCU 闪存中,我想发送完整的二进制映像。
为了测试它,我制作了一个zero.bin图像(只包含0):
# hexdump zero.bin
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0020000
# arm-none-eabi-gdb
(gdb) target remote 127.0.0.1:7224
(gdb) mon reset halt
(gdb) mon reset init
(gdb) set arm fallback-mode auto
(gdb) set debug arm
(gdb) restore zero.bin binary 0x0
Restoring binary file zero.bin into memory (0x0 to 0x20000)
Writing to flash memory forbidden in this context
(gdb) info mem
Using memory regions provided by the target.
Num Enb Low Addr High Addr Attrs
0 y 0x00000000 0x00020000 flash blocksize 0x800 nocache
1 y 0x00020000 0x100000000 rw nocache
(gdb) delete mem 1
warning: Switching to manual control of memory regions; use "mem auto" to fetch regions from the target again.
(gdb) delete mem 0
(gdb) mem 0 0x100000000 rw nocache
(gdb) info mem
Using user-defined memory regions.
Num Enb Low Addr High Addr Attrs
1 y 0x00000000 0x100000000 rw nocache
(gdb) restore zero.bin binary 0x0
Restoring binary file zero.bin into memory (0x0 to 0x20000)
(gdb) x/10 0x0
0x0: 0x20003000 0x00003c5d 0x00003c7d 0x00003c7d
0x10: 0x00000000 0x00000000 0x00000000 0x00000000
0x20: 0x00000000 0x00000000
所以这似乎不起作用,正如你在 0x0 中看到的那样,它应该充满“0”,但它仍然包含我以前的固件(实际上是向量表)
我想念什么?或者也许还有另一种使用 gdb 加载二进制文件的方法?
如果您正在使用OpenOCD,
mon flash write_bank <num> <file_name> <offset>
应该对你有帮助。
例如,如果您的闪光灯开始于0x400000
,
mon flash write_bank 0 zero.bin 0x100000
将在以下位置写入 Zero.bin 文件0x500000
,假设该地址可写。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)