To test your development environment and get some validation that everything is ready to work on hardware, you can build one of the Sample Programs that come bundled in with the Zephyr RTOS source installation. Doing this doesn’t tell you much about how to set up your own application, but it does at least make sure that when you do have your custom application created, it’ll flash to the board correctly. 

The Feather STM32F405 Express is built into Zephyr as a supported development board. This means that it's easy to get code built and flashed onto the board in just a few commands, with no board-specific configuration required. To get started, open your terminal and set up the environmental variables for your project: 

Download: file
cd ~/zephyrproject/zephyr
source zephyr-env.sh

Then, build the most basic example, blinky, with the following command: 

Download: file
west build -p auto -b adafruit_feather_stm32f405 samples/basic/blinky

The -p auto parameter will automatically clear out the remains of previous builds, so you can try building some other samples this way later without extra steps. 

Once your sample is finished building, you’ll need to use one of the two programming options we discussed in the Hardware section. 

DFU Bootloader

DFU is the default programming option supported by west for the Feather STM32F405. Plug in the STM32 Feather, making sure the Boot0 pin (B0) is connected to 3.3V, and hit the reset button. Then run the following:

Download: file
west flash

If for whatever reason you'd rather not use the west tool, you can also run the DFU-util command directly on the binary:

Download: file
cd ~/zephyrproject/zephyr/build/zephyr
dfu-util -a 0 --dfuse-address 0x08000000 -D zephyr.bin

Jlink

Jlink is also supported as a west flash "runner", but it isn't the default option, so you need a slightly longer command to override it. Connect the Jlink and USB cable to your board, and run:

Download: file
west flash --runner jlink

In either case, you should get a blinking LED light on your board if everything is set up correctly.  

This guide was first published on Feb 25, 2020. It was last updated on Feb 25, 2020.
This page (Building a Sample Program) was last updated on Sep 18, 2020.