阅读 95

windows10 vscode+stm32cubemx完成对使stm32的开发和配置

windows10 vscode+stm32cubemx完成对使stm32的开发和配置

学习stm32的时候发现keil的颜值太低,而且代码提示很差劲,因此想到使用自己喜欢的vscode来进行开发。经过在网上的一番折腾终于找到了可靠的教程。

将环境配置好的话,每次创建项目只需要完成以下工作:

创建.vscode文件夹以及相关配置文件

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "D:/Software/GNU/10 2021.07/lib/gcc/arm-none-eabi/10.3.1/include",
                "${workspaceFolder}/Inc",
                "${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc",
                "${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy",
                "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
                "${workspaceFolder}/Drivers/CMSIS/Include"
            ],
            "defines": [
                "USE_HAL_DRIVER",
                "STM32F407xx"  
            ],
            "compilerPath": "D:/Software/GNU/10 2021.07/bin/arm-none-eabi-gcc.exe",
            "intelliSenseMode": "gcc-x64",
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": "",
                "path": [
                    "${workspaceFolder}"
                ]
            }
        }
    ],
    "version": 4
}

launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Cortex Debug",
            "cwd": "${workspaceRoot}",
            "executable": "${workspaceRoot}/build/${workspaceFolderBasename}.elf",
            "request": "launch",
            "type": "cortex-debug",
            
            "device":"STM32F407VE",        //使用J-link GDB Server时必须;其他GBD Server时可选(有可能帮助自动选择SVD文件)。支持的设备见 https://www.segger.com/downloads/supported-devices.php
            "svdFile": "./STM32F407.svd",  //svd文件,有这个文件才能查看寄存器的值,每个单片机都不同。可以在以下地址找到 https://github.com/posborne/cmsis-svd
            "servertype": "openocd",       //使用的GDB Server
            "configFiles": [                  
                "${workspaceRoot}/openocd.cfg"
            ],
            "preLaunchTask": "build",
            "armToolchainPath": "D:/Software/GNU/10 2021.07/bin"
        }
    ]
}

settings.json

{
    "terminal.integrated.shell.windows": "D:/Software/Git/bin/bash.exe",
    "files.associations": {
        "stm32f4xx_hal.h": "c"
    }
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "build",
                "type": "shell",
                "command": "make",
                "args": [
                    "-j4"
                ] 
            },
            {
                "label": "clean",
                "type": "shell",
                "command": "make",
                "args": [
                    "clean"
                ] 
            }
        ]
}

配置的具体含义大家看上面博主的教程就可以了。虽然有点麻烦,但是配置好之后就简单了。

最后就是我在运行gdb server的时候发现运行报错了。我的分析是没有插入jlink并安装相关驱动造成的,并不是配置出错。

在项目根目录下配置openocd.cfg文件

# 选择调试器为jlink
source [find interface/jlink.cfg]
#source [find interface/cmsis-dap.cfg]

# 选择接口为SWD
transport select swd

# 选择目标芯片
source [find target/stm32f4x.cfg]

复制对应的svd文件到根目录

svd文件上面那个博主里的教程也给出了链接,按照上面一步一步来就可以了。

配置完成之后的项目目录的样子为:

配置自己的项目大家只需要修改我上面给出的配置路径就可以,其他的不需要动。

原文:https://www.cnblogs.com/3236676588buladuo/p/15202615.html

文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐