Giter Club home page Giter Club logo

stm32-cmake's Introduction

stm32 cmake

Use cmake to build your stm32 project!

Requirements

Usage

stm32 cmake tool

You need to do :

cmake -DSTM32_MODEL=<your chip model> -DCMAKE_TOOLCHAIN_FILE=<path_to_STM32.cmake> -DCMAKE_BUILD_TYPE=Debug <path_to_source_dir>

and add ${STM32_INCLUDE} ${STM32_SOURCE_FILES} to your CMakeLists.txt. Maybe your need to link with ${STM32_LIBRARY}

  • STM32_MODEL - Must. eg. STM32F411CE ( Only 12 ).
  • CMAKE_TOOLCHAIN_FILE - Must. ${stm32-cmake_PATH}/Modules/STM32.cmake.
  • TOOLCHAIN_PREFIX - default: arm-none-eabi.
  • STM32Cube_DIR - Set the STM32Cube repository directory. default: ~/STM32Cube/Repository/.
  • STM32Cube_VERSION - Set the STM32Cube firmware version. default: latest. eg. ${STM32Cube_DIR}/STM32Cube_FW_${STM32_SERIES}_V${STM32Cube_VERSION}
  • STM32_SPECS - Set the compile option: --specs. default: nosys.( Documentation )
  • STM32_CUSTOM_SYSCALL - If ON, will generate a syscalls.c to your ${PROJECT_SOURCE_DIR}. default: OFF.( Documentation )
  • STM32_LINKER_SCRIPT - You can custom the link script template. default: ${stm32-cmake_PATH}/Modules/STM32/${STM32_SERIES}/ldscript.template.

find package tool

Now, I only completed one find_package for stm32. In the future, I will write more find_package for stm32.

⚠️

You must use the stm32 cmake tool first, then can use these find_package.

find_package ( STM32LL COMPONENTS gpio REQUIRED )

The ${STM32LL_FOUND} ${STM32LL_INCLUDE} and ${STM32LL_STM32LL_SOURCE_FILES} will be created, just add to

include_directories (
	${STM32_INCLUDE}
	${STM32LL_INCLUDE}
)
add_executable ( ${TARGET_NAME} ${SOURCE_FILES} ${STM32_SOURCE_FILES} ${STM32LL_SOURCE_FILES} )

Add chip support

Now, Only supports four chip. but you can add a support for your chip.

Support List Cmake Script
STM32F103C8 STM32F103C8.cmake
STM32F103VC STM32F103VC.cmake
STM32F103ZE STM32F103ZE.cmake
STM32F411CE STM32F411CE.cmake
├── Modules
│   ├── FindCMSIS.cmake
│   ├── FindSTM32Cube.cmake
│   ├── FindSTM32HAL.cmake
│   ├── STM32
│   │   ├── F1                     #F1 series.
│   │   │   ├── STM32F103C8.cmake  #Chip model ( One to one ).
│   │   │   ├── STM32F103VC.cmake  #Chip model ( One to one ).
│   │   │   ├── STM32F103ZE.cmake  #Chip model ( One to one ).
│   │   │   ├── cmake.cmake        #F1 cmake.
│   │   │   └── ldscript.template  #F1 link script template.
│   │   ├── F4                     #F4 series.
│   │   │   ├── STM32F411CE.cmake  #Chip model ( One to one ).
│   │   │   ├── cmake.cmake        #F4 cmake.
│   │   │   └── ldscript.template  #F4 link script template.
│   │   ├── Linker.cmake
│   │   ├── Util.cmake
│   │   └── syscalls.c
│   └── STM32.cmake                #Main cmake.

If you use the F1 or F4 series chip, you only need copy STM32F103C8.cmake or STM32F411CE.cmake and change some parameters.

  • add_definitions ( -DSTM32F411xE ) - Set chip marco.
  • STM32_RAM_START_ADDRESS - Chip ram start address.
  • STM32_ROM_START_ADDRESS - Chip rom start address.
  • STM32_RAM_SIZE - Chip ram size.
  • STM32_ROM_SIZE - Chip rom size.
  • STM32_RAM_END_ADDRESS - Chip ram end address ( ram start address + ram size ).
  • STM32_STARTUP_SOURCE_NAME - Chip startup source code name.

Finally, push it!!! Thanks!

If you don't use F1 or F4 series chip, you can copy Modules/F4/cmake.cmake and change some parameters too. But I think you can take a issues and tell me the parameters. Then I will do it.

stm32-cmake's People

Contributors

invincibl-e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.