liveBook · Manning

Portability

As explained in Embedded Software with Rust

Portability is the ability of software or development methods to operate across different hardware architectures or platforms with limited adaptation.

Portability lets firmware logic work across different microcontroller platforms with limited adaptation. In embedded Rust, traits such as embedded-hal’s OutputPin give drivers a shared interface even when hardware abstraction layers use different GPIO designs. section 3.5.4

pub trait OutputPin {
    /// The error type returned by the methods.
    type Error;

    /// Set the pin to high logic level.
    fn set_high(&mut self) -> Result<(), Self::Error>;

    /// Set the pin to low logic level.
    fn set_low(&mut self) -> Result<(), Self::Error>;
}

OutputPin defines the shared high- and low-level operations that platform-specific pin implementations can provide. section 3.5.4

One LED driver, different platforms

A blink_led function can use OutputPin and a delay provider without knowing the chip architecture. Cortex-M and RISC-V applications supply their own LED and delay instances; the blinking logic remains unchanged. Trait-based interfaces also allow mock pins and delays to record calls in unit tests. section 3.5.4

The same pattern extends beyond GPIO: a UART echo function can use shared read and write traits with platform-specific UART instances. section 3.5.4

How Embedded Software with Rust covers it

How deep it goes
Works through trait implementations, reusable LED and UART functions, platform-specific setup, and mock-based testing.
Examples
Uses LED blinking on Cortex-M and RISC-V, mock peripherals, and UART echo examples for STM32 and ESP32-C3.
What you can do after
Apply embedded-hal traits to write reusable LED-blinking logic across Cortex-M and RISC-V platforms.
How it connects
Links embedded-hal traits with GPIO, delay providers, UART, hardware abstraction layers, and unit testing.

Also explained in

Compare how 9 books explain portability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.