当前位置:网站首页>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 了 .
边栏推荐
- Chaos engineering platform chaosblade box new heavy release
- 联合搜索:搜索中的所有需求
- Slashgear shares 2021 life changing technology products, which are somewhat unexpected
- 2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验
- Qt入门-制作一个简易的计算器
- The conference on the growth of all things was held in Hangzhou, and dangbei was selected into the top 100 list of future unicorns in China in 2022
- 路由(二)
- Everyone believes that the one-stop credit platform makes the credit scenario "useful"
- Qt-制作一个简单的计算器-实现四则运算-将结果以对话框的形式弹出来
- Halcon extract orange (Orange)
猜你喜欢

The 29 year old programmer in Shanghai was sentenced to 10 months for "deleting the database and running away" on the day of his resignation!

Essential elements of science fiction 3D scenes - City

TeamTalk源码分析之win-client

How kaggle uses utility script

2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验

BeanUtils -- shallow copy -- example / principle

Federated Search: all requirements in search

Design of non main lamp: how to make intelligent lighting more "intelligent"?

Custom events, global event bus, message subscription and publishing, $nexttick

Codeforces Round #803 (Div. 2)(A~D)
随机推荐
Unity small map production [2]
HMS core machine learning service helps zaful users to shop conveniently
Dingtalk send message
<口算练习机 方案开发原理图>口算练习机/口算宝/儿童数学宝/儿童计算器 LCD液晶显示驱动IC-VK1621B,提供技术支持
D language, possible 'string plug-ins'
freemarker的使用
路由(二)
关于Flink框架窗口(window)函数最全解析
Halcon extract orange (Orange)
石子合并板子【区间DP】(普通石子合并 & 环形石子合并)
Multi rotor aircraft control using PID and LQR controllers
In 2021, the global styrene butadiene styrene (SBS) revenue was about $3722.7 million, and it is expected to reach $5679.6 million in 2028
Federated Search: all requirements in search
Tencent cloud tstor unified storage passed the evaluation of the first batch of basic file storage capabilities of the ICT Institute
混沌工程平台 ChaosBlade-Box 新版重磅发布
Custom events, global event bus, message subscription and publishing, $nexttick
C crystal report printing
Adhere to the foundation of 20 minutes go every day II
uni-app中使用computed解决了tab切换中data()值显示的异常
OpenHarmony笔记-----------(四)