当前位置:网站首页>How openocd directly downloads programs to STM32 board through stlink (solved)
How openocd directly downloads programs to STM32 board through stlink (solved)
2022-07-28 19:34:00 【Biao】
First , About OpenOCD Introduction to , And how to debug , Look at my article :
because OpenOCD Once connected , Meeting Automatic entry 3 Port listening mode ( That's one of them gdbserver port , Actually OpenOCD It's essentially a gdbserver), So debug ( choice gdb Port can , The above article says ), It's easy . But this article is about how Direct download program , Instead of debugging .
The existing good reference blogs are as follows ( These two blogs talk about the same ):
Windows Upper use OpenOCD to STM32 Download program _MCUlover666 Technology blog _51CTO Blog
There are two ways to download the program to the board :
(win10,stm32f103ZET6 Single chip microcomputer ,st-link v2 Hardware Debugger ,OpenOCD edition OpenOCD-20211118-0.11.0)
1. Use port connection mode
Connect first OpenOCD To the hardware debugger , open powershell Command line window
Command line :openocd -f < Interface profile > -f < Target chip configuration file >
For example, I stm32f103zet6 The board :openocd -f scripts/interface/stlink.cfg -f scripts/target/stm32f1x.cfg

So you can have Three port connection protocols :tcl 、 telnet 、gdb( Debugging function use , This is what I use in this blog The embedded IDE principle OpenOCD Introduce as well as stlink How to connect stm32 The board _ mark biao The blog of -CSDN Blog ).
If you choose telnet Port connection , Then open another powershell Command line window ,
Enter the command line :telnet localhost 4444 Connect to openocd
- Enter the command :halt, The target chip is suspended , It's like shutting down
- Enter the command :flash write_image erase < Files to download >, Download the file to the target chip flash
- Enter the command :reset, The target chip is reset

Empathy ,tcl Port connections are similar .
But downloading the program is too troublesome , Can you not connect the port , One command line , Download directly ? Tolerable , as follows
2. Use direct download
One command line :
openocd -f scripts/interface/stlink.cfg -f scripts/target/stm32f1x.cfg -c init -c "reset halt; wait_halt; flash write_image erase build/ project 15.bin 0x08000000" -c reset -c shutdown
explain :
- openocd -f scripts/interface/stlink.cfg -f scripts/target/stm32f1x.cfg Used to connect to OpenOCD
- -c Indicates the option to be executed ,-c init For initialization
- -c "reset halt; wait_halt; flash write_image erase build/ project 15.bin 0x08000000" To execute a command , among reset halt; wait_hal First stop the SCM ( You can't have less semicolons ), This sentence is very important
- -c reset -c shutdown, Indicates resetting the SCM , And quit OpenOCD
Be careful :
reset halt; wait_hal , This sentence is indispensable , Otherwise, the first download will succeed , But the second download will report an error :timeout waiting for algorithm, a target reset is recommended, For example, the following blog has such a problem :
Windows Upper use OpenOCD to STM32 Download program _MCUlover666 Technology blog _51CTO Blog STM32 development environment 】Linux Lower development stm32( Two ) | Use openocd Download program _Mculover666 The blog of -CSDN Blog _openocd
Thread: [OpenOCD-devel] J-TAG flash programming issues STM32F7 | OpenOCD - Open On-Chip Debugger
I guess the reason :
- The first is mine OpenOCD The version is different from them , This is the latest version .
- second , Because it's connected OpenOCD, This one. gdbserver There is no normal exit
- Third , Commands written directly -c halt No entry into force , It must be written in my way .
Some people on the Internet write the command line like this :( It is here that I get inspiration , You can also enlighten yourself )
openocd -f interface/ftdi/jtagkey.cfg -f myboard_EK390.cfg -c "init; targets; reset halt; wait_halt; poll; flash write_image erase unlock Debug-EK390-0/FirmwareEK390_caffe.elf; flash erase_check 0; reset run; shutdown"
OpenOCD Reference manual :
- Use openocd Some tips :OpenOCD Use guide -oceanhehy-ChinaUnix Blog
Use jtag when , Best used cpu After reset, do not execute any instructions directly halt, The relevant instructions are :reset halt, There are also similar instructions reset run、reset init, These instructions are in openocd There are instructions in the manual .
Openocd The configuration file is tcl Script , So use proc You can define an interface similar to a function . By using proc, Can save a lot of trouble .
stay MinGW Compile the openocd Can be in windows Of cmd Run directly in , But if jtag The interface does not interface with the board , The program will die , And it can't be returned . At this time, plug and unplug again when the board is charged openjtag, Then reopen the new cmd function openocd that will do . however , Must be changed at this time telnet_port, because , Just died openocd Occupying the original port . - Official documents OpenOCD User guide _ Confucius said Xiao Jiu's blog -CSDN Blog _openocd
边栏推荐
- BeanFactory not initialized or already closed - call ‘refresh‘ before accessing beans via the Applic
- New this prototype precompiled exercise
- IMU 加热
- 2022年全国最新消防设施操作员(中级消防设施操作员)题库及答案
- Image processing web application development tutorial
- TSDB and blockchain
- 英文翻译意大利语-批量英文翻译意大利语工具免费
- The mystery of ID number
- Cvpr21 unsupervised anomaly detection cutpaste:self supervised learning for anomaly detection and localization
- Investment of 3.545 billion yuan! Gree Group participates in Xiaomi industry fund
猜你喜欢

JS preventDefault() 键盘输入限制 onmousewheel stopPropagation停止事件传播

ES6's new data container map

Fantasy 5 (ue5) game engine complete course 2022

在矩池云快速安装torch-sparse、torch-geometric等包

Rust Getting Started Guide (modules and engineering structures)

使用百度EasyDL实现明厨亮灶厨师帽识别

VAE:变分自编码器的理解与实现

Saltstack system initialization

Rust 入门指南(rustup, cargo)

微信公众号授权登录后报redirect_uri参数错误的问题
随机推荐
英文翻译阿拉伯语-批量英文翻译阿拉伯语工具免费
Method of win7 system anti ARP attack
Rust Getting Started Guide (crite Management)
Share several coding code receiving verification code platforms, which will be updated in February 2022
剑指 Offer II 109. 开密码锁
NDK series (5): from introduction to practice, JNI explodes the liver and explains everything in detail!
宝塔面板搭建小说CMS管理系统源码实测 - ThinkPHP6.0
投资35.45亿元!格力集团参与小米产业基金
App自动化测试是怎么实现H5测试的
Avoidance Adjusted Climbrate
VAE:变分自编码器的理解与实现
redis 主从架构(sizeof函数怎么计算)
[深入研究4G/5G/6G专题-44]: URLLC-15-《3GPP URLLC相关协议、规范、技术原理深度解读》-9-低延时技术-3-非时隙调度Mini slot
初步学习函数(第3篇博客)
China's first chip stamp released: built-in 120um ultra-thin NFC chip
Powerbi time series analysis, prediction and visualization tutorial
可转债概念表 x Notion 给你方便快捷的体验!
英文翻译意大利语-批量英文翻译意大利语工具免费
lua语言的左对齐函数(手写)
Ardupilot software in the loop simulation and online debugging