openocd下载stm32程序【使用jlink】

打开cmd

如果没有配置环境变量,则需需要先配置环境变量

下载zadig

option->list all device打钩
option->ignore Hubs or Composite Parents打钩
选择j-link
install driver

将需要下载的文件拷贝到openocd工作的文件夹下

OpenOCD-20211118-0.11.0\share\openocd\scripts
在这个目录下新建一个文件夹,命名为outputfile,
在文件夹中放入要烧写的hex,并命名为origin.hex

命令

openocd -c "adapter driver jlink" -c"transport select swd" -c "adapter speed 1000" -f"target/stm32f1x.cfg" -c "program outputfile/origin.hex" -c reset -c shutdown

Clion使用openocd脚本

打开OpenOCD-20211118-0.11.0\share\openocd\scripts\board
新建一个脚本,建议用0开头,这样非常好找配置文件,例如0_stm32f103_dowm.cfg
脚本文件内容如下:
adapter driver jlink
transport select swd
source [find target/stm32f1x.cfg]
adapter speed 2000

vscode使用openocd下载脚本

vscode新建一个tasks.json

注意:
1.vscode下面路径分隔符不是"\",而是“/"
2.命令格式和cmd里面的不同
3.hex,写相对路径即可,(相对于vscode工作区的目录)
内容如下:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "label": "echo",
        "type": "shell",
        "command": "echo Hello",
    },
    {
        "type": "shell",
        "label": "download",
        "command": "openocd",
        "args": [
            "-c",
            "adapter driver jlink",
            "-c",
            "transport select swd",
            "-c",
            " adapter speed 1000",
            "-f"
            "target/stm32f1x.cfg",
            "-c", 
            // "program ${workspaceFolder}\\com.quest.firmware.bc.reader\\build\\debug\\BC_Reader_STM32F1_debug.hex",
            "program com.quest.firmware.bc.reader/build/debug/BC_Reader_STM32F1_debug.hex",
            "-c",
            "reset",
            "-c",
            "shutdown"
        ],
        "problemMatcher": [
            "$gcc"
        ],
        "group": "build",
        "dependsOn": "Build"
    }
]

}

运行vscode脚本

vscode顶上有个终端(T)->运行任务->download
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值