diff --git a/application_processor/Makefile b/application_processor/Makefile index 9056342..b20f7b4 100644 --- a/application_processor/Makefile +++ b/application_processor/Makefile @@ -1,4 +1,5 @@ all: + export RUSTFLAGS='--cfg debug=true' echo "${POST_BOOT_CODE}" cargo make -e BUILD_TYPE=release -e CARGO_TARGET_DIR=${CURDIR}/target ap --verbose diff --git a/application_processor/src/main.rs b/application_processor/src/main.rs index c9f7687..8586254 100644 --- a/application_processor/src/main.rs +++ b/application_processor/src/main.rs @@ -102,11 +102,13 @@ fn main() -> ! { #[panic_handler] fn panic(info: &PanicInfo) -> ! { - led_on(Led::Red); - led_off(Led::Green); - led_off(Led::Blue); + if cfg!(debug) { + led_on(Led::Red); + led_off(Led::Green); + led_off(Led::Blue); - uprintln_error!("Panic: {info}"); + uprintln_error!("Panic: {info}"); + } loop {} } diff --git a/component/Makefile b/component/Makefile index 7b12884..0b345ac 100644 --- a/component/Makefile +++ b/component/Makefile @@ -1,4 +1,5 @@ all: + export RUSTFLAGS='--cfg debug=true' echo "${POST_BOOT_CODE}" cargo make -e BUILD_TYPE=release -e CARGO_TARGET_DIR=${CURDIR}/target component --verbose diff --git a/component/build.rs b/component/build.rs index ddc12a4..d985be4 100644 --- a/component/build.rs +++ b/component/build.rs @@ -153,9 +153,7 @@ fn main() { let max_spacing = 0x1000; - let stack_start = ram_origin + (ram_length/4) + gen_addr(0, max_spacing, &mut rng); - let sentry = gen_addr(0, max_spacing, &mut rng); let textoffset = gen_addr(0, max_spacing, &mut rng); @@ -163,14 +161,13 @@ fn main() { let dataoffset = gen_addr(0, max_spacing, &mut rng); let bssoffset = gen_addr(0, max_spacing, &mut rng); - let memory_x = format!(" MEMORY {{ /* ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000 */ FLASH (rx) : ORIGIN = {flash_origin:#x}, LENGTH = {flash_length:#x} /* 448KB Flash */ RAM (rwx) : ORIGIN = {ram_origin:#x}, LENGTH = {ram_length:#x} /* 128kB SRAM */ }} - + /* Bootloader jumps to this address to start the ap */ _sentry = {sentry:#x}; @@ -181,17 +178,14 @@ fn main() { bssoffset = {bssoffset:#x}; textoffset = {textoffset:#x}; "); - - + File::create(out.join("memory.x")) .unwrap() .write_all(memory_x.as_bytes()) .unwrap(); - - println!("cargo:rustc-link-search={}", out.display()); + println!("cargo:rustc-link-search={}", out.display()); println!("cargo:rerun-if-changed=memory.x"); - println!("cargo:rustc-link-arg=--nmagic"); // Set the linker script to the one provided by cortex-m-rt. diff --git a/component/src/main.rs b/component/src/main.rs index e50bc2f..06d995c 100644 --- a/component/src/main.rs +++ b/component/src/main.rs @@ -96,11 +96,13 @@ fn main() -> ! { #[panic_handler] fn panic(info: &PanicInfo) -> ! { - led_on(Led::Red); - led_off(Led::Blue); - led_off(Led::Green); + if cfg!(debug) { + led_on(Led::Red); + led_off(Led::Blue); + led_off(Led::Green); - uprintln_error!("{info}"); + uprintln_error!("{info}"); + } loop {} } diff --git a/deployment/src/lib.rs b/deployment/src/lib.rs index 37e3804..8e9acbf 100644 --- a/deployment/src/lib.rs +++ b/deployment/src/lib.rs @@ -141,7 +141,7 @@ impl SecretDb { ); match result { - Err(rusqlite::Error::SqliteFailure(error, _)) + Err(Error::SqliteFailure(error, _)) if error.code == ErrorCode::ConstraintViolation => { // this means the build id was generated was not unique, so try again continue; @@ -204,7 +204,7 @@ impl SecretDb { WHERE component_build_ids.component_id = ?1", )?; - let componeny_keypair = statement.query_map([component_id], |row| { + let component_keypair = statement.query_map([component_id], |row| { Ok(ComponentKeyPair { build_id: row.get(0)?, keypair: KeyPair { @@ -214,12 +214,12 @@ impl SecretDb { }) })?.next(); - // this components keypair is already defined - if let Some(keypair) = componeny_keypair { + // this component's keypair is already defined + if let Some(keypair) = component_keypair { return Ok(keypair?); } - // this components keypair is not defined, make it defined + // this component's keypair is not defined, make it defined let mut statement = self.db.prepare( "UPDATE component_keypairs SET in_use = TRUE @@ -262,4 +262,4 @@ pub fn parse_component_id(n: &str) -> u32 { n.parse::() .expect("could not parse component id") } -} \ No newline at end of file +}