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

推荐订阅源

Vercel News
Vercel News
Recorded Future
Recorded Future
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
N
News | PayPal Newsroom
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
博客园 - Franky
SecWiki News
SecWiki News
Recent Announcements
Recent Announcements
T
Troy Hunt's Blog
The Register - Security
The Register - Security
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
S
Security Affairs
博客园 - 司徒正美
S
Schneier on Security
I
InfoQ
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Forbes - Security
Forbes - Security
腾讯CDC
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
Cloudbric
Cloudbric
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
B
Blog
V
Vulnerabilities – Threatpost
C
Check Point Blog
Google DeepMind News
Google DeepMind News
Google Online Security Blog
Google Online Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
Schneier on Security
Schneier on Security
O
OpenAI News
K
Kaspersky official 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 }
                ]
            }