当前位置:网站首页>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 了 .
边栏推荐
- PyQt5_QScrollArea内容保存成图片
- Slashgear shares 2021 life changing technology products, which are somewhat unexpected
- Chaos engineering platform chaosblade box new heavy release
- php链表创建和遍历
- Default slot, named slot, scope slot
- QT new project_ MyNotepad++
- 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
- Error: eacces: permission denied, access to "/usr/lib/node_modules"
- The xftp connection Haikang camera reported an error: the SFTP subsystem application has been rejected. Please ensure that the SFTP subsystem settings of the SSH connection are valid
- 故事点 vs. 人天
猜你喜欢
YOLOv3&YOLOv5输出结果说明
腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测
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
默认插槽,具名插槽,作用域插槽
Whole house Wi Fi: a pain point that no one can solve?
kaggle如何使用utility script
Origin绘制热重TG和微分热重DTG曲线
快解析:轻松实现共享上网
关于Flink框架窗口(window)函数最全解析
selenium 在pycharm中安装selenium
随机推荐
石子合并板子【区间DP】(普通石子合并 & 环形石子合并)
PyQt5_ Qscrollarea content is saved as a picture
Mysql5.7 installation super easy tutorial
Origin绘制热重TG和微分热重DTG曲线
freemarker的使用
Subcontracting configuration of uniapp applet subpackages
Qt如何设置固定大小
selenium,元素操作以及浏览器操作方法
qt中uic的使用
Some interview suggestions for Android programmers "suggestions collection"
mysql ---- Oracle中的rownum转换成MySQL
Penetrate the remote connection database through the Intranet
如何设置Qt手工布局
线性dp求解 最长子序列 —— 小题三则
自定义事件,全局事件总线,消息订阅与发布,$nextTick
Just 1000 fans, record it
每天坚持20分钟go的基础二
C crystal report printing
Talk about idempotent design
Qt新项目_MyNotepad++