1.下载vscode及插件STM32 VS Code Ectersion 版本号1.0.0,之后这个有导入功能。
2.等待自动安装对应插件,提示缺少什么就补什么
3.在左侧出现stm32图标。点击Import a local project导入本地项目。
4.报错
[{"resource": "/f:V11/cmake/st-project.cmake","owner": "cmake-configure-diags","severity": 8,"message": "CMake Error at cmake/st-project.cmake:115 (target_link_options):Syntax error in cmake code at\n\n F:V11/cmake/st-project.cmake:126\n\nwhen parsing string\n\n $<$<CONFIG:Debug>:SHELL:\\\"${workspace_loc:/${ProjName}/Drivers/DSP/libarm_cortexM4lf_math.a}\\\">\n\nInvalid character (':') in a variable name: 'workspace_loc'","source": "CMake (target_link_options)","startLineNumber": 115,"startColumn": 1,"endLineNumber": 115,"endColumn": 10000,"relatedInformation": [{"startLineNumber": 8,"startColumn": 1,"endLineNumber": 8,"endColumn": 1000,"message": "In call to 'add_st_target_properties' here","resource": "/F:V11/CMakeLists.txt"}]
}]
对应cmake为:
target_link_options(${TARGET_NAME} PRIVATE"$<$<CONFIG:Debug>:-mcpu=cortex-m4>""$<$<CONFIG:Debug>:-mfpu=fpv4-sp-d16>""$<$<CONFIG:Debug>:-mfloat-abi=hard>""$<$<NOT:$<CONFIG:Debug>>:-mcpu=cortex-m4>""$<$<NOT:$<CONFIG:Debug>>:-mfpu=fpv4-sp-d16>""$<$<NOT:$<CONFIG:Debug>>:-mfloat-abi=hard>"-T"$<$<CONFIG:Debug>:${PROJECT_SOURCE_DIR}/STM32F407VETX_FLASH.ld>""$<$<NOT:$<CONFIG:Debug>>:${PROJECT_SOURCE_DIR}/STM32F407VETX_FLASH.ld>""$<$<CONFIG:Debug>:SHELL:\"${workspace_loc:/${ProjName}/Drivers/DSP/libarm_cortexM4lf_math.a}\">"
)
最后一行改为
"$<$<CONFIG:Debug>:${PROJECT_SOURCE_DIR}/Drivers/DSP/libarm_cortexM4lf_math.a>"