git clone https://garage44.eu/jeroen/pinnacle.gitcartopolis-agent · 2026-11-30T14:36:15Z
feat(xtask): closed firmware as data, described, fetched and checked firmware/intel-wifi.txt describes Intel's Wi-Fi firmware as a package of its own: vendor, licence (LICENCE.iwlwifi_firmware, with its URL), the linux-firmware tag 20261124 and commit c46910a4, and per file its path there, size, SHA-256 and which chips it serves: the API 77 files for AX201 (Qu-b0, Qu-c0, QuZ-a0 with HR), the API 89 files and .pnvm for AX210/AX211 (so-a0-gf-a0, ty-a0-gf-a0, ma-b0-gf-a0), and the licence. The blobs are not in the repository. xtask/src/firmware.rs reads every firmware/*.txt; `cargo xtask firmware` fetches each file with curl from git.kernel.org at the pinned commit into target/firmware/<name>/, refusing any whose size or SHA-256 differs. disks_for() puts them, with the description, in system:/firmware/intel/ on a PC's system disk (so `pc`, `laptop`, `installer pc` and what an installation copies carry them), fetching first when absent and going without them, said, when they cannot be fetched; PINNACLE_NO_FIRMWARE=1 leaves them out. ARM's disk carries none. Tested on mac-2: `cargo xtask firmware` fetched all ten files and they matched; `cargo xtask pc` passed with them on the disk; clippy for xtask shows nothing.
firmware/intel-wifi.txt | 92 ++++++++++++++++++
xtask/src/firmware.rs | 245 ++++++++++++++++++++++++++++++++++++++++++++++++
xtask/src/main.rs | 19 +++-
3 files changed, 355 insertions(+), 1 deletion(-)
diff --git a/firmware/intel-wifi.txt b/firmware/intel-wifi.txt
new file mode 100644
index 0000000..eaef877
--- /dev/null
+++ b/firmware/intel-wifi.txt
@@ -0,0 +1,92 @@
+# Intel's Wi-Fi firmware: closed code that runs on the radio itself, not
+# on the computer. Pinnacle's driver (kernel/src/drivers/iwlwifi.rs) is its
+# own open Rust; these chips start only with a program from Intel loaded
+# into them, and that program is what this package is. It is data to
+# Pinnacle: read from the system disk, handed to the chip, never run on
+# the CPU.
+#
+# Not in this repository: `cargo xtask firmware` fetches each file below
+# from linux-firmware at the commit named, checks its size and SHA-256,
+# and keeps it in target/firmware/intel-wifi/. A PC's system disk carries
+# them in system:/firmware/intel/ with this description beside them,
+# unless built with PINNACLE_NO_FIRMWARE=1 (docs/hardware.md, "Closed
+# firmware").
+#
+# Format: `key: value` lines; `file:` starts a file, its own keys
+# indented below it. Lines starting with # are comments.
+
+name: intel-wifi
+title: Intel Wi-Fi firmware (AX201, AX210, AX211)
+vendor: Intel
+licence: Intel's licence for iwlwifi firmware (LICENCE.iwlwifi_firmware): redistribution in binary form, unmodified, with the notice; no reverse engineering, decompilation or disassembly
+licence-url: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/LICENSES/LICENCE.iwlwifi_firmware?id=c46910a4cbd8332ac45205424c5383dfbcb99ac5
+source: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
+tag: 20261124
+commit: c46910a4cbd8332ac45205424c5383dfbcb99ac5
+installs-to: system:/firmware/intel
+
+file: LICENCE.iwlwifi_firmware
+ from: LICENSES/LICENCE.iwlwifi_firmware
+ size: 2046
+ sha256: 16d5040c7cf851fc693b7542e20870935b99802533ea1bfd231c377a2305e5c5
+ serves: the licence, which travels with the files
+
+file: iwlwifi-Qu-b0-hr-b0-77.ucode
+ from: intel/iwlwifi/iwlwifi-Qu-b0-hr-b0-77.ucode
+ size: 1406576
+ sha256: 5e53c77a19f0cfabe039541bad814f90f47a6fec75ca6e3274610167c25897de
+ version: 74.3cda2a2c.0
+ serves: AX201 (CNVi, 10th and 11th generation): PCI 8086:02f0 06f0 34f0 4df0 43f0 a0f0 whose MAC is Qu step B (CSR_HW_REV type 0x33, step 1), with an HR radio (RF 0x10a or 0x10c)
+
+file: iwlwifi-Qu-c0-hr-b0-77.ucode
+ from: intel/iwlwifi/iwlwifi-Qu-c0-hr-b0-77.ucode
+ size: 1406592
+ sha256: 71bfd1f64299dcc32a6b3ff068a3b7c189f56a78d9d90add4b79cd463506700e
+ version: 74.3cda2a2c.0
+ serves: AX201 as above whose MAC is Qu step C (type 0x33, step 2)
+
+file: iwlwifi-QuZ-a0-hr-b0-77.ucode
+ from: intel/iwlwifi/iwlwifi-QuZ-a0-hr-b0-77.ucode
+ size: 1406720
+ sha256: 8f1b9bb98739a402d8414b7855b2c42256550ede329d06947d0f431f538dde77
+ version: 74.3cda2a2c.0
+ serves: AX201 as above whose MAC is QuZ (type 0x35, any step)
+
+file: iwlwifi-so-a0-gf-a0-89.ucode
+ from: intel/iwlwifi/iwlwifi-so-a0-gf-a0-89.ucode
+ size: 1737112
+ sha256: fb3025e8033cd3e5a2872f3edbd475dc7d8a046041def6aae01e8db8cc6f3795
+ version: 86.a67023b2.0
+ serves: AX211 (CNVi, 12th generation on): PCI 8086:51f0 51f1 54f0 7af0, MAC So or SoF (type 0x37, 0x43), GF radio (RF 0x10d, not CDB)
+
+file: iwlwifi-so-a0-gf-a0.pnvm
+ from: intel/iwlwifi/iwlwifi-so-a0-gf-a0.pnvm
+ size: 55152
+ sha256: 1597d11ad821a8e0c313c8bcac6201522407b10f60c78740bc057fac7f148d62
+ serves: the platform settings (PNVM) the So firmware asks for after it starts, one section per SKU
+
+file: iwlwifi-ty-a0-gf-a0-89.ucode
+ from: intel/iwlwifi/iwlwifi-ty-a0-gf-a0-89.ucode
+ size: 1679180
+ sha256: ecea9a005669b81279eef906bfdd62cd8a0356e73dfa01901a16b3aae4356dc8
+ version: 86.a67023b2.0
+ serves: AX210 (a card, M.2): PCI 8086:2725, MAC Ty (type 0x42), GF radio
+
+file: iwlwifi-ty-a0-gf-a0.pnvm
+ from: intel/iwlwifi/iwlwifi-ty-a0-gf-a0.pnvm
+ size: 55020
+ sha256: 9ec7f36114c68d518f6c34212c3e7959ff60be0d1fae8e774a70cf6d9b7159fd
+ serves: the platform settings (PNVM) for the Ty firmware
+
+file: iwlwifi-ma-b0-gf-a0-89.ucode
+ from: intel/iwlwifi/iwlwifi-ma-b0-gf-a0-89.ucode
+ size: 1753076
+ sha256: fd745741f4b9d722cfdc313747f04b4375c1e30370b97de59e2e9712e151822e
+ version: 86.a67023b2.0
+ serves: AX211 on Meteor Lake (CNVi): PCI 8086:7e40, MAC Ma step B (type 0x44, step 1), GF radio
+
+file: iwlwifi-ma-b0-gf-a0.pnvm
+ from: intel/iwlwifi/iwlwifi-ma-b0-gf-a0.pnvm
+ size: 55072
+ sha256: 9d540dde17b8fce6bc08d39ac7745bafa724b6d49825c745aeb5650223424d98
+ serves: the platform settings (PNVM) for the Ma firmware
diff --git a/xtask/src/firmware.rs b/xtask/src/firmware.rs
new file mode 100644
index 0000000..cfaaab3
--- /dev/null
+++ b/xtask/src/firmware.rs
@@ -0,0 +1,245 @@
+//! Closed firmware, carried as data and kept apart from Pinnacle's own code
+//! (`docs/hardware.md`, "Closed firmware"). Each package is described in
+//! `firmware/<name>.txt`: whose it is, its licence, the linux-firmware
+//! commit it comes from, and each file's path there, size and SHA-256. The
+//! files are not in the repository: `cargo xtask firmware` fetches them
+//! into `target/firmware/<name>/`, refusing any whose size or hash differs,
+//! and a PC's system disk carries them, with the description, in
+//! `system:/firmware/<vendor folder>/` unless `PINNACLE_NO_FIRMWARE=1`.
+
+use crate::{Result, root};
+use std::path::{Path, PathBuf};
+use std::process::Command;
+
+/// One package, as its description gives it.
+pub struct Package {
+ /// The description's own name, `intel-wifi`.
+ pub name: String,
+ /// The file the description was read from.
+ pub description: PathBuf,
+ /// Where on the system disk it goes, without the disk: `/firmware/intel`.
+ pub folder: String,
+ /// The repository (`…/linux-firmware.git`) and the commit taken.
+ source: String,
+ commit: String,
+ pub files: Vec<File>,
+}
+
+/// One file of a package.
+pub struct File {
+ /// Its name on the system disk.
+ pub name: String,
+ /// Its path in the source repository.
+ from: String,
+ size: u64,
+ sha256: [u8; 32],
+}
+
+fn hex32(s: &str) -> Option<[u8; 32]> {
+ let s = s.trim();
+ if s.len() != 64 {
+ return None;
+ }
+ let mut out = [0u8; 32];
+ for (i, b) in out.iter_mut().enumerate() {
+ *b = u8::from_str_radix(&s[2 * i..2 * i + 2], 16).ok()?;
+ }
+ Some(out)
+}
+
+fn hex(bytes: &[u8]) -> String {
+ bytes.iter().map(|b| format!("{b:02x}")).collect()
+}
+
+/// Reads a description: `key: value` lines, `file:` starting a file whose
+/// keys are indented below it, `#` comments.
+fn parse(path: &Path, text: &str) -> Result<Package> {
+ let fail = |line: usize, what: &str| format!("{}:{}: {what}", path.display(), line + 1);
+ let mut top: Vec<(String, String)> = Vec::new();
+ let mut files: Vec<(String, Vec<(String, String)>)> = Vec::new();
+ for (n, line) in text.lines().enumerate() {
+ let trimmed = line.trim();
+ if trimmed.is_empty() || trimmed.starts_with('#') {
+ continue;
+ }
+ let (key, value) = trimmed
+ .split_once(':')
+ .ok_or_else(|| fail(n, "not `key: value`"))?;
+ let (key, value) = (key.trim().to_string(), value.trim().to_string());
+ if line.starts_with([' ', '\t']) {
+ let (_, keys) = files
+ .last_mut()
+ .ok_or_else(|| fail(n, "an indented key outside a file"))?;
+ keys.push((key, value));
+ } else if key == "file" {
+ files.push((value, Vec::new()));
+ } else {
+ top.push((key, value));
+ }
+ }
+ let get = |list: &[(String, String)], key: &str| {
+ list.iter()
+ .find(|(k, _)| k == key)
+ .map(|(_, v)| v.clone())
+ .ok_or_else(|| format!("{}: no `{key}`", path.display()))
+ };
+ let installs = get(&top, "installs-to")?;
+ let folder = installs
+ .strip_prefix("system:")
+ .filter(|f| f.starts_with("/firmware/"))
+ .ok_or_else(|| format!("{}: installs-to must be under system:/firmware/", path.display()))?
+ .to_string();
+ for key in ["vendor", "licence", "licence-url", "tag"] {
+ get(&top, key)?;
+ }
+ let files = files
+ .into_iter()
+ .map(|(name, keys)| {
+ if name.contains(['/', ':']) || name.starts_with('.') {
+ return Err(format!("{}: `{name}` is not a plain file name", path.display()));
+ }
+ Ok(File {
+ from: get(&keys, "from")?,
+ size: get(&keys, "size")?
+ .parse()
+ .map_err(|_| format!("{}: {name}: size is not a number", path.display()))?,
+ sha256: hex32(&get(&keys, "sha256")?)
+ .ok_or_else(|| format!("{}: {name}: sha256 is not 64 hex digits", path.display()))?,
+ name,
+ })
+ })
+ .collect::<Result<Vec<_>>>()?;
+ Ok(Package {
+ name: get(&top, "name")?,
+ description: path.to_path_buf(),
+ folder,
+ source: get(&top, "source")?,
+ commit: get(&top, "commit")?,
+ files,
+ })
+}
+
+/// Every package `firmware/` describes, by name.
+pub fn packages() -> Result<Vec<Package>> {
+ let dir = root().join("firmware");
+ let mut paths: Vec<PathBuf> = std::fs::read_dir(&dir)
+ .map_err(|e| format!("{}: {e}", dir.display()))?
+ .filter_map(|e| e.ok().map(|e| e.path()))
+ .filter(|p| p.extension().is_some_and(|x| x == "txt"))
+ .collect();
+ paths.sort();
+ paths
+ .iter()
+ .map(|p| {
+ let text = std::fs::read_to_string(p).map_err(|e| format!("{}: {e}", p.display()))?;
+ parse(p, &text)
+ })
+ .collect()
+}
+
+/// Where a package's fetched files are kept.
+fn kept(package: &Package) -> PathBuf {
+ root().join("target/firmware").join(&package.name)
+}
+
+/// Whether `bytes` are the file the description names.
+fn checks(file: &File, bytes: &[u8]) -> std::result::Result<(), String> {
+ if bytes.len() as u64 != file.size {
+ return Err(format!("{} bytes, not the {} described", bytes.len(), file.size));
+ }
+ let got = pinnacle_crypto::sha2::Sha256::digest(bytes);
+ if got != file.sha256 {
+ return Err(format!(
+ "SHA-256 {}, not the {} described",
+ hex(&got),
+ hex(&file.sha256)
+ ));
+ }
+ Ok(())
+}
+
+/// Fetches every file of `package` not already kept and whole, from its
+/// source at its commit, each checked before it is kept. Returns the folder.
+pub fn fetch(package: &Package) -> Result<PathBuf> {
+ let dir = kept(package);
+ std::fs::create_dir_all(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
+ for file in &package.files {
+ let at = dir.join(&file.name);
+ if std::fs::read(&at).is_ok_and(|b| checks(file, &b).is_ok()) {
+ continue;
+ }
+ let url = format!("{}/plain/{}?id={}", package.source, file.from, package.commit);
+ let part = dir.join(format!("{}.part", file.name));
+ let status = Command::new("curl")
+ .args(["-sSfL", "--retry", "2", "--max-time", "300", "-o"])
+ .arg(&part)
+ .arg(&url)
+ .status()
+ .map_err(|e| format!("curl: {e}"))?;
+ if !status.success() {
+ let _ = std::fs::remove_file(&part);
+ return Err(format!("{}: could not fetch {url}", file.name));
+ }
+ let bytes = std::fs::read(&part).map_err(|e| format!("{}: {e}", part.display()))?;
+ if let Err(e) = checks(file, &bytes) {
+ let _ = std::fs::remove_file(&part);
+ return Err(format!("{}: refused: {e}", file.name));
+ }
+ std::fs::rename(&part, &at).map_err(|e| format!("{}: {e}", at.display()))?;
+ println!(
+ "firmware: {} ({} bytes, sha256 {})",
+ file.name,
+ file.size,
+ hex(&file.sha256)
+ );
+ }
+ Ok(dir)
+}
+
+/// `cargo xtask firmware`: every package fetched and checked.
+pub fn fetch_all() -> Result {
+ for package in packages()? {
+ let dir = fetch(&package)?;
+ println!(
+ "firmware: {}: {} files in {}",
+ package.name,
+ package.files.len(),
+ dir.display()
+ );
+ }
+ Ok(())
+}
+
+/// What a PC's system disk carries of the closed firmware: each package's
+/// files and its description, as (path on the disk, bytes). None with
+/// `PINNACLE_NO_FIRMWARE=1`; a package that cannot be fetched (no network)
+/// is left out, and said so.
+pub fn for_image() -> Result<Vec<(String, Vec<u8>)>> {
+ if std::env::var("PINNACLE_NO_FIRMWARE").is_ok_and(|v| v == "1") {
+ println!("firmware: none on the system disk (PINNACLE_NO_FIRMWARE=1)");
+ return Ok(Vec::new());
+ }
+ let mut out = Vec::new();
+ for package in packages()? {
+ let dir = match fetch(&package) {
+ Ok(dir) => dir,
+ Err(e) => {
+ eprintln!(
+ "xtask: firmware {} left off the system disk: {e} (`cargo xtask firmware` fetches it)",
+ package.name
+ );
+ continue;
+ }
+ };
+ for file in &package.files {
+ let at = dir.join(&file.name);
+ let bytes = std::fs::read(&at).map_err(|e| format!("{}: {e}", at.display()))?;
+ checks(file, &bytes).map_err(|e| format!("{}: {e}", at.display()))?;
+ out.push((format!("{}/{}", package.folder, file.name), bytes));
+ }
+ let description = std::fs::read(&package.description)
+ .map_err(|e| format!("{}: {e}", package.description.display()))?;
+ out.push((format!("{}/{}.txt", package.folder, package.name), description));
+ }
+ Ok(out)
+}
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 9ae3e65..44b3c6f 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -50,7 +50,11 @@
//! - `loader [pc]`, `installer [pc]`, `install-test [pc]`, `install-demo
//! [pc]`: Pinnacle's UEFI loader, an install medium for a USB stick, and
//! installing from it onto a disk in QEMU (`install.rs`)
+//! - `firmware` the closed firmware `firmware/*.txt` describes (Intel's
+//! Wi-Fi), fetched into `target/firmware/` and checked (`firmware.rs`); a
+//! PC's system disk carries it unless `PINNACLE_NO_FIRMWARE=1`
+mod firmware;
mod install;
mod model;
mod profile;
@@ -157,6 +161,7 @@ fn main() -> ExitCode {
["install-demo"] => install::demo(Arch::Arm),
["install-demo", "pc"] => install::demo(Arch::Pc),
["laptop"] => install::laptop(),
+ ["firmware"] => firmware::fetch_all(),
_ => Err(
"usage: cargo xtask build|image [qemu-virt|rk3399] | sdcard | run | bundle [pc] | test | gate | pair | remote"
.into(),
@@ -2778,8 +2783,14 @@ fn disks_for(
let repository = repository().join(arch.store_path());
let fail = |e: pinnacle_fs::Error| format!("{e:?}");
let system_path = system_path.to_path_buf();
+ // A PC's closed firmware (Intel's Wi-Fi), as data in a folder of its
+ // own, unless PINNACLE_NO_FIRMWARE=1 (`firmware/`, docs/hardware.md).
+ let firmware = match arch {
+ Arch::Pc => firmware::for_image()?,
+ Arch::Arm => Vec::new(),
+ };
// The room, and room for what is added (Cartopolis is 141 MiB).
- let added: usize = extra.iter().map(|(_, bytes)| bytes.len()).sum();
+ let added: usize = extra.iter().chain(&firmware).map(|(_, bytes)| bytes.len()).sum();
let mib = room_mib + (added + added / 4).div_ceil(1 << 20);
let mut system = new_image(&system_path, mib as _, "system")?;
for (name, title, description) in PREINSTALLED {
@@ -2838,6 +2849,12 @@ fn disks_for(
}
system.write(path, contents).map_err(fail)?;
}
+ for (path, contents) in &firmware {
+ if let Some((dir, _)) = path.rsplit_once('/') {
+ system.create_dir(dir).map_err(fail)?;
+ }
+ system.write(path, contents).map_err(fail)?;
+ }
// The keys the system trusts: this checkout's publisher, whose packages
// `serve` offers, and the hosted Store's; for apps, and apart for
// systems (`docs/updates.md`), which no app's publisher signs.