Skip to main content

Crate ssh_stamp_hal

Crate ssh_stamp_hal 

Source
Expand description

§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

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

TraitRequired?ESP32 impl
NetworkProviderHalalwaysEspWifi
WifiHalWiFi portsEspWifi
BufferedSerialalwaysBufferedUart
OtaActionssftp-otaEspOtaWriter
PlatformServicesalwaysEspPlatform

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.

Re-exports§

pub use config::BandMode;
pub use config::Parity;
pub use config::UartConfig;
pub use config::UartParams;
pub use config::WifiApConfigStatic;
pub use error::FlashError;
pub use error::HalError;
pub use error::HashError;
pub use error::UartError;
pub use error::WifiError;
pub use traits::*;

Modules§

config
Hardware configuration types.
error
HAL error types.
traits
Peripheral trait definitions.