当前位置:网站首页>Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
2022-07-02 14:14:00 【IOsetting】
OpenOCD burn STM32 Failure problem
Linux Next use OpenOCD burn STM32, There is Error: init mode failed (unable to connect to the target) error .
If in code , Carelessly PA13,PA14 Of SWD Function off , For example, the following code is used
rcc_periph_clock_enable(RCC_GPIOA); // Need GPIOA clock
gpio_primary_remap(
AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF, // Optional
AFIO_MAPR_TIM2_REMAP_NO_REMAP); // This is default: TIM2.CH2=GPIOA1
Or in STM32CubeMX Forget to check in PA13/PA14 Serial port debugging function , Will cause subsequent burning and connection failure , appear
Uploading .pio/build/bluepill_f103c8/firmware.elf
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:15)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
hla_swd
none separate
Error: init mode failed (unable to connect to the target)
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
*** [upload] Error 1
STLINK Tools st-flash and st-info
First, check whether there is st-flash and st-info command , If not, it needs to be installed
Installation steps
git clone https://github.com/stlink-org/stlink.git
cd stlink/
make
# If the libusb error , Just install it libusb-1.0-0-dev, Again make
sudo apt install libusb-1.0-0-dev
make clean
make
cd build/Release/
sudo make install
adopt st-info Check You will be prompted that you cannot enter SWD Pattern
$ st-info --probe
Failed to parse flash type or unrecognized flash type
Failed to enter SWD mode
Found 1 stlink programmers
version: V2J37S7
serial: 56FF6B064966485627161123
flash: 0 (pagesize: 0)
sram: 0
chipid: 0x000
detected chip_id parametres
# Device Type: unknown
# Reference Manual: RM0000
#
chip_id 0x0
flash_type 0
flash_size_reg 0x0
flash_pagesize 0x0
sram_size 0x0
bootrom_base 0x0
bootrom_size 0x0
option_base 0x0
option_size 0x0
flags 0
dev-type: unknown
Use st-flash and st-info solve STM32 Burning failed
Most of the schemes found on the Internet , For example, this stackoverflow The answer to , It's all about getting there Windows Next , adopt ST-link utility Go to reset erase , Here is an introduction Linux Treatment method under
st-info Use --connect-under-reset Parameters
You need to use --connect-under-reset Parameters , Press and hold the development board RESET After the key , Execute the following command , The chip information can be correctly detected
$ st-info --probe --connect-under-reset
Failed to parse flash type or unrecognized flash type
detected chip_id parametres
# Device Type: STM32F1xx_MD
# Reference Manual: RM0008
#
chip_id 0x410
flash_type 1
flash_size_reg 0x1ffff7e0
flash_pagesize 0x400
sram_size 0x5000
bootrom_base 0x1ffff000
bootrom_size 0x800
option_base 0x1ffff800
option_size 0x10
flags 2
Found 1 stlink programmers
version: V2J37S7
serial: 56FF6B064966485627161123
flash: 0 (pagesize: 1024)
sram: 20480
chipid: 0x410
detected chip_id parametres
# Device Type: STM32F1xx_MD
# Reference Manual: RM0008
#
chip_id 0x410
flash_type 1
flash_size_reg 0x1ffff7e0
flash_pagesize 0x400
sram_size 0x5000
bootrom_base 0x1ffff000
bootrom_size 0x800
option_base 0x1ffff800
option_size 0x10
flags 2
dev-type: STM32F1xx_MD
If that's the case , That is the PA13/PA14 Function reuse of , The problem can be solved by firmware erasure
st-flash Erase firmware
st-flash Similarly, add --connect-under-reset Competition , Press and hold RESET Key and execute the following command
$ st-flash --connect-under-reset erase
st-flash 1.7.0-184-g468b1d2
Failed to parse flash type or unrecognized flash type
2022-02-14T22:51:20 ERROR common.c: Soft reset failed: timeout
detected chip_id parametres
# Device Type: STM32F1xx_MD
# Reference Manual: RM0008
#
chip_id 0x410
flash_type 1
flash_size_reg 0x1ffff7e0
flash_pagesize 0x400
sram_size 0x5000
bootrom_base 0x1ffff000
bootrom_size 0x800
option_base 0x1ffff800
option_size 0x10
flags 2
2022-02-14T22:51:20 INFO common.c: STM32F1xx_MD: 20 KiB SRAM, 0 KiB flash in at least 1 KiB pages.
Mass erasing
In the presence of Mass erasing after , The power cannot be cut off immediately , It's going to take a little while , After use st-info --probe Check for success , If it still shows Failed to enter SWD mode, Just repeat the above operation again .
If st-info --probe Can directly detect the chip , Just explain SWD The function has been restored , Can continue in Linux Next use OpenOCD Burn happily STM32 了 .
边栏推荐
- 2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验
- 联合搜索:搜索中的所有需求
- P3008 [USACO11JAN]Roads and Planes G (SPFA + SLF优化)
- [template] longest common subsequence ([DP or greedy] board)
- Multi rotor aircraft control using PID and LQR controllers
- P1908 reverse sequence pair
- P3008 [usaco11jan]roads and planes g (SPFA + SLF optimization)
- QT new project_ MyNotepad++
- HMS core machine learning service helps zaful users to shop conveniently
- Quarkus learning IV - project development to deployment
猜你喜欢

Everyone believes that the one-stop credit platform makes the credit scenario "useful"

自定义事件,全局事件总线,消息订阅与发布,$nextTick

快解析:轻松实现共享上网

【虹科技术分享】如何测试 DNS 服务器:DNS 性能和响应时间测试

2022 home projector preferred! Dangbei F5 brings the ultimate audio-visual experience with its powerful audio-visual effect

qt中uic的使用

Simple introduction to ENSP

PyQt5_QScrollArea内容保存成图片

ensp简单入门

<口算练习机 方案开发原理图>口算练习机/口算宝/儿童数学宝/儿童计算器 LCD液晶显示驱动IC-VK1621B,提供技术支持
随机推荐
Story point vs. Human Sky
[document tree, setting] font becomes smaller
mysql ---- Oracle中的rownum转换成MySQL
Adhere to the foundation of 20 minutes go every day II
Just 1000 fans, record it
Using computed in uni app solves the abnormal display of data () value in tab switching
QT how to set fixed size
Solving the longest subsequence with linear DP -- three questions
一般来讲,如果频繁出现inconsistent tab and space的报错
P1908 reverse sequence pair
你的 Sleep 服务会梦到服务网格外的 bookinfo 吗
Characteristics of selenium
693. 行程排序(map + 拓扑)
Essential elements of science fiction 3D scenes - City
SystemServer进程
Téléchargement par navigateur
Methods of software testing
故事點 vs. 人天
每日学习2
抓包工具fiddler学习