ssh-stamp-hal 1.0.4

Hardware Abstraction Layer traits for ssh-stamp
Documentation

SSH-Stamp Hardware Abstraction Layer

Platform-agnostic traits for ssh-stamp, following the embedded-hal pattern of fine-grained, composable traits. Each supported platform implements these traits in a separate port crate (e.g. ssh-stamp-esp32).

Overview

  • Peripheral traits: [WifiHal], [NetworkProviderHal], [RngHal], [HashHal], [TimerHal], [OtaActions]
  • Configuration: [WifiApConfigStatic]
  • Error handling: [HalError] with variants per peripheral type

For standard peripheral traits (Read, Write, flash storage), this crate defers to embedded-io-async and embedded-storage-async from the embedded-hal ecosystem rather than redefining them.

HAL trait map

Trait Required? ESP32 impl
[NetworkProviderHal] always EspWifi
[WifiHal] WiFi ports EspWifi
BufferedSerial always BufferedUart
[OtaActions] sftp-ota EspOtaWriter
PlatformServices always EspPlatform

[WifiHal] is required only for WiFi-based ports. Ethernet ports would implement [NetworkProviderHal] directly.

Adding a new port

To port ssh-stamp to a new microcontroller family:

  1. Create the port crate under the manufacturer's directory, boards/ssh-stamp-<manufacturer>/ssh-stamp-<platform>/, with a lib (src/lib.rs) and a bin (src/bin/ssh-stamp-<platform>.rs), and add it to members in the workspace Cargo.toml. Its board support crate (ssh-stamp-<platform>-boards) and HIL tests (ssh-stamp-<platform>-hil) sit next to it. The Espressif port in boards/ssh-stamp-esp/ is the reference.
  2. Implement the needed traits from ssh-stamp-hal/src/traits/. At a minimum: a [NetworkProviderHal] (or [WifiHal]), [OtaActions], and a UART type implementing the BufferedSerial trait from the ssh-stamp crate.
  3. Implement the PlatformServices trait from ssh-stamp::platform for the platform.
  4. In the binary, mirror the ESP32 boot flow: bring up peripherals, load config via ssh-stamp::store::load_or_create, spawn the UART task, bring up the network, call ssh-stamp::app::run_app.
  5. Register the chips and boards in xtask/src/board.rs so that cargo xtask <board> build works for them.

No changes are needed in ssh-stamp or ssh-stamp-hal.