This is a template cmake project for the stm32f103. So what's so special about it? Well, it supports the following things:
- STM32 Standard Peripheral Library
- STM32 USB FS Device Driver Library
- opencm3 library for STM32
- 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 toONenables the stdperiph libraryUSE_STM32_USB_FS_LIB: If set toONenabled the ST's USB libUSE_LIBOPENCM3: If set toONenables the opencm3 libraryUSE_FREERTOS: If set toONenables FreeRTOS
You also need to provide cmake with the source folder by pointing
the folder to the SRC parameter.
Finally, you also need to provide the path of the toolchain to
use in the CMAKE_TOOLCHAIN.
Because this repo has dependencies on other submodules, in order to fetch the repo use the following command:
git clone --recursive -j8 git@bitbucket.org:dimtass/stm32f103-cmake-template.git
# or for http
git clone --recursive -j8 https://dimtass@bitbucket.org/dimtass/stm32f103-cmake-template.gitTo use the stdperiph library example run this command:
CLEANBUILD=true USE_STDPERIPH_DRIVER=ON SRC=src_stdperiph ./build.shTo use the freertos/opencm3 example run this command:
CLEANBUILD=true USE_LIBOPENCM3=ON USE_FREERTOS=ON SRC=src_freertos ./build.shTo 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\stm32f103_wifi_usb_psu.hex -Rst
To flash the bin in Linux:
st-flash --reset write build-stm32/src_stdperiph/stm32-cmake-template.bin 0x8000000
CMSIS version: 5.3.0StdPeriph Library version: 3.6.1STM3 USB Driver version: 4.1.0