diff --git a/.gitignore b/.gitignore index e92715691..fc7e53abb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ target /emulation/obj # auto-generated services/xous-ticktimer/src/version.rs +bao1x-boot/boot0/src/version.rs +bao1x-boot/boot1/src/version.rs apps/i18n.json services/gam/src/apps.rs services/status/src/app_autogen.rs diff --git a/bao1x-boot/blobs/README.md b/bao1x-boot/blobs/README.md new file mode 100644 index 000000000..8e197ee99 --- /dev/null +++ b/bao1x-boot/blobs/README.md @@ -0,0 +1,8 @@ +# Binary Data Used in Programming + +## One-Way Counter Defaults + +These blobs are burned into the one-way counter array to force some counters to be +tripped, thus pre-configuring the behavior of a given board. + +* `dabao-owc.bin`: Sets board type to `dabao`, and sets wait on boot to true diff --git a/bao1x-boot/blobs/dabao-owc.bin b/bao1x-boot/blobs/dabao-owc.bin new file mode 100644 index 000000000..e27cace9b Binary files /dev/null and b/bao1x-boot/blobs/dabao-owc.bin differ diff --git a/bao1x-boot/boot0/src/main.rs b/bao1x-boot/boot0/src/main.rs index bb49c0f74..ba87f2535 100644 --- a/bao1x-boot/boot0/src/main.rs +++ b/bao1x-boot/boot0/src/main.rs @@ -8,6 +8,7 @@ mod asm; mod platform; #[cfg(feature = "unsafe-dev")] mod repl; +mod version; #[cfg(feature = "unsafe-dev")] use alloc::collections::VecDeque; #[cfg(feature = "unsafe-dev")] @@ -51,7 +52,7 @@ pub fn uart_irq_handler() { #[export_name = "rust_entry"] pub unsafe extern "C" fn rust_entry() -> ! { crate::platform::early_init(); - crate::println!("\n~~boot0 up!~~\n"); + crate::println!("\n~~boot0 up! ({})~~\n", crate::version::SEMVER); #[cfg(feature = "unsafe-dev")] let mut repl = crate::repl::Repl::new(); diff --git a/bao1x-boot/boot1/src/main.rs b/bao1x-boot/boot1/src/main.rs index d8c2918e4..ad27edb48 100644 --- a/bao1x-boot/boot1/src/main.rs +++ b/bao1x-boot/boot1/src/main.rs @@ -8,6 +8,7 @@ mod platform; mod repl; mod secboot; mod uf2; +mod version; use alloc::collections::VecDeque; use core::{ @@ -28,6 +29,8 @@ use crate::platform::usb::glue; use crate::secboot::boot_or_die; use crate::{delay, platform::irq::disable_all_irqs}; +const RELEASE_DESCRIPTION: &'static str = "Dabao Alpha-0 Sample"; + static UART_RX: Mutex>> = Mutex::new(RefCell::new(VecDeque::new())); #[allow(dead_code)] static USB_RX: Mutex>> = Mutex::new(RefCell::new(VecDeque::new())); @@ -72,7 +75,7 @@ pub unsafe extern "C" fn rust_entry() -> ! { crate::println_d!("TX_IDLE: {:?}", crate::platform::usb::TX_IDLE.load(Ordering::SeqCst)); let perclk: u32; (board_type, perclk) = crate::platform::early_init(board_type); - crate::println!("\n~~Boot1 up!~~\n"); + crate::println!("\n~~Boot1 up! ({}: {})~~\n", crate::version::SEMVER, RELEASE_DESCRIPTION); crate::println!("Configured board type: {:?}", board_type); if board_type == BoardTypeCoding::Baosec { IS_BAOSEC.store(true, Ordering::SeqCst); diff --git a/bao1x-boot/boot1/src/repl.rs b/bao1x-boot/boot1/src/repl.rs index de6f0ed86..b2adc5741 100644 --- a/bao1x-boot/boot1/src/repl.rs +++ b/bao1x-boot/boot1/src/repl.rs @@ -208,6 +208,14 @@ impl Repl { "Boot partition is: {:?}", owc.get_decoded::() ); + crate::println!("Semver is: {}", crate::version::SEMVER); + crate::println!("Description is: {}", crate::RELEASE_DESCRIPTION); + // TODO: replace this with a proper API, this is a hack to allow an initial + // alpha run of boards to be churned out on short notice. The hard-coded number + // below ostensibly belongs to "data slot 0". For this run, it's just an incrementing + // number, but in the future it might be a truncated hash, or randomly generated number. + let sn = unsafe { core::slice::from_raw_parts(0x603d_c000 as *const u32, 4) }; + crate::println!("Device serializer: {:08x}-{:08x}-{:08x}-{:08x}", sn[3], sn[2], sn[1], sn[0]); crate::println!("Revocations:"); crate::println!("Stage key0 key1 key2 key3"); let key_array = [ diff --git a/tools/src/sign_image.rs b/tools/src/sign_image.rs index 5a4b53bd3..0452570b1 100644 --- a/tools/src/sign_image.rs +++ b/tools/src/sign_image.rs @@ -245,7 +245,7 @@ pub fn sign_image( // Write the header dest_file.write_all(&header.as_ref()[..UNSIGNED_LEN])?; - println!("dest_file wrote {}, {}", dest_file.len(), UNSIGNED_LEN); + // println!("dest_file wrote {}, {}", dest_file.len(), UNSIGNED_LEN); if defile { println!( diff --git a/xtask/src/versioning.rs b/xtask/src/versioning.rs index 043e96a74..0dbabf342 100644 --- a/xtask/src/versioning.rs +++ b/xtask/src/versioning.rs @@ -18,6 +18,8 @@ pub(crate) fn generate_version(add_timestamp: bool) { let semver = String::from_utf8_lossy(&gitver); let version_file = "services/xous-ticktimer/src/version.rs"; + let boot0_version_file = "bao1x-boot/boot0/src/version.rs"; + let boot1_version_file = "bao1x-boot/boot1/src/version.rs"; // Read the existing file to see if it needs to be updated. let mut existing_data = Vec::new(); @@ -39,12 +41,14 @@ pub(crate) fn generate_version(add_timestamp: bool) { write!(new_data, "#[allow(dead_code)]\npub const TIMESTAMP: &'static str = \"unavailable\";\n") .expect("couldn't add our timestamp"); } + let mut semver_code = Vec::new(); writeln!( - new_data, + semver_code, "pub const SEMVER: &'static str = \"{}\";", semver.strip_suffix("\r\n").or(semver.strip_suffix('\n')).unwrap_or(&semver) ) .expect("couldn't add our semver"); + new_data.extend_from_slice(&semver_code); if existing_data != new_data { let mut vfile = OpenOptions::new() @@ -55,6 +59,22 @@ pub(crate) fn generate_version(add_timestamp: bool) { .open(version_file) .expect("Can't open our version file for writing"); vfile.write_all(&new_data).expect("couldn't write new timestamp to version.rs"); + let mut vfile = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .truncate(true) + .open(boot0_version_file) + .expect("Can't open our version file for writing"); + vfile.write_all(&semver_code).expect("couldn't write semver to version.rs"); + let mut vfile = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .truncate(true) + .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"); } }