Skip to content

Nickez/ble one version part #1445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
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
Binary file modified bitbox-da14531-firmware.o
Binary file not shown.
2 changes: 1 addition & 1 deletion src/bootloader/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ static bool _devdevice_enter(secbool_u32 firmware_verified)
bool res = memory_spi_get_active_ble_firmware_version(&version);
if (res) {
char buf[50];
snprintf(buf, sizeof(buf), "ble fw: %d.%d.%d", version.major, version.minor, version.patch);
snprintf(buf, sizeof(buf), "ble: %d (%s)", version.version, util_dbg_hex(version.hash, 4));
UG_PutString(0, SCREEN_HEIGHT - 18, buf, false);
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/factorysetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

// We commit to the BLE firmware hash here to avoid accidentally installing an unexpected firmware.
static const uint8_t _allowed_ble_fw_hash[32] =
"\x6d\x9e\x19\xe4\x94\x31\x0b\x73\x0b\xfe\x22\x8a\x4d\xdc\x50\x3b\xee\xd1\x5f\xa1\x28\xd2\xea"
"\x35\x44\x6f\xb8\xad\x35\x02\xac\x7a";
"\x18\xca\x5a\xcb\x3a\x60\x2f\x89\xb2\x65\x25\xdb\xff\x1c\x4f\x07\x60\x3d\x76\x70\xd2\xf5\x4e"
"\x7a\x76\xfb\x1f\x9c\x4b\x29\x66\x4f";

// 65 bytes uncompressed secp256k1 root attestation pubkey.
#define ROOT_PUBKEY_SIZE 65
Expand Down
6 changes: 0 additions & 6 deletions src/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ int main(void)
if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) {
da14531_protocol_init();
}

struct da14531_firmware_version version;
if (memory_spi_get_active_ble_firmware_version(&version)) {
util_log("%d.%d.%d", version.major, version.minor, version.patch);
util_log("hex %s", util_dbg_hex(version.hash, 20));
}
usb_processing_init();
firmware_main_loop();
return 0;
Expand Down
2 changes: 2 additions & 0 deletions src/memory/memory_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ USE_RESULT bool memory_spi_get_active_ble_firmware_version(struct da14531_firmwa
memcpy((uint8_t*)version, firmware, sizeof(struct da14531_firmware_version));
free(firmware);

ASSERT(version->version == 1);

if (version->version == 1) {
return true;
}
Expand Down
7 changes: 2 additions & 5 deletions src/memory/memory_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ USE_RESULT bool memory_spi_get_active_ble_firmware(

// This struct is always placed at 0x110 in the firmware
struct da14531_firmware_version {
uint8_t version; // The version of the format of this struct.
uint16_t major;
uint16_t minor;
uint16_t patch;
uint8_t metadata_version; // The version of the format of this struct.
uint16_t version; // The version of the firmware
uint8_t hash[20];
uint8_t modified;
} __attribute__((packed));

USE_RESULT bool memory_spi_get_active_ble_firmware_version(
Expand Down
2 changes: 1 addition & 1 deletion src/rust/bitbox02-rust/src/hww/api/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use alloc::vec::Vec;

use bitbox02::{memory, spi_mem};

const ALLOWED_HASH: &[u8; 32] = b"\x6d\x9e\x19\xe4\x94\x31\x0b\x73\x0b\xfe\x22\x8a\x4d\xdc\x50\x3b\xee\xd1\x5f\xa1\x28\xd2\xea\x35\x44\x6f\xb8\xad\x35\x02\xac\x7a";
const ALLOWED_HASH: &[u8; 32] = b"\x18\xca\x5a\xcb\x3a\x60\x2f\x89\xb2\x65\x25\xdb\xff\x1c\x4f\x07\x60\x3d\x76\x70\xd2\xf5\x4e\x7a\x76\xfb\x1f\x9c\x4b\x29\x66\x4f";

// We want to write FW to the memory chip in erase-size chunks, so that we don't repeatedly need to
// read-erase-write the same sector.
Expand Down
8 changes: 2 additions & 6 deletions src/rust/bitbox02/src/spi_mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ pub fn get_active_ble_firmware_version() -> Result<String, ()> {
true => {
let ble_fw_version = ble_fw_version.assume_init();
// Copy to avoid taking references to unaligned struct fields.
let (major, minor, patch) = (
ble_fw_version.major,
ble_fw_version.minor,
ble_fw_version.patch,
);
Ok(format!("{}.{}.{}", major, minor, patch))
let version = ble_fw_version.version;
Ok(format!("{}", version))
}
false => Err(()),
}
Expand Down