培训机构网站php源码,网站调整方案,万网备案初审过了后网站能访问吗,网站访问速度优化工具简介
当使用ARM Cortex-M微控制器时#xff0c;Cortex-Debug是一个Visual Studio Code的扩展#xff0c;以简化调试过程。本文档介绍了如何编写启动配置(launch.json)。
settings.json配置
打开VSCode用户设置文件settings.json: 文件→偏好→设置选择用户设置: 在搜索栏中…简介
当使用ARM Cortex-M微控制器时Cortex-Debug是一个Visual Studio Code的扩展以简化调试过程。本文档介绍了如何编写启动配置(launch.json)。
settings.json配置
打开VSCode用户设置文件settings.json: 文件→偏好→设置选择用户设置: 在搜索栏中输入 json (带或不带双引号)。在设置中找到“编辑”链接。然后点击它。这将打开~/.config/Code/User/settings.json文件将以下行添加到settings.json文件在大括号{}之间:
{cortex-debug.openocdPath: /usr/bin/openocd,cortex-debug.armToolchainPath.linux: /opt/toolchains/gcc-arm- none-eabi-10.3-2021.10/bin,cortex-debug.armToolchainPath.windows: C:\\ProgramData\\chocolatey\\bin,cortex-debug.gdbPath.linux: /opt/toolchains/gcc-arm-none-eabi-10.3-2021.10/bin//arm-none-eabi-gdb,cortex-debug.gdbPath.windows: C:\\ProgramData\\chocolatey\\bin\\arm-none-eabi-gdb.exe
}请注意:您系统上的路径可能不同。确保该路径与文件的实际位置匹配。
保存文件settings.json
launch.json配置
要在VS Code中运行或调试一个简单的应用程序我们可以在debug start视图中选择run and debug或者我们可以按F5, VS Code将尝试运行当前活动的文件。
创建启动配置文件是有益的因为它允许我们配置和保存调试设置的详细信息。VSCode会在启动时调试配置信息。位于工作空间(项目根文件夹)中的.vscode文件夹中的Json文件。
launch.json文件用于在Visual Studio Code中配置调试器。
参数 以下是launch.json中的参数列表。为特定的设备和环境配置它们。
cwd:项目路径
configFiles:要加载的OpenOCD配置文件
device:目标设备标识符
接口:用于连接的调试接口类型(默认为SWD) -用于J-Link和BMP探针。
name:配置名称;显示在启动配置下拉菜单中。
preLaunchTask:在调试会话开始之前运行的任务。指定在tasks.json中定义的任务。
request:配置请求类型。可以是“发射”或“附加”。
runToEntryPoint:如果启用调试器将运行直到主函数开始。
serialNumber: J-Link专用参数。J-Link序列号-仅当多个J-Link连接到计算机时需要
servertype: GDB服务器类型—支持jlink、openocd、pyocd、pe、stutil
svdFile:描述微控制器外设的SVD文件的路径;如果没有提供那么可以根据输入的“设备”选择一个。这可能会根据“设备”自动加载。
swoConfig: SWO/ITM配置。
enabled:开启SWO解码。
cpuFrequency: CPU的目标频率单位为Hz。
swoffrequency: SWO频率单位为Hz。
source:SWO数据来源。可以是“探针”直接从调试探针获得也可以是串行端口设备使用调试探针外部的串行端口。
decoders:SWO解码器配置
label:输出窗口的标签。
port: ITM端口号打开VSCode启动配置文件launch. json: Run→Add Configuration…复制以下代码
{version: 0.2.0,configurations: [{name: Debug (OpenOCD),cwd: ${workspaceRoot},executable: ${workspaceRoot}/build/blinky.elf,request: launch,type: cortex-debug,servertype: openocd,interface: swd,device: TM4C123GH6PM,runToEntryPoint: main,svdFile: ${workspaceRoot}/svd/TM4C123GH6PM.svd,configFiles: [board/ek-tm4c123gxl.cfg],preLaunchCommands: [set mem inaccessible-by-default off,monitor reset],postLaunchCommands: [monitor reset init,monitor sleep 200]}]
}修改“executable”、“svdFile”和“device”参数并保存svdFile: launch. json中的“svdFile”条目。在Json文件是可选的但对嵌入式系统调试至关重要因为它描述了设备的外设寄存器。
例1: Discovery Board / OpenOCD
这是开发板的配置。这基本上是cortex-m-quickstart的默认设置。
launch. json
{version: 0.2.0,configurations: [{type: cortex-debug,request: launch,name: Debug (OpenOCD),servertype: openocd,cwd: ${workspaceRoot},preLaunchTask: cargo build,runToMain: true,executable: ./target/thumbv7em-none-eabihf/debug/project-name,device: STM32F303VCT6,configFiles: [interface/stlink-v2-1.cfg,target/stm32f3x.cfg],svdFile: ${workspaceRoot}/.vscode/STM32F303.svd,swoConfig: {enabled: true,cpuFrequency: 8000000,swoFrequency: 2000000,source: probe,decoders: [{ type: console, label: ITM, port: 0 }]}}]
}例2:Nucleo-F429ZI Board / J-Link
将Nucleo-F429的STLink固件升级为JLink。因此对于我的核与J-Link固件我更改设置“servertype”为“jlink”和“interface”为“swd”。
{version: 0.2.0,configurations: [{type: cortex-debug,request: launch,name: Debug (J-Link),cwd: ${workspaceRoot},executable: ./target/thumbv7em-none-eabihf/debug/project-name,servertype: jlink,device: STM32F429ZI,interface: swd,serialNumber: ,preLaunchTask: cargo build,runToMain: true,svdFile: ${workspaceRoot}/.vscode/STM32F429.svd,swoConfig: {enabled: true,cpuFrequency: 8000000,swoFrequency: 2000000,source: probe,decoders: [{ type: console, label: ITM, port: 0 }]}},]
}结合Makefile设置调试方法
添加构建编译、链接等任务tasks.json
ctrlshiftp打开命令行输入Tasks: Run task》 Create tasks.json file from template 生成默认的tasks.json文件。
{// See https://go.microsoft.com/fwlink/?LinkId733558// for the documentation about the tasks.json formatversion: 2.0.0,tasks: [{label: echo,type: shell,command: echo Hello}]
}工程采用makefile编译则改为
{version: 2.0.0,tasks: [{label: make all,type: shell,command: make all,group: {kind: build,isDefault: true},problemMatcher: $gcc}]
}或者
{version: 2.0.0,tasks: [{type: shell,label: build,command: cd C:/project/debug; make,args: [], }]
}配置c_cpp_properties.json
{configurations: [{name: Win32,includePath: [${workspaceFolder}/**,${workspaceFolder}\\libs\\nnom\\inc,${workspaceFolder}\\libs\\nnom\\inc\\layers],defines: [_DEBUG,UNICODE,_UNICODE],compilerPath: D:\\soft\\Qt5.6.2\\Tools\\mingw492_32\\bin\\gcc.exe,cStandard: c99,cppStandard: c14,intelliSenseMode: windows-gcc-x86}],version: 4
}