From 96c18148e9477c79501f02b19cae6be05f182fec Mon Sep 17 00:00:00 2001 From: Gabriel Arjones Date: Thu, 15 Apr 2021 21:47:21 -0300 Subject: [PATCH 1/9] Allow setting paths through env vars --- cmake/FindBSP.cmake | 4 ++++ cmake/FindCMSIS.cmake | 4 ++++ cmake/FindFreeRTOS.cmake | 4 ++++ cmake/FindHAL.cmake | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/cmake/FindBSP.cmake b/cmake/FindBSP.cmake index 3479d026..af5bbf48 100644 --- a/cmake/FindBSP.cmake +++ b/cmake/FindBSP.cmake @@ -262,6 +262,10 @@ foreach(COMP ${BSP_FIND_COMPONENTS}) set(FAMILY ${CMAKE_MATCH_1}) string(TOLOWER ${FAMILY} FAMILY_L) + if(NOT STM32_CUBE_${FAMILY}_PATH) + set(STM32_CUBE_${FAMILY}_PATH $ENV{STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}") + endif() + if(NOT STM32_CUBE_${FAMILY}_PATH) set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") message(STATUS "No STM32_CUBE_${FAMILY}_PATH specified using default: ${STM32_CUBE_${FAMILY}_PATH}") diff --git a/cmake/FindCMSIS.cmake b/cmake/FindCMSIS.cmake index 6ee3f804..3821538f 100644 --- a/cmake/FindCMSIS.cmake +++ b/cmake/FindCMSIS.cmake @@ -71,6 +71,10 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS}) string(TOLOWER ${FAMILY} FAMILY_L) + if((NOT STM32_CMSIS_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH)) + set(STM32_CUBE_${FAMILY}_PATH $ENV{STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}") + endif() + if((NOT STM32_CMSIS_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH)) set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") diff --git a/cmake/FindFreeRTOS.cmake b/cmake/FindFreeRTOS.cmake index 44adc4b7..75c26a53 100644 --- a/cmake/FindFreeRTOS.cmake +++ b/cmake/FindFreeRTOS.cmake @@ -7,6 +7,10 @@ list(REMOVE_DUPLICATES FreeRTOS_FIND_COMPONENTS) set(FreeRTOS_HEAPS 1 2 3 4 5) +if(NOT FREERTOS_PATH) + set(FREERTOS_PATH $ENV{FREERTOS_PATH} CACHE PATH "Path to FreeRTOS") +endif() + if(NOT FREERTOS_PATH) set(FREERTOS_PATH /opt/FreeRTOS CACHE PATH "Path to FreeRTOS") message(STATUS "No FREERTOS_PATH specified using default: ${FREERTOS_PATH}") diff --git a/cmake/FindHAL.cmake b/cmake/FindHAL.cmake index 6af022a4..655d19e3 100644 --- a/cmake/FindHAL.cmake +++ b/cmake/FindHAL.cmake @@ -237,6 +237,10 @@ foreach(COMP ${HAL_FIND_COMPONENTS_FAMILIES}) set(FAMILY ${CMAKE_MATCH_1}) string(TOLOWER ${FAMILY} FAMILY_L) + if((NOT STM32_HAL_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH)) + set(STM32_CUBE_${FAMILY}_PATH $ENV{STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}") + endif() + if((NOT STM32_HAL_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH)) set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}") message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_HAL_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}") From c2ad6a95ab489b196b318736c6e9acc51e04722a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 3 Jul 2021 16:46:44 +0200 Subject: [PATCH 2/9] update README --- README.md | 90 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index a1008b75..07fba08a 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,9 @@ It will compile a project for the `F4` family by default, but you can also compi # Usage First of all you need to configure toolchain and library paths using CMake variables. -You can do this by passing values through command line during cmake run or by setting variables inside your `CMakeLists.txt` +You can do this by passing values through command line during cmake run or by setting variables +inside your `CMakeLists.txt`. You can also set pass these variables to CMake by setting them +as environmental variables. ## Configuration @@ -45,17 +47,22 @@ You can do this by passing values through command line during cmake run or by se * `TARGET_TRIPLET` - toolchain target triplet, **default**: `arm-none-eabi` * `STM32_CUBE__PATH` - path to STM32Cube directory, where `` is one of `F0 G0 L0 F1 L1 F2 F3 F4 G4 L4 F7 H7` **default**: `/opt/STM32Cube` -## Common usage +## Common usage First thing that you need to do after toolchain configuration in your `CMakeLists.txt` script is to find CMSIS package: ```cmake find_package(CMSIS [CMSIS_version] COMPONENTS STM32F4 REQUIRED) ``` -You can specify STM32 family or even specific device (`STM32F407VG`) in `COMPONENTS` or omit `COMPONENTS` totally - in that case stm32-cmake will find ALL sources for ALL families and ALL chips (you'll need ALL STM32Cube packages somewhere). +You can specify STM32 family or even specific device (`STM32F407VG`) in `COMPONENTS` or omit +`COMPONENTS` totally - in that case stm32-cmake will find ALL sources for ALL families and +ALL chips (you'll need ALL STM32Cube packages somewhere). -[CMSIS_version] is an optional version requirement. See [find_package documentation](https://cmake.org/cmake/help/v3.13/command/find_package.html?highlight=find%20package#id4). This parameter does not make sense if multiple STM32 families are requested. +[CMSIS_version] is an optional version requirement. See +[find_package documentation](https://cmake.org/cmake/help/v3.13/command/find_package.html?highlight=find%20package#id4). +This parameter does not make sense if multiple STM32 families are requested. -Each STM32 device can be categorized into family and device type groups, for example STM32F407VG is device from `F4` family, with type `F407xx`. +Each STM32 device can be categorized into family and device type groups, for example STM32F407VG +is device from `F4` family, with type `F407xx`. ***Note**: Some devices in STM32H7 family have two different cores (Cortex-M7 and Cortex-M4). For those devices the name used must include the core name e.g STM32H7_M7 and STM32H7_M4. @@ -67,7 +74,10 @@ CMSIS consists of three main components: * Device-specific linker scripts which requires information about memory sizes stm32-cmake uses modern CMake features notably imported targets and target properties. -Every CMSIS component is CMake's target (aka library), which defines compiler definitions, compiler flags, include dirs, sources, etc. to build and propagate them as dependencies. So in a simple use-case all you need is to link your executable with library `CMSIS::STM32::`: +Every CMSIS component is CMake's target (aka library), which defines compiler definitions, +compiler flags, include dirs, sources, etc. to build and propagate them as dependencies. +So in a simple use-case all you need is to link your executable with library `CMSIS::STM32::`: + ```cmake add_executable(stm32-template main.c) target_link_libraries(stm32-template CMSIS::STM32::F407VG) @@ -80,22 +90,35 @@ CMSIS creates the following targets: * `CMSIS::STM32::` (e.g. `CMSIS::STM32::F407xx`) - common startup source for device type, depends on `CMSIS::STM32::` * `CMSIS::STM32::` (e.g. `CMSIS::STM32::F407VG`) - linker script for device, depends on `CMSIS::STM32::` -So, if you don't need linker script, you can link only `CMSIS::STM32::` library and provide your own script using `stm32_add_linker_script` function +So, if you don't need the linker script or want to adapt it for your own needs, you can link +only `CMSIS::STM32::` library and provide your own script using `stm32_add_linker_script` +function -***Note**: For H7 family, because of it's multi-core architecture, all H7 targets also have a suffix (::M7 or ::M4). -For example, targets created for STM32H747BI will look like `CMSIS::STM32::H7::M7`, `CMSIS::STM32::H7::M4`, `CMSIS::STM32::H747BI::M7`, `CMSIS::STM32::H747BI::M4`, etc.* +***Note**: For H7 family, because of its multi-core architecture, all H7 targets also have a suffix (::M7 or ::M4). +For example, targets created for STM32H747BI will look like `CMSIS::STM32::H7::M7`, +`CMSIS::STM32::H7::M4`, `CMSIS::STM32::H747BI::M7`, `CMSIS::STM32::H747BI::M4`, etc.* -The GCC C/C++ standard libraries are added by linking the library `STM32::NoSys`. This will add the `--specs=nosys.specs` to compiler and linker flags. -If you want to use C++ on MCUs with little flash, you might instead want to link the newlib-nano to reduce the code size. You can do so by linking `STM32::Nano`, which will add the `--specs=nano.specs` flags to both compiler and linker. -Keep in mind that when using `STM32::Nano`, by default you cannot use floats in printf/scanf calls, and you have to provide implementations for several OS interfacing functions (_sbrk, _close, _fstat, and others). +The GCC C/C++ standard libraries are added by linking the library `STM32::NoSys`. This will add +the `--specs=nosys.specs` to compiler and linker flags. +If you want to use C++ on MCUs with little flash, you might instead want to link the newlib-nano to +reduce the code size. You can do so by linking `STM32::Nano`, which will add the +`--specs=nano.specs` flags to both compiler and linker. +Keep in mind that when using `STM32::Nano`, by default you cannot use floats in printf/scanf calls, +and you have to provide implementations for several OS interfacing +functions (`_sbrk`, `_close`, `_fstat`, and others). You can enable printf/scanf floating point +support with newlib-nano by linking against `STM32::Nano::FloatPrint` and/or +`STM32::Nano::FloatScan`. It is also possible to combine `STM32::Nano` and `STM32::NoSys` +to have the benefits of reduced code size while not being forced to implement system calls. -## HAL +## HAL STM32 HAL can be used similar to CMSIS. + ```cmake find_package(HAL [HAL_version] COMPONENTS STM32F4 REQUIRED) set(CMAKE_INCLUDE_CURRENT_DIR TRUE) ``` + *`CMAKE_INCLUDE_CURRENT_DIR` here because HAL requires `stm32xx_hal_conf.h` file being in include headers path.* [HAL_version] is an optional version requirement. See [find_package documentation](https://cmake.org/cmake/help/v3.13/command/find_package.html?highlight=find%20package#id4). This parameter does not make sense if multiple STM32 families are requested. @@ -109,11 +132,11 @@ HAL module will search all drivers supported by family and create the following ***Note**: Targets for STM32H7 will look like `HAL::STM32::::[M7|M4]`, `HAL::STM32::::[M7|M4]::`, etc.* -Here is typical usage: +Here is typical usage for a F4 device: ```cmake -add_executable(stm32-blinky-f4 blinky.c stm32f4xx_hal_conf.h) -target_link_libraries(stm32-blinky-f4 +add_executable(${TARGET_NAME} blinky.c stm32f4xx_hal_conf.h) +target_link_libraries(${TARGET_NAME} HAL::STM32::F4::RCC HAL::STM32::F4::GPIO HAL::STM32::F4::CORTEX @@ -122,16 +145,33 @@ target_link_libraries(stm32-blinky-f4 ) ``` -### Building +Here is another usage for a H7 device with the M7 core: +```cmake +target_link_libraries(${TARGET_NAME} PRIVATE + HAL::STM32::H7::M7::RCC + HAL::STM32::H7::M7::GPIO + HAL::STM32::H7::M7::CORTEX + CMSIS::STM32::H743ZI::M7 + STM32::NoSys +) ``` - $ cmake -DCMAKE_TOOLCHAIN_FILE= -DCMAKE_BUILD_TYPE=Debug - $ make + +### Building + +```sh +cmake -DCMAKE_TOOLCHAIN_FILE= -DCMAKE_BUILD_TYPE=Debug +cmake --build . ``` +You can also ommit the `-DCMAKE_TOOLCHAIN_FILE` argument and use `set (CMAKE_TOOLCHAIN_FILE ...)` +in your `CMakeLists.txt` file + ## Linker script & variables -CMSIS package will generate linker script for your device automatically (target `CMSIS::STM32::`). To specify a custom linker script, use `stm32_add_linker_script` function. +CMSIS package will generate linker script for your device automatically (target +`CMSIS::STM32::`). To specify a custom linker script, use the +`stm32_add_linker_script` function. ## Useful CMake functions @@ -146,9 +186,14 @@ CMSIS package will generate linker script for your device automatically (target stm32-cmake contains additional CMake modules for finding and configuring various libraries and RTOSes used in the embedded world. -## FreeRTOS +## FreeRTOS -[cmake/FindFreeRTOS](cmake/FindFreeRTOS) - finds FreeRTOS sources in location specified by `FREERTOS_PATH` (*default*: `/opt/FreeRTOS`) variable and format them as `IMPORTED` targets. `FREERTOS_PATH` can be either the path to the whole [FreeRTOS/FreeRTOS](https://github.com/FreeRTOS/FreeRTOS) github repo, or the path to FreeRTOS-Kernel (usually located in the subfolder `FreeRTOS` on a downloaded release) +[cmake/FindFreeRTOS](cmake/FindFreeRTOS.cmake) - finds FreeRTOS sources in location specified by +`FREERTOS_PATH` (*default*: `/opt/FreeRTOS`) variable and format them as `IMPORTED` targets. +`FREERTOS_PATH` can be either the path to the whole +[FreeRTOS/FreeRTOS](https://github.com/FreeRTOS/FreeRTOS) github repo, or the path to +FreeRTOS-Kernel (usually located in the subfolder `FreeRTOS` on a downloaded release). +You can supply `FREERTOS_PATH` as an environmental variable as well. Typical usage: @@ -166,4 +211,3 @@ Other FreeRTOS libraries: * `FreeRTOS::StreamBuffer` - stream buffer (`stream_buffer.c`) * `FreeRTOS::Timers` - timers (`timers.c`) * `FreeRTOS::Heap::` - heap implementation (`heap_.c`), ``: [1-5] - From fb2a8fdf56cb9559846c19703c2179c9e981be2f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 4 Jul 2021 12:33:03 +0200 Subject: [PATCH 3/9] removed unrelated README changes --- README.md | 63 +++++++++++++------------------------------------------ 1 file changed, 15 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 07fba08a..fa0406dc 100644 --- a/README.md +++ b/README.md @@ -47,22 +47,17 @@ as environmental variables. * `TARGET_TRIPLET` - toolchain target triplet, **default**: `arm-none-eabi` * `STM32_CUBE__PATH` - path to STM32Cube directory, where `` is one of `F0 G0 L0 F1 L1 F2 F3 F4 G4 L4 F7 H7` **default**: `/opt/STM32Cube` -## Common usage +## Common usage First thing that you need to do after toolchain configuration in your `CMakeLists.txt` script is to find CMSIS package: ```cmake find_package(CMSIS [CMSIS_version] COMPONENTS STM32F4 REQUIRED) ``` -You can specify STM32 family or even specific device (`STM32F407VG`) in `COMPONENTS` or omit -`COMPONENTS` totally - in that case stm32-cmake will find ALL sources for ALL families and -ALL chips (you'll need ALL STM32Cube packages somewhere). +You can specify STM32 family or even specific device (`STM32F407VG`) in `COMPONENTS` or omit `COMPONENTS` totally - in that case stm32-cmake will find ALL sources for ALL families and ALL chips (you'll need ALL STM32Cube packages somewhere). -[CMSIS_version] is an optional version requirement. See -[find_package documentation](https://cmake.org/cmake/help/v3.13/command/find_package.html?highlight=find%20package#id4). -This parameter does not make sense if multiple STM32 families are requested. +[CMSIS_version] is an optional version requirement. See [find_package documentation](https://cmake.org/cmake/help/v3.13/command/find_package.html?highlight=find%20package#id4). This parameter does not make sense if multiple STM32 families are requested. -Each STM32 device can be categorized into family and device type groups, for example STM32F407VG -is device from `F4` family, with type `F407xx`. +Each STM32 device can be categorized into family and device type groups, for example STM32F407VG is device from `F4` family, with type `F407xx`. ***Note**: Some devices in STM32H7 family have two different cores (Cortex-M7 and Cortex-M4). For those devices the name used must include the core name e.g STM32H7_M7 and STM32H7_M4. @@ -74,10 +69,7 @@ CMSIS consists of three main components: * Device-specific linker scripts which requires information about memory sizes stm32-cmake uses modern CMake features notably imported targets and target properties. -Every CMSIS component is CMake's target (aka library), which defines compiler definitions, -compiler flags, include dirs, sources, etc. to build and propagate them as dependencies. -So in a simple use-case all you need is to link your executable with library `CMSIS::STM32::`: - +Every CMSIS component is CMake's target (aka library), which defines compiler definitions, compiler flags, include dirs, sources, etc. to build and propagate them as dependencies. So in a simple use-case all you need is to link your executable with library `CMSIS::STM32::`: ```cmake add_executable(stm32-template main.c) target_link_libraries(stm32-template CMSIS::STM32::F407VG) @@ -90,35 +82,22 @@ CMSIS creates the following targets: * `CMSIS::STM32::` (e.g. `CMSIS::STM32::F407xx`) - common startup source for device type, depends on `CMSIS::STM32::` * `CMSIS::STM32::` (e.g. `CMSIS::STM32::F407VG`) - linker script for device, depends on `CMSIS::STM32::` -So, if you don't need the linker script or want to adapt it for your own needs, you can link -only `CMSIS::STM32::` library and provide your own script using `stm32_add_linker_script` -function +So, if you don't need linker script, you can link only `CMSIS::STM32::` library and provide your own script using `stm32_add_linker_script` function -***Note**: For H7 family, because of its multi-core architecture, all H7 targets also have a suffix (::M7 or ::M4). -For example, targets created for STM32H747BI will look like `CMSIS::STM32::H7::M7`, -`CMSIS::STM32::H7::M4`, `CMSIS::STM32::H747BI::M7`, `CMSIS::STM32::H747BI::M4`, etc.* +***Note**: For H7 family, because of it's multi-core architecture, all H7 targets also have a suffix (::M7 or ::M4). +For example, targets created for STM32H747BI will look like `CMSIS::STM32::H7::M7`, `CMSIS::STM32::H7::M4`, `CMSIS::STM32::H747BI::M7`, `CMSIS::STM32::H747BI::M4`, etc.* -The GCC C/C++ standard libraries are added by linking the library `STM32::NoSys`. This will add -the `--specs=nosys.specs` to compiler and linker flags. -If you want to use C++ on MCUs with little flash, you might instead want to link the newlib-nano to -reduce the code size. You can do so by linking `STM32::Nano`, which will add the -`--specs=nano.specs` flags to both compiler and linker. -Keep in mind that when using `STM32::Nano`, by default you cannot use floats in printf/scanf calls, -and you have to provide implementations for several OS interfacing -functions (`_sbrk`, `_close`, `_fstat`, and others). You can enable printf/scanf floating point -support with newlib-nano by linking against `STM32::Nano::FloatPrint` and/or -`STM32::Nano::FloatScan`. It is also possible to combine `STM32::Nano` and `STM32::NoSys` -to have the benefits of reduced code size while not being forced to implement system calls. +The GCC C/C++ standard libraries are added by linking the library `STM32::NoSys`. This will add the `--specs=nosys.specs` to compiler and linker flags. +If you want to use C++ on MCUs with little flash, you might instead want to link the newlib-nano to reduce the code size. You can do so by linking `STM32::Nano`, which will add the `--specs=nano.specs` flags to both compiler and linker. +Keep in mind that when using `STM32::Nano`, by default you cannot use floats in printf/scanf calls, and you have to provide implementations for several OS interfacing functions (_sbrk, _close, _fstat, and others). -## HAL +## HAL STM32 HAL can be used similar to CMSIS. - ```cmake find_package(HAL [HAL_version] COMPONENTS STM32F4 REQUIRED) set(CMAKE_INCLUDE_CURRENT_DIR TRUE) ``` - *`CMAKE_INCLUDE_CURRENT_DIR` here because HAL requires `stm32xx_hal_conf.h` file being in include headers path.* [HAL_version] is an optional version requirement. See [find_package documentation](https://cmake.org/cmake/help/v3.13/command/find_package.html?highlight=find%20package#id4). This parameter does not make sense if multiple STM32 families are requested. @@ -132,11 +111,11 @@ HAL module will search all drivers supported by family and create the following ***Note**: Targets for STM32H7 will look like `HAL::STM32::::[M7|M4]`, `HAL::STM32::::[M7|M4]::`, etc.* -Here is typical usage for a F4 device: +Here is typical usage: ```cmake -add_executable(${TARGET_NAME} blinky.c stm32f4xx_hal_conf.h) -target_link_libraries(${TARGET_NAME} +add_executable(stm32-blinky-f4 blinky.c stm32f4xx_hal_conf.h) +target_link_libraries(stm32-blinky-f4 HAL::STM32::F4::RCC HAL::STM32::F4::GPIO HAL::STM32::F4::CORTEX @@ -145,18 +124,6 @@ target_link_libraries(${TARGET_NAME} ) ``` -Here is another usage for a H7 device with the M7 core: - -```cmake -target_link_libraries(${TARGET_NAME} PRIVATE - HAL::STM32::H7::M7::RCC - HAL::STM32::H7::M7::GPIO - HAL::STM32::H7::M7::CORTEX - CMSIS::STM32::H743ZI::M7 - STM32::NoSys -) -``` - ### Building ```sh From 46c10b7fee12d66f98252320bf94c167a01877db Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 4 Jul 2021 12:34:27 +0200 Subject: [PATCH 4/9] removing unrelated changes --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fa0406dc..d5419f58 100644 --- a/README.md +++ b/README.md @@ -126,13 +126,10 @@ target_link_libraries(stm32-blinky-f4 ### Building -```sh -cmake -DCMAKE_TOOLCHAIN_FILE= -DCMAKE_BUILD_TYPE=Debug -cmake --build . ``` - -You can also ommit the `-DCMAKE_TOOLCHAIN_FILE` argument and use `set (CMAKE_TOOLCHAIN_FILE ...)` -in your `CMakeLists.txt` file + $ cmake -DCMAKE_TOOLCHAIN_FILE= -DCMAKE_BUILD_TYPE=Debug + $ make +``` ## Linker script & variables From f850a0aeb9746808039d78ff14dbf16dcdc185c0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 4 Jul 2021 12:34:58 +0200 Subject: [PATCH 5/9] removing unrelated changes --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d5419f58..0fe58d4d 100644 --- a/README.md +++ b/README.md @@ -133,9 +133,7 @@ target_link_libraries(stm32-blinky-f4 ## Linker script & variables -CMSIS package will generate linker script for your device automatically (target -`CMSIS::STM32::`). To specify a custom linker script, use the -`stm32_add_linker_script` function. +CMSIS package will generate linker script for your device automatically (target `CMSIS::STM32::`). To specify a custom linker script, use `stm32_add_linker_script` function. ## Useful CMake functions From aeafb569e3aaa1f44483f4b2fe5637f48a7f4842 Mon Sep 17 00:00:00 2001 From: Spacefish <31589589+rmspacefish@users.noreply.github.com> Date: Tue, 6 Jul 2021 03:10:52 -0400 Subject: [PATCH 6/9] Update README.md Co-authored-by: Julien Staub --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fe58d4d..0a577f66 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ It will compile a project for the `F4` family by default, but you can also compi First of all you need to configure toolchain and library paths using CMake variables. You can do this by passing values through command line during cmake run or by setting variables -inside your `CMakeLists.txt`. You can also set pass these variables to CMake by setting them +inside your `CMakeLists.txt`. You can also pass these variables to CMake by setting them as environmental variables. ## Configuration From 08ceb4b6023a90a2d0dbe4d1c4f1a939860f3cc2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Jul 2021 09:18:59 +0200 Subject: [PATCH 7/9] update README --- README.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0a577f66..288636a1 100644 --- a/README.md +++ b/README.md @@ -37,15 +37,35 @@ It will compile a project for the `F4` family by default, but you can also compi # Usage First of all you need to configure toolchain and library paths using CMake variables. -You can do this by passing values through command line during cmake run or by setting variables -inside your `CMakeLists.txt`. You can also pass these variables to CMake by setting them -as environmental variables. +You can do this by passing values through command line during cmake run with passed to CMake with +`-D=...`or by setting variables inside your `CMakeLists.txt`. You can also pass these +variables to CMake by setting them as environmental variables. The most important set of variables +which needs to be set can be found in the following section ## Configuration +These configuration options need to be or by setting them +as environmental variables. + * `STM32_TOOLCHAIN_PATH` - where toolchain is located, **default**: `/usr` +* `STM32_CUBE__PATH` - path to STM32Cube directory, where `` is one + of `F0 G0 L0 F1 L1 F2 F3 F4 G4 L4 F7 H7` **default**: `/opt/STM32Cube` + +These configuration variables are optional: + * `TARGET_TRIPLET` - toolchain target triplet, **default**: `arm-none-eabi` -* `STM32_CUBE__PATH` - path to STM32Cube directory, where `` is one of `F0 G0 L0 F1 L1 F2 F3 F4 G4 L4 F7 H7` **default**: `/opt/STM32Cube` +* `FREERTOS_PATH` - Path to the FreeRTOS kernel when compiling with a RTOS. Does not need to be + specified when using CMSIS + +Alternatively, you can write a small `path_helper.sh` script like this + +```sh +export STM32_TOOLCHAIN_PATH= +export TARGET_TRIPLET=arm-none-eabi +export STM32_CUBE__PATH= +``` + +and then use `. path_helper.sh` to set up the environment in one go. ## Common usage From 7251a8f99ee3cf1c9c722e97d8ee8669409da546 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Jul 2021 11:56:36 +0200 Subject: [PATCH 8/9] still need to test the windows part --- README.md | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 288636a1..5df69eb4 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,18 @@ It will compile a project for the `F4` family by default, but you can also compi # Usage -First of all you need to configure toolchain and library paths using CMake variables. -You can do this by passing values through command line during cmake run with passed to CMake with -`-D=...`or by setting variables inside your `CMakeLists.txt`. You can also pass these -variables to CMake by setting them as environmental variables. The most important set of variables -which needs to be set can be found in the following section +First of all you need to configure toolchain and library paths using CMake variables. There are +generally three ways to do this +1. Pass the variables through command line during cmake run with passed to CMake with + `-D=...` +2. Set the variables inside your `CMakeLists.txt` +3. Pass these variables to CMake by setting them as environmental variables. + +The most important set of variables which needs to be set can be found in the following section. ## Configuration -These configuration options need to be or by setting them -as environmental variables. +These configuration options need to be set for the build process to work properly: * `STM32_TOOLCHAIN_PATH` - where toolchain is located, **default**: `/usr` * `STM32_CUBE__PATH` - path to STM32Cube directory, where `` is one @@ -57,15 +59,28 @@ These configuration variables are optional: * `FREERTOS_PATH` - Path to the FreeRTOS kernel when compiling with a RTOS. Does not need to be specified when using CMSIS -Alternatively, you can write a small `path_helper.sh` script like this +### Helper script on Unix shells + +If you have access to a Unix shell, which is the default terminal on Linux, or tools like +`MinGW64` or `git bash` on Windows, you can write a small `path_helper.sh` script like this ```sh -export STM32_TOOLCHAIN_PATH= +export STM32_TOOLCHAIN_PATH="" export TARGET_TRIPLET=arm-none-eabi -export STM32_CUBE__PATH= +export STM32_CUBE__PATH="" ``` -and then use `. path_helper.sh` to set up the environment in one go. +and then use `. path_helper.sh` to set up the environment for the local terminal instance in one go. + +### Helper script in Powershell + +On Windows, you can use a Powershell script `path_helper.ps1`to set up the environment + +```sh +$env:STM32_TOOLCHAIN_PATH = "" +$env:TARGET_TRIPLET = arm-none-eabi +$env:STM32_CUBE__PATH="" +``` ## Common usage From 1a2ac70964a914c9ccf1d0c57d742421674a6e88 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Jul 2021 15:38:54 +0200 Subject: [PATCH 9/9] README small tweak --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5df69eb4..100b333d 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ It will compile a project for the `F4` family by default, but you can also compi # Usage First of all you need to configure toolchain and library paths using CMake variables. There are -generally three ways to do this +generally three ways to do this: + 1. Pass the variables through command line during cmake run with passed to CMake with `-D=...` 2. Set the variables inside your `CMakeLists.txt` @@ -62,7 +63,7 @@ These configuration variables are optional: ### Helper script on Unix shells If you have access to a Unix shell, which is the default terminal on Linux, or tools like -`MinGW64` or `git bash` on Windows, you can write a small `path_helper.sh` script like this +`MinGW64` or `git bash` on Windows, you can write a small `path_helper.sh` script like this: ```sh export STM32_TOOLCHAIN_PATH="" @@ -74,7 +75,7 @@ and then use `. path_helper.sh` to set up the environment for the local terminal ### Helper script in Powershell -On Windows, you can use a Powershell script `path_helper.ps1`to set up the environment +On Windows, you can use a Powershell script `path_helper.ps1`to set up the environment: ```sh $env:STM32_TOOLCHAIN_PATH = ""