当存在多个 J-Link 版本时,SDK 安装包只会为最近安装的 J-Link 软件添加芯片支持包;
SDK 安装包目前不支持为 pyOCD 等工具添加芯片支持包。对于这些情况,可以使用 SDK 附带的
Python 脚本 ingchips_packs_addon.py
为调试工具添加芯片程序下载和调试支持。
通过 -h 参数获取脚本使用帮助:
python ingchips_packs_addon.py -h
pyOCD
假设 SDK 安装目录为 C:\Programs\ING_SDK。
安装 pyOCD
pip install pyocd
使用镜像源加速pyocd安装
pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple pyocd
更新 pack 索引
注意必须先更新pack索引否则更新pack支持可能会失败
pyocd pack update
执行 Python 脚本
python ingchips_packs_addon.py -t pyocd -tp "C:/Programs/ING_SDK"
J-Link
假设 SDK 安装目录为 C:\Programs\ING_SDK。
V6.80 - V7.60 版本
假设 J-Link 的安装目录为 C:\Program Files (x86)\SEGGER\JLink_V630d
执行 Python 脚本
python ingchips_packs_addon.py -t jlink_v6 -p "C:/Program Files (x86)/SEGGER/JLink_V630d" -tp "C:/Programs/ING_SDK"
V7.62 以上
执行python脚本
python ingchips_packs_addon.py -t jlink_v7 -tp "C:/Programs/ING_SDK"
pyOCD 新版本更新出现的问题(版本大于0.36.0)
pyOCD 版本 >= 0.36.0版本默认关闭了源码的双缓冲区烧录,导致烧录速度性能下降(官方关闭该功能原因未知)。并且新版本的日志格式变化导致 VSCode 的 Cortex-Debug 插件无法正常连接识别 gdb 服务器的启动。
烧录速度性能下降解决方案
直接修改源码增加双缓冲机制。
-
克隆仓库源码
git clone https://github.com/pyocd/pyOCD.git -
打开安装的 pyOCD 版本源码 (打开源码,打开类似如下路径的 builder.py 文件。)
path\to\pyocd\flash\builder.py -
打开这个文件找到文件的204行,查看到源代码如下:
... def __init__(self, flash): super().__init__() self.flash = flash self.flash_start = flash.region.start self.flash_operation_list = [] self.sector_list: List[_FlashSector] = [] self.page_list: List[_FlashPage] = [] self.perf = ProgrammingInfo() self.enable_double_buffering = False self.log_performance = True self._buffered_data_size = 0 self.program_byte_count = 0 self.sector_erase_count = 0 self.chip_erase_count = 0 # Number of pages to program using chip erase method. self.chip_erase_weight = 0 # Erase/program weight using chip erase method. self.sector_erase_count = 0 # Number of pages to program using sector erase method. self.sector_erase_weight = 0 # Erase/program weight using sector erase method. self.algo_inited_for_read = False ...将
self.enable_double_buffering = False修改为self.enable_double_buffering = True这样开启双缓冲可以加速下载。 -
在项目根目录重新安装
python -m pip install -e .
Cortex-Debug 插件无法连接的方案
为 VSCode 的 launch.json 文件添加对应的配置信息:
"overrideGDBServerStartedRegex": "(started|Listening) on port"
pyOCD 使用 launch.json 文件的示例:
{
"version": "0.2.0",
"configurations": [
{
"name": "Cortex Debug (pyOCD + ING916XX)",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/cmake-build-debug-mingw-arm/ING20XX",
"servertype": "pyocd",
"targetId": "ING91600",
"runToEntryPoint": "app_main",
"interface": "swd",
"armToolchainPath": "C:\\arm_gcc\\bin\\",
"showDevDebugOutput": "raw",
"overrideGDBServerStartedRegex": "(started|Listening) on port"
}
]
}
使用时:
-
executable需要替换为实际的 elf 文件路径; -
targetId需要替换为实际的芯片 id; -
armToolchainPath需要替换为实际的arm-none-eabi-gdb文件所在路径。
