Simple board support for STM32 Nucleo boards

An improved makefile template for STM32Cube generated HAL code linked with ChibiOS, running on STM32 nucleo boards

Project motivation

Based on my STM32 makefile template, I've created some non-IDE demo projects running on various STM32 nucleo boards.

Common features

  • STM32Cube MX generated initialization code
  • STM32Cube HAL firmware library
  • ChibiOS 16.1.4 used as RTOS
  • My own simple uart driver
  • Blinking LED
  • Sending "Hello World" over the uart
  • printf() debugging enabled (sending stdout through an uart, implemented in syscalls.c)
  • Run "make" to compile
  • Run "make flash" to flash your board using openocd
  • Supported boards

  • Nucleo-F042K6 (tiny Nucleo-32 board)
  • Nucleo-F072RB (standard Nucleo-64 board)
  • Nucleo-F103RB (standard Nucleo-64 board)
  • Nucleo-F302R8 (standard Nucleo-64 board)
  • Nucleo-F303K8 (tiny Nucleo-32 board)
  • Nucleo-F401RE (standard Nucleo-64 board)
  • Nucleo-F410RB (standard Nucleo-64 board)
  • Nucleo-F746ZG (large Nucleo-144 board)
  • Nucleo-L476RG (standard Nucleo-64 board)
  • These examples are intended as a simple starting point for your own projects. You've got the choice to use the HAL provided drivers or write your own and still use the STM32Cube generated initialization like I did for the uart driver. For each board, I've provided a STM32CubeMX project file (*.ioc), a top level Makefile and a simple main() demo creating two ChibiOS tasks (one blinking the LED, the other one sending messages over the uart).

    If you want to create a new project, take a deeper look at the code generation settings in one of the example projects. You'll have to clone them manually in your new project to make everything work as expected.

    Check the clock source configuration: Some nucleo boards have the 8MHz (MCO solder bridges) installed, others don't. Either read the documentation, or just look at the backside of the board for the solder jumpers labelled "MCO" (one located at the ST-Link part, one located near the controller). If they are open, you must use the internal HSI RC oscillator.

    The top level Makefile includes several other makefiles:

  • A common project header, initializing some variables
  • A target specific makefile setting up the whole make process
  • Makefiles for the libraries (HAL, ChibiOS)
  • Makefiles for commonly used sources (hard fault handler, simple bsp)
  • A target specific makefile implementing the openocd parameters
  • A common makefile that runs the compiler, linker etc.
  • Download

    here: nucleo-simple-bsp.tar.gz

    All neccessary library files are included in the tarball. You do not need to download or install additional sources to compile the examples. The included sources might not be complete in terms of their original source, get the full Cube HAL sources from STmicro. Some of the HAL source files were modified from their original state to make my uart driver work.

    At the time of writing, the STM32F410 was brand new and not yet fully supported by openocd and ChibiOS. I've made some minor modifications to ChibiOS to get it running. Thanks to Uwe Bonnes' patches, STM32F410 support is available for openocd, but since it is not yet merged to the main branch, you'll have to cherry-pick these from the git repository and compile your own openocd. Or just simply wait for the patches to be merged, this is just a matter of time. If you don't like compiling openocd yourself, you may want to check Freddie Chopins website for pre-compiled versions.

    If you don't want to use the latest STM32 controllers (STM32F410, STM32F746), the latest stable openocd (0.9.0) should do the job. For STM32F746 you'll need a more recent version (0.10.0-dev).

    If you don't like the STM32CubeMX approach, try ChibiOS HAL. The ChibiOS package contains quite a lot of readily compileable examples for many STM32 discovery and nucleo boards. ChibiOS HAL also provides a lot of peripheral drivers for the STM32 family.

    System requirements

  • A recent Linux or Cygwin system (I don't mind native windows, I guess it'll just won't work)
  • The usual collection of GNU/Linux standard utilities (sed, gawk, find, ...)
  • A recent arm-none-eabi toolchain, recommended GCC ARM Embedded
  • A recent version of OpenOCD
  • Your favourite text editor
  • Links

    Download the full ChibiOS source code here: Chibios Homepage
    OpenOCD repository
    Freddie Chopin's homepage

    Look here: The STM32 files for my other STM32 related pages. ... und ein Zaehlpixel hab ich auch :-)