当前位置: 首页 > news >正文

openpnp - Smoothieware - LPC17xx-DFU-Bootloader - 固件调试环境搭建

文章目录

    • openpnp - Smoothieware - LPC17xx-DFU-Bootloader - 固件调试环境搭建
    • 概述
    • 笔记
    • 启动的脚本(start_eclipsecpp_with_msys2_arm_gcc_and_make.bat)中,要有arm-gcc工具链
      • start_eclipsecpp_with_msys2_arm_gcc_and_make.bat
    • 更改openocd用到的硬件调试器
    • 拷贝JLink.cfg为自己的配置文件
      • my-jlink-swd.cfg v0
      • my-jlink-swd.cfg v1
    • 备注
    • END

openpnp - Smoothieware - LPC17xx-DFU-Bootloader - 固件调试环境搭建

概述

接着笔记(Smoothieware - LPC17xx-DFU-Bootloader - study)做实验。
前面将硬件环境(openpnp - Smoothieware - MKS SGEN_L V1.0 + JLink-edu-mini 连接测试)搭好了。

现在搭建软件调试环境。
上次笔记(Smoothieware - LPC17xx-DFU-Bootloader - study),软件环境大致搭好了,但是那次实验是烧录bootloader, 并没有单步。

按照上次笔记留下的环境单步调试,有问题,修正一下。

笔记

启动的脚本(start_eclipsecpp_with_msys2_arm_gcc_and_make.bat)中,要有arm-gcc工具链

start_eclipsecpp_with_msys2_arm_gcc_and_make.bat启动的环境中,有arm-gcc工具链,否则eclipse不能正确编译工程。
但是单步调试时,eclipse报错,arm-none-eabi-gdb --version执行失败。
查了一下, msys2环境中,咋没有arm-none-eabi-gdb呢?


好奇怪,msys2中有arm-none-eabi-gcc.exe, 但是没有arm-none-eabi-gdb.exe. 这不都是一套东西么?

D:\tools\eclipse>where arm-none-eabi-gcc D:\my-arm-gnu-toolchain\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe C:\msys64\mingw64\bin\arm-none-eabi-gcc.exe D:\tools\eclipse>where arm-none-eabi-gdb D:\my-arm-gnu-toolchain\arm-gnu-toolchain\bin\arm-none-eabi-gdb.exe D:\tools\eclipse>

查了一下,arm-none-eabi-gdb在mysys2中要另外安装的,和arm-gcc不是一个包…

chenx@ls3561 MINGW64 ~ $ pacman -Ss arm-none-eabi-gdb mingw32/mingw-w64-i686-gdb-multiarch16.3-1(mingw-w64-i686-toolchain)GNU Debugger(supports all targets)mingw64/mingw-w64-x86_64-gdb-multiarch16.3-1(mingw-w64-x86_64-toolchain)[installed]GNU Debugger(supports all targets)ucrt64/mingw-w64-ucrt-x86_64-gdb-multiarch16.3-1(mingw-w64-ucrt-x86_64-toolchain)GNU Debugger(supports all targets)clang64/mingw-w64-clang-x86_64-gdb-multiarch16.3-1 GNU Debugger(supports all targets)

确认mysys2中已经安装了arm-gdb的包,为啥where不到arm-none-eabi-gdb呢?
那无法再用mysys2来重新安装arm-none-eabi-gdb,只能用从arm官方下载的工具链。
改一下 start_eclipsecpp_with_msys2_arm_gcc_and_make.bat,将arm-gcc的官方工具链加到path中。

start_eclipsecpp_with_msys2_arm_gcc_and_make.bat

将mysys2环境放在arm-gcc官方工具链前面,保证编译时,和mysys2命令行的环境一致,调试时,mysys2中没有arm-gdb, 就用arm-gcc官方的。

@echo off rem @file start_eclipsecpp_with_arm_gcc_and_make.bat rem @breif 通用的arm-gcc工具链,编译哪个工程都可以 rem C:\msys64\mingw64\bin 中有arm-none-eabi-*.exe 和 make.exe rem C:\msys64\usr\bin 中 curl.exesetpath=D:\my-arm-gnu-toolchain\arm-gnu-toolchain;D:\my-arm-gnu-toolchain\arm-gnu-toolchain\bin;%path%setpath=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%path% rem D:\tools\eclipse\eclipse-embedcpp-2025-09-R-win32-x86_64\eclipse 中有 eclipse-cpp.exesetpath=D:\tools\eclipse\eclipse-embedcpp-2025-09-R-win32-x86_64\eclipse;%path% start eclipse.exe cmd /k"echo %~nx0 && title %~nx0"

启动bat, eclipse-cpp启动后,在bat命令行中验证一下路径优先级。

start_eclipsecpp_with_msys2_arm_gcc_and_make.bat D:\tools\eclipse>where arm-none-eabi-gcc C:\msys64\mingw64\bin\arm-none-eabi-gcc.exe D:\my-arm-gnu-toolchain\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe D:\tools\eclipse>

可以了,可以保证eclipse-cpp和mysys2-mingw64命令行环境编译工程的效果相同。

更改openocd用到的硬件调试器

我这次实验,用的硬件调试器是JLink-edu-mini. 要在eclipse-cpp配置中,将openocd用到的调试器改为JLink.

-f interface/jlink.cfg -f target/lpc17xx.cfg


调试时,会显示LIBUSB_ERROR_NOT_FOUND失败信息。
查资料,说驱动不对。
需要将JLINK驱动换为普通USB驱动才行。
去(https://zadig.akeo.ie/)去下载zadig-2.9.exe, 以管理员身份运行。


JLink驱动,原来是JLINK自己的,换成libusb-win32(v1.4.0.0)后,用openocd命令行测试,不好使。
换成WinUSB(V6.1.7600.16385)是好使的。

现在openocd可以连接调试器了,但是用JFLASH连接调试器失效了,说通过USB找不到调试器。
在重新使用JFLASH之前,需要将JLINK官方软件重新装一下,让JLINK使用自己的USB驱动才行。

拷贝JLink.cfg为自己的配置文件

JLink.cfg默认是用JTAG接口来调试的,板子是SWD接口。
配置文件在D:\tools\openocd\openocd-v0.12.0-i686-w64-mingw32\share\openocd\scripts\interface
拷贝JLink.cfg为my-jlink-swd.cfg, 增加SWD接口选择的命令

my-jlink-swd.cfg v0

# SPDX-License-Identifier: GPL-2.0-or-later## SEGGER J-Link## http://www.segger.com/jlink.html#adapter driver jlink# The serial number can be used to select a specific device in case more than# one is connected to the host.## Example: Select J-Link with serial number 123456789## adapter serial 123456789transportselectswd

用openocd命令行临时测试

openocd -f interface/my-jlink-swd.cfg -f target/lpc17xx.cfg

测试成功,已经在监听端口了。

my-jlink-swd.cfg v1

在自己的配置文件中,除了指定SWD接口外,还可以指定通讯速率
用JFLASH测试过,4MHZ的通讯速率是可以的。

# SPDX-License-Identifier: GPL-2.0-or-later## SEGGER J-Link## http://www.segger.com/jlink.html#adapter driver jlink# The serial number can be used to select a specific device in case more than# one is connected to the host.## Example: Select J-Link with serial number 123456789## adapter serial 123456789# debug interface = SWDtransportselectswd# adapter speed = 4MHZadapter speed4000


现在可以在eclipse-cpp中设置openocd参数,试试是否可以单步调试?

-f interface/my-jlink-swd.cfg -f target/lpc17xx.cfg


可以正常调试。
在能正常调试之前,有一些超时告警,不管了。

Open On-Chip Debugger0.12.0(2023-01-14-23:37)Licensed under GNU GPL v2 For bug reports,readhttp://openocd.org/doc/doxygen/bugs.html adapter speed:4000kHz cortex_m reset_config sysresetreq Started by GNU MCU Eclipse Info:Listening on port6666fortcl connections Info:Listening on port4444fortelnet connections Info:J-Link EDU Mini V1 compiled Nov10202513:45:53 Info:Hardware version:1.00Info:VTarget=3.298V Info:clock speed10kHz Info:SWD DPIDR 0x2ba01477 Info:[lpc17xx.cpu]Cortex-M3 r2p0 processor detected Info:[lpc17xx.cpu]target has6breakpoints,4watchpoints Info:starting gdb serverforlpc17xx.cpu on3333Info:Listening on port3333forgdb connections Info:accepting'gdb'connection on tcp/3333 Warn:keep_alive()was not invokedinthe1000ms timelimit. GDB alive packet not sent!(1765ms). Workaround: increase"set remotetimeout"inGDB Warn:Prefer GDBcommand"target extended-remote :3333"instead of"target remote :3333"[lpc17xx.cpu]halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc[lpc17xx.cpu]halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc, semihosting Warn:keep_alive()was not invokedinthe1000ms timelimit. GDB alive packet not sent!(1036ms). Workaround: increase"set remotetimeout"inGDB Warn:keep_alive()was not invokedinthe1000ms timelimit. GDB alive packet not sent!(1750ms). Workaround: increase"set remotetimeout"inGDB Info:Padding image section0at 0x0000302c with4bytes Warn:Boot verification checksuminimage(0x00000000)to be written to flash is different from calculated vector checksum(0xefff1ea0). Warn:OpenOCD willwritethe correct checksum. To remove this warning modify build tools on developer PC to inject correct LPC vector checksum. Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:Failed to receive data from device: LIBUSB_ERROR_TIMEOUT Warn:keep_alive()was not invokedinthe1000ms timelimit. GDB alive packet not sent!(23689ms). Workaround: increase"set remotetimeout"inGDB[lpc17xx.cpu]halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc, semihosting Warn:keep_alive()was not invokedinthe1000ms timelimit. GDB alive packet not sent!(1060ms). Workaround: increase"set remotetimeout"inGDB[lpc17xx.cpu]halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc, semihosting Warn:keep_alive()was not invokedinthe1000ms timelimit. GDB alive packet not sent!(1066ms). Workaround: increase"set remotetimeout"inGDB

备注

至此,固件单步调试的环境(MKS SGEN_L V1.0 + JLink-edu-mini + Smoothieware/LPC17xx-DFU-Bootloader)就能用了。

END

http://www.jsqmd.com/news/89487/

相关文章:

  • E-Hentai批量下载工具:高效管理数字收藏资源的最佳方案
  • 新的Unicode标准 18.0有些什么? 小篆字会进入标准!
  • GUID为什么不会重复?
  • 深蓝词库转换:轻松打通全平台输入法数据壁垒
  • 【time-rs】time库 ConversionRange 错误类型详解(error/conversion_range.rs)
  • 理解 Cursor 的核心概念、优势和适用场景。
  • 雪花ID是什么?
  • 百度网盘直链解析工具:轻松获取高速下载链接的完整指南
  • 基于自适应启动策略的混合交叉动态约束多目标优化算法(MC-DCMOEA)求解CEC2018研究附Matlab代码
  • 以空间为核心的信息感知与态势管控关键技术研究
  • 自学嵌入式day30,回收进程
  • 考虑可再生能源消纳的电热综合能源系统日前经济调度模型研究附Matlab代码
  • [iOS原理] Block的本质
  • 农作物检测和识别2:基于深度学习YOLOv12神经网络实现农作物检测和识别(含训练代码和数据集)
  • 计及N-k安全约束的含光热电站电力系统优化调度模型【IEEE14节点、118节点】附Matlab代码
  • MlaProlog算子全景透视-结构流程与依赖关系深度分析
  • 2025低成本AI认证指南:从入门到进阶的高性价比路径盘点
  • 计及调度经济性的光热电站储热容量配置方法【IEEE30节点】附Matlab代码
  • 2025年应届生闭坑指南:如何挑选低费用、高认可度的AI技能证书?
  • 计及需求响应的粒子群算法求解风能、光伏、柴油机、储能容量优化配置附Matlab代码
  • 基于YOLOv12农作物检测系统1:农作物检测数据集说明(含下载链接)
  • Java 大视界 -- Java 大数据在智能物流仓储货位优化与库存周转率提升中的应用实战
  • MouseTester终极指南:5步完成专业鼠标性能测试
  • Python基础五:了解和使用常用类型int、float、bool、str
  • 百度首页 登录 托福培训机构怎么选?2025高性价比推荐指南(附选课攻略) - 品牌测评鉴赏家
  • 深度解析:2PC与Saga分布式事务模式的技术选型实战
  • 农作物检测和识别3:基于深度学习YOLOv12神经网络实现农作物检测和识别(含训练代码、数据集和GUI交互界面)
  • 2025年儿童OK镜佩戴注意事项TOP5推荐榜单
  • 2025 雅思培训班红榜|亲测 3 家宝藏机构,选对少走 99% 弯路 - 品牌测评鉴赏家
  • Python基础六:算数运算符、赋值运算符、逻辑运算符与比较运算符