VS Code与STM32CubeMX Clion Ozone集成开发STM32:优雅实践指南
前言:在用过keil5、Clion、VS Code等编辑器之后,还是发现VScode用起来比较舒服,特此在这记录开发环境的搭建流程。
注:仅个人开发记录 谨慎参考
一、VS Code安装及配置
- Cmake Tools
- Better C++ Syntak
- C/C++
- Chinese (Simplfied)
- Cmake
- Cortex-Debug
{
"version": "2.0.0",
"tasks": [
{
"label": "JLink DownLoad",
"type": "shell",
"command": "C:\\Users\\Administrator\\.eide\\tools\\jlink\\JLink.exe",
"args": [
"-ExitOnError",
"1",
"-AutoConnect",
"1",
"-Device",
"STM32G474RE",
"-If",
"SWD",
"-Speed",
"8000",
"-CommandFile",
"build\\commands.jlink"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"detail": "Runs JLink with specified parameters"
}
]
}
tasks.json文件
{
"version": "2.0.0",
"tasks": [
{
"label": "JLink DownLoad",
"type": "shell",
"command": "C:\\Users\\Administrator\\.eide\\tools\\jlink\\JLink.exe",
"args": [
"-ExitOnError",
"1",
"-AutoConnect",
"1",
"-Device",
"STM32G474RE",
"-If",
"SWD",
"-Speed",
"8000",
"-CommandFile",
"build\\commands.jlink"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"detail": "Runs JLink with specified parameters"
}
]
}
#解除注释开启硬件浮点加速
add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING)
add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
add_link_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
#链接数学库
link_directories(${CMAKE_SOURCE_DIR}/Middlewares/ST/ARM/DSP/Lib)
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
target_link_libraries(${PROJECT_NAME}.elf libarm_cortexM4lf_math.a)
"cortex-debug.armToolchainPath": "D:\\STM32Toolchains\\gcc-arm-none-eabi-10.3-2021.10\\bin",
"cortex-debug.openocdPath": "D:\\STM32Toolchains\\OpenOCD-20231002-0.12.0\\bin\\openocd.exe",
"cortex-debug.JLinkGDBServerPath": "D:\\J-Link\\JLinkGDBServerCL.exe",
"cmake.generator": "MinGW Makefiles"


二、STM32CubeMX配置
配置完成后直接将次工程导入Clion生成Cmakelists。
三、环境变量添加
四、工程添加commands.jlink
r
halt
loadfile "C:\Users\Administrator\Desktop\NDIR_Somke\build\NDIR_Somke.hex"
r
go
exit
附录
工具软件下载地址
作者:Handsome_row