Coder Social home page Coder Social logo

stm32-cmake's Introduction

About

Tests

This project is used to develop applications for the STM32 - ST's ARM Cortex-Mx MCUs. It uses cmake and GCC, along with newlib (libc), STM32Cube. Supports C0 F0 F1 F2 F3 F4 F7 G0 G4 H7 L0 L1 L4 L5 U0 U5 WB WL device families.

Requirements

  • cmake >= 3.16
  • GCC toolchain with newlib (optional).
  • STM32Cube package for appropriate STM32 family.

Project contains

  • CMake toolchain file, that configures cmake to use the arm toolchain: cmake/stm32_gcc.cmake.
  • CMake module that contains useful functions: cmake/stm32/common.cmake
  • CMake modules that contains information about each family - RAM/flash sizes, CPU types, device types and device naming (e.g. it can tell that STM32F407VG is F4 family with 1MB flash, 128KB RAM with CMSIS type F407xx)
  • CMake toolchain file that can generate a tunable linker script cmake/stm32/linker_ld.cmake
  • CMake module to find and configure CMSIS library cmake/FindCMSIS.cmake
  • CMake module to find and configure STM32 HAL library cmake/FindHAL.cmake
  • CMake modules for various libraries/RTOSes
  • CMake project template and examples
  • Some testing project to check cmake scripts working properly tests

Examples

  • template (examples/template) - project template, empty source linked compiled with CMSIS.
  • custom-linker-script (examples/custom-linker-script) - similar to template but using custom linker script.
  • fetch-cube (examples/fetch-cube) - example of using FetchContent for fetching STM32Cube from ST's git.
  • fetch-cmsis-hal (examples/fetch-cmsis-hal) - example of using FetchContent for fetching STM32 CMSIS and HAL from ST's git.
  • blinky (examples/blinky) - blink led using STM32 HAL library and SysTick. It will compile a project for the F4 family by default, but you can also compile for the L0 and F1 family by passing BLINKY_L0_EXAMPLE=ON or BLINKY_F1_EXAMPLE=ON to the CMake generation call. Using C++ instead of C is possible using USE_CPP_FILE=ON.
  • freertos (examples/freertos) - blink led using STM32 HAL library and FreeRTOS. You need to specify at least one board by passing FREERTOS_<BOARD>_EXAMPLE=ON to CMake. Currently, the example can be built for the H743ZI and F407VG board targets. You can opt to use the FreeRTOS CMSIS implementation provided by the Cube repository by supplying USE_CMSIS_RTOS=ON or USE_CMSIS_RTOS_V2 to CMake.

Usage

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<VAR_NAME>=...
  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 set for the build process to work properly:

  • STM32_CUBE_<FAMILY>_PATH - path to STM32Cube directory, where <FAMILY> is one of C0 F0 F1 F2 F3 F4 F7 G0 G4 H7 L0 L1 L4 L5 U0 U5 WB WL default: /opt/STM32Cube<FAMILY>

These configuration variables are optional:

  • STM32_TOOLCHAIN_PATH - where toolchain is located, default: /usr. Alternatively you can add the folder containing the toolchain binaries to the system path. If both are given, the STM32_TOOLCHAIN_PATH setting takes precedence
  • STM32_TARGET_TRIPLET - toolchain target triplet, default: arm-none-eabi
  • FREERTOS_PATH - Path to the FreeRTOS kernel when compiling with a RTOS. Does not need to be specified when using CMSIS

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:

export STM32_TOOLCHAIN_PATH="<ToolchainPath>"
export STM32_TARGET_TRIPLET=arm-none-eabi
export STM32_CUBE_<FAMILY>_PATH="<PathToCubeRoot>"

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.ps1to set up the environment:

$env:STM32_TOOLCHAIN_PATH = "<ToolchainPath>"
$env:STM32_TARGET_TRIPLET = arm-none-eabi
$env:STM32_CUBE_<FAMILY>_PATH="<PathToCubeRoot>"

Common usage

First thing that you need to do after toolchain configuration in your CMakeLists.txt script is to find CMSIS package:

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).

[CMSIS_version] is an optional version requirement. See find_package documentation. 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.

*Note: Some devices have two different cores (e.g. STM32H7 has Cortex-M7 and Cortex-M4). For those devices the name used must include the core name e.g STM32H7_M7 and STM32H7_M4. STM32WB is a multi-cores device even if the second core is not accessible by end user.

CMSIS consists of three main components:

  • Family-specific headers, e.g. stm32f4xx.h
  • Peripheral access layer header and source, e.g. system_stm32f4xx.[c|h]
  • Device type-specific startup sources (e.g. startup_stm32f407xx.s) (if ASM language is enabled)
  • Device-specific linker scripts which requires information about memory sizes (if ASM language is enabled)

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::<device>:

add_executable(stm32-template main.c)
target_link_libraries(stm32-template CMSIS::STM32::F407VG)

That will add include directories, peripheral layer files, startup source, linker script and compiler flags to your executable.

CMSIS creates the following targets:

  • CMSIS::STM32::<FAMILY> (e.g. CMSIS::STM32::F4) - common includes, compiler flags and defines for family
  • CMSIS::STM32::<TYPE> (e.g. CMSIS::STM32::F407xx) - common startup source for device type and peripheral access layer files, depends on CMSIS::STM32::<FAMILY>
  • CMSIS::STM32::<DEVICE> (e.g. CMSIS::STM32::F407VG) - linker script for device, depends on CMSIS::STM32::<TYPE>

So, if you don't need linker script, you can link only CMSIS::STM32::<TYPE> library and provide your own script using stm32_add_linker_script function

Note: Because of some families multi-cores architecture, all targets also have a suffix (e.g. STM32H7 has ::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.

HAL

STM32 HAL can be used similar to CMSIS.

find_package(HAL [HAL_version] COMPONENTS STM32F4 REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)

CMAKE_INCLUDE_CURRENT_DIR here because HAL requires stm32<family>xx_hal_conf.h file being in include headers path.

[HAL_version] is an optional version requirement. See find_package documentation. This parameter does not make sense if multiple STM32 families are requested.

HAL module will search all drivers supported by family and create the following targets:

  • HAL::STM32::<FAMILY> (e.g. HAL::STM32::F4) - common HAL source, depends on CMSIS::STM32::<FAMILY>
  • HAL::STM32::<FAMILY>::<DRIVER> (e.g. HAL::STM32::F4::GPIO) - HAL driver , depends on HAL::STM32::<FAMILY>
  • HAL::STM32::<FAMILY>::<DRIVER>Ex (e.g. HAL::STM32::F4::ADCEx) - HAL Extension driver , depends on HAL::STM32::<FAMILY>::<DRIVER>
  • HAL::STM32::<FAMILY>::LL_<DRIVER> (e.g. HAL::STM32::F4::LL_ADC) - HAL LL (Low-Level) driver , depends on HAL::STM32::<FAMILY>

Note: Targets for multi-cores devices will look like HAL::STM32::<FAMILY>::<CORE>, HAL::STM32::<FAMILY>::<CORE>::<DRIVER>, etc.

Here is typical usage:

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
    CMSIS::STM32::F407VG
    STM32::NoSys
)

Building

    $ cmake -DCMAKE_TOOLCHAIN_FILE=<path_to_gcc_stm32.cmake> -DCMAKE_BUILD_TYPE=Debug <path_to_sources>
    $ make

Linker script & variables

CMSIS package will generate linker script for your device automatically (target CMSIS::STM32::<DEVICE>). To specify a custom linker script, use stm32_add_linker_script function.

Useful CMake functions

  • stm32_get_chip_info(<chip> [FAMILY <family>] [TYPE <type>] [DEVICE <device>]) - classify device using name, will return device family (into <family> variable), type (<type>) and canonical name (<device>, uppercase without any package codes)
  • stm32_get_memory_info((CHIP <chip>)|(DEVICE <device> TYPE <type>) [FLASH|RAM|CCRAM|STACK|HEAP] [SIZE <size>] [ORIGIN <origin>]) - get information about device memories (into <size> and <origin>). Linker script generator uses values from this function
  • stm32_print_size_of_target(<target>) - Print the application sizes for all formats
  • stm32_generate_binary_file(<target>) - Generate the binary file for the given target
  • stm32_generate_srec_file(<target>) - Generate the srec file for the given target
  • stm32_generate_hex_file(<target>) - Generate the hex file for the given target

In the following functions, you can also specify mutiple families.

  • stm32_get_devices_by_family(STM_DEVICES [FAMILY families...]) - return into STM_DEVICES all supported devices by family (or all devices if FAMILY is omitted)
  • stm32_print_devices_by_family([FAMILY families...]) - Print all supported devices by family (or all devices if FAMILY is omitted)

Additional CMake modules

stm32-cmake contains additional CMake modules for finding and configuring various libraries and RTOSes used in the embedded world.

FreeRTOS

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 github repo, or the path to FreeRTOS-Kernel (usually located in the subfolder FreeRTOS on a downloaded release). FREERTOS_PATH can be supplied as an environmental variable as well.

It is possible to either use the FreeRTOS kernel provided in the Cube repositories, or a separate FreeRTOS kernel. The Cube repository also provides the CMSIS RTOS and CMSIS RTOS V2 implementations. If the CMSIS implementations is used, it is recommended to also use the FreeRTOS sources provided in the Cube repository because the CMSIS port might be incompatible to newer kernel versions. The FreeRTOS port to use is specified as a FreeRTOS component. A list of available ports can be found below. If the FreeRTOS sources provided in the Cube repository are used, the device family also has to be specified as a component for the FreeRTOS package.

CMSIS RTOS can be used by specifying a CMSIS target and by finding the CMSIS RTOS package. The following section will show a few example configurations for the H7 and F4 family. You can also find example code for several devices in the examples folder.

Typical usage for a H7 device when using the M7 core, using an external kernel without CMSIS support. The FreeRTOS namespace is set to FreeRTOS and the ARM_CM7 port is used:

find_package(CMSIS COMPONENTS STM32H743ZI STM32H7_M7 REQUIRED)
find_package(FreeRTOS ARM_CM7 REQUIRED)
target_link_libraries(${TARGET_NAME} PRIVATE
    ...
    FreeRTOS::ARM_CM7
)

Typical usage for a F4 device, using an external kernel without CMSIS support. The FreeRTOS namespace is set to FreeRTOS and the ARM_CM4F port is used:

find_package(FreeRTOS COMPONENTS ARM_CM4F REQUIRED)
target_link_libraries(${TARGET_NAME} PRIVATE
    ...
    FreeRTOS::ARM_CM4F
)

For ARMv8-M architecture (CM23 and CM33) you can choose "No Trust Zone" port:

find_package(FreeRTOS COMPONENTS ARM_CM33_NTZ REQUIRED)
target_link_libraries(${TARGET_NAME} PRIVATE
    ...
    FreeRTOS::ARM_CM33_NTZ
)

Or you can use the trust zone with:

find_package(FreeRTOS COMPONENTS ARM_CM33 REQUIRED)
target_link_libraries(${SECURE_TARGET_NAME} PRIVATE
    ...
    FreeRTOS::ARM_CM33::SECURE
)
target_link_libraries(${NON_SECURE_TARGET_NAME} PRIVATE
    ...
    FreeRTOS::ARM_CM33::NON_SECURE
)

Another typical usage using the FreeRTOS provided in the Cube repository and the CMSIS support. The FreeRTOS namespace is set to FreeRTOS::STM32::<FAMILY>, the ARM_CM7 port is used and the device family is specified as a FreeRTOS component with STM32H7:

find_package(CMSIS COMPONENTS STM32H743ZI STM32H7_M7 RTOS REQUIRED)
find_package(FreeRTOS COMPONENTS ARM_CM7 STM32H7 REQUIRED)
target_link_libraries(${TARGET_NAME} PRIVATE
    ...
    FreeRTOS::STM32::H7::M7::ARM_CM7
    CMSIS::STM32::H7::M7::RTOS
)

The following CMSIS targets are available in general:

  • CMSIS::STM32::<Family>::RTOS
  • CMSIS::STM32::<Family>::RTOS_V2

The following additional FreeRTOS targets are available in general to use the FreeRTOS provided in the Cube repository

  • FreeRTOS::STM32::<Family>

For the multi-core architectures, both family and core need to be specified like shown in the example above.

The following FreeRTOS ports are supported in general: ARM_CM0, ARM_CM3, ARM_CM3_MPU, ARM_CM4F, ARM_CM4_MPU, ARM_CM7, ARM_CM7_MPU, ARM_CM23, ARM_CM23_NTZ, ARM_CM33, ARM_CM33_NTZ.

Other FreeRTOS libraries, with FREERTOS_NAMESPACE being set as specified in the examples above:

  • ${FREERTOS_NAMESPACE}::Coroutine - co-routines (croutines.c)
  • ${FREERTOS_NAMESPACE}::EventGroups - event groups (event_groups.c)
  • ${FREERTOS_NAMESPACE}::StreamBuffer - stream buffer (stream_buffer.c)
  • ${FREERTOS_NAMESPACE}::Timers - timers (timers.c)
  • ${FREERTOS_NAMESPACE}::Heap::<N> - heap implementation (heap_<N>.c), <N>: [1-5]

stm32-cmake's People

Contributors

alxhoff avatar atsju avatar crvux avatar cwgthornton avatar danaozhong avatar g-arjones avatar grafalex82 avatar gudnimg avatar hish15 avatar inujel avatar janoc avatar jocussoft avatar jonathan-hamberg avatar kkoovalsky avatar ma11 avatar mikepurvis avatar nknotts avatar novikovas avatar obko avatar pavlot avatar pymaximus avatar r2axz avatar roamingthings avatar robamu avatar rpavlik avatar skt041959 avatar slide333333 avatar thopiekar avatar xanthio avatar xgroleau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stm32-cmake's Issues

Board support packages for more Nucleo / Discovery boards

It seems to me that board support packages are not directly supported except for STM32F429I-Discovery, since stm32-cmake will only set the variables BSP_HEADERS and BSP_SRC in FindSTM32BSP.cmake, if STM_BOARD is STM32F429I-Discovery.

The user can work around this by manually pointing these two variables to the appropriate files for their target development board, for example:

set(BSP_HEADERS "stm32f4xx_nucleo_144.h")
set(BSP_SRC "stm32f4xx_nucleo_144.c")
find_package(STM32BSP REQUIRED)

incorrect chip define for f0

for example in case of STM32_CHIP=stm32f030f4
ram and flash set correctly, but define is STM32F030xC (should be STM32F030x6)

GCC Link time optimization makes it impossible to override interrupt handlers

Steps to reproduce:

  • Create a project named Project.
  • Write an interrupt handler, such as
void HardFault_Handler(void)
{
    while (1)
    {
    }
}
  • Build the project in DEBUG mode.
  • Run nm Project | grep Handler and find the handler you've just written. You can see it's in a different address than most handlers, which shows that it's overriden by our custom handler.
  • Now build the project in RELEASE mode.
  • Run nm Project | grep Handler again. This time you should see that your handler is the same as other handlers, which means that it's not overriden.
  • Remove -flto in gcc_stm32.cmake line 74-77 and build again. You can see that the handler comes back.

This indicates that the GCC link time optimization has removed our handlers. That's why my SysTick_Handler not working and the RTOS can't get SysTick signal and stuck there.

There are two temporary workarounds:

  • Remove the weak definitions of the handlers you want to override in STM32Cube_FW_F0_V1.9.0/Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/gcc/startup_stm32f031x6.s(modify the path to suit your MCU)
-  .weak      HardFault_Handler
-  .thumb_set HardFault_Handler,Default_Handler
  • Or disable -flto option as described above.

Hope someone could solve this problem.

Could NOT find STM32HAL (missing: STM32HAL_SOURCES)

I use STM32Cube F4 version 1.19.0 on Mac OS. There are 4 "NOT_FOUND" files at the end of STM32HAL_SOURCES:

...
HAL_stm32f4xx_hal_fmc_c_FILE-NOTFOUND
HAL_stm32f4xx_hal_fsmc_c_FILE-NOTFOUND
HAL_stm32f4xx_hal_sdmmc_c_FILE-NOTFOUND
HAL_stm32f4xx_hal_usb_c_FILE-NOTFOUND

That is why FIND_PACKAGE_HANDLE_STANDARD_ARGS at the end of FindSTM32HAL.cmake throws the error.

Adding OpenCV to project

I have an image processing project and I use OpenCV library on PC. Now I must to implement it on an ARM micro like stm32f4 series(They have not OS). How can I build OpenCV for stm32 micros? (The problem is OpenCV is written in C++ but we must write in C language in order to program the code)

Generated linker file wastes 4 bytes of stack

The following line in file stm32_linker.cmake initialises the reset stack pointer to an odd address:

  "_estack = ${STM32_RAM_ORIGIN} + ${STM32_RAM_SIZE} - 1\;\n"

For instance, on an STM32F070 (16kB or SRAM) this results in the address 0x20003fff.

When the stack pointer on an STM32 MCU is loaded, bits 0 and 1 are always set to zero, resulting in address 0x20003ffc. When the stack is used, the stack pointer is first decremented before data is placed on the stack. That means that the top 4 bytes of the stack are never used.

This can easily be fixed by changing the line to:

  "_estack = ${STM32_RAM_ORIGIN} + ${STM32_RAM_SIZE}\;\n"

Is modern cmake would be possible in embedded world ?

Hi,
(I am a "desktop c++ dev" )

cmake >3.0 invite us to see packages as "TARGET"

  1. would it be possible to have CMSIS, HAL... as target and be able to write:
    capture
...


add_library(MySensorInterfaceLib ${files}
target_link_libraries(MySensorInterfaceLib  PRIVATE Stm32::CMSIS)

add_library(MyBusinessValueLib ${files}
target_link_libraries(MyBusinessValueLib PUBLIC MySensorInterfaceLib  )

add_executable(MyProject main.c)
target_link_libraries(MyProject PRIVATE MyBusinessValueLib ) 

i think it would be more "readable" and it can help low coupling

  1. as a general question, why embedded world encourage us to not create libraries but build all files ?

excuse my english...

Compile under Windows - undefined reference to `_exit'

I recently set up a template project for our future stm32 projects. Under Linux everything works like a charm but under Windows I cannot get it to work correctly.

When running cmake the compiler check fails with:

exit.c:(.text.exit+0x18): undefined reference to `_exit'
collect2.exe: error: ld returned 1 exit status

While testing I compiled a simple hello World using arm-none-eabi-gcc This was successful after adding --specs=nosys.specs to the command. Without it threw the same error as cmake.

I cannot figure out what I have to change in cmake to make this work. I tried to set CMAKE_EXE_LINKER_FLAGS, even in the toolchain file for F0, did not work.

Not sure if it's a bug or my inability...

Versions used:
Windows 7
CMake 3.8.2
arm gcc 6-2017-q1
CubeFW_F0 1,8.0

generated linker for stm32f303 causes hard faults

I experienced hard faults with the generated linker for my STM32F3 Discovery board. After a long puzzle, I used a linker file from the CMSIS directory:

SET(STM32_LINKER_SCRIPT /home/bart/STM32Cube/Repository/STM32Cube_FW_F3_V1.6.0/Projects/STM32F3-Discovery/Examples/GPIO/GPIO_EXTI/SW4STM32/STM32F3-Discovery/STM32F303VCTx_FLASH.ld)

The code is now running. The difference is a CCRAM specification:

in the memory section:
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 8K

and further down after .data and before .bss:

 _siccmram = LOADADDR(.ccmram);

  /* CCM-RAM section 
  * 
  * IMPORTANT NOTE! 
  * If initialized variables will be placed in this section,
  * the startup code needs to be modified to copy the init-values.  
  */
  .ccmram :
  {
    . = ALIGN(4);
    _sccmram = .;       /* create a global symbol at ccmram start */
    *(.ccmram)
    *(.ccmram*)
    
    . = ALIGN(4);
    _eccmram = .;       /* create a global symbol at ccmram end */
  } >CCMRAM AT> FLASH

Allow user to modify compiler flags in CMake Cache

Hi everyone!

Any reasons to make all compiler, linker etc. flags CACHE INTERNAL instead of CACHE STRING?

Well, if I would like to build my project using your stm32-cmake library with -mfloat-abi=hard instead of -mfloat-abi=softfp I have to modify gcc_stm32f4.cmake file, which is something unexpected for me. Maybe I did something stupid and missed correct way to modify the flags?

My guess your library should help users to get everything compiling but not forcing them to use only your flags. It would be pretty nice to have possibility to change flags and play around optimization options without modifying build scripts at the stm32-cmake.

Making there flags CACHE STRING instead of INTERNAL should make the day. What do you think?

[Question] How to exclude STM32Cube from stm32-cmake?

I don't use STM32Cube in my project, I use older stm32 standard peripheral driver. Some functions has conflicts.

How to disable STM32Cube?

-- No STM32Cube_DIR specified, using default: /opt/STM32Cube_FW_F4_V1.8.0
CMake Error at /usr/local/Cellar/cmake/3.13.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find CMSIS (missing: CMSIS_INCLUDE_DIRS CMSIS_SOURCES)

Thanks for your attention.

Don't Assume BSP Components Have Source Files

FindSTM32BSP.cmake wrongly assumes that all the components of the STM32Cube board support packages contain a source file. This is generally true but does not apply to the LCD module components and a serial flash component (ampire480272, ampire640480, and n25q256a), which contain headers only (STM32Cube v1.23.0).

If one includes a line like find_package(STM32BSP COMPONENTS ampire480272 ampire640480 n25q256a REQUIRED) in their CMakeLists.txt in addition to add_executable(${CMAKE_PROJECT_NAME} ${STM32BSP_SOURCES} then FindSTM32BSP.cmake will attempt to locate the source for these components and give output like below

-- BSP file is BSP_ampire480272.c_FILE-NOTFOUND
-- BSP file is BSP_ampire640480.c_FILE-NOTFOUND
-- BSP file is BSP_n25q256a.c_FILE-NOTFOUND

FindSTM32BSP:50 blindly appends the non-existent source file to BSP_SRC which is later used in the project as ${STM32BSP_SOURCES}, giving output

CMake Error at CMakeLists.txt:41 (add_executable):
  Cannot find source file:

    BSP_ampire480272.c_FILE-NOTFOUND

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

A temporary workaround for this issue is to create some empty source files in the STM32Cube BSP source tree.

Wonder the correct usage of stm32-cmake

I installed arm-gcc toolchain and added to path under Windows. However I tried to follow the instructions and finally got some weird result.

PS F:\Users\yuan\Desktop\stm32-cmake\stm32-blinky> cmake -DSTM32_CHIP=STM32F103C8 -DCMAKE_TOOLCHAIN_FILE=F:/Users/yuan/D
esktop/stm32-cmake/cmake/gcc_stm32f1.cmake -DCMAKE_BUILD_TYPE=Debug .
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.10.25019.0
-- The CXX compiler identification is MSVC 19.10.25019.0
-- Check for working C compiler: E:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Check for working C compiler: E:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: E:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Check for working CXX compiler: E:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is MSVC
-- Found assembler: E:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Warning: Did not find file Compiler/MSVC-ASM
CMake Error at CMakeLists.txt:6 (FIND_PACKAGE):
  By not providing "FindCMSIS.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "CMSIS", but
  CMake did not find one.

  Could not find a package configuration file provided by "CMSIS" with any of
  the following names:

    CMSISConfig.cmake
    cmsis-config.cmake

  Add the installation prefix of "CMSIS" to CMAKE_PREFIX_PATH or set
  "CMSIS_DIR" to a directory containing one of the above files.  If "CMSIS"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "F:/Users/yuan/Desktop/stm32-cmake/stm32-blinky/CMakeFiles/CMakeOutput.log".
PS F:\Users\yuan\Desktop\stm32-cmake\stm32-blinky>

I am a newbie of cmake and want to know how to get it work.

Unknown CMake command "STM32_GET_CHIP_TYPE"

Just trying to compile one of the examples, I get this:

$ cmake . -DSTM32_CHIP=STM32F407IG -DCMAKE_MODULE_PATH=../cmake
CMake Error at /Users/kamil/intellijel/eurorack/ARM/stm32-cmake/cmake/FindCMSIS.cmake:3 (STM32_GET_CHIP_TYPE):
  Unknown CMake command "STM32_GET_CHIP_TYPE".
Call Stack (most recent call first):
  CMakeLists.txt:6 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "/Users/kamil/intellijel/eurorack/ARM/stm32-cmake/stm32-blinky/CMakeFiles/CMakeOutput.log".

wrong about undefined reference to `SystemInit'

sorry for my bad english .I meet some problem when I build in CMakeFiles/stm32-template.
Could you tell me what is wrong in it

CMakeFiles/stm32-template.dir/usr/arm-none-eabi/share/cmsis/startup_stm32f10x_md_vl.s.obj: In function LoopFillZerobss': (.text.Reset_Handler+0x26): undefined reference toSystemInit'
collect2: error: ld returned 1 exit status
make[2]: *** [stm32-template] Error 1
make[1]: *** [CMakeFiles/stm32-template.dir/all] Error 2
make: *** [all] Error 2

Support LL

Hi,

So it would be great if the new LL libs were also supported. I have seen that you added the libs as an alternate way. But I think that is not good because you also can mix HAL and LL - ST dose this in some examples. See here the new version for the F1 as an example

STM32Cube_FW_F1_V1.6.0\Projects\STM32F103RB-Nucleo\Examples_MIX\

I am willing to help here but do you have any preferred way of fixing that. I think I would be great do separate the HAL and LL stuff.

cheers mathias

automatic discovery of components

I am trying to use the stm32-cmake package in my project but I come across new extended component in F7 firmware. The available HAL components and extended components are hard-coded in cmake/FindSTM32HAL.cmake. Instead of just adding the missing entry I created cmake function that scans the available files and discovers components automatically and override the hand crafted lists. this functionality is enabled via cmake flag. Check this branch: https://github.com/maciejmatuszak/stm32-cmake/tree/automatic_component_discovery
I also added macro to enable the components by creating target defines HAL_XXX_MODULE_ENABLED this can replace the modification of the stm32fXxx_hal_conf.h file. The list of component you want to use can be set into variable:

set(REQUIRED_COMPONENTS uart tim spi adc dac gpio rtc dma exti rcc flash pwr i2c cortex)

and then reused:

FIND_PACKAGE(STM32HAL COMPONENTS ${REQUIRED_COMPONENTS} REQUIRED)
...
...
STM32_ENABLE_HAL_COMPONENT(${CMAKE_PROJECT_NAME} ${REQUIRED_COMPONENTS})

I would suggest to include this functionality back to this repo.

Including a license file

This project really looks useful and well written, thanks for that! However, no license comes with it, limiting (forbidding?) its usage.

Could you include a license with this project ?

FreeRTOS port

Would you consider merging a pull-request for this?

Using EXECUTABLE_OUTPUT_PATH vs CMAKE_RUNTIME_OUTPUT_DIRECTORY

I noticed when configuring a project that gcc_stm32.cmake uses EXECUTABLE_OUTPUT_PATH rather than CMAKE_RUNTIME_OUTPUT_DIRECTORY when figuring out where to put the .elf, .hex, and .bin files. I was wondering if there's a big reason behind that (maintaining compatibility with older versions of CMake for example). I tried looking back and figuring out when exactly it was deprecated (at least since 3.0.2 it seems).

Not sure how trivial a thing it is to change or if there is good reason for keeping it as such.

Thanks!

STM32_CODES in gcc_stm32l4.cmake

Hi,

I believe all code in this line must be upper case.

Thus not

SET(STM32_CODES ..... "4a6.." "4r5.." "4r7.." "4r9.." "4s5.." "4s7.." "4s9..")

but

SET(STM32_CODES ..... "4A6.." "4R5.." "4R7.." "4R9.." "4S5.." "4S7.." "4S9..")

Otherwise a line such as this will not succeed:

cmake -DSTM32_CHIP=STM32L4R5VI `#-DSTM32_CHIP_TYPE=4r5xx` -DSTM32Cube_DIR=~/projects/arm/stm32/STM32Cube_FW_L4_V1.13.0    `#-DSTM32_FAMILY=L4` -DCMAKE_TOOLCHAIN_FILE=../cmake/gcc_stm32.cmake -DCMAKE_BUILD_TYPE=Debug ../stm32-blinky/

According to this valid names for the L4 family seem to be
STM32L4R5VI, STM32L4R5QI, STM32L4R5ZI, STM32L4R5AI, STM32L4R5AG, STM32L4R5QG, STM32L4R5VG, STM32L4R5ZG

Could NOT find CMSIS (missing: CMSIS_SOURCES)

I'm new to cmaka and CL building. So maybe I'm missing something. Thanks!

OS: macOS 10.13.2
cmake: 3.10.0

/usr/local/opt/cmake/bin/cmake -DCMAKE_C_COMPILER=/usr/local/bin/arm-none-eabi-gcc -DCMAKE_CXX_COMPILER=/usr/local/bin/arm-none-eabi-g++ -DCMAKE_ECLIPSE_VERSION=4.7 -DSTM32_CHIP=STM32F411VE -DTOOLCHAIN_PREFIX=/usr/local/bin/  -DSTM32Cube_DIR=~/STM32Cube -DCMAKE_MODULE_PATH=~/opt/cmake/ -DCMAKE_TOOLCHAIN_FILE=~/opt/cmake/gcc_stm32f4.cmake -DCMAKE_BUILD_TYPE=Debug .
-- The C compiler identification is GNU 6.3.1
-- The CXX compiler identification is GNU 6.3.1
-- Eclipse version is set to 4.7. Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
-- Check for working C compiler: /usr/local/bin/arm-none-eabi-gcc
-- Check for working C compiler: /usr/local/bin/arm-none-eabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - no
-- Check for working CXX compiler: /usr/local/bin/arm-none-eabi-g++
-- Check for working CXX compiler: /usr/local/bin/arm-none-eabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/local/bin/arm-none-eabi-gcc
-- STM32F411VE is 411xE device
CMake Error at /usr/local/Cellar/cmake/3.10.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find CMSIS (missing: CMSIS_SOURCES)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.10.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /Users/vagif/opt/cmake/FindCMSIS.cmake:152 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:6 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "/Users/vagif/workspace/eclipse/cmaketest/CMakeFiles/CMakeOutput.log".
See also "/Users/vagif/workspace/eclipse/cmaketest/CMakeFiles/CMakeError.log".

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.

My plan is to compile ChibiOS 3 using cmake.
I'm trying to run cmake for stm32-chibios and getting following:

ton@aircat:/Users/ton/Copter/chibios3test/build% cmake -DSTM32_CHIP=STM32F407IG -DCMAKE_TOOLCHAIN_FILE=../cmake/gcc_stm32.cmake -DCMAKE_MODULE_PATH=../cmake -DCHIBIOS_ROOT=../ChibiOS -DCMAKE_BUILD_TYPE=Debug ../stm32-chibios
-- No TOOLCHAIN_PREFIX specified, using default: /usr/local
-- No TARGET_TRIPLET specified, using default: arm-none-eabi
-- No STM32_FAMILY specified, trying to get it from STM32_CHIP
-- Selected STM32 family: F4
-- The ASM compiler identification is GNU
-- Found assembler: /usr/local/bin/arm-none-eabi-gcc
-- Chibios version:
-- No CHIBIOS_PROCESS_STACK_SIZE specified, using default: 0x400
-- No CHIBIOS_MAIN_STACK_SIZE specified, using default: 0x400
-- Found ChibiOS: CHIBIOS_nil_crt1.c-NOTFOUND;CHIBIOS_nil_vectors.c-NOTFOUND;CHIBIOS_nil_nilcore.c-NOTFOUND;CHIBIOS_nil_nil.c-NOTFOUND;CHIBIOS_nil_crt0_v7m.s-NOTFOUND;CHIBIOS_nil_nilcore_v7m.c-NOTFOUND;CHIBIOS_nil_nilcoreasm_v7m.s-NOTFOUND;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/src/hal.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/src/hal_queues.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/osal/nil/osal.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/ports/STM32/STM32F4xx/hal_lld.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/ports/STM32/LLD/DMAv2/stm32_dma.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/ports/common/ARMCMx/nvic.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/src/pal.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/pal_lld.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/src/serial.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/ports/STM32/LLD/USARTv1/serial_lld.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/src/st.c;/Users/ton/Copter/chibios3test/ChibiOS/os/hal/ports/STM32/LLD/TIMv1/st_lld.c  
-- STM32F407IG has 1024KiB of flash memory and 128KiB of RAM
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CHIBIOS_nil_PLATFORM_cmparams.h_INCLUDE_DIR
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
CHIBIOS_nil_PLATFORM_core_cm4.h_INCLUDE_DIR
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
CHIBIOS_nil_PLATFORM_stm32f4xx.h_INCLUDE_DIR
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
CHIBIOS_nil_nil.h_INCLUDE_DIR
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
CHIBIOS_nil_nilcore.h_INCLUDE_DIR
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
CHIBIOS_nil_niltypes.h_INCLUDE_DIR
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios
   used as include directory in directory /Users/ton/Copter/chibios3test/stm32-chibios

-- Configuring incomplete, errors occurred!
See also "/Users/ton/Copter/chibios3test/build/CMakeFiles/CMakeOutput.log".

What I'm doing wrong?

STM32F746G-DISCO Unsupported

First of all, thanks for this project, it definitely helps my projects !!

Testing with a STM32 F7 Discovery board with STM32F746NGH6 MCU and cmake things its a 765xx device.

23:22 $ cmake -DSTM32_CHIP=STM32F746NG -DCMAKE_TOOLCHAIN_FILE=/Users/frank/other_repos/stm32-cmake/cmake/gcc_stm32.cmake -DCMAKE_BUILD_TYPE=Debug ../
-- No TARGET_TRIPLET specified, using default: arm-none-eabi
-- No STM32_FAMILY specified, trying to get it from STM32_CHIP
-- Selected STM32 family: F7
-- STM32F746NG is 765xx device

If I make the following change

diff --git a/cmake/gcc_stm32f7.cmake b/cmake/gcc_stm32f7.cmake
index 910795c..0bfb256 100644
--- a/cmake/gcc_stm32f7.cmake
+++ b/cmake/gcc_stm32f7.cmake
@@ -5,7 +5,7 @@ SET(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=softf
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections -mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=softfp -mabi=aapcs" CACHE INTERNAL "executable linker flags")
SET(CMAKE_MODULE_LINKER_FLAGS "-mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=softfp -mabi=aapcs" CACHE INTERNAL "module linker flags")
SET(CMAKE_SHARED_LINKER_FLAGS "-mthumb -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=softfp -mabi=aapcs" CACHE INTERNAL "shared linker flags")
-SET(STM32_CHIP_TYPES 745xx 765xx 756xx 767xx 777xx 769xx 779xx CACHE INTERNAL "stm32f4 chip types")
+SET(STM32_CHIP_TYPES 745xx 746xx 756xx 767xx 777xx 769xx 779xx CACHE INTERNAL "stm32f4 chip types")
SET(STM32_CODES "745.." "746.." "756.." "767.." "777.." "769.." "779..")

ie: change the 765xx into 746xx in STM32_CHIP_TYPES then all is well.

โœ” ~/repos/stm32f746G_disco_TIM_TimeBase/build
00:15 $ cmake -DSTM32_CHIP=STM32F746NG -DCMAKE_TOOLCHAIN_FILE=/Users/frank/other_repos/stm32-cmake/cmake/gcc_stm32.cmake -DCMAKE_BUILD_TYPE=Debug ../
-- No TARGET_TRIPLET specified, using default: arm-none-eabi
-- No STM32_FAMILY specified, trying to get it from STM32_CHIP
-- Selected STM32 family: F7
-- The C compiler identification is GNU 6.3.1
-- The CXX compiler identification is GNU 6.3.1
-- Check for working C compiler: /Users/frank/opt/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-gcc
-- Check for working C compiler: /Users/frank/opt/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Users/frank/opt/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-g++
-- Check for working CXX compiler: /Users/frank/opt/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /Users/frank/opt/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-gcc
-- STM32F746NG is 746xx device
-- Found CMSIS: /Users/frank/STM32Cube/Repository/STM32Cube_FW_F7_V1.7.0/Drivers/CMSIS/Device/ST/STM32F7xx/Include;/Users/frank/STM32Cube/Repository/STM32Cube_FW_F7_V1.7.0/Drivers/CMSIS/Include
-- Found STM32HAL: /Users/frank/STM32Cube/Repository/STM32Cube_FW_F7_V1.7.0/Drivers/STM32F7xx_HAL_Driver/Inc
-- No linker script specified, generating default
-- STM32F746NG has 1024KiB of flash memory and 320KiB of RAM
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/frank/repos/stm32f746G_disco_TIM_TimeBase/build

The flash and ram sizes are correct for this chipset, according to the linker script provided by
STM32Cube

00:20 $ grep ORIGIN STM32F746NGHx_FLASH.ld
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K

-DNDEBUG in Release modes flags is missing

Dear stm32-cmake community,
it seems that 'NDEBUG' definition is kind of 'standard' for CMake release mode compilation flags. Some projects rely on it. I had a minor problems cross-compiling my project for STM32, while I was expecting this flag in release modes. Though It's not a big deal, maybe it is reasonable to keep common CMake's way and add this definition to release mode compilation flags?
I know adding this flag back might cause problems for other stm32-cmake based projects, so this issue is debatable.

Automatically create * .bin * .hex

Use this in gcc_stm32.cmake
ADD_CUSTOM_TARGET(${TARGET}.hex ALL DEPENDS ${TARGET} COMMAND ${CMAKE_OBJCOPY} -Oihex ${FILENAME} ${FILENAME}.hex)

cmake build error

Hi @ObKo

When I try to generate package of CMSIS and StdPeriph libraries and headers, cmake output error message as blelow. The step is following package README.md

inflating: STM32F10x_StdPeriph_Lib_V3.5.0/_htmresc/CMSIS_Logo_Final.jpg
inflating: STM32F10x_StdPeriph_Lib_V3.5.0/_htmresc/logo.bmp
CMake Error at CMakeLists.txt:52 (add_subdirectory):
add_subdirectory given source "../cmsis" which is not an existing
directory.

CMake Error at CMakeLists.txt:55 (get_property):
get_property DIRECTORY scope provided but requested directory was not
found. This could be because the directory argument was invalid or, it is
valid but has not been processed yet.

CMake Error at CMakeLists.txt:56 (add_subdirectory):
add_subdirectory given source "../stdperiph" which is not an existing
directory.

-- Configuring incomplete, errors occurred!

REM - rake embedded

Hi ObKo!

Sorry to open an issue for this, but I find your project very interesting and I think it is the only way to contact you. I think we have had the same ideas behind our projects ;)

Please take a look at my microcontroller buildsystem:
https://github.com/franzflasch/REM

The idea behind my project is quite similar to yours, however I use rake as a basis, not cmake. My project also supports FreeRTOS, and not just STM32 controllers! It also supports AVR and 8051 controllers. It is easily extendable!

If you're interested, just take a look at it!

Thanks,
Franz

Precompiled CMSIS and StdPeriph might be a bad idea

I just ran into a problem with above and thought I'd share my experiences.

Some devices (e.g. STM32Primer2) use crystals with frequencies !=8MHz (in my case 12MHz).
Clock configuration code in sdtpheriphlib uses 8MHz as a default if the variable HSE_VALUE ist not set to the correct xtal frequency either directly in stm32f10x.h or via commandline preprocessor define.
This makes the compiled libs depend on the target system in more ways than just family and chip type and can lead to wrong system timing, wrong UART BAUDrates and other nasty errors.

I used your solution with libs installed in my GCC environment until i ran into above.

Since setting a #define after compilation has no effect, you will need to recompile/reinstall the library every time you switch targets or risk getting above behaviour.

My solution is to ship CMSIS/STDPERIPH sources with every project and compile them before the project. That way CMAKE picks up changes like above that need to trigger a recompilation of the library and the user need only specify his target specific options in a cmake file.

cmsis?

Hello,
I came back to this project today. As I found out now a lot of stuff has changed. So for a first try I use a ubuntu VM to set up everything. So I think the first thing someone should do is build the packages folder. But as I found out there is no CMSIS download feature within this version. As I remember some time ago the scripts also handle the download of CMSIS. So do you have a good place to download them and where to place them in the file system?`

thx

Deprecated flags and errors

Building example:
cmake -DSTM32_CHIP=STM32F103C8 -DCMAKE_TOOLCHAIN_FILE=/home/john/work/stm32-cmake/stm32-cmake/cmake/gcc_stm32f1.cmake -DCMAKE_BUILD_TYPE=Release /home/john/work/stm32-cmake/stm32-cmake/stm32-blinky/

CMakeError.log:
CMakeError.txt

Debug Support in Eclipse CDT

Dear ObKo,

thank you again for helping me to get things running. Compilation works fine with makefiles and I can flash the resulting bin-Files to my board using the ST Link Utility. Great!

Next thing I tried is to generate an Eclipse project, import the project in my workspace, compile it using the make target "stm32-blinky.bin" an flash the resulting bin file to my test board using the ST-Link Utility. Great, this works as well! There is only one drawback:The indexer does not work properly. Many code elements (e.g. all integer variable types) are underlined in red. This makes development in Eclipse a bit hard as I normally rely on these live code checks...

Up to now, I have used the "GNU ARM Eclipse"-Plugin, which enables convenient compiling, flashing and debugging STM32 code within Eclipse. After having configured cmake to create an Eclipse CDT Project with CMAKE_BUILD_TYPE=DEBUG, I tried to create a new debug configuration for the stm32-blinky-Debug@stm32-blinky-sources" project. After having started the debugger I got the message

Launching stm32-blicnky-Debug_stm32-blinky-sources Configuration has encountered a problem. Error while launching command: gdb --version

My question is now: Do stm32-cmake projects generally support debugging in Eclipse? If yes, what do I need to do?

Thank you in advance for your answer!

Klaus

cmake errors

Hey,

I am using cmake 3.3.2 and get the following errors:

 ~/git/stm32-cmake/stm32-chibios/build (git)-[master] % cmake -DCMAKE_TOOLCHAIN_FILE=/home/abc/git/stm32-cmake/cmake/gcc_stm32.cmake ..
-- No TOOLCHAIN_PREFIX specified, using default: /usr
-- No TARGET_TRIPLET specified, using default: arm-none-eabi
-- No STM32_FAMILY specified, trying to get it from STM32_CHIP
-- Neither STM32_FAMILY nor STM32_CHIP specified, using default STM32_FAMILY: F1
CMake Error at /home/abc/git/stm32-cmake/cmake/gcc_stm32.cmake:74 (include):
  include could not find load file:

    gcc_stm32f1
Call Stack (most recent call first):
  /usr/share/cmake-3.3/Modules/CMakeDetermineSystem.cmake:98 (include)
  CMakeLists.txt:1 (PROJECT)


CMake Error at /home/abc/git/stm32-cmake/cmake/gcc_stm32.cmake:74 (include):
  include could not find load file:

    gcc_stm32f1
Call Stack (most recent call first):
  build/CMakeFiles/3.3.2/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:1 (PROJECT)


-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
CMake Error at CMakeLists.txt:6 (FIND_PACKAGE):
  By not providing "FindChibiOS.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "ChibiOS", but
  CMake did not find one.

  Could not find a package configuration file provided by "ChibiOS" with any
  of the following names:

    ChibiOSConfig.cmake
    chibios-config.cmake

  Add the installation prefix of "ChibiOS" to CMAKE_PREFIX_PATH or set
  "ChibiOS_DIR" to a directory containing one of the above files.  If
  "ChibiOS" provides a separate development package or SDK, be sure it has
  been installed.


-- Configuring incomplete, errors occurred!
See also "/home/abc/git/stm32-cmake/stm32-chibios/build/CMakeFiles/CMakeOutput.log".
~/git/stm32-cmake/stm32-chibios/build (git)-[master] %

Any idea why this is happening?

cmake error with GNU Tools ARM Embedded\7 2017-q4-major

Hi,
I do have some problems with gcc 7.21 running on Windows 10


-- No TARGET_TRIPLET specified, using default: arm-none-eabi
-- No STM32_FAMILY specified, trying to get it from STM32_CHIP
-- Selected STM32 family: F4
-- The C compiler identification is GNU 7.2.1
-- The CXX compiler identification is GNU 7.2.1
-- Check for working C compiler: c:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/bin/arm-none-eabi-gcc.exe
-- Check for working C compiler: c:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/bin/arm-none-eabi-gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "c:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/bin/arm-none-eabi-gcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: E:/LWN/github_c/stm32f4_canpie-fd/Debug/CMakeFiles/CMakeTmp

    Run Build Command:"C:/PROGRA~2/GNUARM~1/BUILDT~1/2DBD0~1.8-2/bin/make.exe" "cmTC_c6f86/fast"
    C:/PROGRA~2/GNUARM~1/BUILDT~1/2DBD0~1.8-2/bin/make.exe -f CMakeFiles/cmTC_c6f86.dir/build.make CMakeFiles/cmTC_c6f86.dir/build
    make.exe[1]: Entering directory 'E:/LWN/github_c/stm32f4_canpie-fd/Debug/CMakeFiles/CMakeTmp'
    c:/program files (x86)/gnu arm eclipse/build tools/2.8-201611221915/bin/sh: /C/Program Files/CMake/bin/cmake.exe: not found
    CMakeFiles/cmTC_c6f86.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_c6f86.dir/testCCompiler.c.obj' failed
    make.exe[1]: *** [CMakeFiles/cmTC_c6f86.dir/testCCompiler.c.obj] Error 127
    make.exe[1]: Leaving directory 'E:/LWN/github_c/stm32f4_canpie-fd/Debug/CMakeFiles/CMakeTmp'
    Makefile:126: recipe for target 'cmTC_c6f86/fast' failed
    make.exe: *** [cmTC_c6f86/fast] Error 2

I do not find out whats the problem.

Many thanks
cheers
geri

Set flash origin and size?

Hello,

What is the correct way to set the flash origin and size?

I tried to set the documented variables this way:

SET(STM32_FLASH_ORIGIN "0x08007400" CACHE STRING "set flash origin")
SET(STM32_FLASH_SIZE "94K" CACHE STRING "set flash origin")

but i only get:

MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08007400, LENGTH = 128K
  RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 20K

By the way is there a possibility to set a custom linker file which is splitted into multiple files? The GNU ARM eclipse plugin uses a 3 file combination for linker files (libs.ld, mem.ld, and sections.ld) I like this schema but it would be great if there is a way to set all this three files as a custom linker files with stm32-cmake.

many thanks

CMakeForceCompiler is required for CMake 3.5.x

Since you moved away from CMAKE_FORCE_XXX_COMPILER (1910bc5#diff-ed993e724594a8cbe4fc49c78ad27d97), I'm running into this issue:

http://cmake.3232098.n2.nabble.com/Toolchains-and-CMAKE-FORCE-C-COMPILER-in-3-5-td7592757.html

Basically, CMAKE is unable to validate my toolchain because of linkage error. This is somehow correct, as I compile for bare metal and I am providing the _exit function in my code:

-- No TOOLCHAIN_PREFIX specified, using default: /usr
-- No TARGET_TRIPLET specified, using default: arm-none-eabi
-- No STM32_FAMILY specified, trying to get it from STM32_CHIP
-- Selected STM32 family: F4
-- The C compiler identification is GNU 6.2.1
-- The CXX compiler identification is GNU 6.2.1
-- Check for working C compiler: /usr/bin/arm-none-eabi-gcc
-- Check for working C compiler: /usr/bin/arm-none-eabi-gcc -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/arm-none-eabi-gcc" is not able to compile a simple
  test program.

  It fails with the following output:

   Change Dir: /home/renaud/Workspace/test/build/CMakeFiles/CMakeTmp

  Run Build Command:"/usr/bin/make" "cmTC_17f06/fast"

  /usr/bin/make -f CMakeFiles/cmTC_17f06.dir/build.make
  CMakeFiles/cmTC_17f06.dir/build

  make[1]: Entering directory
  '/home/renaud/Workspace/test/build/CMakeFiles/CMakeTmp'

  Building C object CMakeFiles/cmTC_17f06.dir/testCCompiler.c.obj

  /usr/bin/arm-none-eabi-gcc -mthumb -fno-builtin -mcpu=cortex-m4
  -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Wall -std=gnu99 -ffunction-sections
  -fdata-sections -fomit-frame-pointer -mabi=aapcs -fno-unroll-loops
  -ffast-math -ftree-vectorize -o
  CMakeFiles/cmTC_17f06.dir/testCCompiler.c.obj -c
  /home/renaud/Workspace/test/build/CMakeFiles/CMakeTmp/testCCompiler.c

  Linking C executable cmTC_17f06

  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_17f06.dir/link.txt
  --verbose=1

  /usr/bin/arm-none-eabi-gcc -mthumb -fno-builtin -mcpu=cortex-m4
  -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Wall -std=gnu99 -ffunction-sections
  -fdata-sections -fomit-frame-pointer -mabi=aapcs -fno-unroll-loops
  -ffast-math -ftree-vectorize -Wl,--gc-sections -mthumb -mcpu=cortex-m3
  -mabi=aapcs CMakeFiles/cmTC_17f06.dir/testCCompiler.c.obj -o cmTC_17f06

  /usr/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o):
  In function `exit':

  exit.c:(.text.exit+0x2c): undefined reference to `_exit'

  collect2: error: ld returned 1 exit status

  CMakeFiles/cmTC_17f06.dir/build.make:97: recipe for target 'cmTC_17f06'
  failed

  make[1]: *** [cmTC_17f06] Error 1

  make[1]: Leaving directory
  '/home/renaud/Workspace/test/build/CMakeFiles/CMakeTmp'

  Makefile:126: recipe for target 'cmTC_17f06/fast' failed

  make: *** [cmTC_17f06/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:6 (PROJECT)

-- Configuring incomplete, errors occurred!

As a quick fix, I had to re-enable CMAKE_FORCE_XXX_COMPILER:

diff --git a/cmake/gcc_stm32.cmake b/cmake/gcc_stm32.cmake
index be637e2..27a9f44 100644
--- a/cmake/gcc_stm32.cmake
+++ b/cmake/gcc_stm32.cmake
@@ -1,3 +1,5 @@
+INCLUDE(CMakeForceCompiler)
+
 GET_FILENAME_COMPONENT(STM32_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} DIRECTORY)
 SET(CMAKE_MODULE_PATH ${STM32_CMAKE_DIR} ${CMAKE_MODULE_PATH})
 
@@ -44,6 +46,9 @@ ELSE()
     SET(TOOL_EXECUTABLE_SUFFIX "")
 ENDIF()
 
+CMAKE_FORCE_C_COMPILER(${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gcc${TOOL_EXECUTABLE_SUFFIX} GNU)
+CMAKE_FORCE_CXX_COMPILER(${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-g++${TOOL_EXECUTABLE_SUFFIX} GNU)
+
 SET(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
 SET(CMAKE_C_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gcc${TOOL_EXECUTABLE_SUFFIX})
 SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-g++${TOOL_EXECUTABLE_SUFFIX})

Any comments on this?

CMake Error at FindCMSIS.cmake:3 (STM32_GET_CHIP_TYPE)

Hello. I have met a problem:

[uuy@pc stm32-blinky]$ cmake -DCMAKE_BUILD_TYPE=Debug -DSTM32_CHIP=STM32F407VG -DCMAKE_TOOLCHAIN_FILE=gcc_stm32.cmake  ./
CMake Error at ...../stm32-cmake/cmake/FindCMSIS.cmake:3 (STM32_GET_CHIP_TYPE):
  Unknown CMake command "STM32_GET_CHIP_TYPE".

Update. I also tried to use absolute and relative path to gcc_stm32.cmake:

-DCMAKE_TOOLCHAIN_FILE=../cmake/gcc_stm32.cmake
-DCMAKE_TOOLCHAIN_FILE=/home/uuy/devel/embed/stm32-cmake/cmake/gcc_stm32.cmake  

and got the same result.

Please help to resolve.

CMake performs test-compiles with wrong CC

Hi,
I'm trying to compile the "blinky" example project for the STM32F407VG, however running
cmake -DSTM32_CHIP=STM32F407VG -DCMAKE_TOOLCHAIN_FILE=../stm32-cmake/cmake/gcc_stm32.cmake -DCMAKE_BUILD_TYPE=Debug -G "Eclipse CDT4 - Unix Makefiles" .
leads to the following errors:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Eclipse version is set to 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-3.7/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/christian5/Desktop/share/projekt-blinky/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_08b95/fast"

make: Warning: File 'Makefile' has modification time 1.4 s in the future

/usr/bin/make -f CMakeFiles/cmTC_08b95.dir/build.make
CMakeFiles/cmTC_08b95.dir/build

make[1]: Entering directory
'/home/christian5/Desktop/share/projekt-blinky/CMakeFiles/CMakeTmp'

make[1]: Warning: File 'CMakeFiles/cmTC_08b95.dir/flags.make' has
modification time 1.3 s in the future

Building C object CMakeFiles/cmTC_08b95.dir/testCCompiler.c.o

/usr/bin/cc -mthumb -fno-builtin -mcpu=cortex-m4 -mfpu=fpv4-sp-d16
-mfloat-abi=softfp -Wall -std=gnu99 -ffunction-sections -fdata-sections
-fomit-frame-pointer -mabi=aapcs -fno-unroll-loops -ffast-math
-ftree-vectorize -o CMakeFiles/cmTC_08b95.dir/testCCompiler.c.o -c
/home/christian5/Desktop/share/projekt-blinky/CMakeFiles/CMakeTmp/testCCompiler.c

cc: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead

cc: error: unrecognized argument in option '-mabi=aapcs'

cc: note: valid arguments to '-mabi=' are: ms sysv

cc: error: unrecognized command line option '-mthumb'; did you mean
'-mtbm'?

cc: error: unrecognized command line option '-mfpu=fpv4-sp-d16'

cc: error: unrecognized command line option '-mfloat-abi=softfp'

make[1]: *** [CMakeFiles/cmTC_08b95.dir/build.make:66:
CMakeFiles/cmTC_08b95.dir/testCCompiler.c.o] Error 1

make[1]: Leaving directory
'/home/christian5/Desktop/share/projekt-blinky/CMakeFiles/CMakeTmp'

make: *** [Makefile:126: cmTC_08b95/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (PROJECT)

-- Configuring incomplete, errors occurred!

It appears that CMake is trying to use the flags for the ARM compiler with the standard CC (x86). My CMake version is 3.7.1

make C++ optional

some tollchains may be without C++ compiler. Can stm32-cmake handle such situations?

Make Error 2 @ Win 8.1

Dear ObKo,

thank you for this work to support cmake & stm32. I have tried to use your scripts in win8.1 with gnu arm gcc 4.8.

I adapted:

  • in stdperiph/CMakeLists the path STM32F1_StdPeriphLib_DIR
  • in cmsis/CMakeLists the path STM32F1_StdPeriphLib_DIR
  • in cmsis-3.0/CMakeLists the path STM32F1_StdPeriphLib_DIR
  • in gcc_stm32.cmake
    *TOOLCHAIN_PREFIX
    *SET(TOOLCHAIN_BIN_DIR ${TOOLCHAIN_PREFIX}/${TARGET_TRIPLET}/bin) (directory structure in Windows seems to be different that in Linux)
    *CMAKE_FORCE_C_COMPILER(${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gcc.exe GNU) (added .exe)
    *CMAKE_FORCE_CXX_COMPILER(${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-g++.exe GNU) (added .exe)
    *SET(CMAKE_ASM_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gcc.exe )(added .exe)
    *SET(CMAKE_OBJCOPY ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-objcopy.exe CACHE INTERNAL "objcopy tool")(added .exe)
    *SET(CMAKE_OBJDUMP ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-objdump.exe CACHE INTERNAL "objdump tool")(added .exe)

Futhermore I copied/renamed some executables in the toolchain directory in order to fulfil the expected structure.

Then i issued the following command...and got an error

c:\stm32tc\stm32-cmake-master\cmsis> cmake -DCMAKE_TOOLCHAIN_FILE=../gcc_stm32.c
make -DSTM32_FAMILY=F1 -DCMAKE_INSTALL_PREFIX=C:\stm32tc\gcc48_2014q3\arm-none-e
abi/ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"
-- No TOOLCHAIN_PREFIX specified, using default: C:/stm32tc/gcc48_2014q3
-- No TARGET_TRIPLET specified, using default: arm-none-eabi
-- The ASM compiler identification is GNU
-- Found assembler: C:/stm32tc/gcc48_2014q3/arm-none-eabi/bin/arm-none-eabi-gcc.
exe
-- No STM32F1_StdPeriphLib_DIR specified, using default: C:/stm32tc/STM32F10x_St
dPeriph_Lib_V3.5.0
-- Configuring done
-- Generating done
-- Build files have been written to: C:/stm32tc/stm32-cmake-master/cmsis

c:\stm32tc\stm32-cmake-master\cmsis>make
Scanning dependencies of target cmsis_f1_cl
[ 12%] Building C object CMakeFiles/cmsis_f1_cl.dir/C_/stm32tc/STM32F10x_StdPeri
ph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c.
obj
arm-none-eabi-gcc.exe: error: CreateProcess: No such file or directory
make[2]: *** [CMakeFiles/cmsis_f1_cl.dir/C_/stm32tc/STM32F10x_StdPeriph_Lib_V3.5
.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c.obj] Fehler
1
make[1]: *** [CMakeFiles/cmsis_f1_cl.dir/all] Fehler 2

make: *** [all] Fehler 2

In fact, the directory C:\stm32tc\stm32-cmake-master\cmsis\CMakeFiles\cmsis_f1_cl.dir\C_\stm32tc\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x is empty...

What can I do?

Thank you in advance!

Regards,

Klaus

question, package generation

I am having an error, if I go to https://github.com/ObKo/stm32-cmake/tree/master/packages and I try to run:

mkdir packages/build
cd packages/build
cmake .. -DSTM32_FAMILY=F4

My error:

.
.
.
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
CMake Error at /opt/CMake/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find CMSIS (missing: CMSIS_INCLUDE_DIRS CMSIS_SOURCES)
Call Stack (most recent call first):
/opt/CMake/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/home/adacosta/Rusia/stm32-cmake/cmake/FindCMSIS.cmake:152 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:8 (FIND_PACKAGE)
.
.
.

What should CMake find this?

https://github.com/ObKo/stm32-cmake/blob/master/packages/CMakeLists.txt#L52

Add support for STM32H7 family

Check out this monster, we have to have it :).

The STM32F7 is already handled so I think there is not much work to do.
If I'm not wrong it's just the cmake/gcc_stm32H7.cmake to write right?

Edit : I've done it and will PR it later this week :)

Support more STM32 families

In my project I use STM32F207 chip so I branched https://github.com/ted-xp/stm32-cmake and extended it to support 0xx and 2xx. Some minor refactoring was done too.

The following contribution is planned:
(1) support 0xx and 2xx chip family (done already);
(2) investigate issues with cross-building from Windows (done too);
(3) support STM32 Cube peripherial library for 2xx chips.

Current result is uploaded but tested under Windows only.

I would be glad to have some preliminary feedback and discussion from stm32-cmake developers to be able to prepare code (I hope!) for future pull request.

Linking: HAL functions aren't accessible for internal libs

I have a project like this:
|--CMakeLists.txt
|--appmain
| |--main.c
| --CMakeLists.txt --libapp
|--libfunc.c
`--CMakeLists.txt

libfunc.c uses some HAL functions that aren't used from the main.c
During the build libapp.a and main.o are built fine.
But link stage fails, complaining that HAL functions above aren't resolved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.