feat: Rust CLI + library port of the flash pipeline#1
Merged
Conversation
Port the just/bash pipeline to a Rust crate (lib `jetson_flash` + bin `jetson-flash`), kept alongside the existing scripts. Same six stages: deps, fetch, stage, preconfig, check, flash. - Config: TOML (`jetson-flash.toml`) via figment, `JETSON_*` env override. - Recovery detection: native libusb (rusb), no lsusb parsing; exposes a typed `UsbState`/`Model` for library consumers. - NM keyfile + identity baking done natively; NVIDIA `l4t_*.sh` / `apply_binaries.sh` and apt/wget/tar stay as subprocesses. - Typed error enum (thiserror) instead of anyhow strings; anyhow only in the binary. - Clean terminal UX: subprocess output captured to `logs/<step>-<ts>.log` with an indicatif spinner; `-v/--verbose` streams live. Downloads and the flash use live stdio so their native progress shows. On failure the captured log tail is printed.
- stage: explicit skip logs when Linux_for_Tegra/, rootfs, or applied NVIDIA binaries are already present (reuse instead of silent skip). - preconfig: skip l4t_create_default_user.sh (not idempotent) when the user is already baked into rootfs/etc/passwd, so preconfig is safe to re-run.
- Cargo.toml: repository/readme/keywords/categories/rust-version + publish exclude (work, logs, docs, scripts, justfile). - CI workflow: fmt --check, clippy -D warnings, build, test (installs libusb for the rusb link dep). - Release workflow: on a v* tag, verify tag==version, dry-run, then `cargo publish` via CARGO_REGISTRY_TOKEN secret — so `cargo install jetson-flash` works once tagged. - CHANGELOG.md (Keep a Changelog) with the 0.1.0 entry. - README: cargo install instructions. - rustfmt normalization of stage/preconfig.
- Config is now nested-TOML profiles: a [default] base + one [<name>] table per board (orin-nano, orin-agx). Select with --profile / JETSON_PROFILE (required for every stage). `Config::load(path, profile)`. - Secrets removed from the file: identity.password is Option, supplied via JETSON_IDENTITY_PASSWORD; wifi psk via JETSON_NETWORK_WIFI_PSK. - `init` seeds a jetson-flash.toml from a template embedded in the binary (include_str!) so an installed CLI self-seeds; destination is --config <path>, else --global (XDG), else ./. - `edit` opens the resolved config in $EDITOR; `profiles` lists profiles. - Config discovery: --config -> ./jetson-flash.toml -> XDG. - clap `env` feature enabled (JETSON_PROFILE); friendly errors for unknown/ missing profile and missing secret. - README + CHANGELOG updated.
…first docs
- Version 1.0.0 (first release).
- jetpack presets per profile ("6.2.1" -> L4T r36.4.4, "7.2" -> r39.2);
resolves L4T version + BSP/rootfs URLs; explicit [profile.l4t] overrides.
- Namespaced workspace/cache: downloads/<ver>/ (shared) + work|logs/<profile>-<ver>/
so boards and JetPack versions never collide. Base = --work-dir, else repo
checkout, else ~/.cache/jetson-flash.
- Library pipeline API: Step, run_step, run_all (open per-slot log + dispatch);
binary reuses them (dropped the bespoke Runner). examples/pipeline.rs added.
- Bare `jetson-flash` prints help (exit 0) instead of a usage error.
- Fix: NM dns keyfile double-semicolon.
- Docs: Rust CLI is now primary; just/bash moved to docs/legacy-just.md.
Both Orin Nano Super and AGX Orin marked hardware-validated (JetPack 7.2).
Prereqs trimmed to cargo + libusb; sudo-TTY + recovery-ID troubleshooting.
- Validated end-to-end on hardware: fetch/stage/preconfig/check/flash of an
Orin Nano Super, NVMe + QSPI, "Flash is successful".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the
just/bash flashing pipeline to a Rust crate (libjetson_flash+ binjetson-flash), kept alongside the existing scripts. Same six stages:deps, fetch, stage, preconfig, check, flash(+all).What
jetson-flash.toml) via figment;JETSON_*env vars override.rusb) — nolsusbparsing. Exposes typedUsbState/Modelfor library consumers.l4t_*.sh/apply_binaries.shandapt/wget/tar, driven through a logged runner.thiserrorenum (Error,RecoveryError) instead ofanyhowstrings;anyhowstays only in the binary.logs/<step>-<ts>.logwith anindicatifspinner (console stays clean, unlike bash).-v/--verbosestreams live. Downloads (wget) and the flash use live stdio so their native progress shows. On failure the captured log tail is printed.Layout
just <step>jetson-flash <step>.envjetson-flash.tomllsusbparserusb)Library use
Each stage is
fn(&Config, &Paths, &Logger) -> Result<()>, callable from other Rust commissioning tooling.Notes
_, so leaf keys containing_(external_device,static_ip,bsp_url,rootfs_url) are TOML-only; single-word leaves (board.name,identity.hostname) work.rusbvendorslibusb1-sys(cc build) — no systemlibusb-devneeded.clippyclean,checkverified against live USB.