GithubHelp home page GithubHelp logo

dimtass / stm32f4xx-cmake-template Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 33.1 MB

This is a template cmake project for the stm32f4xx.

Shell 0.14% CMake 0.01% C 91.59% HTML 1.41% C++ 3.49% Assembly 1.60% JavaScript 0.01% Python 0.01% Makefile 0.40% M4 0.05% Perl 0.03% SWIG 0.16% Batchfile 0.05% Scala 0.01% Objective-C 0.32% CartoCSS 0.02% Tcl 0.71% GDB 0.01% LSL 0.01% PowerShell 0.01%

stm32f4xx-cmake-template's Introduction

STM32F4xx cmake template

dimtass

This is a template cmake project for the stm32f4xx. So what's so special about it? Well, it supports the following things:

  • STM32 Standard Peripheral Library
  • FreeRTOS

To select the which libraries you want to use you need to provide cmake with the proper options. By default all the options are set to OFF. The supported options are:

  • USE_STDPERIPH_DRIVER: If set to ON enables the stdperiph library
  • USE_FREERTOS: If set to ON enables FreeRTOS

You also need to provide cmake with the source folder by pointing the folder to the SRC parameter. In this case those two parameters are supported:

SRC=src_stdperiph
SCR=src_freertos

Finally, you also need to provide the path of the toolchain to use in the CMAKE_TOOLCHAIN.

To enable the UART debug print (TRACE()) then you need to enable the USE_DBGUART build flag. This will enable a UART port with the following pinout with 115200 bps baudrate:

UART TX UART RX
PA9 PA10

For the debug uart, by default there's full support for printf, but if you want a light-weight printf then you can enable the USE_TINY_PRINTF build flag. This printf won't support uint32_t and float.

Finally, you need to specify the MCU type using these parameters:

USE_LINKER_SCRIPT
USE_STARTUP_FILE
USE_DEVICE

The default values in the build.sh script are:

: ${USE_LINKER_SCRIPT:=STM32F411xE/STM32F411RETx_FLASH.ld}
: ${USE_STARTUP_FILE:=startup_stm32f411xe.s}
: ${USE_DEVICE:=STM32F411xE}

In order to find the supported devices you can run this command:

./list-supported-devices.sh

The linker files are located in source/config/LinkerScripts/ and the startup files in source/libs/cmsis/startup/. Just have in mind that only for the linker script you also need to include the top folder name (see the default build.sh script).

Cloning the code

Because this repo has dependencies on other submodules, in order to fetch the repo use the following command:

git clone --recursive -j8 https://[email protected]/dimtass/stm32f4xx-cmake-template.git

Examples

To use the stdperiph library example run this command:

CLEANBUILD=true USE_DBGUART=ON USE_STDPERIPH_DRIVER=ON SRC=src_stdperiph ./build.sh

To use the freertos example run this command:

CLEANBUILD=true USE_DBGUART=ON USE_STDPERIPH_DRIVER=ON USE_FREERTOS=ON SRC=src_freertos ./build.sh

Using docker

Instead of setting up a build environment, then if you have docker you can use my CDE image to build the code without much hassle. Just clone the code like this:

docker run --rm -it -v $(pwd):/tmp -w=/tmp dimtass/stm32-cde-image:0.1 -c "CLEANBUILD=true USE_DBGUART=ON USE_STDPERIPH_DRIVER=ON SRC=src_stdperiph ./build.sh"

or

docker run --rm -it -v $(pwd):/tmp -w=/tmp dimtass/stm32-cde-image:0.1 -c "CLEANBUILD=true USE_DBGUART=ON USE_STDPERIPH_DRIVER=ON USE_FREERTOS=ON SRC=src_freertos ./build.sh"

Flashing the firmware

To flash the firmware in Linux you need the texane/stlink tool. Then you can use the flash script like this:

./flash.sh

Otherwise you can build the firmware and then use any programmer you like. The elf, hex and bin firmwares are located in the build-stm32 folder

./build-stm32/*/stm32f4xx-cmake-template.bin
./build-stm32/*/stm32f4xx-cmake-template.hex
./build-stm32/*/stm32f4xx-cmake-template.elf

To flash the HEX file in windows use st-link utility like this: "C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe" -c SWD -p build-stm32\src_stdperiph\stm32f4xx-cmake-template.hex -Rst

To flash the bin in Linux: st-flash --reset write build-stm32/src_stdperiph/stm32f4xx-cmake-template.bin 0x8000000

FW details

  • CMSIS version: 5.0.4
  • StdPeriph Library version: 1.8.0
  • STM3 USB Driver version: 1.2.1
  • FreeRTOS: v10.2.1

Resources

The default MCU for this template is the STM32F411CEU6. You can find more resources and tools for this MCU here

stm32f4xx-cmake-template's People

Contributors

dimtass avatar

Stargazers

 avatar  avatar

Watchers

 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.