本帖最后由 921742079 于 2019-11-20 21:48 编辑
先上图
下载toolchain
安装openocd,用于调试
sudo apt install gdb-multiarch openocd -y
我是jlink,编写jlink_board.cfg
source [find interface/jlink.cfg]
transport select swd
source [find target/stm32f1x.cfg]
vscode,安装插件
C/C++
Cortex-Debug
C++ Intellisense
复制下面两个文件到项目目录
launch.json, runToMain 如果为false,可以一步步调试rtt的启动流程,为true的话,直接到applications里面的main函数
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "openocd_debug",
"cwd": "${workspaceRoot}",
"executable": "${workspaceRoot}/rt-thread.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"device": "stm32f411ce",
"gdbpath": "/usr/bin/gdb-multiarch",
"configFiles":[
"/home/xxx/dev/embedded/stm32/openocd/stm32f4x/jlink_board.cfg"
],
// "preLaunchTask": "build",
"runToMain": true
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "scons -c; scons"
},
{
"label": "serial",
"type": "shell",
"command": "picocom -b 115200 -s 'sb -vv' -v 'rb -vv' /dev/ttyUSB0"
},
{
"label": "burn",
"type": "shell",
// 请注意修改这里具体的板子配置文件
"command": "openocd -f ~/dev/embedded/stm32/openocd/stm32f4x/jlink_board.cfg -c init -c 'reset halt' -c 'flash write_image erase rtthread.bin 0x08000000' -c 'verify_image rtthread.bin 0x08000000' -c 'reset run' -c shutdown"
},
{
"label": "erase",
"type": "shell",
// 请注意修改这里具体的板子配置文件
// 如果无法erase,请按住板子的reset键,再erase
"command": "openocd -f ~/dev/embedded/stm32/openocd/stm32f4x/jlink_board.cfg -c init -c 'reset halt' -c 'flash info 0' -c 'flash erase_sector 0 0 last' -c 'flash erase_check 0' -c shutdown"
}
]
}按F5, 即可调试
代码补全按F1, edit configurations, 设置includePath
基本上补全,断点,都有了