VsCode-解决Jlink驱动导致的程序烧录和调试的问题

目录

  1. 问题现象
  2. 原因分析
  3. 解决方法
  4. 插件配置


本案例以 HC32 芯片平台为例进行问题解决。


1. 问题现象

1.1 程序能正常编译成功

在这里插入图片描述


1.2 烧录程序进度条正常,但程序hex文件烧写失败

在这里插入图片描述


1.3 能正常进入调试界面,但未跳转到main函数入口或调试运行错乱

在这里插入图片描述


2. 原因分析

  • Embedded IDE 实用工具安装里面的Jlink驱动版本过低,缺少对应芯片驱动或驱动不完善导致;

在这里插入图片描述


  • 若进行了升级分区,更改了程序的起始运行地址,就会导致 Hex文件烧写不成功;

在这里插入图片描述


  程序能编译成功,且编译生成的hex文件起始偏移地址是0x2800;但.eide/tools/jlink 版本过低,不完善使得程序烧写可能是从偏移地址0开始烧写的,使用Embedded IDE 烧录可能烧写成功,有可能烧写不成功,但hex文件是烧写失败的。

3. 解决方法

  • 使用独立安装的最新版Jlink驱动程序 ,此处安装的是 JLink_V796,安装目录 D:/tool/Jlink/JLink_V796q ;
  • 在 VsCode 中,需要对 J-Link 相关的调试配置文件进行正确设置;


4. 插件配置

4.1 Embedded IDE 更改 jlink路径

在这里插入图片描述


4.2 Cortex-Debug 更改 setting.json文件

原配置
{
    "C_Cpp.default.compilerPath": "D:mingw\\MinGW\\bin\\gcc.exe",
    "files.autoGuessEncoding": true,
    "EIDE.ARM.Option.AxfToElf": true,
    "editor.wordWrap":"on",
    "EIDE.DisplayLanguage": "zh-cn",
    "EIDE.OpenOCD.ExePath": "${userRoot}/.eide/tools/openocd_7a1adfbec_mingw32/bin/openocd.exe",
    "EIDE.JLink.InstallDirectory": "${userRoot}/.eide/tools/jlink",
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    "EIDE.SDCC.InstallDirectory": "${userRoot}/.eide/tools/sdcc",
    "cortex-debug.armToolchainPath": null,
    "cortex-debug.openocdPath":null,
    "cortex-debug.JLinkGDBServerPath": null,
    "EIDE.Cppcheck.ExecutablePath": "${userRoot}/.eide/tools/cppcheck/cppcheck.exe",
    "workbench.editorAssociations": {
        "*.FLM": "default"
    },
    "workbench.startupEditor": "none",
    "EIDE.STLink.ExePath": "${userRoot}/.eide/tools/st_cube_programer/bin/STM32_Programmer_CLI.exe",
    "EIDE.ARM.INI.Path": "",
    "EIDE.C51.INI.Path": ""
}

更改后的配置
{
        "C_Cpp.default.compilerPath": "D:mingw\\MinGW\\bin\\gcc.exe",
        "files.autoGuessEncoding": true,
        "EIDE.ARM.Option.AxfToElf": true,
        "editor.wordWrap":"on",
        "EIDE.DisplayLanguage": "zh-cn",
        "EIDE.OpenOCD.ExePath": "${userRoot}/.eide/tools/openocd_7a1adfbec_mingw32/bin/openocd.exe",
        "EIDE.JLink.InstallDirectory":  "D:/tool/Jlink/JLink_V796q",
        "terminal.integrated.defaultProfile.windows": "PowerShell",
        "EIDE.SDCC.InstallDirectory": "${userRoot}/.eide/tools/sdcc",
        "cortex-debug.armToolchainPath": null,
        "cortex-debug.openocdPath":null,
       "cortex-debug.JLinkGDBServerPath": "D:/tool/Jlink/JLink_V796q/JLinkGDBServerCL.exe",
        "EIDE.Cppcheck.ExecutablePath": "${userRoot}/.eide/tools/cppcheck/cppcheck.exe",
        "workbench.editorAssociations": {
            "*.FLM": "default"
        },
        "workbench.startupEditor": "none",
        "EIDE.STLink.ExePath": "${userRoot}/.eide/tools/st_cube_programer/bin/STM32_Programmer_CLI.exe",
        "EIDE.ARM.INI.Path": "",
        "EIDE.C51.INI.Path": ""
    }


主要是下面2处配置更改为新版Jlink安装的路径对应:

  • “EIDE.JLink.InstallDirectory”: “D:/tool/Jlink/JLink_V796q”,
  • “cortex-debug.JLinkGDBServerPath”: “D:/tool/Jlink/JLink_V796q/JLinkGDBServerCL.exe”,

上述配置更改成功后,要将所有打开的VsCode进行关闭, 然后重新打开工程即可正常使用.

重新编译工程,能正常进行程序烧录:

在这里插入图片描述


进入debug调试界面后,能正常进行程序调试:

在这里插入图片描述





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值