Update vscode & CMake related points

This commit is contained in:
Tilen Majerle 2022-05-18 20:11:07 +02:00
parent f5738aa725
commit 67537be39f
9 changed files with 162 additions and 96 deletions

View File

@ -1,20 +0,0 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
# Some default GCC settings
# arm-none-eabi- must be part of path environment
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(FLAGS "-fdata-sections -ffunction-sections --specs=nano.specs -Wl,--gc-sections")
set(CPP_FLAGS "-fno-rtti -fno-exceptions -fno-threadsafe-statics")
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc ${FLAGS})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++ ${FLAGS} ${CPP_FLAGS})
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size)
set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

View File

@ -2,7 +2,7 @@
"version": 4,
"configurations": [
{
/* ms-vscode.cmake-tools plugin shall to be installed, which provides include paths and defines through CMake file */
/* ms-vscode.cmake-tools plugin should be installed; it provides include paths and defines through CMake file */
"name": "STM32",
"includePath": [],
"defines": [],

View File

@ -17,7 +17,7 @@
"runToMain": true,
"svdFile": "path/to/file.svd", //Path to SVD file to see registers
"v1": false,
"showDevDebugOutput": true,
"showDevDebugOutput": "both",
/* Will get automatically detected if STM32CubeIDE is installed to default directory
or it can be manually provided if necessary.. */

View File

@ -34,6 +34,49 @@
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
}
},
{
"type": "shell",
"label": "CubeProg: Flash project (SWD)",
"command": "STM32_Programmer_CLI",
"args": [
"--connect",
"port=swd",
"--download", "${command:cmake.launchTargetPath}",
"-hardRst"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
{
"type": "shell",
"label": "CubeProg: Flash project with defined serial number (SWD) - you must set serial number first",
"command": "STM32_Programmer_CLI",
"args": [
"--connect",
"port=swd",
"sn=<yourserialnumber>",
"--download", "${command:cmake.launchTargetPath}",
"-hardRst"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
{
"type": "shell",
"label": "CubeProg: List all available communication interfaces",
"command": "STM32_Programmer_CLI",
"args": [
"--list",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
]
}

View File

@ -26,8 +26,8 @@ set(CPU_PARAMETERS
# Other parameters
# -mcpu, -mfloat, -mfloat-abi, ...
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
)
# Set linker script
@ -38,50 +38,50 @@ set(EXECUTABLE ${CMAKE_PROJECT_NAME})
# Source files
#
set(src_freertos_SRCS
${PROJ_PATH}/../../lib/FreeRTOS/CMSIS_RTOS_V2/cmsis_os2.c
${PROJ_PATH}/../../lib/FreeRTOS/croutine.c
${PROJ_PATH}/../../lib/FreeRTOS/event_groups.c
${PROJ_PATH}/../../lib/FreeRTOS/portable/MemMang/heap_4.c
${PROJ_PATH}/../../lib/FreeRTOS/list.c
${PROJ_PATH}/../../lib/FreeRTOS/portable/GCC/ARM_CM4F/port.c
${PROJ_PATH}/../../lib/FreeRTOS/queue.c
${PROJ_PATH}/../../lib/FreeRTOS/tasks.c
${PROJ_PATH}/../../lib/FreeRTOS/timers.c)
${PROJ_PATH}/../../lib/FreeRTOS/CMSIS_RTOS_V2/cmsis_os2.c
${PROJ_PATH}/../../lib/FreeRTOS/croutine.c
${PROJ_PATH}/../../lib/FreeRTOS/event_groups.c
${PROJ_PATH}/../../lib/FreeRTOS/portable/MemMang/heap_4.c
${PROJ_PATH}/../../lib/FreeRTOS/list.c
${PROJ_PATH}/../../lib/FreeRTOS/portable/GCC/ARM_CM4F/port.c
${PROJ_PATH}/../../lib/FreeRTOS/queue.c
${PROJ_PATH}/../../lib/FreeRTOS/tasks.c
${PROJ_PATH}/../../lib/FreeRTOS/timers.c)
set(src_lwmem_SRCS
${PROJ_PATH}/../../../lwmem/src/lwmem/lwmem.c
${PROJ_PATH}/../../../lwmem/src/system/lwmem_sys_cmsis_os.c)
${PROJ_PATH}/../../../lwmem/src/lwmem/lwmem.c
${PROJ_PATH}/../../../lwmem/src/system/lwmem_sys_cmsis_os.c)
set(src_stm32l4xx_hal_drivers_SRCS
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_dma.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_exti.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_gpio.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_pwr.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_rcc.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usart.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_utils.c)
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_dma.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_exti.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_gpio.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_pwr.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_rcc.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usart.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_utils.c)
set(src_user_SRCS
${PROJ_PATH}/src/main.c
${PROJ_PATH}/src/stm32l4xx_it.c
${PROJ_PATH}/src/syscalls.c
${PROJ_PATH}/src/system_stm32l4xx.c)
${PROJ_PATH}/src/main.c
${PROJ_PATH}/src/stm32l4xx_it.c
${PROJ_PATH}/src/syscalls.c
${PROJ_PATH}/src/system_stm32l4xx.c)
set(src_startup_SRCS
${PROJ_PATH}/STM32CubeIDE/startup/startup_stm32l496xx.s)
${PROJ_PATH}/STM32CubeIDE/startup/startup_stm32l496xx.s)
#
# Include directories
#
set(include_c_DIRS
${PROJ_PATH}/inc
${PROJ_PATH}/../../../lwmem/src/include
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Inc
${PROJ_PATH}/../../lib/st/CMSIS/Device/ST/STM32L4xx/Include
${PROJ_PATH}/../../lib/st/CMSIS/Include
${PROJ_PATH}/../../lib/FreeRTOS/include
${PROJ_PATH}/../../lib/FreeRTOS/CMSIS_RTOS_V2
${PROJ_PATH}/../../lib/FreeRTOS/portable/GCC/ARM_CM4F
${PROJ_PATH}/../../../lwmem/src/include
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Inc
${PROJ_PATH}/../../lib/st/CMSIS/Device/ST/STM32L4xx/Include
${PROJ_PATH}/../../lib/st/CMSIS/Include
${PROJ_PATH}/../../lib/FreeRTOS/include
${PROJ_PATH}/../../lib/FreeRTOS/CMSIS_RTOS_V2
${PROJ_PATH}/../../lib/FreeRTOS/portable/GCC/ARM_CM4F
)
set(include_cxx_DIRS
@ -95,13 +95,13 @@ set(include_asm_DIRS
#
set(symbols_c_SYMB
"__weak=__attribute__((weak))"
"__packed=__attribute__((__packed__))"
"USE_FULL_LL_DRIVER"
"STM32L496xx"
"__packed=__attribute__((__packed__))"
"USE_FULL_LL_DRIVER"
"STM32L496xx"
)
set(symbols_cxx_SYMB
"STM32F10X_MD"
"USE_STDPERIPH_DRIVER"
"USE_STDPERIPH_DRIVER"
)
set(symbols_asm_SYMB
@ -120,11 +120,11 @@ link_directories(${EXECUTABLE} ${link_DIRS})
# Executable files
#
add_executable(${EXECUTABLE}
${src_freertos_SRCS}
${src_lwmem_SRCS}
${src_stm32l4xx_hal_drivers_SRCS}
${src_user_SRCS}
${src_startup_SRCS})
${src_freertos_SRCS}
${src_lwmem_SRCS}
${src_stm32l4xx_hal_drivers_SRCS}
${src_user_SRCS}
${src_startup_SRCS})
#
# Add linked libraries for linker
@ -195,7 +195,7 @@ target_compile_options(${EXECUTABLE} PRIVATE
# Setup linker parameters
target_link_options(${EXECUTABLE} PRIVATE
-T${MCU_LINKER_SCRIPT}${linker_script_SRC}
-T${linker_script_SRC}
${CPU_PARAMETERS}
-Wl,-Map=${CMAKE_PROJECT_NAME}.map
-u _printf_float # STDIO float formatting support (remove if not used)

View File

@ -2,7 +2,7 @@
"version": 4,
"configurations": [
{
/* ms-vscode.cmake-tools plugin shall to be installed, which provides include paths and defines through CMake file */
/* ms-vscode.cmake-tools plugin should be installed; it provides include paths and defines through CMake file */
"name": "STM32",
"includePath": [],
"defines": [],

View File

@ -17,7 +17,7 @@
"runToMain": true,
"svdFile": "path/to/file.svd", //Path to SVD file to see registers
"v1": false,
"showDevDebugOutput": true,
"showDevDebugOutput": "both",
/* Will get automatically detected if STM32CubeIDE is installed to default directory
or it can be manually provided if necessary.. */

View File

@ -34,6 +34,49 @@
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
}
},
{
"type": "shell",
"label": "CubeProg: Flash project (SWD)",
"command": "STM32_Programmer_CLI",
"args": [
"--connect",
"port=swd",
"--download", "${command:cmake.launchTargetPath}",
"-hardRst"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
{
"type": "shell",
"label": "CubeProg: Flash project with defined serial number (SWD) - you must set serial number first",
"command": "STM32_Programmer_CLI",
"args": [
"--connect",
"port=swd",
"sn=<yourserialnumber>",
"--download", "${command:cmake.launchTargetPath}",
"-hardRst"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
{
"type": "shell",
"label": "CubeProg: List all available communication interfaces",
"command": "STM32_Programmer_CLI",
"args": [
"--list",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
]
}

View File

@ -26,8 +26,8 @@ set(CPU_PARAMETERS
# Other parameters
# -mcpu, -mfloat, -mfloat-abi, ...
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
)
# Set linker script
@ -38,35 +38,35 @@ set(EXECUTABLE ${CMAKE_PROJECT_NAME})
# Source files
#
set(src_lwmem_SRCS
${PROJ_PATH}/../../../lwmem/src/lwmem/lwmem.c)
${PROJ_PATH}/../../../lwmem/src/lwmem/lwmem.c)
set(src_stm32l4xx_hal_drivers_SRCS
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_dma.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_exti.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_gpio.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_pwr.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_rcc.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usart.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_utils.c)
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_dma.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_exti.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_gpio.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_pwr.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_rcc.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usart.c
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_utils.c)
set(src_user_SRCS
${PROJ_PATH}/src/main.c
${PROJ_PATH}/src/stm32l4xx_it.c
${PROJ_PATH}/src/syscalls.c
${PROJ_PATH}/src/system_stm32l4xx.c)
${PROJ_PATH}/src/main.c
${PROJ_PATH}/src/stm32l4xx_it.c
${PROJ_PATH}/src/syscalls.c
${PROJ_PATH}/src/system_stm32l4xx.c)
set(src_startup_SRCS
${PROJ_PATH}/STM32CubeIDE/startup/startup_stm32l496xx.s)
${PROJ_PATH}/STM32CubeIDE/startup/startup_stm32l496xx.s)
#
# Include directories
#
set(include_c_DIRS
${PROJ_PATH}/inc
${PROJ_PATH}/../../../lwmem/src/include
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Inc
${PROJ_PATH}/../../lib/st/CMSIS/Device/ST/STM32L4xx/Include
${PROJ_PATH}/../../lib/st/CMSIS/Include
${PROJ_PATH}/../../../lwmem/src/include
${PROJ_PATH}/../../lib/st/STM32L4xx_HAL_Driver/Inc
${PROJ_PATH}/../../lib/st/CMSIS/Device/ST/STM32L4xx/Include
${PROJ_PATH}/../../lib/st/CMSIS/Include
)
set(include_cxx_DIRS
@ -80,13 +80,13 @@ set(include_asm_DIRS
#
set(symbols_c_SYMB
"__weak=__attribute__((weak))"
"__packed=__attribute__((__packed__))"
"USE_FULL_LL_DRIVER"
"STM32L496xx"
"__packed=__attribute__((__packed__))"
"USE_FULL_LL_DRIVER"
"STM32L496xx"
)
set(symbols_cxx_SYMB
"STM32F10X_MD"
"USE_STDPERIPH_DRIVER"
"USE_STDPERIPH_DRIVER"
)
set(symbols_asm_SYMB
@ -105,10 +105,10 @@ link_directories(${EXECUTABLE} ${link_DIRS})
# Executable files
#
add_executable(${EXECUTABLE}
${src_lwmem_SRCS}
${src_stm32l4xx_hal_drivers_SRCS}
${src_user_SRCS}
${src_startup_SRCS})
${src_lwmem_SRCS}
${src_stm32l4xx_hal_drivers_SRCS}
${src_user_SRCS}
${src_startup_SRCS})
#
# Add linked libraries for linker
@ -179,7 +179,7 @@ target_compile_options(${EXECUTABLE} PRIVATE
# Setup linker parameters
target_link_options(${EXECUTABLE} PRIVATE
-T${MCU_LINKER_SCRIPT}${linker_script_SRC}
-T${linker_script_SRC}
${CPU_PARAMETERS}
-Wl,-Map=${CMAKE_PROJECT_NAME}.map
-u _printf_float # STDIO float formatting support (remove if not used)