This is a small university project of mine, which should show the process of developing for STM32F4XX chips under Linux and OS X. There are four sub directories, each having the code that does the very same thing. First button toggles second LED and vice versa.
- hal subdirectory contains example with plain make files and uses STM HAL library
- raw subdirectory contains example with plain make files and does not use STM HAL library
- cmake-hal subdirectory contains example with CMake and uses STM HAL library
- cmake-raw subdirectory contains example with CMake and does not use STM HAL library
- arm-none-eabi gcc toolchain. On Fedora package is arm-none-eabi-gcc-cs, on Ubuntu package is gcc-arm-none-eabi
- CMake minimum version 2.8.11
- mikroe-uhb from https://github.com/thotypous/mikroe-uhb
- OpenOCD - optional
Simply go to one of the project directories and execute make
-
Create build dir outside the source tree and enter it.
-
Execute
cmake -DCMAKE_TOOLCHAIN_FILE=<path-to-arm-toolchain.cmake> <path-to-project-sources>
-
Execute
make
The toolchain file is located in subdirectory cmake and is named arm-toolchain.cmake
-
Connect device via USB
-
Execute
mikroe-uhb image.hex
-
Reset or cycle power on the clicker 2 device
To run OpenOCD for clicker 2 device execute:
`openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/share/openocd/scripts/target/stm32f4x.cfg`
On OS X paths to openocd configuration files may differ depending on the way how OpenOCD is installed.
This code is tested with Mikroelektronika Clicker 2 for STM32 board, but it should work with any other STM32F4XX boards with minor changes like using proper pin for LEDs and buttons and/or port.