Set up the environment for the stm32-Discovery Board

Reading Time: 4 minutes

In today’s blog, we will set up the environment for the stm32 discovery board. We are only going to set up the configurations for the “Linux System”.

In previous blogs we discussed the Valid and Invalid Addresses, you can check those blogs to get a better understanding of how to work with the Register Addresses.

As we are working with the Embedded Systems they make our task fast and reliable. Also, they are much smaller in size compared to traditional computers, which makes them compact and portable, and useful for mass production. Management of Embedded Systems is pretty easy, as elements used in their creation are cheap & long-lasting. Embedded Systems are also cost-effective.

What to do after you buy the discovery board? How to start your work? How to set up your system to work with bare metals? You will get the answer to these questions soon from this blog.

From where to start?

So at this point, I am assuming that you have basic knowledge about the board(DISCOVERY BOARD) you are using. Now we are going to set up the environment for the stm32 discovery board and other necessary requirements.

We are going to deal with the architecture different from your system. So to deal with such architecture we need some tools so that we can run and debug a “remote” device. Let’s begin with the tools first.

Required Tools

Tools we are going to need throughout the implementation of “The Discovery Book“:

  • Rust 1.31 or a newer
  • itmdump >=0.3.1
  • OpenOCD >=0.8
  • arm-none-eabi-gdb (Version 7.12 or newer highly recommended)
  • cargo-binutils (Version 0.1.4 or newer.)
  • minicom (on Linux and macOS)

Note: If your computer has Bluetooth functionality and you have the Bluetooth module, you can additionally install these tools to play with the Bluetooth module. All these are optional:

  • Linux, only if you don’t have a Bluetooth manager application like Blueman.
    • bluez
    • hcitool
    • rfcomm
    • rfkill

Install the Required Tools

Install – rustc & cargo

First, install rustup from here and then check whether your stable channel is up to date or not using the command.

rustc -V

You can upgrade your version using command rustup update stable

Install itmdump

Use to print the data to itm terminal.

cargo install itm

Verify using command

itmdump -V


itm is already installed in my system that’s why it got replaced with the new one.

Install cargo binutils

Install llvm-tools-preview using command

rustup component add llvm-tools-preview

then use command

cargo install cargo-binutils

Verify the installed tools

Run the following command to verify

cargo new test-size

On running this command you will see output like this

Created binary (application) `test-size` package

Now your binary is created successfully. Now run commands

  1. cd test-size
  2. cargo run
  3. cargo size — -version


All the required tools are installed successfully. Now it’s time to work with the Operating System.

Install required LINUX packages

For Ubuntu 18.04 or newer / Debian stretch or newer

sudo apt-get install \
  gdb-multiarch \
  minicom \

NOTE:  gdb-multiarch is the GDB command you’ll use to debug your ARM Cortex-M programs.

For Fedora 23 or newer

sudo dnf install \
  minicom \
  openocd \

NOTE: arm-none-eabi-gdb is the GDB command you’ll use to debug your ARM Cortex-M programs.

For Arch Linux

sudo pacman -S \
  arm-none-eabi-gdb \
  minicom \

udev Rules to connect with stmf3 board

You can use your f3 board without using “sudo” using these rules.

Connect the STM32F3DISCOVERY to your computer using a USB cable. Be sure to connect the cable to the “USB ST-LINK” port. Execute command.

lsusb | grep ST-LINK


You will see something like this.

Create /etc/udev/rules.d/99-openocd.rules:

sudo vi /etc/udev/rules.d/99-openocd.rules


Get out from here using “:q command. Now put the last command and we are done.

sudo udevadm control –reload-rules (NOTE: After this unplug the board and plug it again).

Last Stage (Verification of the connected Board)

Connect the board using cable at USB ST-LINK port.

Run command -> lsusb | grep -i stm


So my board is at Bus 001 and Device at 007 taken by the system. Now before running the next command change your bus and device according to this only. After that run command.

ls -la /dev/bus/usb/007/001


I got my permission successfully.

OpenOCD connection

Connect the STM32F3DISCOVERY using the USB cable to the USB port in the center of edge of the board, the one that’s labeled “USB ST-LINK”. Use command

openocd -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg

Two red LEDs should turn on right after connecting the USB cable to the board.


Use ctrl+c to stop OpenOCD or close/kill the terminal.

We are done and ready to use the board and we can implement the chapters of the Discovery Book.

Please visit here for Windows, Mac, and for Verification. Hope you like this blog and this will be helpful for you in setting up the hardware and system quickly.

If you want to read more content like this?  Subscribe to Rust Times Newsletter and receive insights and latest updates, bi-weekly, straight into your inbox. Subscribe to Rust Times Newsletter:

rust times

Written by 

Nitin is a Software Consultant, with experience of more than 1.4 years. He works on Rust Programming Language and Embedded Development using Rust. He is also fond of Java Programming & Artificial Intelligence. Apart from that, his hobbies are Watching Netflix, Reading, Singing & Writing.