AliOS Things Development: Let your board supports debugging AliOS Studio

Brief introduction

In AliOS-Things version 2.1 later, AliOS Studio provides a straightforward interface that allows developers to easily adapt development board supports debugging. It can support most of the debugging interface:

  • ST-Link
  • JLink
  • CMSIS-DAP

AliOS Studio debugging results as shown below:

AliOS Studio debugging mechanism

AliOS Studio main function is to perform aos debug command, aos debug and then run gdb server in the background, and then use the debugging capabilities vscode-cpptools the (gdb client) to achieve debugging. AliOS Studio debug mechanism frame is shown below:

This article will explain how to make AliOS Studio support your development board debugging in detail.

Ready to work

pca10040 development board is equipped with Nordic produced a nRF52832 development board, on-board debugging interface jlink interface, you can download the image interface, the debugger by jlink.
This example uses pca10040 development board as an example, implemented in the AliOS Studiopress F5to start debugging pca10040 application support windows, linux and macOS.

Ready to work

Write configuration file

aos upload会调用upload的配置文件来实现具体的image烧录过程,我们需要编写这个配置文件来达到启动gdb server的目的,aos debug目前已经支持的开发板可以参考这里,同时,开发者也可以贡献自己适配好的json配置文件到AliOS-Things中。

debug配置文件说明

pca10040开发板的debug配置文件如下:

{
    "cmd": [
        {
            "Linux64": "JLinkGDBServerCLExe", 
            "OSX": "JLinkGDBServerCLExe", 
            "Win32": "JLinkGDBServerCL.exe"
        }, 
        "-if", 
        "swd", 
        "-device", 
        "nRF52840_xxAA", 
        "-port", 
        "4242"
    ], 
    "port": 4242, 
    "prompt": "Please INSTALL Jlink Software Package, and ADD JLink to PATH environment, check: www.github.com/alibaba/AliOS-Things/wiki/debug", 
}

配置文件参数说明

参数 说明 默认
cmd 运行的指令,指令中支持针对不同PC系统运行不用的命令:Linux64OSXWin32,支持多个参数
port gdb server监听的端口,,统一为4242 4242
prompt 当aos debug执行失败的时候,会显示prompt,用来提示用户出错原因

启动调试

编写好配置文件之后,进入AliOS Studio,按F5即可启动调试。

其他

下载JLink并配置环境变量

JLink软件包下载地址。请分别下载对应开发环境的软件包。

windows环境配置

windows环境下,需要把JLink的bin目录添加到Path环境变量,JLink 默认的bin目录为:C:\Program Files (x86)\SEGGER\JLink_V640,具体如何配置Path环境变量请参考:How to add a folder to Path environment variable

请注意JLink默认的bin目录中的JLink_V640,会根据不同的jlink版本会有所不同。设置完Path环境变量需要重启cmd、bash、vscode等,最好重启电脑。

windows环境下的JLink Commander名称为:JLink.exe。

linux/macOS环境配置

按照正常的安装流程安装即可,linux/macOS环境下的JLink Commander名称为:JLinkExe。

参考文档

Guess you like

Origin yq.aliyun.com/articles/720279