30Wedge / cortex-m-quickstart-nucleo-stm32g474

Applied template examples to run on Nucleo_STM32G474 hardware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cortex-m-quickstart-nucleo-stm32g474

This is a fork of https://github.com/rust-embedded/cortex-m-quickstart where I get some of their examples running on a NUCLEO-STM32G474RE board.

The goal of this repo is to make a few toy low level embedded stable rust programs that run on hardware. I'm sticking to low-level hardware abstractions by only using a rust2svd-based crate (stm32g4 in this case) for hardware abstraction. I wrote these while following along with the rust-embedded book

Dependencies

I used the following to build & run these embedded programs on Ubuntu 24.

  • Rust 1.78, stable toolchain.
  • gdb-multiarch & openocd to run the programs on target hardware.
  • Install udev rules per the embedded book instructions if this is the first time you've used this devkit hardware.
  • rust-std components (pre-compiled core crate) for ARM Cortex-M4F target. Run:
$ rustup target add thumbv7em-none-eabihf

Check out the book if that doesn't work https://docs.rust-embedded.org/book/intro/install.html

Running these Examples

  1. Build the examples in release and debug profiles with the following commands. The crash example only works in the 'release' profile, so that's why I build both profiles.
cargo build --examples
cargo build --release --examples
  1. Connect the USB ST-LINK port of the NUCLEO-STM32G474RE board to a USB port on your computer.
  2. From a terminal in the root of this repo, run openocd. That will pick up the configuration from openocd.cfg for connecting to your devkit.
  3. From a separate terminal, run a gdb command that looks like one of these. Make sure to pick up gdb configuration with -x openocd.gdb.
$ gdb-multiarch -x openocd.gdb <path_to_example_binary>

$ gdb-multiarch -x openocd.gdb target/thumbv7em-none-eabihf/debug/examples/mtime
# release example build
$ gdb-multiarch -x openocd.gdb target/thumbv7em-none-eabihf/release/examples/crash

License

These examples is licensed under either of

at your option(same as the template).

About

Applied template examples to run on Nucleo_STM32G474 hardware


Languages

Language:Rust 66.9%Language:GDB 33.1%