Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/cosmo/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ target = "thumbv7em-none-eabihf"
chip = "../../chips/stm32h7"
memory = "memory-large.toml"
stacksize = 896
fwid = true

[kernel]
name = "cosmo"
Expand Down
1 change: 0 additions & 1 deletion app/gemini-bu/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ target = "thumbv7em-none-eabihf"
board = "gemini-bu-1"
chip = "../../chips/stm32h7"
stacksize = 896
fwid = true

[kernel]
name = "gemini-bu"
Expand Down
1 change: 0 additions & 1 deletion app/gimlet/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ target = "thumbv7em-none-eabihf"
chip = "../../chips/stm32h7"
memory = "memory-large.toml"
stacksize = 896
fwid = true

[kernel]
name = "gimlet"
Expand Down
1 change: 0 additions & 1 deletion app/gimletlet/app-mgmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ target = "thumbv7em-none-eabihf"
board = "gimletlet-1"
chip = "../../chips/stm32h7"
stacksize = 1024
fwid = true

[kernel]
name = "gimletlet"
Expand Down
1 change: 0 additions & 1 deletion app/gimletlet/base-gimletlet2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ memory = "memory-large.toml"
stacksize = 896
epoch = 0
version = 0
fwid = true

[kernel]
name = "gimletlet"
Expand Down
1 change: 0 additions & 1 deletion app/grapefruit/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ memory = "memory-large.toml"
stacksize = 896
epoch = 0
version = 0
fwid = true

[mmio]
peripheral-region = "fmc_nor_psram_bank_1"
Expand Down
1 change: 0 additions & 1 deletion app/lpc55xpresso/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ board = "lpcxpresso55s69"
chip = "../../chips/lpc55"
stacksize = 1024
image-names = ["a", "b"]
fwid = true

[kernel]
name = "lpc55xpresso"
Expand Down
1 change: 0 additions & 1 deletion app/medusa/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ target = "thumbv7em-none-eabihf"
chip = "../../chips/stm32h7"
memory = "memory-large.toml"
stacksize = 896
fwid = true

[kernel]
name = "medusa"
Expand Down
1 change: 0 additions & 1 deletion app/minibar/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ target = "thumbv7em-none-eabihf"
chip = "../../chips/stm32h7"
stacksize = 896
memory = "memory-large.toml"
fwid = true

[kernel]
name = "minibar"
Expand Down
1 change: 0 additions & 1 deletion app/oxide-rot-1/app-dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ stacksize = 1024
image-names = ["a", "b"]
epoch = 0
version = 0
fwid = true

[kernel]
name = "oxide-rot-1"
Expand Down
1 change: 0 additions & 1 deletion app/oxide-rot-1/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ stacksize = 1024
image-names = ["a", "b"]
epoch = 0
version = 0
fwid = true

[kernel]
name = "oxide-rot-1"
Expand Down
1 change: 0 additions & 1 deletion app/psc/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ target = "thumbv7em-none-eabihf"
chip = "../../chips/stm32h7"
memory = "memory-large.toml"
stacksize = 896
fwid = true

[kernel]
name = "psc"
Expand Down
1 change: 0 additions & 1 deletion app/rot-carrier/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ stacksize = 1024
image-names = ["a", "b"]
epoch = 0
version = 0
fwid = true

[kernel]
name = "rot-carrier"
Expand Down
1 change: 0 additions & 1 deletion app/sidecar/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ target = "thumbv7em-none-eabihf"
chip = "../../chips/stm32h7"
stacksize = 896
memory = "memory-large.toml"
fwid = true

[kernel]
name = "sidecar"
Expand Down
4 changes: 0 additions & 4 deletions build/xtask/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ struct RawConfig {
epoch: u32,
#[serde(default)]
version: u32,
#[serde(default)]
fwid: bool,
memory: Option<String>,
#[serde(default)]
image_names: Vec<String>,
Expand Down Expand Up @@ -67,7 +65,6 @@ pub struct Config {
pub epoch: u32,
pub mmio: Option<MmioData>,
pub version: u32,
pub fwid: bool,
pub image_names: Vec<String>,
pub signing: Option<RoTMfgSettings>,
pub stacksize: Option<u32>,
Expand Down Expand Up @@ -262,7 +259,6 @@ impl Config {
mmio,
epoch: toml.epoch,
version: toml.version,
fwid: toml.fwid,
signing: toml.signing,
stacksize: toml.stacksize,
kernel: toml.kernel,
Expand Down
68 changes: 0 additions & 68 deletions build/xtask/src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
use std::ffi::OsStr;
use std::fmt::Write as _;
use std::fs::{self, File};
use std::hash::{Hash, Hasher};
Expand All @@ -15,10 +14,8 @@ use std::process::{Command, Stdio};
use anyhow::{anyhow, bail, Context, Result};
use atty::Stream;
use indexmap::IndexMap;
use lpc55_rom_data::FLASH_PAGE_SIZE as LPC55_FLASH_PAGE_SIZE;
use multimap::MultiMap;
use path_slash::{PathBufExt, PathExt};
use sha3::{Digest, Sha3_256};
use zerocopy::IntoBytes;

use crate::{
Expand Down Expand Up @@ -720,10 +717,6 @@ pub fn package(
archive.overwrite()?;
}

if cfg.toml.fwid {
write_fwid(&cfg, image_name, &flash, &archive_name)?;
}

// Unzip the signed + caboose'd images into our build directory
let archive = hubtools::RawHubrisArchive::load(&archive_name)
.context("loading archive with hubtools")?;
Expand All @@ -738,67 +731,6 @@ pub fn package(
Ok(allocated)
}

// generate file with hash of expected flash contents
fn write_fwid(
cfg: &PackageConfig,
image_name: &str,
flash: &Range<u32>,
archive_name: &PathBuf,
) -> Result<()> {
let mut archive = hubtools::RawHubrisArchive::load(archive_name)
.context("loading archive with hubtools")?;

let bin = archive
.extract_file("img/final.bin")
.context("extracting final.bin after signing & caboosing")?;

let chip_name = Path::new(&cfg.toml.chip);

// determine length of padding
let pad = match chip_name.file_name().and_then(OsStr::to_str) {
Some("lpc55") => {
// Flash is programmed in 512 blocks. If the final block is not
// filled, it is padded with 0xff's. Unwritten flash pages cannot
// be read and are not included in the FWID calculation.
LPC55_FLASH_PAGE_SIZE - bin.len() % LPC55_FLASH_PAGE_SIZE
}
Some("stm32h7") => {
// all unprogrammed flash is read as 0xff
flash.end as usize - flash.start as usize - bin.len()
}
Some(c) => {
bail!("no FWID algorithm defined for chip: \"{}\"", c)
}
None => bail!("Failed to get file name of {}", chip_name.display()),
};

let mut sha = Sha3_256::new();
sha.update(&bin);

if pad != 0 {
sha.update(vec![0xff_u8; pad])
}

let digest = sha.finalize();

// after we've appended a newline fwid is immutable
let mut fwid = hex::encode(digest);
writeln!(fwid).context("appending newline to FWID")?;
let fwid = fwid;

// the archive already exists so we write the FWID to the same path in
// the build output and archive to keep the two consistent
fs::write(cfg.img_file("final.fwid", image_name), &fwid)
.context("writing FWID to build output")?;
archive
.add_file("img/final.fwid", fwid.as_bytes())
.context("writing FWID to archive")?;

archive.overwrite()?;

Ok(())
}

fn write_gdb_script(cfg: &PackageConfig, image_name: &str) -> Result<()> {
// Humility doesn't know about images right now. The gdb symbol file
// paths all assume a flat layout with everything in dist. For now,
Expand Down