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- ...
随机推荐
- 如何在vscode 背景配置一个动态小女孩
D:\Microsoft VS Code\resources\app\out\vs\code\electron-browser\workbench <!-- Copyright (C) Micr ...
- 我大抵是卷上瘾了,横竖睡不着!竟让一个Bug,搞我两次!
作者:小傅哥 博客:https://bugstack.cn 沉淀.分享.成长,让自己和他人都能有所收获! 一.前言:一个Bug 没想到一个Bug,竟然搞我两次! 我大抵是卷上瘾了,横竖都睡不着,坐起来 ...
- oracle-安装与访问、卸载
安装oracle 官网(http://oracle.com/ )下载oracle -->Oracle Database -->点击接受Accept --> 下载11g(Downloa ...
- org/apache/poi/POIXMLTypeLoader或者java.lang.NoSuchFieldError: RETURN_NULL_AND_BLANK
原因是之前我的poi和ooxml版本有点低, 解决方案 将两者版本提高,我是将两者的版本都提高到了3.15
- windows系统下.NET CORE c# 通过bat脚本发布iis应用程序,半智能点击式ci/cd
这里以git为例子讲解: 第一个 pullCode.bat 文件是 拉取代码 git pull 第二个 publish.bat 脚本,编译代码,并发布指定文件夹 dotnet publish &quo ...
- NuGetTools:批量上传、删除和显示NuGet包
快照 前言 NuGet是.NET开发必不可少的包管理工具,在日常更新版本过程中,可能需要批量发布 NuGet 包,也不可避免需要发布一些测试的包,后期想将这些测试或者过期的包删除掉.nuget.org ...
- Python语法糖,提升编程幸福感!!!
转载请注明出处️ 作者:测试蔡坨坨 原文链接:caituotuo.top/a52bc938.html 大家好,我是测试蔡坨坨. 今天,我们来盘点一下Python中的那些语法糖. 什么是语法糖?语法糖不 ...
- java 九九乘法表(for循环)
package study5ran2yl.study; public class ForDemo01 { public static void main(String[] args) { int h; ...
- 升级了Springboot版本后项目启动不了了
问题背景 项目上使用的springboot版本是2.1.1.RELEASE,现在因为要接入elasticsearch7.x版本,参考官方文档要求,需要将springboot版本升级到2.5.14. 本 ...
- 2022.7.9 单向链表&数组优化
相比起数组,链表解决了数组不方便移动,插入,删除元素的弊端,但相应的,链表付出了更加大的内存牺牲换来的这些功能的实现. 链表概述 包含单链表,双链表,循环单链表,实际应用中的功能不同,但实现方式都差不 ...