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”.
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.
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.
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.
You can upgrade your version using command rustup update stable
Use to print the data to itm terminal.
cargo install itm
Verify using command
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
- cd test-size
- cargo run
- 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 \ openocd
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 \ gdb
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 \ openocd
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.
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.
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.
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: https://bit.ly/2Vdlld7.