打印
[技术讨论]

使用VSCode调试全志R128的C906 RISC-V核心

[复制链接]
221|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
神棍地海棠|  楼主 | 2023-11-20 17:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
调试 XuanTie C906 核心准备工具
  • T-Head DebugServer(CSkyDebugServer) - 搭建调试服务器
  • 下载地址:[color=var(--md-typeset-a-color)]T-Head DebugServer
  • 手册:[color=var(--md-typeset-a-color)]T-Head Debugger Server User Guide
  • 驱动:[color=var(--md-typeset-a-color)]cklink_dirvers
  • VSCode - 开发&调试
  • 下载地址:[color=var(--md-typeset-a-color)]VSCode
配置 SDK 启用调试功能
[color=rgba(0, 0, 0, 0.87)]在对应的C906的 main.c 函数最后面加上下列代码,配置 GPIO MUX 为 JTAG
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">writel(0x00f66660, 0x4004a40c);
[color=rgba(0, 0, 0, 0.87)][color=var(--md-typeset-a-color)]
[color=rgba(0, 0, 0, 0.87)]参考手册:
[color=rgba(0, 0, 0, 0.87)][color=var(--md-typeset-a-color)]
[color=rgba(0, 0, 0, 0.87)]然后编译下载。
安装驱动
[color=rgba(0, 0, 0, 0.87)]连接上CKLink,在设备管理器新增的USB设备上->右键->更新驱动程序->浏览我的电脑以查找驱动程序->浏览对应的驱动然后包括子文件夹->然后下一步即可。
[color=rgba(0, 0, 0, 0.87)][color=var(--md-typeset-a-color)]
运行配置CSkyDebugServer code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">CSkyDebugServer->setting->Target Setting
[color=rgba(0, 0, 0, 0.87)][color=var(--md-typeset-a-color)]
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">CSkyDebugServer->setting->Socket Setting
[color=rgba(0, 0, 0, 0.87)][color=var(--md-typeset-a-color)]
启动CSkyDebugServer
[color=rgba(0, 0, 0, 0.87)]确保R128正常运行,CKLink 正常连接,点击红色按钮启动调试
[color=rgba(0, 0, 0, 0.87)][color=var(--md-typeset-a-color)]
[color=rgba(0, 0, 0, 0.87)]此时如果电脑本地上有编译环境,可以使用 riscv64-unknown-elf-gdb 进行调试,假设编译获得的文件路径为 /lichee/rtos/build/r128_module_c906/img/rt_system.elf,运行命令如下:
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">riscv64-unknown-elf-gdb -ex 'set arch riscv:rv64' -ex 'file ./lichee/rtos/build/r128_module_c906/img/rt_system.elf' -ex 'set remotetimeout 20' -ex 'target remote 127.0.0.1:3333'
[color=rgba(0, 0, 0, 0.87)]也可以如下操作
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">riscv64-unknown-elf-gdb ./lichee/rtos/build/r128_module_c906/img/rt_system.elf控制台界面输入set remotetimeout 20target remote :3333才可以建立连接配置 VSCode
[color=rgba(0, 0, 0, 0.87)]配置如下 .vscode/launch.json 文件
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">{    // Use IntelliSense to learn about possible attributes.    // Hover to view descriptions of existing attributes.    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387    "version": "0.2.0",    "configurations": [        {            "name": "(gdb) Launch",            "type": "cppdbg",            "request": "launch",            "program": "${workspaceFolder}/lichee/rtos/build/r128_module_c906/img/rt_system.elf", // 对应板子方案的elf文件            "args": [],            "stopAtEntry": false,            "cwd": "${fileDirname}",            "environment": [],            "externalConsole": false,            "MIMode": "gdb",            "miDebuggerPath": "${workspaceFolder}/lichee/rtos/tools/riscv64-elf-x86_64-20201104/bin/riscv64-unknown-elf-gdb",            "miDebuggerServerAddress": "localhost:3333", // 端口号,本文电脑的CSkyDebugServer端口3333            "setupCommands": [ // 不能省略否则会报错,报错如下                {                    "description": "Enable pretty-printing for gdb",                    "text": "set remotetimeout 20",                    "ignoreFailures": true                }            ]        }    ]}
[color=rgba(0, 0, 0, 0.87)]省略后的报错:
code" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: inherit; font-family: inherit; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-width: 0px; border-style: initial; border-color: initial; position: absolute; top: 0.5em; right: 0.5em; z-index: 1; width: 1.5em; height: 1.5em; border-radius: 0.1rem; outline: none; outline-offset: 0.1rem; cursor: pointer; transition: color 0.25s ease 0s;">Remote replied unexpectedly to 'vMustReplyEmpty': PacketSize=1000;QStartNoAckMode+;qThreadExtraInfo+;qXfer:features:read+开始调试
[color=rgba(0, 0, 0, 0.87)]点击 VSCode 调试按键,开始调试。
[color=rgba(0, 0, 0, 0.87)][color=var(--md-typeset-a-color)]

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

191

主题

199

帖子

0

粉丝