发帖
3 0 0

openocd调试bl602

hdydy
论坛元老

39

主题

84

回帖

5816

积分

论坛元老

积分
5816
Rd-01系列 47 3 前天 16:12
[i=s] 本帖最后由 hdydy 于 2025-4-14 16:14 编辑 [/i]

Rd-01板载的bl602芯片支持jtag调试,下面用openocd+cmsis-dap调试bl602

jtag调试需要4个IO,还好Rd-01留了5个IO,不然没办法用jtag调试
image.png

一、设置jtag引脚

bl602默认jtag引脚为GPIO11,GPIO12,GPIO14,GPIO17
image.png

Rd-01只有GPIO1,GPIO2,GPIO4,GPIO5,GPIO17,所以需要修改jtag引脚。根据数据手册,最终选择这4个引脚GPIO1,GPIO2,GPIO4,GPIO17
image.png
image.png

最终接线为
image.png

修改代码

#include "bl602_glb.h"

void bl602_jtag_init() {
    // GLB_GPIO_Type pin = GLB_GPIO_PIN_11;
    // GLB_GPIO_Func_Init(GPIO_FUN_JTAG, &pin, 1);
    // pin = GLB_GPIO_PIN_12;
    // GLB_GPIO_Func_Init(GPIO_FUN_JTAG, &pin, 1);
    // pin = GLB_GPIO_PIN_14;
    // GLB_GPIO_Func_Init(GPIO_FUN_JTAG, &pin, 1);
    // pin = GLB_GPIO_PIN_17;
    // GLB_GPIO_Func_Init(GPIO_FUN_JTAG, &pin, 1);
    GLB_GPIO_Type pins[4] = {GLB_GPIO_PIN_1, GLB_GPIO_PIN_2, GLB_GPIO_PIN_4, GLB_GPIO_PIN_17};// TDI,TCK,TMS,TDI
    GLB_GPIO_Func_Init(GPIO_FUN_JTAG, pins, 4);
    GLB_JTAG_Sig_Swap_Set(JTAG_SIG_SWAP_GPIO16_GPIO19);// GLB_GPIO_PIN_17 TDI -> TDO
}

image.png
image.png

编译,烧录,重启

烧录教程https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=46160

二、测试jtag连接

获取openocd

官方https://openocd.org/pages/getting-openocd.html

或者下载https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=46140中的附件

修改配置,tgt_602_xip_attach.cfg中用到了新版openocd舍弃的命令 riscv set_prefer_sba on,需要替换为 riscv set_mem_access sysbus progbuf abstract
image.png

将 TDI,TCK,TMS,TDO,3V3,GND对应接好,cmsis-dap插入电脑,openocd连接bl602
image.png

出现如下结果表示连接成功
image.png

如果提示端口错误,可以查看6666端口是否被占用 netstat -ano | findstr 6666,杀掉占用6666端口的进程后重试,taskkill /f /pid <PID>

三、调试

配置文件
image.png

设置断点后调试,可以单步,查看变量值和内存
image.png
image.png

执行gdb命令
image.png

已知bug,如果不设断点,运行(F5)之后无法暂停(F6)

──── 0人觉得很赞 ────

使用道具 举报

前天 16:19
f5是全速运行吧
前天 17:52

eclipse中运行之后也可以打断(暂停)
https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=46172
您需要登录后才可以回帖 立即登录
高级模式
返回
统计信息
  • 会员数: 28427 个
  • 话题数: 40507 篇