Overview of Bare-Metal Rust

A Layered Approach

When building bare-metal Systems in Rust, we use Rust crates to help us build a modular system.

The elements in our system are:

  • The program you are writing
  • The MCU are running on
  • The PCB (or Board) your MCU is on
  • The external devices connected to your MCU

The Layers

To support these elements, we (usually) have these layers.

  • Application
  • Board Support
  • External Drivers (e.g. SPI LCD Driver)
  • Hardware Abstraction Layer Traits
  • MCU Hardware Abstraction Layer Implementation
  • MCU Peripheral Access Crate
  • Core Peripherals
  • Core Runtime

---

%3appApplication(my_application)bscBoard Support(nrf52840_dk)app->bsclcd_driverSPI LCD Driver(ssd1306)app->lcd_driverrtCore Runtime(cortex_m_rt)app->rthalMCU HAL Implementation(nrf52480_hal)bsc->halhal_traitsHAL Traits(embedded_hal)bsc->hal_traitspacMCU PAC(nrf52840-pac)hal->pachal->hal_traitsimplementspac->rtcpCore Peripherals(cortex_m)pac->cplcd_driver->hal_traitsrt->cp

Don't worry

There's a lot here. We're going to take it step by step, starting at the bottom.