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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 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 }
                ]
            }