Skip to content

Add --baobit-commit flag for build provenance#821

Merged
bunnie merged 2 commits intobetrusted-io:mainfrom
sbellem:bao1x-boot-baobit-toolchain
Feb 15, 2026
Merged

Add --baobit-commit flag for build provenance#821
bunnie merged 2 commits intobetrusted-io:mainfrom
sbellem:bao1x-boot-baobit-toolchain

Conversation

@sbellem
Copy link
Copy Markdown
Contributor

@sbellem sbellem commented Feb 15, 2026

Summary

This PR adds support for embedding the Guix build channel (baobit) commit hash in firmware, enabling verification of reproducible builds.

Changes

  • xtask/src/main.rs: Add --baobit-commit <hash> CLI flag
  • xtask/src/versioning.rs: Generate BAOBIT_COMMIT constant in boot0/boot1 version.rs files; simplified to always write version files
  • bao1x-boot/boot1/src/audit.rs: Display baobit commit in audit output

Usage

cargo xtask bao1x-boot1 --baobit-commit abc123def456

Audit Output

Semver is: v0.10.0-58-gb112c38a8
Baobit commit is: abc123def456
Description is: bao2-0

Motivation

For reproducible builds via Guix, it's useful to know which version of the build toolchain (baobit channel) was used to produce a given firmware. This enables:

  1. Reproducibility verification: Given firmware, identify the exact baobit commit to reproduce the build
  2. Audit trail: Factory verification can confirm build provenance
  3. Debugging: Correlate firmware behavior with specific build toolchain versions

When --baobit-commit is not provided, the constant defaults to "unknown".

@sbellem sbellem force-pushed the bao1x-boot-baobit-toolchain branch from cbc4953 to 3ea92d3 Compare February 15, 2026 14:28
@sbellem sbellem changed the title Bao1x boot baobit toolchain Add --baobit-commit flag for build provenance Feb 15, 2026
const GIT_ABBREV_LEN: u8 = 9;

pub(crate) fn generate_version(add_timestamp: bool, forced_version: Option<String>) {
fn write_if_changed(path: &str, new_data: &[u8]) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a function we can re-use to check if files have been written before

.open(boot1_version_file)
.expect("Can't open our version file for writing");
vfile.write_all(&semver_code).expect("couldn't write semver to version.rs");
// Baochip versioning is just SEMVER + BAOBIT_COMMIT. Now that
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semver has already been appended to the Precursor version of the version.rs, so we can re-use it to build the baochip version here without having to copy it.

.expect("couldn't add baobit commit");
} else {
// For builds that aren't built in the reproducible environment, the baobit commit is unspecified
writeln!(semver_code, "pub const BAOBIT_COMMIT: &'static str = \"unspecified\";")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope unspecified is OK with you? I feel like this is less alarming than unknown - in an audit, I feel like "unknown" could mean the version got corrupted, where as "unspecified" indicates intent to not specify it.

@bunnie
Copy link
Copy Markdown
Member

bunnie commented Feb 15, 2026

If this goes CI-clean I'll merge it - please open a new PR if you disagree with the changes! The main reason I'm merging before you can comment is it drops this into the hardware CI hopper, which I want to have run overnight.

@bunnie bunnie merged commit a902b54 into betrusted-io:main Feb 15, 2026
15 checks passed
sbellem and others added 2 commits February 16, 2026 08:24
Adds BAOBIT_COMMIT constant to boot0/boot1 version.rs, allowing
the Guix build channel commit to be embedded in firmware for
reproducibility verification.

- Add --baobit-commit CLI flag to xtask
- Generate BAOBIT_COMMIT in boot version files
- Display in audit command output
- Simplify versioning.rs to always write files
- add a function we can re-use to check if a file needs updating
- change the wording of the baobit commit when it's not specified
to "unspecified" vs. "unknown"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants