Skip to content

Commit a590e6f

Browse files
committed
ble: fewer version parts
1 parent e2561b9 commit a590e6f

File tree

7 files changed

+10
-15
lines changed

7 files changed

+10
-15
lines changed

bitbox-da14531-firmware.o

-4 Bytes
Binary file not shown.

src/bootloader/bootloader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ static bool _devdevice_enter(secbool_u32 firmware_verified)
956956
bool res = memory_spi_get_active_ble_firmware_version(&version);
957957
if (res) {
958958
char buf[50];
959-
snprintf(buf, sizeof(buf), "ble fw: %d.%d.%d", version.major, version.minor, version.patch);
959+
snprintf(buf, sizeof(buf), "ble: %d (%s)", version.version, util_dbg_hex(version.hash, 4));
960960
UG_PutString(0, SCREEN_HEIGHT - 18, buf, false);
961961
}
962962
#endif

src/factorysetup.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747

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

5353
// 65 bytes uncompressed secp256k1 root attestation pubkey.
5454
#define ROOT_PUBKEY_SIZE 65

src/memory/memory_spi.c

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ USE_RESULT bool memory_spi_get_active_ble_firmware_version(struct da14531_firmwa
7676
memcpy((uint8_t*)version, firmware, sizeof(struct da14531_firmware_version));
7777
free(firmware);
7878

79+
ASSERT(version->version == 1);
80+
7981
if (version->version == 1) {
8082
return true;
8183
}

src/memory/memory_spi.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ USE_RESULT bool memory_spi_get_active_ble_firmware(
5353

5454
// This struct is always placed at 0x110 in the firmware
5555
struct da14531_firmware_version {
56-
uint8_t version; // The version of the format of this struct.
57-
uint16_t major;
58-
uint16_t minor;
59-
uint16_t patch;
56+
uint8_t metadata_version; // The version of the format of this struct.
57+
uint16_t version; // The version of the firmware
6058
uint8_t hash[20];
61-
uint8_t modified;
6259
} __attribute__((packed));
6360

6461
USE_RESULT bool memory_spi_get_active_ble_firmware_version(

src/rust/bitbox02-rust/src/hww/api/bluetooth.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use alloc::vec::Vec;
2727

2828
use bitbox02::{memory, spi_mem};
2929

30-
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";
30+
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";
3131

3232
// We want to write FW to the memory chip in erase-size chunks, so that we don't repeatedly need to
3333
// read-erase-write the same sector.

src/rust/bitbox02/src/spi_mem.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ pub fn get_active_ble_firmware_version() -> Result<String, ()> {
3535
true => {
3636
let ble_fw_version = ble_fw_version.assume_init();
3737
// Copy to avoid taking references to unaligned struct fields.
38-
let (major, minor, patch) = (
39-
ble_fw_version.major,
40-
ble_fw_version.minor,
41-
ble_fw_version.patch,
42-
);
43-
Ok(format!("{}.{}.{}", major, minor, patch))
38+
let version = ble_fw_version.version;
39+
Ok(format!("{}", version))
4440
}
4541
false => Err(()),
4642
}

0 commit comments

Comments
 (0)