如何解决在 Raspberry Pi 4 上使用 OpenOCD 编程 STM32F4
我正在尝试通过 SWD 接口在 STM32F407 上刷新引导加载程序,有问题的板是 Makerbase Robin Nano v3,这是一个 3D 打印机控制器板。
我的 OpenOCD 在我的 RaspBerry Pi 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,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 unlock 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
这是我的 raspBerrypi2_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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。