设为首页 加入收藏

TOP

HC32L110(五) Ubuntu20.04 VSCode的Debug环境配置(一)
2023-07-23 13:27:59 】 浏览:64
Tags:HC32L110 Ubuntu20.04 VSCode Debug

目录

本文介绍在Ubuntu20.04下, VSCode中如何设置对 HC32L110 进行 debug

仓库地址: https://github.com/IOsetting/hc32l110-template

如果转载, 请注明出处.

环境说明

本文使用的软硬件环境已经在前面介绍

硬件

  • 基于 HC32L110 系列MCU的开发板
  • JLink OB

软件

  • Ubuntu20.04
  • VSCode

配置步骤

安装配置 Cortex-Debug

在VSCode的插件中, 搜索安装Cortex-Debug

在VSCode中, 切换到Run And Debug, 点击上方的 Add Configuration, 会在 .vscode 目录下的 launch.json (如果没有会自动创建)中添加配置, 需要增加对应的配置信息

"configurations": [
        {
            "name": "Cortex Debug",
            "cwd": "${workspaceFolder}",
            "executable": "${workspaceFolder}/Build/app.elf",
            "request": "launch",        // 可以是launch或attach, 后者表示运行中接入, 前者会执行前置任务并重启
            "type": "cortex-debug",
            "runToEntryPoint": "main",
            "servertype": "jlink",
            "device": "HC32L110X4",     // 如果是32K的版本, 需要修改为 HC32L110X6
            "interface": "swd",
            "runToMain": true,          // false则从 reset handler 开始停留
            "preLaunchTask": "build",   // 根据 tasks.json 中配置的任务填写, 
            // "preLaunchCommands": ["Build all"], // 如果不使用 preLaunchTask, 可以用这个参数指定命令行命令
            "svdFile": "",              // svd 用于观察外设
            "showDevDebugOutput": "vscode", // 输出的日志级别, parsed:解析后的内容, raw:直接输出, vscode:包含scode调用和raw
            "swoConfig":
            {
                "enabled": true,
                "cpuFrequency": 24000000,
                "swoFrequency":  4000000,
                "source": "probe",
                "decoders":
                [
                    {
                        "label": "ITM port 0 output",
                        "type": "console",
                        "port": 0,
                        "showOnStartup": true,
                        "encoding": "ascii"
                    }
                ]
            }
        }
    ]

具体的配置项含义, 可以参考 Debug Attributes

同时在 .vscode/settings.json 中增加以下配置, 如果文件不存在则创建. 路径根据自己的环境修改

{
    "cortex-debug.gdbPath": "/opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb",
    "cortex-debug.JLinkGDBServerPath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",
}

修改 rules.mk

在rules.mk中开启debug, 涉及到两处, OPT要使用-O0, 表示不执行任何优化. 使用优化后代码中的部分变量在编译后会被丢弃无法跟踪

OPT         ?= -O0

CFLAGS中增加gdb输出

CFLAGS      += -g -gdwarf-2 # original: -g

这样编译后, 尺寸会比原先大不少

Ubuntu20.04下遇到的问题

以上配置后, 点击 Run And Debug 中的绿色运行图标应该就能启动Debug, 但是可能在看到以下输出后就没有反应了

Reading symbols from /opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-objdump --syms -C -h -w /home/milton/Stm32Projects/hc32_workspace/hc32l110-template/Build/app.elf
Reading symbols from /opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-nm --defined-only -S -l -C -p /home/milton/Stm32Projects/hc32_workspace/hc32l110-template/Build/app.elf
Launching GDB: /opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb -q --interpreter=mi2
1-gdb-version

这时候到命令行执行一下命令/opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb -q --interpreter=mi2就能看到问题

1. libncursesw.so.5: cannot open shared object file

首先是会有这样的错误输出

/opt/gcc-arm/gcc-arm-
首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇物联网技术基础及应用绪论 下一篇巴西针对电源产品的新法规

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目