在Raspberry Pi 4上用OpenOCD编程STM32F4



我正试图通过SWD接口在STM32F407上闪存引导程序,有问题的板是Makerbase Robin Nano v3,这是一个3d打印机控制器板。

我有OpenOCD在我的树莓派4上运行良好,我能够读取内部内存的扇区

问题是我不会写字,我不知道为什么。

我用做了一个简单的测试

READ  -> stm32f4.cpu mdb 0x8000000 -> output: 0xFF
WRITE -> stm32f4.cpu mwb 0x8000000 0xAA -> no output
READ  -> stm32f4.cpu mdb 0x8000000 -> output: 0xFF // didn't change

写入特定字节似乎不起作用。

如果我尝试用load_image编程,这就是输出

> load_image nano_v3_bootloader.bin 0x8000000     
SWD DPIDR 0x2ba01477
Failed to write memory and, additionally, failed to find out where
SWD DPIDR 0x2ba01477

如果我尝试用program编程,这就是输出

> program nano_v3_bootloader.bin 0x8000000
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
SWD DPIDR 0xdeadbeef
Failed to write memory and, additionally, failed to find out where
error writing to flash at address 0x08000000 at offset 0x00000000
embedded:startup.tcl:308: Error: auto erase enabled
at file "embedded:startup.tcl", line 308

我是ARM的新手,我的猜测是,也许引导程序被锁定了(我试图用stm32f4x解锁0解锁它,似乎没有什么区别(,或者我做的事情顺序不对,或者在某个地方错过了一步。

如果有人能帮我弄清楚做错了什么,我将不胜感激

这是我的openocd.cfg

source [find interface/raspberrypi2-native.cfg]
transport select swd
set CHIPNAME stm32f4
source [find target/stm32f4x.cfg]
# did not yet manage to make a working setup using srst
#reset_config srst_only
reset_config  srst_nogate
adapter_nsrst_delay 100
adapter_nsrst_assert_width 100
init
targets
reset halt

这是我的raspperrypi2_native.cfg

#
# Config for using Raspberry Pi's expansion header
#
# This is best used with a fast enough buffer but also
# is suitable for direct connection if the target voltage
# matches RPi's 3.3V and the cable is short enough.
#
# Do not forget the GND connection, pin 6 of the expansion header.
#
adapter driver bcm2835gpio
bcm2835gpio_peripheral_base 0xFE000000
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 700MHz
# bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
bcm2835gpio_speed_coeffs 236181 60
# Each of the JTAG lines need a gpio number set: tck tms tdi tdo
# Header pin numbers: 23 22 19 21
bcm2835gpio_jtag_nums 11 25 10 9
# Each of the SWD lines need a gpio number set: swclk swdio
# Header pin numbers: 23 22
bcm2835gpio_swd_nums 25 24
# If you define trst or srst, use appropriate reset_config
# Header pin numbers: TRST - 26, SRST - 18
# bcm2835gpio_trst_num 7
# reset_config trst_only
bcm2835gpio_srst_num 18
reset_config srst_only srst_push_pull
# or if you have both connected,
# reset_config trst_and_srst srst_push_pull

运行这些命令修复了问题

> flash erase_sector 0 0 11 // this will erase bank 0
> flash write_bank 0 nano_v3_bootloader.bin 0 // this will write the bin file to the bank 0

最新更新