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
- Peripheral traits:
WifiHal,NetworkProviderHal,RngHal,HashHal,TimerHal,OtaActions - Configuration:
WifiApConfigStatic - Error handling:
HalErrorwith 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:
- 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 tomembersin the workspaceCargo.toml. Its board support crate (ssh-stamp-<platform>-boards) and HIL tests (ssh-stamp-<platform>-hil) sit next to it. The Espressif port inboards/ssh-stamp-esp/is the reference. - Implement the needed traits from
ssh-stamp-hal/src/traits/. At a minimum: aNetworkProviderHal(orWifiHal),OtaActions, and a UART type implementing theBufferedSerialtrait from thessh-stampcrate. - Implement the
PlatformServicestrait fromssh-stamp::platformfor the platform. - 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, callssh-stamp::app::run_app. - Register the chips and boards in
xtask/src/board.rsso thatcargo xtask <board> buildworks 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::*;