1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// The crate-root docs intentionally link to private modules; docs.rs renders
// them with `--document-private-items` (see Cargo.toml), so the resulting
// "links to private item" lint is expected — silence it here.
//! Norbert — a patient SPI-NOR flasher for the Pico de Gallo USB bridge.
//!
//! Norbert identifies, erases, programs, verifies, and reads back raw SPI-NOR
//! flash chips over a [Pico de Gallo] v1.1 USB-to-SPI bridge. It reads a chip's
//! JEDEC ID and, where available, its SFDP tables to learn the real geometry
//! (page size, address width, erase menu) before touching a single byte —
//! falling back to a small built-in table for parts that do not self-describe.
//! It never guesses.
//!
//! Norbert ships as a thin binary over this library; these docs describe its
//! internal modules rather than a stable public API. The pieces fit together
//! like this:
//!
//! - [`cli`] — the command-line surface (global flags + subcommands). Parsing
//! only.
//! - [`commands`] — one handler per subcommand, plus the bus-session helpers
//! ([`with_bus`](commands::with_bus)/[`with_cancel`](commands::with_cancel))
//! that guarantee the shared bus is always released.
//! - [`flash`] — the hardware-agnostic flashing core: RDID, SFDP probing,
//! erase planning, page programming, verification.
//! - [`device`] — binds the flashing core to the Pico de Gallo HAL over a fixed
//! pin map and drives the flash's control lines.
//! - [`profile`] / [`sfdp`] / [`catalog`] — the flash geometry model, the SFDP
//! byte parser, and the human-name + no-SFDP fallback tables.
//! - [`ui`] / [`voice`] — presentation. `ui` owns all terminal output and the
//! Human/Machine (`--quiet`) split; `voice` holds the personality text.
//!
//! [`run`] only parses arguments, builds the [`Ui`], and dispatches; personality
//! lives in [`voice`], output in [`ui`].
//!
//! [Pico de Gallo]: https://github.com/felipebalbi/norbert
use ExitCode;
use Parser;
use Cli;
use Ui;
/// Parse the command line, build the [`Ui`], and dispatch the selected
/// subcommand, returning the process exit code.
///
/// [`ExitCode::SUCCESS`] is returned for `--version` and the bare
/// no-subcommand help path; command failures are rendered through the UI and
/// mapped to a failure exit code.
pub async