惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
N
News and Events Feed by Topic
S
Secure Thoughts
Vercel News
Vercel News
S
Security @ Cisco Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - 聂微东
WordPress大学
WordPress大学
Google Online Security Blog
Google Online Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
PCI Perspectives
PCI Perspectives
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
Apple Machine Learning Research
Apple Machine Learning Research
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
博客园 - 司徒正美
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
A
About on SuperTechFans
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
V
V2EX
I
Intezer
H
Hacker News: Front Page
www.infosecurity-magazine.com
www.infosecurity-magazine.com
L
Lohrmann on Cybersecurity
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
博客园 - 叶小钗
The Cloudflare Blog
月光博客
月光博客
W
WeLiveSecurity
T
Tenable Blog
P
Proofpoint News Feed
aimingoo的专栏
aimingoo的专栏
Help Net Security
Help Net Security
L
LangChain Blog
C
CERT Recently Published Vulnerability Notes
T
The Exploit Database - CXSecurity.com
美团技术团队
B
Blog

MoonLab

Clangd + VSCode使用方法 Keil5 编译错误 error: call to undeclared function '__enable_irq' BTSNOOP is FUN! 算法 - 前缀和 2025蓝桥杯赛后总结 三星ZFold 3改造 JavaScript 逆向 Steam 登录二维码 快速求解平方根倒数算法 Protobuf Android设备安装Debian成为BT下载服务器 [双系统] Windows 更新摧毁了我的Linux系统 Reading List Golang embed 使用问题 Hexo博客自动备份插件 云盘备份支持 通过汇编分析栈、函数调用 esp&ebp Git push 出现 permisson denied error 403 坑:Litepal save方法返回true却没有保存 Android Shizuku源码分析 第二篇 Android Shizuku源码分析 Android 监听第三方Activity的一举一动 Android笔记#1 View的事件分发机制解析 知乎日报的问题 使用Hexo Hello World Ubnutu 无法启动网易云音乐 - 总结 Windows 好软推荐 | 这一定是良心软件 typecho - http转https 如何评价Android P MoonLab MoonLab MoonLab 关于 项目
VSCode + OpenOCD 远程调试开发STM32
LingC · 2025-11-01 · via MoonLab

[PC] --Wi-Fi--> [树莓派5] --USB--> [DAPLink] --SWD--> [STM32目标板]

树莓派配置

测试Daplink USB连接状态

必要的包

  • openocd
  • gdb-multiarch
  • git
  • make
sudo apt install openocd gdb-multiarch git make
openocd -f interface/cmsis-dap.cfg -f target/stm32f1x.cfg

默认情况下,OpenOCD启动的GDB服务器(3333端口)只监听本地回环地址(127.0.0.1

我们需要让OpenOCD监听所有网络接口(0.0.0.0

nano ~/remote_daplink.cfg
# 指定使用CMSIS-DAP接口
adapter driver cmsis-dap

# 使用SWD协议,STM32F1支持SWD
transport select swd

# 可选:设置适配器速度,如果连接不稳定可以降低速度(单位kHz)
adapter speed 1000

# 指定STM32F1x的目标配置文件
source [find target/stm32f1x.cfg]

bindto 0.0.0.0
gdb_port 3333
telnet_port 4444
tcl_port 6666

# 可选:如果你希望OpenOCD在后台运行(作为守护进程
# daemon_startup attach
sudo openocd -f ~/remote_daplink.cfg

Tips: -d:输出调试信息

后台运行

nohup sudo openocd -f ~/remote_daplink.cfg > /tmp/openocd.log 2>&1 &

PC配置

主要是为了arm-none-eabi-gdb程序。

» ARM GNU Toolchain

arm-none-eabi-gdb (GDB) 调试器依赖于 OpenOCD 调试服务器。GDB中下达的命令,都会通过网络发送到OpenOCD,再由OpenOCD翻译成底层的JTAG/SWD命令,通过调试探针发送给芯片执行。

Keil Output

Options for Target -> Output
文件类型用途
.axf包含完整调试信息的可执行文件。用于调试和通过OpenOCD+GDB烧录。
.hexIntel Hex格式文件,常用于生产烧录。
.bin纯二进制镜像文件,常用于OTA升级等。

VSCode

首先在VSCode中安装 Cortex-Debug 插件

远程调试,编辑 ./vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Remote Debug (STM32F1)",
      "cwd": "${workspaceFolder}",
      "executable": "./MDK-ARM/RaspVisionCar/RaspVisionCar.axf",
      "request": "launch",
      "type": "cortex-debug",
      "servertype": "external",
      "gdbTarget": "192.168.156.107:3333",
      "gdbPath": "arm-none-eabi-gdb",
      "device": "STM32F103C8",
      "runToEntryPoint": "main"

    },
......
arm-none-eabi-gdb "D:/Projects/STM32/RaspVisionCar/MDK-ARM/RaspVisionCar/RaspVisionCar.axf"
target extended-remote 192.168.156.107:3333
monitor reset halt
load

远程烧录,编辑`./vscode/tasks.json:

{  
    "label": "Flash via Remote GDB (OpenOCD)",  
    "type": "shell",  
    "command": "arm-none-eabi-gdb", // 确保在 PATH 中(GNU Arm Embedded Toolchain)  
    "args": [  
        "build/RaspVisionCar.elf",  
        "-q",  
        "-ex", "target extended-remote ${input:remoteGdbHost}:3333",  
        "-ex", "monitor reset halt",  
        "-ex", "load",  
        "-ex", "monitor reset",  
        "-ex", "detach",  
        "-ex", "quit"  
    ],  
    "group": "build",  
    "presentation": {  
        "echo": true,  
        "reveal": "silent",  
        "focus": false,  
        "panel": "shared",  
        "clear": true  
    },  
    "dependsOn": "Build Project (Release)" // 远程烧录前先构建  
}