HC32L110(五) Ubuntu20.04 VSCode的Debug环境配置
目录
- HC32L110(一) HC32L110芯片介绍和Win10下的烧录
- HC32L110(二) HC32L110在Ubuntu下的烧录
- HC32L110(三) HC32L110的GCC工具链和VSCode开发环境
- HC32L110(四) HC32L110的startup启动文件和ld连接脚本
- 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-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb -q --interpreter=mi2
/opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb: error while loading shared libraries: libncursesw.so.5: cannot open shared object file: No such file or directory
观察ldd可以看到缺少两个so: libncursesw.so.5, libpython3.6m.so.1.0
ldd /opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb
linux-vdso.so.1 (0x00007ffc82998000)
libncursesw.so.5 => not found
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f326ba1e000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f326ba18000)
libpython3.6m.so.1.0 => not found
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f326b9f5000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f326b9f0000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f326b89f000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f326b871000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f326b68f000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f326b674000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f326b482000)
/lib64/ld-linux-x86-64.so.2 (0x00007f326ba6e000)
libncursesw.so.5可以通过安装 libncursesw5 可以解决
sudo apt install libncursesw5
2. libpython3.6m.so.1.0: cannot open shared object file
这样就剩下另一个动态连接库无法找到
/opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb -q --interpreter=mi2
/opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
但是 Ubuntu20.04 自带的 Python3.8, 无法安装 Python3.6
~$ sudo apt-get install libpython3.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libpython3.6-stdlib' for regex 'libpython3.6'
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.
简单粗暴的解决方法就是直接用3.8的代替
cd /usr/lib/x86_64-linux-gnu/
$ ll libpython*
lrwxrwxrwx 1 root root 19 Jul 1 20:27 libpython2.7.so.1 -> libpython2.7.so.1.0
-rw-r--r-- 1 root root 3455600 Jul 1 20:27 libpython2.7.so.1.0
lrwxrwxrwx 1 root root 55 Jun 23 04:18 libpython3.8.a -> ../python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a
lrwxrwxrwx 1 root root 17 Jun 23 04:18 libpython3.8.so -> libpython3.8.so.1
lrwxrwxrwx 1 root root 19 Jun 23 04:18 libpython3.8.so.1 -> libpython3.8.so.1.0
-rw-r--r-- 1 root root 5449112 Jun 23 04:18 libpython3.8.so.1.0
$ sudo ln -s libpython3.8.so.1.0 libpython3.6m.so.1.0
这时候再运行就可以启动了
$ /opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb -q --interpreter=mi2
/opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb: Symbol `PyBool_Type' has different size in shared object, consider re-linking
/opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb: Symbol `PySlice_Type' has different size in shared object, consider re-linking
/opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb: Symbol `PyFloat_Type' has different size in shared object, consider re-linking
=thread-group-added,id="i1"
(gdb)
使用
点击 Run And Debug 中的绿色运行图标启动Debug, F10 下一步, F11 进入, Shift + F11 跳出. 左侧能观察到变量值和寄存器值. 操作方法和其它IDE基本一致.
参考
Cortex-Debug Wiki https://github.com/Marus/cortex-debug/wiki
Matej Blagšič: Debugging STM32 in VSCODE with stlink and jlink https://www.youtube.com/watch?v=g2Kf6RbdrIs
Cortex-Debug 参数说明 https://github.com/Marus/cortex-debug/blob/master/debug_attributes.md
libpython3.6m.so.1.0: cannot open shared object file: No such file or directory https://github.com/JacquesLucke/animation_nodes/issues/906
How to install libpython3.6m.so.1.0 on ubuntu 20.04 https://askubuntu.com/questions/1404248/how-to-install-libpython3-6m-so-1-0-on-ubuntu-20-04
HC32L110(五) Ubuntu20.04 VSCode的Debug环境配置的更多相关文章
- 联盛德 HLK-W806 (一): Ubuntu20.04下的开发环境配置, 编译和烧录说明
目录 联盛德 HLK-W806 (一): Ubuntu20.04下的开发环境配置, 编译和烧录说明 联盛德 HLK-W806 (二): Win10下的开发环境配置, 编译和烧录说明 联盛德 HLK-W ...
- Ubuntu 16.04+1080Ti机器学习基本环境配置【转】
本文转载自:https://blog.csdn.net/MahoneSun/article/details/80808930 一.设置网络 机器有两张网卡,将当前正在使用的“有线连接1”配置为以下的设 ...
- VSCode Java 开发环境配置 详细教程
VSCode Java 开发环境配置 详细教程 配置java 下载 用于现在大多数使用者用的是java 8,小白的我先安装java 8好了,^ w ^. 下载地址:Java 8 | Java SE 打 ...
- VSCode PHP 开发环境配置 详细教程
VSCode PHP 开发环境配置 详细教程 这篇文章主要介绍了VScode+PHPstudy配置PHP开发环境的步骤,整理了官方以及优秀第三方的内容,对于学习和工作有一定借鉴意义. 配置过程 第一步 ...
- VScode中python环境配置
vscode中python环境配置 想要在vscode中运行python代码必须要告诉vscode使用哪个解释器才行 方法1. 打开命令面板(Ctrl+Shift+P)输入Python: Select ...
- Ubuntu 16.04下的LAMP环境配置
在学习开发过程中,每当遇到新的问题时,通常都能在网上搜到解决的方法,但是网上的方法千千万,有些是已经过时了的,有些是跟自己开发环境不同的,总是不能第一时间能找到答案. 而当时遇到的问题可能在今后的开发 ...
- 自动化kolla-ansible部署ubuntu20.04+openstack-victoria之物理机配置-01
自动化kolla-ansible部署ubuntu20.04+openstack-victoria之物理机配置-01 欢迎加QQ群:1026880196 进行交流学习 近期我发现网上有人转载或者复制 ...
- 从零开始安装搭建win10与ubuntu20.04双系统开发环境——集安装、配置、软件、美化、常见问题等于一体的——超详细教程
目录 **前言 ** 关于系统安装配置与软件安装 一.Win10安装ubuntu20.04双系统 1.按照自己的需求分区 2.配置软件镜像源 软件包管理工具介绍 更换APT源--使用国内镜像 3.解决 ...
- ubuntu 16.04 vscode + php debug
1.vscode 安装PHP Debug扩展: 2.php环境配置: 1.安装xdebug扩展: sudo apt-get install php-xdebug 2.找到扩展的路径: chq@chq- ...
随机推荐
- 文件上传漏洞靶场分析 UPLOAD_LABS
文件上传漏洞靶场(作者前言) 文件上传漏洞 产生原理 PASS 1) function checkFile() { var file = document.getElementsByName('upl ...
- 实现领域驱动设计 - 使用ABP框架 - 解决方案概览
.NET解决方案的分层 下图显示了使用ABP的 应用启动模板 创建的Visual Studio解决方案: 解决方案名称为问题跟踪,它由多个项目组成.通过考虑DDD原则以及开发和部署实践,该解决方案是分 ...
- 关于vue cli 使用iview 自定义主题遇到的坑
定制主题,这里讲变量覆盖 当你老老实实的把上面文档中的代码一一复制粘贴到项目文件中时,发现了还没装less,所以你就 npm install less –savenpm install less-lo ...
- ASP.NET Core 根据环境变量支持多个 appsettings.json配置文件 (开发和生产)
新建一个项目,web根目录会出现一个 appsettings.json 配置文件, 此时添加--新建项,输入 appsettings.Development.json 再新增一个,appsetti ...
- Tapdata “设擂招贤”携手 LeetCode 举办全球极客技术竞赛
2021年11月28日 Tapdata 专场全球极客技术竞赛将在 LeetCode 平台开赛,面向程序员"设擂招贤",打擂成功的前50名挑战者将优先获得 Tapdata 高端技 ...
- HashSet集合介绍和哈希值
HashSet集合介绍 ~java.util.Set接口 extends Collection 接口~Set接口的特点: 1.不允许存储重复的元素 2.没有索引,没有带索引的方法,也不能使用普通的fo ...
- IDEA的项目结构和IDEA的HelloWord
IDEA首次驱动 1. 选择不导入任何设置,点击 OK 2. 选择 Create New Project 3. 点击 new 按钮,配置安装的 JDK9 版本 选择 JDK9 目录,点击确定 4. 不 ...
- 攻防世界进阶区MISC ——56-60
56.low 得到一张bmp,世纪之吻,扔进kali中,binwalk,zsteg,无果,再放进stegsolve中,虽然发现小的数据块,但是过滤通道得不到任何信息,猜测是要用脚本进行 # lsb隐写 ...
- C++学习日记:关于我决定开始学习C++的那些事
苦恼于Python运行时感人的速度,我决定学习C++. 为了激励我自己好好地学习这门未曾谋面的编程语言,我决定在此开设专栏:C++学习日记.希望在读者们的监督下,我可以早日掌握这门语言.当然,如果那位 ...
- 构建 API 的7个建议【翻译】
迄今为止,越来越多的企业依靠API来为客户提供服务,以确保竞争的优势和业务可见性.出现这个情况的原因是微服务和无服务器架构正变得越来越普遍,API作为其中的关键节点,继承和承载了更多业务. 在这个前提 ...