spi: prefix MEMORY_SPI_BLE_FIRMWARE_(1|2)_ADDR with BITBOX02_
What changed, and why it matters
This commit simply renames internal constants so they start with BITBOX02_. It does not change any values, memory addresses, or program behavior. The change is purely cosmetic/clarifying to avoid confusion when these constants are used in shared code.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch renames MEMORY_SPI_BLE_FIRMWARE_1_ADDR, MEMORY_SPI_BLE_FIRMWARE_2_ADDR, and MEMORY_SPI_ERASE_GRANULARITY to BITBOX02_-prefixed equivalents across C and Rust sources. Numeric values and logic remain identical. Static assertions and comments are updated to match. No functional code changes.
Changed components
src/factorysetup.csrc/memory/memory_shared.hsrc/memory/memory_spi.csrc/rust/bitbox02-rust-c/src/lib.rsInspect captured patch +20 / −16
diff --git a/src/factorysetup.c b/src/factorysetup.c
index 0190e50..a0ade4a 100644
--- a/src/factorysetup.c
+++ b/src/factorysetup.c
@@ -1090,7 +1090,9 @@ static ble_error_code_t _setup_ble(void)
// Write FW
screen_print_debug("Writing BLE fw", 0);
if (!spi_mem_write(
- MEMORY_SPI_BLE_FIRMWARE_1_ADDR, da14531_firmware_start(), da14531_firmware_size())) {
+ BITBOX02_MEMORY_SPI_BLE_FIRMWARE_1_ADDR,
+ da14531_firmware_start(),
+ da14531_firmware_size())) {
screen_print_debug("Writing BLE fw failed", 0);
return BLE_ERR_FLASH_FW;
}
diff --git a/src/memory/memory_shared.h b/src/memory/memory_shared.h
index 44f6cae..14dbd3f 100644
--- a/src/memory/memory_shared.h
+++ b/src/memory/memory_shared.h
@@ -83,10 +83,10 @@ typedef union {
// Hash of the BLE firmware that is allowed to be loaded into the BLE chip.
uint8_t ble_allowed_firmware_hash[32];
// - 0xFF: uninitialized (should never happen after factorysetup)
- // - 0x00: active BLE firmware is at `MEMORY_SPI_BLE_FIRMWARE_1_ADDR` in the SPI memory
- // chip.
- // - 0x01: active BLE firmware is at `MEMORY_SPI_BLE_FIRMWARE_2_ADDR` in the SPI memory
- // chip.
+ // - 0x00: active BLE firmware is at `BITBOX02_MEMORY_SPI_BLE_FIRMWARE_1_ADDR` in the SPI
+ // memory chip.
+ // - 0x01: active BLE firmware is at `BITBOX02_MEMORY_SPI_BLE_FIRMWARE_2_ADDR` in the SPI
+ // memory chip.
uint8_t ble_active_index;
// Checksum of each of the two BLE stored firmwares.
//
diff --git a/src/memory/memory_spi.c b/src/memory/memory_spi.c
index f07e3a5..9d5cb7f 100644
--- a/src/memory/memory_spi.c
+++ b/src/memory/memory_spi.c
@@ -25,8 +25,8 @@ bool memory_spi_get_active_ble_firmware(
return false;
}
if (firmware_out != NULL) {
- uint32_t ble_addr = metadata.active_index == 0 ? MEMORY_SPI_BLE_FIRMWARE_1_ADDR
- : MEMORY_SPI_BLE_FIRMWARE_2_ADDR;
+ uint32_t ble_addr = metadata.active_index == 0 ? BITBOX02_MEMORY_SPI_BLE_FIRMWARE_1_ADDR
+ : BITBOX02_MEMORY_SPI_BLE_FIRMWARE_2_ADDR;
*firmware_out = spi_mem_read(ble_addr, size);
if (!*firmware_out) {
return false;
@@ -57,8 +57,8 @@ USE_RESULT bool memory_spi_get_active_ble_firmware_version(struct da14531_firmwa
return false;
}
- uint32_t ble_addr = metadata.active_index == 0 ? MEMORY_SPI_BLE_FIRMWARE_1_ADDR
- : MEMORY_SPI_BLE_FIRMWARE_2_ADDR;
+ uint32_t ble_addr = metadata.active_index == 0 ? BITBOX02_MEMORY_SPI_BLE_FIRMWARE_1_ADDR
+ : BITBOX02_MEMORY_SPI_BLE_FIRMWARE_2_ADDR;
uint8_t* firmware_bytes =
spi_mem_read(ble_addr + 0x110, sizeof(struct da14531_firmware_version));
ASSERT(firmware_bytes);
diff --git a/src/rust/bitbox02-rust-c/src/lib.rs b/src/rust/bitbox02-rust-c/src/lib.rs
index 0b4b9dc..0824dde 100644
--- a/src/rust/bitbox02-rust-c/src/lib.rs
+++ b/src/rust/bitbox02-rust-c/src/lib.rs
@@ -75,7 +75,7 @@ const _: [(); bitbox_hal::memory::MULTISIG_NAME_MAX_LEN + 1] =
// Keep these as numeric literals so cbindgen reliably exports them to C.
// The static asserts below enforce consistency with other Rust constants.
/// Erase sector size of SPI memory in bytes.
-const MEMORY_SPI_ERASE_GRANULARITY: u32 = 4096;
+const BITBOX02_MEMORY_SPI_ERASE_GRANULARITY: u32 = 4096;
// Keep this as a numeric literal so cbindgen reliably exports it to C.
// The static assert below enforces consistency with the Rust HAL constant.
/// Maximum size in bytes of a BLE firmware image.
@@ -83,21 +83,23 @@ pub const MEMORY_SPI_BLE_FIRMWARE_MAX_SIZE: u32 = 32 * 1024;
// Keep this as a numeric literal so cbindgen reliably exports it to C.
/// Start address of BLE firmware slot 1 in SPI memory. Cannot change this as it defines the memory
/// layout.
-pub const MEMORY_SPI_BLE_FIRMWARE_1_ADDR: u32 = 0x00;
+pub const BITBOX02_MEMORY_SPI_BLE_FIRMWARE_1_ADDR: u32 = 0x00;
/// Start address of BLE firmware slot 2 in SPI memory. Cannot change this as it defines the memory
/// layout.
-pub const MEMORY_SPI_BLE_FIRMWARE_2_ADDR: u32 = MEMORY_SPI_BLE_FIRMWARE_MAX_SIZE;
+pub const BITBOX02_MEMORY_SPI_BLE_FIRMWARE_2_ADDR: u32 = MEMORY_SPI_BLE_FIRMWARE_MAX_SIZE;
const _: [(); bitbox_hal::memory::BLE_FIRMWARE_MAX_SIZE] =
[(); MEMORY_SPI_BLE_FIRMWARE_MAX_SIZE as usize];
const _: [(); bitbox02::spi_mem::BLE_FIRMWARE_1_ADDR as usize] =
- [(); MEMORY_SPI_BLE_FIRMWARE_1_ADDR as usize];
+ [(); BITBOX02_MEMORY_SPI_BLE_FIRMWARE_1_ADDR as usize];
const _: [(); bitbox02::spi_mem::BLE_FIRMWARE_2_ADDR as usize] =
- [(); MEMORY_SPI_BLE_FIRMWARE_2_ADDR as usize];
+ [(); BITBOX02_MEMORY_SPI_BLE_FIRMWARE_2_ADDR as usize];
// Addresses must be aligned to an erase sector
-const _: [(); 0] = [(); (MEMORY_SPI_BLE_FIRMWARE_1_ADDR % MEMORY_SPI_ERASE_GRANULARITY) as usize];
-const _: [(); 0] = [(); (MEMORY_SPI_BLE_FIRMWARE_2_ADDR % MEMORY_SPI_ERASE_GRANULARITY) as usize];
+const _: [(); 0] = [(); (BITBOX02_MEMORY_SPI_BLE_FIRMWARE_1_ADDR
+ % BITBOX02_MEMORY_SPI_ERASE_GRANULARITY) as usize];
+const _: [(); 0] = [(); (BITBOX02_MEMORY_SPI_BLE_FIRMWARE_2_ADDR
+ % BITBOX02_MEMORY_SPI_ERASE_GRANULARITY) as usize];
// Whenever execution reaches somewhere it isn't supposed to rust code will "panic". Our panic
// handler will print the available information on the screen and over RTT. If we compile with
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.