2017-09-05 51 views
0

我想使用gdb将二进制文件闪存到我的ARM MCU闪存中。使用gdb将二进制文件加载到闪存中

目前我能够加载ELF这样的:

# 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闪存中放入多个固件,我想发送一个完整的二进制图像。 为了测试它,我做(含什么,但0)一zero.bin图像:

# 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加载二进制文件?

+0

恢复命令失败,写入禁止在此上下文中闪存。我试图找出为什么这也发生在我身上 – Jon

+0

实际上,在我的情况下,这是因为这个区域映射到闪存,而gdb需要一种方法来弄清楚如何编程闪存它不可能是某种东西像'addr [i] = data [i]'。我不知道如何设置gdb来做到这一点。无论如何,希望它有帮助! – Ervadac

回答

0

如果您正在使用OpenOCD的

mon flash write_bank <num> <file_name> <offset> 

应该帮助你。

例如,如果你的闪光灯开始于0x400000

mon flash write_bank 0 zero.bin 0x100000

将写入zero.bin文件在0x500000,假设地址是可写的。

相关问题