Skip to main content

rpi_kickstart/
lib.rs

1//! The bring-up an application does before it is an application, for
2//! bare-metal Raspberry Pi boards built on `rpi-hal`.
3//!
4//! `rpi-hal` stops at the peripheral: it hands out a `Uart`, a `Mailbox`,
5//! an `Sd`. What every board then does with them is the same program
6//! written again — a console the whole image can print to, a heap sized
7//! from what the firmware reports, a card mounted and a settings file read
8//! off it, a site served out of RAM, a clock that something has to set.
9//! This crate is that program, once.
10//!
11//! # Everything is opt-in, and everything is replaceable
12//!
13//! Each capability is its own feature and its own module, and none of
14//! them are on by default: a board states what it is, and pays for
15//! nothing else. Where a piece has a plausible second implementation —
16//! the time source above all, which may be the network on one board and a
17//! DS3231 on the next — what this crate owns is the *sink* the rest of the
18//! image reads through, and filling it is the application's to choose.
19//!
20//! The same principle draws the line at the executor. An
21//! `#[embassy_executor::task]` cannot be generic, so this crate never
22//! declares one; it exposes `async fn`s and the application wraps them in
23//! tasks with its own concrete types. Routing, the global allocator and
24//! the panic handler stay with the application for the same reason — they
25//! are single, program-wide choices that a library taking them away
26//! cannot give back.
27//!
28//! # What an application must provide
29//!
30//! - **`rpi-hal`'s `rt` feature**, which supplies the boot sequence,
31//!   the vector table and the `critical-section` implementation.
32//! - **`rpi-hal`'s `mmu` feature** (on by default) for anything using
33//!   atomics, which includes every `embassy` executor.
34//! - **A `#[global_allocator]` and a `#[panic_handler]`.** A program may
35//!   have only one of each, so neither can come from a library.
36
37#![no_std]
38#![deny(missing_docs)]
39
40#[cfg(any(
41    feature = "auth",
42    feature = "config",
43    feature = "metrics",
44    feature = "site",
45    feature = "storage",
46    feature = "tls",
47    feature = "web",
48    test
49))]
50extern crate alloc;
51
52// The splash encoder and the build-info capture run in a board's
53// `build.rs`, on the host, and read files and run `git`.
54#[cfg(any(feature = "splash-build", feature = "metrics-build"))]
55extern crate std;
56
57/// Password login for a board's web interface — see the module's own
58/// documentation for what it protects against and what it does not.
59#[cfg(feature = "auth")]
60pub mod auth;
61/// The wall clock — see the module's own documentation for why it is a
62/// sink with no source of its own, and why it reads `None` until set.
63#[cfg(feature = "clock")]
64pub mod clock;
65/// Reading a board's settings file — see the module's own documentation
66/// for why the semantic checks run after parsing rather than inside it.
67#[cfg(feature = "config")]
68pub mod config;
69/// The console every module logs to — see the module's own documentation
70/// for why its sink is a trait object and its clock is passed in.
71///
72/// The macro that writes to it, [`logln!`], is at the crate root: an
73/// exported `macro_rules!` lands there whatever file it is written in.
74#[cfg(feature = "console")]
75pub mod console;
76/// Hardware entropy, and the `getrandom` backend the crypto stack needs —
77/// see the module's own documentation for what enabling it decides for
78/// the whole program.
79#[cfg(feature = "entropy")]
80pub mod entropy;
81/// The global heap — see the module's own documentation for why it
82/// declares the `#[global_allocator]` and what that decides for the rest
83/// of the program.
84#[cfg(feature = "heap")]
85pub mod heap;
86/// A minimal HTTPS client — see the module's own documentation for why it
87/// is one request per connection, and why the body comes back whatever the
88/// status.
89#[cfg(feature = "https")]
90pub mod https;
91/// An mDNS responder for one name — see the module's own documentation
92/// for the half of the multicast plumbing the board still has to do.
93#[cfg(feature = "mdns")]
94pub mod mdns;
95/// Writing Prometheus's text exposition format — see the module's own
96/// documentation for decimals without a float formatter, and why a label
97/// value is only ever written escaped.
98#[cfg(feature = "metrics")]
99pub mod metrics;
100/// Getting a board onto the network, whichever way it can — see the
101/// module's own documentation for why "is Ethernet available" is two
102/// questions and both are deadlines.
103#[cfg(feature = "net")]
104pub mod net;
105/// Outbound notifications and the channels that deliver them — see the
106/// module's own documentation for what stays the board's.
107#[cfg(feature = "notify")]
108pub mod notify;
109/// Over-the-air updates: the upload route and the reboot after it — see
110/// the module's own documentation for the one response shape every board
111/// answers with.
112#[cfg(feature = "ota")]
113pub mod ota;
114/// The board's web assets, read off the card into RAM — see the module's
115/// own documentation for why the site lives on the card at all.
116#[cfg(feature = "site")]
117pub mod site;
118/// Setting the clock from an NTP server — see the module's own
119/// documentation for what its reply checks do and do not protect against.
120#[cfg(feature = "sntp")]
121pub mod sntp;
122/// A boot logo baked into the kernel image — see the module's own
123/// documentation for why it is run-length-encoded RGB565, and for the
124/// encoder a board's `build.rs` calls.
125#[cfg(feature = "splash")]
126pub mod splash;
127/// Mounting the card's FAT volume — see the module's own documentation
128/// for what it costs in RAM and what time the files it writes carry.
129#[cfg(feature = "storage")]
130pub mod storage;
131/// TLS client connections with real certificate verification — see the
132/// module's own documentation for the three things a Pi has to supply,
133/// one of them an unaudited crypto provider.
134#[cfg(feature = "tls")]
135pub mod tls;
136/// Serving HTTP with `picoserve` — see the module's own documentation for
137/// why this is pieces of a router rather than a server task.
138#[cfg(feature = "web")]
139pub mod web;