开发者

how to program the STM32 flash using openOCD and gdb

开发者 https://www.devze.com 2023-02-04 12:34 出处:网络
I\'m using an Olimex ARM-USB-OCD dongle with openOCD and GDB to program and debug an stm32f103 micro. The IDE I\'m using came from the Olimex dev-kit CD and makes use of eclipse ganymede.

I'm using an Olimex ARM-USB-OCD dongle with openOCD and GDB to program and debug an stm32f103 micro. The IDE I'm using came from the Olimex dev-kit CD and makes use of eclipse ganymede.

I can load a small program into the RAM and step through the code without any problems.

I now have a much larger program which doesn't fit into RAM (which is only 20K) and so I'd like to run it from flash (which is 128K).

I've modified the linker script indicating the program code sh开发者_如何学JAVAould go in the flash section (address 0x8000000), but gdb fails to load the program.

(gdb) 
20 load main.out
&"load main.out\n"
load main.out
~"Loading section .text, size 0xb0e6 lma 0x8000000\n"
Loading section .text, size 0xb0e6 lma 0x8000000
&"Load failed\n"
Load failed

What should I do to get gdb to load the program into flash?


Have you considered flashing directly with openocd? I am doing this in a similar setup, but with an ARM7 microcontroller.

 openocd -f flash.cfg

Here is my flash.cfg

set CHIPNAME at91sam7x512

source [find interface/olimex-arm-usb-ocd.cfg]
source [find target/at91sam7sx.cfg]

init    
halt

flash probe 0
flash probe 1

flash erase_sector 0 0 15
flash erase_sector 1 0 15

flash write_image my-image.elf

at91sam7 gpnvm 0 set
at91sam7 gpnvm 1 set
at91sam7 gpnvm 2 set
shutdown

The GPNVM stuff is Atmel SAM7 specific, but I think this script should give you a good starting point for making a STM32 version. Openocd can be a bit confusing in the beginning, but the documentation is good and worth reading (http://openocd.berlios.de/). The current stable version (0.4.0) is quite old, so if you have problems, download the latest source code and compile your own.

0

精彩评论

暂无评论...
验证码 换一张
取 消