4 Ozone

4.1 Ozone下载和配置方法

  1. 下载Ozone
    可以直接在Segger公司官网下载,如果是windows系统,选择windows版本,Ozone版本可以选择最新的 alt text
    Segger公司的在线调试工具下载地址
    Ozone - The J-Link Debugger Windows 64-bit Installer [调试死机方法]
    注意:
    高版本Ozone和Jlink超过V7.6后的版本,对盗版的Jlink调试器存在检查的问题,对于学习用途的开发者可以推荐Ozone_Windows_V320d_x64.exeJLink_Windows_V758a_x86_64.exe

  2. 配置Device、MCU外设寄存器和RT-Thread OS脚本
    A. 把SiFli-SDK\tools\flash\jlink_drv\JLinkDevices.xml文件替换Ozone配置C:\Users\yourname\AppData\Roaming\SEGGER\JLinkDevices\JLinkDevices.xml,另外C:\Users\yourname\AppData\Roaming\SEGGER\JLinkDevices\Devices\目录下,要创建一个目录SiFli,并把SiFli-SDK-i\tools\flash\jlink_drv\sf32lb52x\SF32LB52X_*.elf复制过去,对应目录和文件如下:
    alt text
    Jlink烧录驱动对应关系见文件JLinkDevices.xml的内容:

<Device>
   <ChipInfo Vendor="SiFli" Name="SF32LB52X_NOR" Core="JLINK_CORE_CORTEX_M33" WorkRAMAddr="0x20000000" WorkRAMSize="0x60000" />
   <FlashBankInfo Name="Internal Flash1" BaseAddr="0x10000000" MaxSize="0x8000000"  Loader="Devices/SiFli/SF32LB52X_INT_FLASH1.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
   <FlashBankInfo Name="External Flash2" BaseAddr="0x12000000" MaxSize="0x8000000" Loader="Devices/SiFli/SF32LB52X_EXT_FLASH2.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
</Device>

B. 把D:\sifli\git\SiFli-SDK-i\tools\svd_external\SF32LB52X\SF32LB52x.*外设寄存器配置文件复制到C:\Program Files\SEGGER\Ozone\Config\Peripherals目录下;
C. 把SiFli-SDK\tools\segger\RtThreadOSPlugin.js复制到C:\Program Files\SEGGER\Ozone\Plugins\OS\目录下,对应目录和文件如下:
alt text
配置A/B/C三项后,打开Ozone后,可以选择到需要调试的Devices和MCU外设寄存器
alt text

配置好MCU外设寄存器和RT-Thread OS脚本后,进入Ozone界面,可以查看对应MCU外设寄存器和OS线程
alt text

4.2 Ozone DebugConnection failed

prompt:
alt text

You need to add the flash driver and XML configuration file as with JLink, so that Ozone supports the SF32LB55X chip;.

C:\Program Files\SEGGER\Ozone\Devices\SiFli\SF32LB55X****.elf
C:\Program Files\SEGGER\Ozone\JLinkDevices.xml
#不同Jlink或者Ozone版本的路径可能如下:
C:\Users\yourname\AppData\Roaming\SEGGER\JLinkDevices.xml
C:\Users\yourname\AppData\Roaming\SEGGER\JLinkDevices\Devices\SF32LB55X****.elf

4.3 Ozone单步调试Debug

1, Jlink默认connect会连接到hcpu,如果调试Hcpu,这一步可以跳过,直接debug Hcpu,如果要debug Lcpu,可以在windows cmd命令窗口执行SDK\tools\segger\jlink_lcpu_a0.bat(55),jlink_lcpu_pro.bat(58),jlink_lcpu_56x.bat(56), 执行该批处理,执行的是\tools\segger\jlink_lcpu_xxx.jlink里面的几条命令:

w4 0x4004f000 1
connect
w4 0x40070000 0 
exit

也可以直接在Jlink窗口依次输入这两条命令,切换到lcpu.
alt text

也可以在代码中,写寄存器把SWD Jlink切到Lcpu调试;
2, 现在以55为例,演示Lcpu单步运行, 先创建一个新项目
alt text

3, Select debug chip, If not found,Need to be in C:\Program Files\SEGGER\Ozone\JLinkDevices.xml Add 55x chip model configuration 和C:\Program Files\SEGGER\Ozone\Devices\SiFli\SF32LB55X_**.elf 四个flash烧录文件
alt text

4, Select the JLink device connected to the PC. If not found, check the JLink connection and JLink power supply;
5, Select the one you compiled
.axf或者
.elf文件,如果是watch_demo工程,Lcpu的axf路径会在

\release\example\rom_bin\lcpu_general_ble_img\lcpu_general_551.axf

alt text

6,选择Jlink或者SifliUsartServer.exe虚拟的ip
alt text
52默认为uart为调试口,需要SifliUsartServer.exe连接后,用ip 127.0.0.1:19025 alt text
7,下一步是选择初始化PC指针和初始的堆栈从哪里获取,选择默认或者选择Do no set选项都行, finish完成
alt text

8, Attach并且halt Program 就是让jlink连接到lcpu,并停在当前运行的PC指针, Attch并且Running Program就是让jlink连接到lcpu,并且开始从当前PC继续运行程序,
alt text

9,点击运行程序箭头图标后, 可以看到lcpu已经可以单步运行,可以添加断点,查看栈信息和寄存器状态.
alt text

4.4 Ozone连接后出现断连问题

Often, after being connected for a while, the following Target Connection Lost dialog box appears, and then the connection is lost;
alt text

如果碰到以上问题,在连接Ozone进行调试前,请关闭Ozone的内存Memory窗口和其他不用的窗口,如下窗口读取了不存在的内存地址或者读取了尚未初始化好的PSRAM内存:
alt text
因为Ozone在连接的时候去读这些内存内容,如果读取失败就会出现断连。

4.5 Ozone enables RTThread RTOS online debugging

Copy the \sdk\tools\segger\RtThreadOSPlugin.js file to the installation directory of Ozone;:
C:\Program Files\SEGGER\Ozone\Plugins\OS\RtThreadOSPlugin.js
And open this file, follow the steps below, you can use Ozone to switch RTThread threads online for viewing and debugging;。
alt text

After Ozone is connected, and Project.SetOSPlugin(“RtThreadOSPlugin”); is enabled, the scene is as follows;:
alt text

4.6 OzoneRedefine file path

When the path of the burned bin is not locally compiled, debugging with Ozone will prompt File not find, unable to locate the corresponding C source code, thus unable to perform line-by-line tracking to locate the issue;。
alt text

解决方法:
鼠标右键该文件,Locate File到对应文件,就能定位到该c源文件,也可以采用 Project.AddPathSubstitute命令重定位路径,实际是需要参考Qzone的手册