This demo program blinks the 4 coloured LEDs on the STM32F4DISCOVERY.
It demonstrates:
- how to organise a project using the content of several xPacks, including the µOS++ IIIe / CMSIS++ code;
- how to integrate the CubeMX initialisation code.
This project does not demonstrate any µOS++ features, the only RTOS feature used is the system clock sleep_for(), to delay execution for a number of ticks.
The content of the xPacks is not part of the repository, and must be dynamically generated. Until the XCDL utility will be available, the generated folder should be created with the scripts/generate.sh script.
bash scripts/generate.sh
Caution: Be sure subsequent runs of generate.sh are done when the Eclipse project is not opened.
µOS++ IIIe uses several C++14 features, available from GCC 5.x up. To be able to build the project, be sure the arm-none-eabi-gcc from Launchpad is installed; for more details, please follow the How to install the ARM toolchain? instructions from the GNU ARM Eclipse web.
This project is an Eclipse managed project. To build it, import it to Eclipse:
- General → Existing Project into Workspace
- Select root directory
- be sure Copy projects into workspace is disabled
- select the
f4discovery-blinky-micro-os-plusproject - import
Caution: Be sure the the project is imported after the system code was generated, and subsequent runs of generate.sh are done when the Eclipse project is not opened.
As for any Eclipse CDT managed project, Eclipse automatically creates the Makefiles needed to build the project.
The procedure to perform the build is simple:
- Eclipse menu → Project → Build All
The result of this command are two folders, one Debug and one Release, each with all build related files, the most important ones being the ELF files.
includecube-mx/Incgenerated/arm-cmsis/core/includegenerated/micro-os-plus-iii/includegenerated/micro-os-plus-iii-cortexm/includegenerated/stm32f4-cmsis/stm32f407xx/includegenerated/stm32f4-hal/include
cube-mx/Srcgenerated/micro-os-plus-iii-cortexm/srcgenerated/micro-os-plus-iii/srcgenerated/stm32f4-cmsis/stm32f407xx/srcgenerated/stm32f4-hal/srcsrc
The µOS++ code uses modern C++ features, and for this it is necessary to use a recent GCC version (v5.x or highrer) and to specify -std=gnu++1y in the GCC command line.
- for
generated/stm32f4-hal/src, to silence C warnings, use-Wno-sign-conversion -Wno-padded -Wno-conversion -Wno-unused-parameter -Wno-bad-function-cast -Wno-sign-compare
To simplify testing, this demo uses the ARM semihosting API to access the host; this is enabled via OS_USE_SEMIHOSTING_SYSCALLS defined on the compiler command line. To run, semihosting normally requires an active debugger connection with the debugged board. However, the µOS++ exception handlers are enhanced with code to fake the semihosting calls if the debugger connection is not active (the JTAG/SWD cable is not connected). Unfortunately these features are available only for ARMv7M devices, so, for small Cortex-M0/M0+ devices, the debugger connection is manadatory.
For standalone applications, remove OS_USE_SEMIHOSTING_SYSCALLS and possibly add -ffreestanding to the compiler command line.