惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
D
DataBreaches.Net
博客园_首页
罗磊的独立博客
B
Blog
T
Threat Research - Cisco Blogs
C
Cisco Blogs
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
G
GRAHAM CLULEY
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
SecWiki News
SecWiki News
T
Threatpost
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Schneier on Security
Schneier on Security
T
The Exploit Database - CXSecurity.com
Google Online Security Blog
Google Online Security Blog
T
Tor Project blog
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
H
Hacker News: Front Page
V
V2EX
Security Latest
Security Latest
Cloudbric
Cloudbric
Simon Willison's Weblog
Simon Willison's Weblog
Attack and Defense Labs
Attack and Defense Labs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
NISL@THU
NISL@THU
S
Secure Thoughts
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
P
Palo Alto Networks Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
Google DeepMind News
Google DeepMind News
Webroot Blog
Webroot Blog

博客园 - yinsua

OpenBCI调试记录 Qt QML/Quick程序部署 一种CAN接口电路的隔离方案 【转载】0-5V转4-20mA电路以及Howland电流源分析与仿真 【转载】外置USB供电与内置锂电池供电自动切换电路 模块的电气隔离的例子(音频采集电路) 【转载】EMC 共模电感选型 RS485的电路防护设计 ubuntu 20.04 安装VMware Tools Linux常用操作 MOS管随笔 RTX V4随笔 【转载】Keil MDK的sct分散加载文件详解 lua语言 简单类测试 Git 加入gitignore文件后应用 git报错error: could not lock config file RT-Thread速览——内核 ARM MDK开发中的\$Super\$\$main与\$Sub\$\$main - yinsua - 博客园 cpolar(内网穿透工具)安装
VSCode + EIDE开发记录
yinsua · 2024-08-28 · via 博客园 - yinsua

环境:Win10, VSCode + Embedded IDE扩展,使用Cortex-Debug进行调试。

使用CubeMX进行代码生成并在VSCode+EIDE中编辑和编译、调试

  1. 首先使用CubeMX配置好时钟、外设等,然后生成工程,其中:Project Manager/Project/Toolchain IDE项目,如使用MDK-ARM,则在其后的EIDE中应设置AC5或AC6编译器进行编译,如使用Makefile,则使用GCC编译器。
  2. 打开VSCode,如选择使用MDK来生成工程,则直接使用EIDE扩展以导入MDK工程的方式来打开工程;如选择使用Makefile的方式生成工程,则首先使用EIDE扩展创建工程,并手动设置好源码目录,头文件查找目录等,添加好xxx.s文件到源码工程(右键Project Resources -> Add file来添加文件到项目中进行编译)。注意要在Project Attributes->Preprocessor Definitions中加入如下宏:USE_HAL_DRIVERSTM32F303x8,其中,STM32F303x8取决于你用的什么MCU,如果你知道你的MCU型号但是不知道对应的宏的话可以查看源码Drivers/CMSIS/Device/ST/STM32FXxx/Include目录,这里的Xxx是你生成工程时候自动生成的。
  3. 如遇到编译xxx.s的文件出错,查看编译器是否选对了,可以查看xxx.s的头部注释,例如:
/**
  ******************************************************************************
  * @file      startup_stm32f303x8.s
  * @author    MCD Application Team
  * @brief     STM32F303x6/STM32F303x8 devices vector table for GCC toolchain.
  *            This module performs:
  *                - Set the initial SP
  *                - Set the initial PC == Reset_Handler,
  *                - Set the vector table entries with the exceptions ISR address,
  *                - Configure the clock system  
  *                - Branches to main in the C library (which eventually
  *                  calls main()).
  *            After Reset the Cortex-M4 processor is in Thread mode,
  *            priority is Privileged, and the Stack is set to Main.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2016 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */

这里的STM32F303x6/STM32F303x8 devices vector table for GCC toolchain.就表明了这个xxx.s文件是使用gcc的汇编格式来使用的。
如果是STM32F303x6/x8 devices vector table for MDK-ARM toolchain.则表示是用ARMCC的汇编格式来使用的。

  1. 注意选择好Builder Configurations->CPU Type,以及设置好Linker Script File Path文件名,默认的文件名不可用。

C/C++ IntelliSense设置

  1. 打开当前目录下的.vscode/c_cpp_properties.json
  2. 修改compilerPath为gcc编译器路径,例如:"compilerPath": "C:/Users/yinsua/.eide/tools/gcc_arm/bin/arm-none-eabi-gcc.exe",
  3. 建议修改C标准为c11:"cStandard": "c11",
  4. 重启VSCode,用EIDE打开工程。
  5. 尝试代码补全。

一般重启VSCode后,下方ouput会出现如下log

[8/28/2024, 11:33:47 AM] For C++ source files, IntelliSenseMode was changed from "windows-gcc-x64" to "windows-gcc-arm" based on compiler args and querying compilerPath: "C:/Users/yinsua/.eide/tools/gcc_arm/bin/arm-none-eabi-gcc.exe"
[8/28/2024, 11:33:47 AM] For C source files, IntelliSenseMode was changed from "windows-gcc-x64" to "windows-gcc-arm" based on compiler args and querying compilerPath: "C:/Users/yinsua/.eide/tools/gcc_arm/bin/arm-none-eabi-gcc.exe"

Cortex-Debug调试

  1. 检查launch.json中是否已添加Cortex-Debug配置
  2. 修改executable为当前程序的elf文件格式输出名
  3. 如果是OpenOCD,则填充configFiles内容

Cortex-Debug + OpenOCD调试STM32F4x示例:

{
      "cwd": "${workspaceRoot}",
      "executable": "./build/Debug/eide_stm32f411ceu6_test.elf",
      "name": "Debug with OpenOCD",
      "request": "launch",
      "type": "cortex-debug",
      "servertype": "openocd",
      "configFiles": [
        "interface/cmsis-dap.cfg",
        "target/stm32f4x.cfg"
      ],
      "searchDir": [],
      "runToEntryPoint": "main",
      "showDevDebugOutput": "none"
    }

也可添加如下内容来增加对其它调试功能的支持:

            "svdFile": "${workspaceRoot}/.vscode/STM32F303.svd",
            "swoConfig": {
                "enabled": true,
                "cpuFrequency": 8000000,
                "swoFrequency": 2000000,
                "source": "probe",
                "decoders": [
                    { "type": "console", "label": "ITM", "port": 0 }
                ]
            }