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
718 changes: 307 additions & 411 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,23 @@ license = "MPL-2.0"

[workspace.dependencies]
hubtools.path = "hubtools"

anyhow = { version = "1" }
clap = { version = "4", features = ["derive", "env", "wrap_help"] }
object = { version = "0.39", default-features = false, features = ["write", "read"] }
path-slash = { version = "0.2", default-features = false }
thiserror = { version = "2", default-features = false }
toml = { version = "1.1", default-features = false, features = ["parse", "serde"] }
x509-cert = { version = "0.2", default-features = false, features = ["std"] }
zerocopy = { version = "0.8", default-features = false }
zip = { version = "8", default-features = false, features = ["bzip2"] }
hex = { version = "0.4.3", default-features = false }
digest = { version = "0.11", default-features = false }
rsa = { version = "0.9.0", default-features = false, features = ["std", "pem", "sha2"] }
sha2 = { version = "0.11.0", default-features = false }
sha3 = { version = "0.11.0", default-features = false }

tlvc = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.4" }
tlvc-text = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.4" }
lpc55_sign = { git = "https://github.com/oxidecomputer/lpc55_support", default-features = false, version = "0.3" }
lpc55_areas = { git = "https://github.com/oxidecomputer/lpc55_support", default-features = false, version = "0.2" }
12 changes: 6 additions & 6 deletions fwidgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ version = "0.1.0"
edition = "2024"

[dependencies]
anyhow.version = "1"
clap = { version = "4.5.32", features = ["derive", "env", "wrap_help"] }
hex = "0.4.3"
anyhow.workspace = true
clap.workspace = true
hex.workspace = true
hubtools.workspace = true
sha2 = "0.10.8"
sha3 = "0.10.8"
toml = { version = "0.7.8", default-features = false, features = ["parse"] }
sha2.workspace = true
sha3.workspace = true
toml.workspace = true
9 changes: 4 additions & 5 deletions hubedit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ version = "0.2.0"
edition = "2024"

[dependencies]
anyhow.version = "1"
anyhow.workspace = true
hubtools.workspace = true
clap = { version = "4", features = ["derive", "env", "wrap_help"] }

tlvc.git = "https://github.com/oxidecomputer/tlvc"
tlvc-text.git = "https://github.com/oxidecomputer/tlvc"
clap.workspace = true
tlvc.workspace = true
tlvc-text.workspace = true
29 changes: 14 additions & 15 deletions hubtools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ version = "0.4.8"
edition = "2024"

[dependencies]
object = { version = "0.30", default-features = false, features = ["write", "read"] }
path-slash = { version = "0.1", default-features = false }
thiserror = { version = "1", default-features = false }
toml = { version = "0.7", default-features = false, features = ["parse"] }
x509-cert = { version = "0.2", default-features = false, features = ["std"] }
zerocopy = { version = "0.6", default-features = false }
zip = { version = "0.6", default-features = false, features = ["bzip2"] }
hex = { version = "0.4.3", default-features = false }
digest = { version = "0.10.7", default-features = false }

tlvc = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.4" }
tlvc-text = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.4" }
lpc55_sign = { git = "https://github.com/oxidecomputer/lpc55_support", default-features = false, version = "0.3" }
lpc55_areas = { git = "https://github.com/oxidecomputer/lpc55_support", default-features = false, version = "0.2" }
rsa = { version = "0.9.0", default-features = false, features = ["std", "pem", "sha2"] }
digest.workspace = true
hex.workspace = true
lpc55_areas.workspace = true
lpc55_sign.workspace = true
object.workspace = true
path-slash.workspace = true
rsa.workspace = true
thiserror.workspace = true
tlvc-text.workspace = true
tlvc.workspace = true
toml.workspace = true
x509-cert.workspace = true
zerocopy.workspace = true
zip.workspace = true
4 changes: 2 additions & 2 deletions hubtools/src/archive_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ impl HubrisArchiveBuilder {
where
W: io::Write + io::Seek,
{
let opts = zip::write::FileOptions::default()
let opts = zip::write::FileOptions::<()>::default()
.compression_method(zip::CompressionMethod::Bzip2);

let mut archive = ZipWriter::new(out);
archive.set_comment(format!(
"hubris build archive v{}",
self.archive_version
));
))?;

archive.start_file("img/final.elf", opts)?;
let elf = self.image.to_elf()?;
Expand Down
4 changes: 2 additions & 2 deletions hubtools/src/bootleby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::HubrisArchiveBuilder;
use crate::RawHubrisArchive;
use crate::RawHubrisImage;
use crate::header;
use zerocopy::AsBytes;
use zerocopy::IntoBytes;

fn image_length(elf: &object::read::File) -> Result<u64, Error> {
let mut total: u64 = 0;
Expand Down Expand Up @@ -79,7 +79,7 @@ fn add_image_header(path: PathBuf) -> Result<Vec<u8>, Error> {

header
.write_to_prefix(&mut f[(offset as usize)..])
.ok_or(Error::BadPrefix)?;
.map_err(|_| Error::BadPrefix)?;

Ok(f)
}
Expand Down
19 changes: 9 additions & 10 deletions hubtools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use object::{Object, ObjectSection, ObjectSegment};
use path_slash::PathBufExt;
use thiserror::Error;
use x509_cert::Certificate;
use zerocopy::{AsBytes, FromBytes};
use zerocopy::{FromBytes, Immutable, IntoBytes};

use std::{
collections::{BTreeMap, btree_map::Entry},
Expand Down Expand Up @@ -339,19 +339,19 @@ impl RawHubrisImage {
}

/// Attempts to read `out.len()` bytes, starting at `start`
fn read<T: AsBytes + FromBytes + ?Sized>(
fn read<T: IntoBytes + FromBytes + Immutable + ?Sized>(
&self,
start: u32,
out: &mut T,
) -> Result<(), Error> {
let size = out.as_bytes().len() as u32;
out.as_bytes_mut()
out.as_mut_bytes()
.copy_from_slice(self.get(start..start + size)?);
Ok(())
}

/// Attempts to read `out.len()` bytes, starting at `start`
fn write<T: AsBytes + FromBytes + ?Sized>(
fn write<T: IntoBytes + FromBytes + Immutable + ?Sized>(
&mut self,
start: u32,
input: &T,
Expand Down Expand Up @@ -812,9 +812,9 @@ impl RawHubrisArchive {
let mut out_buf = vec![];
let out_cursor = Cursor::new(&mut out_buf);
let mut out = zip::ZipWriter::new(out_cursor);
out.set_raw_comment(archive.comment().to_vec());
out.set_raw_comment(archive.comment().into())?;

let opts = zip::write::FileOptions::default()
let opts = zip::write::FileOptions::<()>::default()
.compression_method(zip::CompressionMethod::Bzip2);

for i in 0..archive.len() {
Expand All @@ -824,7 +824,7 @@ impl RawHubrisArchive {
.ok_or_else(|| Error::BadFileInZip(file.name().to_owned()))?
.to_owned();

let path = outpath.to_slash().unwrap();
let path = outpath.to_slash().unwrap().into_owned();
if !self.new_files.contains_key(&path) {
out.start_file(path, opts)?;
std::io::copy(&mut file, &mut out).unwrap();
Expand All @@ -838,7 +838,6 @@ impl RawHubrisArchive {
}

out.finish()?;
drop(out);

Ok(out_buf)
}
Expand Down Expand Up @@ -1168,13 +1167,13 @@ impl std::fmt::Display for Chip {
}

mod header {
use zerocopy::{AsBytes, FromBytes};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};

// Defined in the kernel ABI crate - we support both the original and
// new-style magic numbers, which use the same header layout.
pub(crate) const MAGIC: [u32; 2] = [0x15356637, 0x64_CE_D6_CA];

#[derive(Default, AsBytes, FromBytes)]
#[derive(Default, IntoBytes, FromBytes, Immutable, KnownLayout)]
#[repr(C)]
pub(crate) struct ImageHeader {
pub magic: u32,
Expand Down
Loading