diff --git a/.ci/check-unwanted-symbols b/.ci/check-unwanted-symbols index 9af90725ba..e7c0d02b50 100755 --- a/.ci/check-unwanted-symbols +++ b/.ci/check-unwanted-symbols @@ -93,12 +93,11 @@ check_production_bootloader() { "Use the existing PUKCC SHA-256 implementation in production bootloaders instead." } -firmware_elf=build/bin/firmware.elf -if [[ -f "$firmware_elf" ]]; then +shopt -s nullglob +for firmware_elf in build/bin/firmware*.elf; do check_firmware "$firmware_elf" -fi +done -shopt -s nullglob for bootloader_elf in build/bin/*-bl-*-production.elf; do check_production_bootloader "$bootloader_elf" done diff --git a/.github/workflows/ci-common.yml b/.github/workflows/ci-common.yml index 8663c95a42..713ac40cc4 100644 --- a/.github/workflows/ci-common.yml +++ b/.github/workflows/ci-common.yml @@ -207,15 +207,17 @@ jobs: - bootloader-btc - bootloader-btc-development - bootloader-btc-production - - bootloader-plus - - bootloader-plus-development - - bootloader-plus-production - - bootloader-plus-debug - - bootloader-plus-btc - - bootloader-plus-btc-development - - bootloader-plus-btc-production + - bootloader-nova + - bootloader-nova-development + - bootloader-nova-production + - bootloader-nova-debug + - bootloader-nova-btc + - bootloader-nova-btc-development + - bootloader-nova-btc-production - firmware - firmware-btc + - firmware-nova + - firmware-nova-btc - factory-setup - firmware-debug - simulator @@ -242,7 +244,7 @@ jobs: run: make -j$(($(nproc)+1)) ${{ matrix.target }} - name: Check unwanted symbols - if: (matrix.target == 'firmware' || (startsWith(matrix.target, 'bootloader') && endsWith(matrix.target, 'production'))) && !cancelled() + if: ((matrix.target == 'firmware' || matrix.target == 'firmware-nova') || (startsWith(matrix.target, 'bootloader') && endsWith(matrix.target, 'production'))) && !cancelled() run: ./.ci/check-unwanted-symbols - name: Print hashes diff --git a/Makefile b/Makefile index 7a32c7c85e..d69145a7a1 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,10 @@ firmware: | build $(MAKE) -C build firmware.elf firmware-btc: | build $(MAKE) -C build firmware-btc.elf +firmware-nova: | build + $(MAKE) -C build firmware-nova.elf +firmware-nova-btc: | build + $(MAKE) -C build firmware-nova-btc.elf firmware-debug: | build-debug $(MAKE) -C build-debug firmware.elf @@ -70,20 +74,20 @@ bootloader-btc-development: | build bootloader-btc-production: | build $(MAKE) -C build bb02-bl-btconly-production.elf -bootloader-plus: | build +bootloader-nova: | build $(MAKE) -C build bb02p-bl-multi.elf -bootloader-plus-development: | build +bootloader-nova-development: | build $(MAKE) -C build bb02p-bl-multi-development.elf -bootloader-plus-production: | build +bootloader-nova-production: | build $(MAKE) -C build bb02p-bl-multi-production.elf -bootloader-plus-debug: | build-debug +bootloader-nova-debug: | build-debug $(MAKE) -C build-debug bb02p-bl-multi-development.elf -bootloader-plus-btc: | build +bootloader-nova-btc: | build $(MAKE) -C build bb02p-bl-btconly.elf -bootloader-plus-btc-development: | build +bootloader-nova-btc-development: | build $(MAKE) -C build bb02p-bl-btconly-development.elf -bootloader-plus-btc-production: | build +bootloader-nova-btc-production: | build $(MAKE) -C build bb02p-bl-btconly-production.elf factory-setup: | build @@ -125,9 +129,9 @@ flash-dev-firmware: ./py/load_firmware.py build/bin/firmware.bin --debug jlink-flash-bootloader-development: | build JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build/scripts/bb02-bl-multi-development.jlink -jlink-flash-bootloader-plus-development: | build +jlink-flash-bootloader-nova-development: | build JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build/scripts/bb02p-bl-multi-development.jlink -jlink-flash-bootloader-btc-plus-development: | build +jlink-flash-bootloader-btc-nova-development: | build JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build/scripts/bb02p-bl-btconly-development.jlink jlink-flash-bootloader-development-locked: | build JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build/scripts/bb02-bl-multi-development-locked.jlink @@ -153,8 +157,8 @@ jlink-flash-reset-version: JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./scripts/reset-version.jlink jlink-flash-set-securechip-optiga: JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./scripts/set-securechip-optiga.jlink -jlink-flash-set-bb02plus: - JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./scripts/set-bb02plus.jlink +jlink-flash-set-bb02nova: + JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./scripts/set-bb02nova.jlink jlink-flash-bb02-set-factory-randomness: JLinkExe -NoGui 1 -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./scripts/bb02-set-factory-randomness.jlink jlink-erase-firmware-quick: diff --git a/releases/describe_signed_firmware.py b/releases/describe_signed_firmware.py index e024992d8d..0ba6547efd 100755 --- a/releases/describe_signed_firmware.py +++ b/releases/describe_signed_firmware.py @@ -14,8 +14,8 @@ MAGIC_LEN = 4 MAGIC_MULTI = struct.pack(">I", 0x653F362B) MAGIC_BTCONLY = struct.pack(">I", 0x11233B0B) -MAGIC_BITBOX02PLUS_MULTI = struct.pack(">I", 0x5B648CEB) -MAGIC_BITBOX02PLUS_BTCONLY = struct.pack(">I", 0x48714774) +MAGIC_BITBOX02NOVA_MULTI = struct.pack(">I", 0x5B648CEB) +MAGIC_BITBOX02NOVA_BTCONLY = struct.pack(">I", 0x48714774) MAX_FIRMWARE_SIZE = 884736 NUM_ROOT_KEYS = 3 @@ -49,9 +49,9 @@ def main() -> int: print("This is a BitBox02 Multi firmware.") elif magic == MAGIC_BTCONLY: print("This is a BitBox02 Bitcoin-only firmware.") - elif magic == MAGIC_BITBOX02PLUS_MULTI: + elif magic == MAGIC_BITBOX02NOVA_MULTI: print("This is a BitBox02 Nova Multi firmware") - elif magic == MAGIC_BITBOX02PLUS_BTCONLY: + elif magic == MAGIC_BITBOX02NOVA_BTCONLY: print("This is a BitBox02 Nova Bitcoin-only firmware.") else: print( diff --git a/scripts/set-bb02plus.jlink b/scripts/set-bb02nova.jlink similarity index 100% rename from scripts/set-bb02plus.jlink rename to scripts/set-bb02nova.jlink diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index deb4e45a54..d53dfdc428 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,14 +120,14 @@ set(QTOUCH-SOURCES ) set(QTOUCH-SOURCES ${QTOUCH-SOURCES} PARENT_SCOPE) -# The additional files required for the plus platform -set(PLATFORM-BITBOX02-PLUS-SOURCES +# The additional files required for the Nova platform +set(PLATFORM-BITBOX02-NOVA-SOURCES ${CMAKE_SOURCE_DIR}/src/da14531/da14531.c ${CMAKE_SOURCE_DIR}/src/da14531/da14531_protocol.c ${CMAKE_SOURCE_DIR}/src/da14531/da14531_handler.c ${CMAKE_SOURCE_DIR}/src/uart.c ) -set(PLATFORM-BITBOX02-PLUS-SOURCES ${PLATFORM-BITBOX02-PLUS-SOURCES} PARENT_SCOPE) +set(PLATFORM-BITBOX02-NOVA-SOURCES ${PLATFORM-BITBOX02-NOVA-SOURCES} PARENT_SCOPE) set(PLATFORM-BITBOX02-SOURCES ${CMAKE_SOURCE_DIR}/src/sd_mmc/sd_mmc_start.c @@ -192,7 +192,7 @@ set(FIRMWARE-SOURCES ${DRIVER-SOURCES} ${QTOUCH-SOURCES} ${SECURECHIP-SOURCES} - ${PLATFORM-BITBOX02-PLUS-SOURCES} + ${PLATFORM-BITBOX02-NOVA-SOURCES} ${CMAKE_SOURCE_DIR}/src/common_main.c ) @@ -292,7 +292,7 @@ set(BOOTLOADERS-BITBOX02 bb02-bl-btconly-development # Runs signed/unsigned firmware and has bootloader menu bb02-bl-btconly-production # Runs signed (btc-only keys) firmware and bootloader is locked ) -set(BOOTLOADERS-BITBOX02PLUS +set(BOOTLOADERS-BITBOX02NOVA bb02p-bl-multi # Runs signed firmware bb02p-bl-multi-development # Runs signed/unsigned firmware and has bootloader menu bb02p-bl-multi-development-locked # Runs signed/unsigned firmware, has bootloader menu and bootloader is locked @@ -303,7 +303,7 @@ set(BOOTLOADERS-BITBOX02PLUS ) set(BOOTLOADERS ${BOOTLOADERS-BITBOX02} - ${BOOTLOADERS-BITBOX02PLUS} + ${BOOTLOADERS-BITBOX02NOVA} ) set(BOOTLOADERS ${BOOTLOADERS} PARENT_SCOPE) @@ -317,6 +317,8 @@ set(DEVDEVICE-BOOTLOADERS set(FIRMWARES firmware # Firmware MULTI firmware-btc # Firmware BTC-ONLY + firmware-nova # Firmware NOVA MULTI + firmware-nova-btc # Firmware NOVA BTC-ONLY factory-setup # Factory-setup ) set(FIRMWARES ${FIRMWARES} PARENT_SCOPE) @@ -438,15 +440,15 @@ if(CMAKE_CROSSCOMPILING) target_link_libraries(${elf} PRIVATE -Wl,--print-memory-usage) endforeach(bootloader) - foreach(bootloader ${DEVDEVICE-BOOTLOADERS} ${BOOTLOADERS-BITBOX02PLUS}) + foreach(bootloader ${DEVDEVICE-BOOTLOADERS} ${BOOTLOADERS-BITBOX02NOVA}) set(elf ${bootloader}.elf) target_link_libraries(${elf} PRIVATE ${QTOUCHLIB_A} ${QTOUCHLIB_B} ${QTOUCHLIB_T}) target_sources(${elf} PRIVATE ${QTOUCH-SOURCES}) endforeach(bootloader) - foreach(bootloader ${BOOTLOADERS-BITBOX02PLUS}) + foreach(bootloader ${BOOTLOADERS-BITBOX02NOVA}) set(elf ${bootloader}.elf) - target_sources(${elf} PRIVATE ${PLATFORM-BITBOX02-PLUS-SOURCES}) + target_sources(${elf} PRIVATE ${PLATFORM-BITBOX02-NOVA-SOURCES}) target_link_libraries(${bootloader}.elf PRIVATE embedded-swd) endforeach(bootloader) @@ -466,20 +468,20 @@ if(CMAKE_CROSSCOMPILING) target_compile_definitions(bb02-bl-btconly-production.elf PRIVATE PRODUCT_BITBOX_BTCONLY BOOTLOADER_PRODUCTION) set_property(TARGET bb02-bl-btconly-production.elf PROPERTY EXCLUDE_FROM_ALL ON) - # BB02PLUS definitions + # BB02NOVA definitions - target_compile_definitions(bb02p-bl-multi.elf PRIVATE PRODUCT_BITBOX_PLUS_MULTI) - target_compile_definitions(bb02p-bl-multi-development.elf PRIVATE PRODUCT_BITBOX_PLUS_MULTI BOOTLOADER_DEVDEVICE) - target_compile_definitions(bb02p-bl-multi-development-locked.elf PRIVATE PRODUCT_BITBOX_PLUS_MULTI BOOTLOADER_DEVDEVICE BOOTLOADER_PRODUCTION) + target_compile_definitions(bb02p-bl-multi.elf PRIVATE PRODUCT_BITBOX_NOVA_MULTI) + target_compile_definitions(bb02p-bl-multi-development.elf PRIVATE PRODUCT_BITBOX_NOVA_MULTI BOOTLOADER_DEVDEVICE) + target_compile_definitions(bb02p-bl-multi-development-locked.elf PRIVATE PRODUCT_BITBOX_NOVA_MULTI BOOTLOADER_DEVDEVICE BOOTLOADER_PRODUCTION) set_property(TARGET bb02p-bl-multi-development-locked.elf PROPERTY EXCLUDE_FROM_ALL ON) - target_compile_definitions(bb02p-bl-multi-production.elf PRIVATE PRODUCT_BITBOX_PLUS_MULTI BOOTLOADER_PRODUCTION) + target_compile_definitions(bb02p-bl-multi-production.elf PRIVATE PRODUCT_BITBOX_NOVA_MULTI BOOTLOADER_PRODUCTION) set_property(TARGET bb02p-bl-multi-production.elf PROPERTY EXCLUDE_FROM_ALL ON) - target_compile_definitions(bb02p-bl-btconly.elf PRIVATE PRODUCT_BITBOX_PLUS_BTCONLY) - target_compile_definitions(bb02p-bl-btconly-development.elf PRIVATE PRODUCT_BITBOX_PLUS_BTCONLY BOOTLOADER_DEVDEVICE) - target_compile_definitions(bb02p-bl-btconly-production.elf PRIVATE PRODUCT_BITBOX_PLUS_BTCONLY BOOTLOADER_PRODUCTION) + target_compile_definitions(bb02p-bl-btconly.elf PRIVATE PRODUCT_BITBOX_NOVA_BTCONLY) + target_compile_definitions(bb02p-bl-btconly-development.elf PRIVATE PRODUCT_BITBOX_NOVA_BTCONLY BOOTLOADER_DEVDEVICE) + target_compile_definitions(bb02p-bl-btconly-production.elf PRIVATE PRODUCT_BITBOX_NOVA_BTCONLY BOOTLOADER_PRODUCTION) set_property(TARGET bb02p-bl-btconly-production.elf PROPERTY EXCLUDE_FROM_ALL ON) foreach(firmware ${FIRMWARES}) @@ -535,6 +537,14 @@ if(CMAKE_CROSSCOMPILING) target_compile_definitions(firmware-btc.elf PRIVATE PRODUCT_BITBOX_BTCONLY "APP_U2F=0") target_sources(firmware-btc.elf PRIVATE ${PLATFORM-BITBOX02-SOURCES}) + target_sources(firmware-nova.elf PRIVATE firmware.c) + target_compile_definitions(firmware-nova.elf PRIVATE PRODUCT_BITBOX_NOVA_MULTI "APP_U2F=1") + target_sources(firmware-nova.elf PRIVATE ${FIRMWARE-U2F-SOURCES} ${FIRMWARE-U2F-DRIVER-SOURCES} ${PLATFORM-BITBOX02-SOURCES}) + + target_sources(firmware-nova-btc.elf PRIVATE firmware.c) + target_compile_definitions(firmware-nova-btc.elf PRIVATE PRODUCT_BITBOX_NOVA_BTCONLY "APP_U2F=0") + target_sources(firmware-nova-btc.elf PRIVATE ${PLATFORM-BITBOX02-SOURCES}) + target_sources(factory-setup.elf PRIVATE factorysetup.c) target_compile_definitions(factory-setup.elf PRIVATE PRODUCT_BITBOX02_FACTORYSETUP "APP_U2F=0") target_sources(factory-setup.elf PRIVATE ${PLATFORM-BITBOX02-SOURCES}) diff --git a/src/bootloader/bootloader.c b/src/bootloader/bootloader.c index 3ebbd7b348..50997610a4 100644 --- a/src/bootloader/bootloader.c +++ b/src/bootloader/bootloader.c @@ -26,12 +26,12 @@ #include #include -#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02PLUS == 1 +#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02NOVA == 1 #include #include #endif -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 #include #include #include @@ -133,7 +133,7 @@ static const uint8_t _empty_bare_flash_hash[SHA256_DIGEST_LENGTH] = { #error "FLASH_APP_LEN changed; recompute _empty_bare_flash_hash" #endif -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 extern struct RustByteQueue* uart_write_queue; #endif @@ -180,7 +180,7 @@ static const uint8_t _root_pubkeys[BOOT_NUM_ROOT_SIGNING_KEYS][BOOT_PUBKEY_LEN] 0xf0, 0xca, 0xde, 0x45, 0xd6, 0x1c, 0x51, 0x4d, 0x86, 0x09, 0xfc, 0xa7, 0x64, 0x1c, 0x9e, 0xe2, } }; -#elif PRODUCT_BITBOX_PLUS_BTCONLY == 1 +#elif PRODUCT_BITBOX_NOVA_BTCONLY == 1 static const uint8_t _root_pubkeys[BOOT_NUM_ROOT_SIGNING_KEYS][BOOT_PUBKEY_LEN] = { // order is important { 0x42, 0xeb, 0x2f, 0xfa, 0x68, 0xd8, 0xc4, 0x62, 0x5a, 0x01, 0x2b, 0x46, 0x7f, 0x04, 0x4a, 0xfc, @@ -201,7 +201,7 @@ static const uint8_t _root_pubkeys[BOOT_NUM_ROOT_SIGNING_KEYS][BOOT_PUBKEY_LEN] 0x1d, 0xc3, 0xd6, 0x6b, 0xc5, 0x51, 0x54, 0x67, 0xba, 0xb1, 0xc1, 0xcb, 0x24, 0x48, 0xa8, 0x7a, } }; -#elif PRODUCT_BITBOX_PLUS_MULTI == 1 +#elif PRODUCT_BITBOX_NOVA_MULTI == 1 static const uint8_t _root_pubkeys[BOOT_NUM_ROOT_SIGNING_KEYS][BOOT_PUBKEY_LEN] = { // order is important { 0x5e, 0x1b, 0x09, 0x1c, 0x8f, 0x71, 0x15, 0xaf, 0xd3, 0x3c, 0x0b, 0x72, 0xe4, 0x4b, 0x3e, 0xd0, @@ -324,7 +324,7 @@ void bootloader_render_default_screen(void) { UG_ClearBuffer(); _load_logo(); -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 UG_PutString(0, SCREEN_HEIGHT - 9 * 2 - 5, "See the BitBoxApp"); if (rust_communication_mode_ble_enabled() && da14531_connected_state < DA14531_CONNECTED_CONNECTED_SECURED) { @@ -343,7 +343,7 @@ void bootloader_render_default_screen(void) UG_SendBuffer(); } -#if PLATFORM_BITBOX02PLUS +#if PLATFORM_BITBOX02NOVA extern bool bootloader_pairing_request; extern uint8_t bootloader_pairing_code_bytes[4]; @@ -878,7 +878,7 @@ static size_t _api_command(const uint8_t* input, uint8_t* output, const size_t m break; case OP_REBOOT: { -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 rust_da14531_set_product(rust_util_bytes(NULL, 0), uart_write_queue); // Send it now, because we are about to reset ourselves while (rust_bytequeue_num(uart_write_queue)) { @@ -1003,7 +1003,7 @@ static bool _devdevice_enter(secbool_u32 firmware_verified) } else { UG_PutString(0, SCREEN_HEIGHT - 9, " No firmware found"); } - #if PLATFORM_BITBOX02PLUS == 1 + #if PLATFORM_BITBOX02NOVA == 1 struct da14531_firmware_version version; bool res = memory_spi_get_active_ble_firmware_version(&version); if (res) { diff --git a/src/bootloader/bootloader.h b/src/bootloader/bootloader.h index d633ca9aa8..a5319f2d4a 100644 --- a/src/bootloader/bootloader.h +++ b/src/bootloader/bootloader.h @@ -13,7 +13,7 @@ void bootloader_jump(void); */ void bootloader_render_default_screen(void); -#if PLATFORM_BITBOX02PLUS +#if PLATFORM_BITBOX02NOVA /** * Renders a BLE pairing confirmations screen. Use the `confirmed` argument to display the * "user has confirmed on bitbox" version. diff --git a/src/bootloader/startup.c b/src/bootloader/startup.c index 7b306d43eb..efc556bff0 100644 --- a/src/bootloader/startup.c +++ b/src/bootloader/startup.c @@ -14,11 +14,11 @@ #include #include -#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02PLUS == 1 +#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02NOVA == 1 #include #endif -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 #include #include #include @@ -26,14 +26,14 @@ #include #include - #if PRODUCT_BITBOX_PLUS_MULTI == 1 + #if PRODUCT_BITBOX_NOVA_MULTI == 1 #define DEVICE_MODE "{\"p\":\"bb02p-bl-multi\",\"v\":\"" BOOTLOADER_VERSION "\"}" - #elif PRODUCT_BITBOX_PLUS_BTCONLY == 1 + #elif PRODUCT_BITBOX_NOVA_BTCONLY == 1 #define DEVICE_MODE "{\"p\":\"bb02p-bl-btconly\",\"v\":\"" BOOTLOADER_VERSION "\"}" #else #error "unknown product" #endif -#endif // PLATFORM_BITBOX02PLUS == 1 +#endif // PLATFORM_BITBOX02NOVA == 1 extern void __attribute__((noreturn)) __stack_chk_fail(void); void __attribute__((noreturn)) __stack_chk_fail(void) @@ -45,7 +45,7 @@ void __attribute__((noreturn)) __stack_chk_fail(void) uint32_t __stack_chk_guard = 0; -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 extern volatile bool measurement_done_touch; int bootloader_pairing_request = false; uint8_t bootloader_pairing_code_bytes[4] = {0}; @@ -69,7 +69,7 @@ int main(void) platform_init(); __stack_chk_guard = rand_sync_read32(&RAND_0); screen_init(oled_set_pixel, oled_mirror, oled_clear_buffer); -#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02PLUS == 1 +#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02NOVA == 1 qtouch_init(); #endif bootloader_jump(); @@ -79,7 +79,7 @@ int main(void) uint8_t hww_data_buf[USB_REPORT_SIZE] = {0}; USB_FRAME hww_frame = {0}; -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 uint8_t uart_read_buf[USART_0_BUFFER_SIZE] = {0}; uint16_t uart_read_buf_len = 0; @@ -117,7 +117,7 @@ int main(void) while (1) { // Do UART I/O -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 if (rust_communication_mode_ble_enabled()) { if (uart_read_buf_len < sizeof(uart_read_buf) || rust_bytequeue_num(uart_write_queue) > 0) { @@ -134,7 +134,7 @@ int main(void) } if (!hww_data && hid_hww_read((uint8_t*)&hww_frame)) { usb_packet_process(&hww_frame); -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 if (rust_communication_mode_ble_enabled()) { // Enqueue a power down command to the da14531 rust_da14531_power_down(uart_write_queue); @@ -147,7 +147,7 @@ int main(void) } #endif } -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 if (rust_communication_mode_ble_enabled()) { struct da14531_protocol_frame* frame = da14531_protocol_poll( &uart_read_buf[0], &uart_read_buf_len, &hww_data, uart_write_queue); @@ -159,7 +159,7 @@ int main(void) } #endif -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 if (!rust_communication_mode_ble_enabled()) { #endif if (hww_data) { @@ -167,12 +167,12 @@ int main(void) hww_data = NULL; } } -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 } #endif usb_processing_process(usb_processing_hww()); -#if PLATFORM_BITBOX02PLUS == 1 +#if PLATFORM_BITBOX02NOVA == 1 qtouch_process(); if (bootloader_pairing_request) { if (!measurement_done_touch) { diff --git a/src/factorysetup.c b/src/factorysetup.c index be591eb6f5..ae79556eeb 100644 --- a/src/factorysetup.c +++ b/src/factorysetup.c @@ -1002,7 +1002,7 @@ static void _api_msg(const uint8_t* input, size_t in_len, uint8_t* output, size_ _reset_mcu(); break; case OP_BLE_RESULT: - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { output[2] = _ble_result; out_len++; } else { @@ -1172,7 +1172,7 @@ int main(void) } } - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { _ble_result = _setup_ble(); } diff --git a/src/firmware.c b/src/firmware.c index 3d251d0825..71557871fb 100644 --- a/src/firmware.c +++ b/src/firmware.c @@ -36,7 +36,7 @@ int main(void) qtouch_init(); common_main(); bitbox02_smarteeprom_init(); - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { da14531_protocol_init(); } rust_main_loop(); diff --git a/src/hww.c b/src/hww.c index c85046c928..2340583b7b 100644 --- a/src/hww.c +++ b/src/hww.c @@ -48,9 +48,9 @@ typedef struct { * 1 byte: platform code: * - 0x00 - BitBox02 * - 0x01 - BitBoxBase (deprecated) - * - 0x02 - BitBox02Plus + * - 0x02 - BitBox02Nova * 1 byte: edition code: - * - For the BitBox02 and BitBox02Plus edition: + * - For the BitBox02 and BitBox02Nova edition: * - - 0x00 - Multi * - - 0x01 - Bitcoin-only * - For the BitBoxBase platform (deprecated): @@ -75,7 +75,7 @@ static size_t _api_info(uint8_t* buf) // 1 byte platform code switch (memory_get_platform()) { - case MEMORY_PLATFORM_BITBOX02_PLUS: + case MEMORY_PLATFORM_BITBOX02_NOVA: *current = 0x02; break; default: @@ -85,9 +85,10 @@ static size_t _api_info(uint8_t* buf) current++; // 1 byte edition code -#if PRODUCT_BITBOX_MULTI == 1 || PRODUCT_BITBOX02_FACTORYSETUP == 1 +#if (PRODUCT_BITBOX_MULTI == 1) || (PRODUCT_BITBOX_NOVA_MULTI == 1) || \ + (PRODUCT_BITBOX02_FACTORYSETUP == 1) *current = 0x00; -#elif PRODUCT_BITBOX_BTCONLY == 1 +#elif (PRODUCT_BITBOX_BTCONLY == 1) || (PRODUCT_BITBOX_NOVA_BTCONLY == 1) *current = 0x01; #endif current++; diff --git a/src/memory/memory.c b/src/memory/memory.c index da4ddb7f8a..4ffa9e613e 100644 --- a/src/memory/memory.c +++ b/src/memory/memory.c @@ -263,7 +263,7 @@ void memory_get_device_name(char* name_out) _read_chunk(CHUNK_1, chunk_bytes); if (chunk.fields.device_name[0] == 0xFF || !rust_util_is_name_valid(chunk.fields.device_name, MEMORY_DEVICE_MAX_LEN_WITH_NULL)) { - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { // For Bluetooth, we want to use an unambiguous default name so this BitBox can be // identified if multiple BitBoxes are advertising at the same time. memory_random_name(name_out); @@ -383,7 +383,7 @@ bool memory_reset_hww(void) bool res = _write_chunk(CHUNK_1, chunk.bytes); // Reset bond-db and reinitialize IRK and identity address - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { uint8_t random_bytes[32]; _interface_functions->random_32_bytes(&random_bytes[0]); chunk_shared_t chunk_shared = {0}; diff --git a/src/memory/memory_shared.c b/src/memory/memory_shared.c index cc92c08b69..2b0f055ddf 100644 --- a/src/memory/memory_shared.c +++ b/src/memory/memory_shared.c @@ -132,7 +132,7 @@ uint8_t memory_get_platform(void) uint8_t platform = chunk.fields.platform; util_zero(&chunk, sizeof(chunk)); switch (platform) { - case MEMORY_PLATFORM_BITBOX02_PLUS: + case MEMORY_PLATFORM_BITBOX02_NOVA: return platform; default: return MEMORY_PLATFORM_BITBOX02; diff --git a/src/memory/memory_shared.h b/src/memory/memory_shared.h index 14dbd3fb37..a3c628d92d 100644 --- a/src/memory/memory_shared.h +++ b/src/memory/memory_shared.h @@ -127,7 +127,7 @@ USE_RESULT uint8_t memory_get_screen_type(void); USE_RESULT uint8_t memory_get_securechip_type(void); #define MEMORY_PLATFORM_BITBOX02 0xFF -#define MEMORY_PLATFORM_BITBOX02_PLUS 0x01 +#define MEMORY_PLATFORM_BITBOX02_NOVA 0x01 USE_RESULT uint8_t memory_get_platform(void); // data must be at least MEMORY_BLE_BOND_DB_LEN long diff --git a/src/platform/driver_init.c b/src/platform/driver_init.c index b7af34a83e..89c495895a 100644 --- a/src/platform/driver_init.c +++ b/src/platform/driver_init.c @@ -368,7 +368,7 @@ void system_init(void) // USB _usb_init(); - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { // External MX25 flash memory _spi_mem_init(); // DA14531 @@ -383,7 +383,7 @@ void bootloader_init(void) _oled_set_pins(); _ptc_clock_init(); -#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02PLUS == 1 +#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02NOVA == 1 // Only needed for qtouch, which is only needed in the devdevice bootloader. _timer_peripheral_init(); #endif @@ -401,7 +401,7 @@ void bootloader_init(void) // USB _usb_init(); - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { // External MX25 flash memory _spi_mem_init(); // DA14531 diff --git a/src/platform/platform_config.h b/src/platform/platform_config.h index b3de453106..40e025ba1d 100644 --- a/src/platform/platform_config.h +++ b/src/platform/platform_config.h @@ -17,15 +17,15 @@ #error "invalid product value" #endif -#if !defined(PRODUCT_BITBOX_PLUS_MULTI) - #define PRODUCT_BITBOX_PLUS_MULTI 0 -#elif PRODUCT_BITBOX_PLUS_MULTI != 1 +#if !defined(PRODUCT_BITBOX_NOVA_MULTI) + #define PRODUCT_BITBOX_NOVA_MULTI 0 +#elif PRODUCT_BITBOX_NOVA_MULTI != 1 #error "invalid product value" #endif -#if !defined(PRODUCT_BITBOX_PLUS_BTCONLY) - #define PRODUCT_BITBOX_PLUS_BTCONLY 0 -#elif PRODUCT_BITBOX_PLUS_BTCONLY != 1 +#if !defined(PRODUCT_BITBOX_NOVA_BTCONLY) + #define PRODUCT_BITBOX_NOVA_BTCONLY 0 +#elif PRODUCT_BITBOX_NOVA_BTCONLY != 1 #error "invalid product value" #endif @@ -38,31 +38,31 @@ // Derive other useful definitions from the product. #if PRODUCT_BITBOX_MULTI == 1 - #define PLATFORM_BITBOX02PLUS 0 + #define PLATFORM_BITBOX02NOVA 0 #define PLATFORM_BITBOX02 1 #define FACTORYSETUP 0 #endif #if PRODUCT_BITBOX_BTCONLY == 1 - #define PLATFORM_BITBOX02PLUS 0 + #define PLATFORM_BITBOX02NOVA 0 #define PLATFORM_BITBOX02 1 #define FACTORYSETUP 0 #endif -#if PRODUCT_BITBOX_PLUS_MULTI == 1 - #define PLATFORM_BITBOX02PLUS 1 +#if PRODUCT_BITBOX_NOVA_MULTI == 1 + #define PLATFORM_BITBOX02NOVA 1 #define PLATFORM_BITBOX02 0 #define FACTORYSETUP 0 #endif -#if PRODUCT_BITBOX_PLUS_BTCONLY == 1 - #define PLATFORM_BITBOX02PLUS 1 +#if PRODUCT_BITBOX_NOVA_BTCONLY == 1 + #define PLATFORM_BITBOX02NOVA 1 #define PLATFORM_BITBOX02 0 #define FACTORYSETUP 0 #endif #if PRODUCT_BITBOX02_FACTORYSETUP == 1 - #define PLATFORM_BITBOX02PLUS 0 + #define PLATFORM_BITBOX02NOVA 0 #define PLATFORM_BITBOX02 1 #define FACTORYSETUP 1 #endif diff --git a/src/platform/platform_init.c b/src/platform/platform_init.c index f1aeafcf8f..86c85a8974 100644 --- a/src/platform/platform_init.c +++ b/src/platform/platform_init.c @@ -28,7 +28,7 @@ void platform_init(void) { oled_init(); #if !(defined(BOOTLOADER) && PLATFORM_BITBOX02 == 1) - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { uart_init(); } #endif @@ -38,27 +38,24 @@ void platform_init(void) #if !defined(BOOTLOADER) sd_mmc_start(); #endif - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { spi_mem_protected_area_lock(); } } -#if !(defined(BOOTLOADER) && PLATFORM_BITBOX02PLUS == 0) +#if !(defined(BOOTLOADER) && PLATFORM_BITBOX02NOVA == 0) #if defined(BOOTLOADER) - #if PRODUCT_BITBOX_PLUS_MULTI == 1 + #if PRODUCT_BITBOX_NOVA_MULTI == 1 #define DEVICE_MODE "{\"p\":\"bb02p-bl-multi\",\"v\":\"" BOOTLOADER_VERSION "\"}" - #elif PRODUCT_BITBOX_PLUS_BTCONLY == 1 + #elif PRODUCT_BITBOX_NOVA_BTCONLY == 1 #define DEVICE_MODE "{\"p\":\"bb02p-bl-btconly\",\"v\":\"" BOOTLOADER_VERSION "\"}" #else #error "unknown product" #endif #else - // Currently we have one firmware for both BB02 and BB02_PLUS, and only the - // PRODUCT_BITBOX_MULTI/BTCONLY definitions apply. The PRODUCT_BITBOX_PLUS_MULTI/BTCONLY - // defs currently only apply in the bootloader, which we don't need here. - #if PRODUCT_BITBOX_MULTI == 1 + #if (PRODUCT_BITBOX_MULTI == 1) || (PRODUCT_BITBOX_NOVA_MULTI == 1) #define PRODUCT_STRING_SUFFIX "multi" - #elif PRODUCT_BITBOX_BTCONLY == 1 + #elif (PRODUCT_BITBOX_BTCONLY == 1) || (PRODUCT_BITBOX_NOVA_BTCONLY == 1) #define PRODUCT_STRING_SUFFIX "btconly" #elif PRODUCT_BITBOX02_FACTORYSETUP == 1 // Dummy, not actually needed, but this file is currently needlessly compiled for diff --git a/src/platform/platform_init.h b/src/platform/platform_init.h index 7fdfdb5bd5..9eee925e37 100644 --- a/src/platform/platform_init.h +++ b/src/platform/platform_init.h @@ -6,7 +6,7 @@ #include void platform_init(void); -#if !(defined(BOOTLOADER) && PLATFORM_BITBOX02PLUS == 0) +#if !(defined(BOOTLOADER) && PLATFORM_BITBOX02NOVA == 0) // Returns a json string representing the firmware type and version const char* platform_product(size_t* len); #endif diff --git a/src/rust/bitbox-hal/src/memory.rs b/src/rust/bitbox-hal/src/memory.rs index e66ee6fedd..9f4d7142a3 100644 --- a/src/rust/bitbox-hal/src/memory.rs +++ b/src/rust/bitbox-hal/src/memory.rs @@ -32,7 +32,7 @@ pub enum SecurechipType { #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Platform { BitBox02, - BitBox02Plus, + BitBox02Nova, BitBox03, } diff --git a/src/rust/bitbox02-rust-c/Cargo.toml b/src/rust/bitbox02-rust-c/Cargo.toml index 16491f7863..8ee1bdf940 100644 --- a/src/rust/bitbox02-rust-c/Cargo.toml +++ b/src/rust/bitbox02-rust-c/Cargo.toml @@ -37,15 +37,17 @@ target-bb02-bl-multi-production = ["bootloader", "platform-bitbox02"] target-bb02-bl-btconly = ["bootloader", "platform-bitbox02"] target-bb02-bl-btconly-development = ["bootloader", "platform-bitbox02"] target-bb02-bl-btconly-production = ["bootloader", "platform-bitbox02"] -target-bb02p-bl-multi = ["bootloader", "platform-bitbox02plus"] -target-bb02p-bl-multi-development = ["bootloader", "platform-bitbox02plus"] -target-bb02p-bl-multi-development-locked = ["bootloader", "platform-bitbox02plus"] -target-bb02p-bl-multi-production = ["bootloader", "platform-bitbox02plus"] -target-bb02p-bl-btconly = ["bootloader", "platform-bitbox02plus"] -target-bb02p-bl-btconly-development = ["bootloader", "platform-bitbox02plus"] -target-bb02p-bl-btconly-production = ["bootloader", "platform-bitbox02plus"] +target-bb02p-bl-multi = ["bootloader", "platform-bitbox02nova"] +target-bb02p-bl-multi-development = ["bootloader", "platform-bitbox02nova"] +target-bb02p-bl-multi-development-locked = ["bootloader", "platform-bitbox02nova"] +target-bb02p-bl-multi-production = ["bootloader", "platform-bitbox02nova"] +target-bb02p-bl-btconly = ["bootloader", "platform-bitbox02nova"] +target-bb02p-bl-btconly-development = ["bootloader", "platform-bitbox02nova"] +target-bb02p-bl-btconly-production = ["bootloader", "platform-bitbox02nova"] target-firmware = ["firmware", "platform-bitbox02", "app-bitcoin", "app-litecoin", "app-ethereum", "app-u2f", "app-cardano"] target-firmware-btc = ["firmware", "platform-bitbox02", "app-bitcoin"] +target-firmware-nova = ["firmware", "platform-bitbox02", "app-bitcoin", "app-litecoin", "app-ethereum", "app-u2f", "app-cardano"] +target-firmware-nova-btc = ["firmware", "platform-bitbox02", "app-bitcoin"] target-factory-setup = [ # enable these features "factory-setup", @@ -65,7 +67,7 @@ target-c-unit-tests = [ ] platform-bitbox02 = [] -platform-bitbox02plus = ["util/sha2", "bitbox-noise", "bitbox02-rust"] +platform-bitbox02nova = ["util/sha2", "bitbox-noise", "bitbox02-rust"] bootloader = [] firmware = [ diff --git a/src/rust/bitbox02-rust-c/src/lib.rs b/src/rust/bitbox02-rust-c/src/lib.rs index 88aebbd10c..9a4a728998 100644 --- a/src/rust/bitbox02-rust-c/src/lib.rs +++ b/src/rust/bitbox02-rust-c/src/lib.rs @@ -14,7 +14,7 @@ extern crate alloc; pub mod async_usb; #[cfg(any( feature = "firmware", - all(feature = "bootloader", feature = "platform-bitbox02plus") + all(feature = "bootloader", feature = "platform-bitbox02nova") ))] mod communication_mode; #[cfg(feature = "firmware")] @@ -40,7 +40,7 @@ extern crate bitbox_aes; // Enable for firmware and for Nova bootloader (BitBox02 bootloader currently does not need it). #[cfg(any( feature = "firmware", - all(feature = "bootloader", feature = "platform-bitbox02plus") + all(feature = "bootloader", feature = "platform-bitbox02nova") ))] extern crate bitbox02_rust; @@ -61,7 +61,7 @@ extern crate util; #[allow(unused)] #[cfg(any( feature = "firmware", - all(feature = "bootloader", feature = "platform-bitbox02plus") + all(feature = "bootloader", feature = "platform-bitbox02nova") ))] type HalImpl = bitbox02::hal::BitBox02Hal; diff --git a/src/rust/bitbox02-rust/src/communication_mode.rs b/src/rust/bitbox02-rust/src/communication_mode.rs index 48367f8083..6859a49c56 100644 --- a/src/rust/bitbox02-rust/src/communication_mode.rs +++ b/src/rust/bitbox02-rust/src/communication_mode.rs @@ -28,7 +28,7 @@ fn has_ble(hal: &mut impl crate::hal::Hal) -> bool { let has_ble = matches!( hal.memory().get_platform(), - Ok(memory::Platform::BitBox02Plus), + Ok(memory::Platform::BitBox02Nova), ); HAS_BLE.write(Some(has_ble)); has_ble @@ -46,7 +46,7 @@ mod tests { } #[test] - fn test_ble_disabled_on_non_plus() { + fn test_ble_disabled_on_non_nova() { reset_for_testing(); let mut hal = TestingHal::new(); hal.memory.set_platform(memory::Platform::BitBox02); @@ -61,7 +61,7 @@ mod tests { fn test_ble_enabled_until_usb_request_seen() { reset_for_testing(); let mut hal = TestingHal::new(); - hal.memory.set_platform(memory::Platform::BitBox02Plus); + hal.memory.set_platform(memory::Platform::BitBox02Nova); assert!(ble_enabled(&mut hal)); diff --git a/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs b/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs index 4c55f7daf3..ca57c7ef7c 100644 --- a/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs +++ b/src/rust/bitbox02-rust/src/hww/api/bluetooth.rs @@ -206,7 +206,7 @@ pub async fn process_api( ) -> Result { if !matches!( hal.memory().get_platform().map_err(|_| Error::Memory)?, - hal_memory::Platform::BitBox02Plus + hal_memory::Platform::BitBox02Nova ) { return Err(Error::Disabled); } diff --git a/src/rust/bitbox02-rust/src/hww/api/device_info.rs b/src/rust/bitbox02-rust/src/hww/api/device_info.rs index 7252821a1b..7cce54fb7b 100644 --- a/src/rust/bitbox02-rust/src/hww/api/device_info.rs +++ b/src/rust/bitbox02-rust/src/hww/api/device_info.rs @@ -8,7 +8,7 @@ use pb::response::Response; pub async fn process(hal: &mut impl crate::hal::Hal) -> Result { let bluetooth = match hal.memory().get_platform().map_err(|_| Error::Memory)? { - hal_memory::Platform::BitBox02Plus | hal_memory::Platform::BitBox03 => { + hal_memory::Platform::BitBox02Nova | hal_memory::Platform::BitBox03 => { let ble_metadata = hal.memory().ble_get_metadata(); Some(pb::device_info_response::Bluetooth { firmware_hash: ble_metadata.allowed_firmware_hash.to_vec(), diff --git a/src/rust/bitbox02-rust/src/hww/transport.rs b/src/rust/bitbox02-rust/src/hww/transport.rs index b6822b07d7..fe51250126 100644 --- a/src/rust/bitbox02-rust/src/hww/transport.rs +++ b/src/rust/bitbox02-rust/src/hww/transport.rs @@ -33,7 +33,7 @@ fn info_response(hal: &mut H) -> Vec { response.push(version.len() as u8); response.extend_from_slice(version); response.push(match hal.memory().get_platform() { - Ok(crate::hal::memory::Platform::BitBox02Plus) => 0x02, + Ok(crate::hal::memory::Platform::BitBox02Nova) => 0x02, Ok(crate::hal::memory::Platform::BitBox03) => 0x03, _ => 0x00, }); @@ -218,7 +218,7 @@ mod tests { fn test_req_info() { let _guard = test_guard(); let mut handler = handler(); - handler.hal.memory.set_platform(Platform::BitBox02Plus); + handler.hal.memory.set_platform(Platform::BitBox02Nova); handler.hal.system.set_btconly(true); handler.hal.memory.set_initialized().unwrap(); let response = handler diff --git a/src/rust/bitbox02-rust/src/main_loop.rs b/src/rust/bitbox02-rust/src/main_loop.rs index c2d7ff13b5..f01b8d8b80 100644 --- a/src/rust/bitbox02-rust/src/main_loop.rs +++ b/src/rust/bitbox02-rust/src/main_loop.rs @@ -170,7 +170,7 @@ pub fn main_loop(hal: &mut H) -> ! { if STARTUP_COMPLETE.swap(false, Ordering::Relaxed) { // hww handler in usb_process must be setup before we can allow ble connections - if let Ok(crate::hal::memory::Platform::BitBox02Plus) = hal.memory().get_platform() { + if let Ok(crate::hal::memory::Platform::BitBox02Nova) = hal.memory().get_platform() { let product = bitbox02::platform::product(); bitbox02::da14531_handler::set_product(product); bitbox_da14531::set_product(product, &mut uart_write_queue) diff --git a/src/rust/bitbox02-rust/src/reset.rs b/src/rust/bitbox02-rust/src/reset.rs index 0746034d1d..a41ed6e84a 100644 --- a/src/rust/bitbox02-rust/src/reset.rs +++ b/src/rust/bitbox02-rust/src/reset.rs @@ -66,7 +66,7 @@ pub(crate) async fn reset(hal: &mut impl crate::hal::Hal, status: bool) { // The ble chip needs to be restarted to load the new secrets. if matches!( hal.memory().get_platform(), - Ok(memory::Platform::BitBox02Plus) + Ok(memory::Platform::BitBox02Nova) ) { hal.system().reset_ble(); } diff --git a/src/rust/bitbox02-sys/build.rs b/src/rust/bitbox02-sys/build.rs index c74fc6871e..84a798ea8f 100644 --- a/src/rust/bitbox02-sys/build.rs +++ b/src/rust/bitbox02-sys/build.rs @@ -22,7 +22,7 @@ const ALLOWLIST_VARS: &[&str] = &[ "MAX_PK_SCRIPT_SIZE", "MAX_VARINT_SIZE", "MEMORY_MULTISIG_NUM_ENTRIES", - "MEMORY_PLATFORM_BITBOX02_PLUS", + "MEMORY_PLATFORM_BITBOX02_NOVA", "MEMORY_PLATFORM_BITBOX02", "MEMORY_SECURECHIP_TYPE_ATECC", "MEMORY_SECURECHIP_TYPE_OPTIGA", diff --git a/src/rust/bitbox02/src/hal/memory.rs b/src/rust/bitbox02/src/hal/memory.rs index 145aef6b44..3b088e0262 100644 --- a/src/rust/bitbox02/src/hal/memory.rs +++ b/src/rust/bitbox02/src/hal/memory.rs @@ -21,7 +21,7 @@ fn to_hal_securechip_type(securechip_type: crate::memory::SecurechipType) -> Sec fn to_hal_platform(platform: crate::memory::Platform) -> Platform { match platform { crate::memory::Platform::BitBox02 => Platform::BitBox02, - crate::memory::Platform::BitBox02Plus => Platform::BitBox02Plus, + crate::memory::Platform::BitBox02Nova => Platform::BitBox02Nova, } } @@ -284,8 +284,8 @@ mod tests { Platform::BitBox02, ); assert_eq!( - to_hal_platform(crate::memory::Platform::BitBox02Plus), - Platform::BitBox02Plus, + to_hal_platform(crate::memory::Platform::BitBox02Nova), + Platform::BitBox02Nova, ); } diff --git a/src/rust/bitbox02/src/memory.rs b/src/rust/bitbox02/src/memory.rs index 415eea867d..ce5b3b9f32 100644 --- a/src/rust/bitbox02/src/memory.rs +++ b/src/rust/bitbox02/src/memory.rs @@ -198,13 +198,13 @@ pub fn multisig_get_by_hash(hash: &[u8]) -> Option { #[derive(Clone, Copy)] pub enum Platform { BitBox02, - BitBox02Plus, + BitBox02Nova, } pub fn get_platform() -> Result { match unsafe { bitbox02_sys::memory_get_platform() as u32 } { bitbox02_sys::MEMORY_PLATFORM_BITBOX02 => Ok(Platform::BitBox02), - bitbox02_sys::MEMORY_PLATFORM_BITBOX02_PLUS => Ok(Platform::BitBox02Plus), + bitbox02_sys::MEMORY_PLATFORM_BITBOX02_NOVA => Ok(Platform::BitBox02Nova), _ => Err(()), } } diff --git a/src/system.c b/src/system.c index d0f611954a..e2e7725add 100644 --- a/src/system.c +++ b/src/system.c @@ -30,7 +30,7 @@ static void _ble_clear_product(void) void reboot_to_bootloader(void) { - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { _ble_clear_product(); } auto_enter_t auto_enter = { @@ -50,7 +50,7 @@ void reboot_to_bootloader(void) void reboot(void) { - if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_PLUS) { + if (memory_get_platform() == MEMORY_PLATFORM_BITBOX02_NOVA) { _ble_clear_product(); } #ifndef TESTING diff --git a/src/ui/components/ui_images.c b/src/ui/components/ui_images.c index 64fe0cc2ef..3a305f8e0d 100644 --- a/src/ui/components/ui_images.c +++ b/src/ui/components/ui_images.c @@ -116,9 +116,9 @@ void image_sdcard(bool mirror) // Logo images: // In the bootloader we hardcode by target. We currently have one firmware for both BB02 and -// BB02-Plus, so we include both in the firmware. +// BB02 Nova, so we include both in the firmware. -#if (PRODUCT_BITBOX_BTCONLY == 1) || (PRODUCT_BITBOX_PLUS_BTCONLY == 1) +#if (PRODUCT_BITBOX_BTCONLY == 1) || (PRODUCT_BITBOX_NOVA_BTCONLY == 1) #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_BTCONLY == 1) #define IMAGE_BITBOX02_LOGO_W 79 @@ -142,10 +142,10 @@ const uint8_t IMAGE_BITBOX02_LOGO[] = { 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}; #endif - #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_PLUS_BTCONLY == 1) - #define IMAGE_BITBOX02_PLUS_LOGO_W 125 - #define IMAGE_BITBOX02_PLUS_LOGO_H 25 -static const uint8_t IMAGE_BITBOX02_PLUS_LOGO[] = { + #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_NOVA_BTCONLY == 1) + #define IMAGE_BITBOX02_NOVA_LOGO_W 125 + #define IMAGE_BITBOX02_NOVA_LOGO_H 25 +static const uint8_t IMAGE_BITBOX02_NOVA_LOGO[] = { 0xfe, 0x0c, 0x30, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x61, 0x83, 0xfc, 0x00, 0x00, 0x00, 0x1e, 0x03, 0xc0, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x30, 0x60, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x01, 0x08, 0x21, 0x07, 0x83, 0x00, 0x00, 0x00, 0x01, 0x83, @@ -174,7 +174,7 @@ static const uint8_t IMAGE_BITBOX02_PLUS_LOGO[] = { }; #endif -#elif (PRODUCT_BITBOX_MULTI == 1) || (PRODUCT_BITBOX_PLUS_MULTI == 1) || \ +#elif (PRODUCT_BITBOX_MULTI == 1) || (PRODUCT_BITBOX_NOVA_MULTI == 1) || \ PRODUCT_BITBOX02_FACTORYSETUP == 1 #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_MULTI == 1) @@ -198,10 +198,10 @@ static const uint8_t IMAGE_BITBOX02_LOGO[] = { 0x00, 0x00, 0x00, 0x00}; #endif - #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_PLUS_MULTI == 1) - #define IMAGE_BITBOX02_PLUS_LOGO_W 125 - #define IMAGE_BITBOX02_PLUS_LOGO_H 23 -static const uint8_t IMAGE_BITBOX02_PLUS_LOGO[] = { + #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_NOVA_MULTI == 1) + #define IMAGE_BITBOX02_NOVA_LOGO_W 125 + #define IMAGE_BITBOX02_NOVA_LOGO_H 23 +static const uint8_t IMAGE_BITBOX02_NOVA_LOGO[] = { 0xfe, 0x0c, 0x30, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x61, 0x83, 0xfc, 0x00, 0x00, 0x00, 0x1e, 0x03, 0xc0, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x30, 0x60, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x01, 0x08, 0x21, 0x07, 0x83, 0x00, 0x00, 0x00, 0x01, 0x83, @@ -253,17 +253,17 @@ image_logo_data_t image_logo_data(void) }, }; return result; - #elif (PRODUCT_BITBOX_PLUS_BTCONLY == 1) || (PRODUCT_BITBOX_PLUS_MULTI == 1) + #elif (PRODUCT_BITBOX_NOVA_BTCONLY == 1) || (PRODUCT_BITBOX_NOVA_MULTI == 1) image_logo_data_t result = { .buffer = { - .data = IMAGE_BITBOX02_PLUS_LOGO, - .len = sizeof(IMAGE_BITBOX02_PLUS_LOGO), + .data = IMAGE_BITBOX02_NOVA_LOGO, + .len = sizeof(IMAGE_BITBOX02_NOVA_LOGO), }, .dimensions = { - .width = IMAGE_BITBOX02_PLUS_LOGO_W, - .height = IMAGE_BITBOX02_PLUS_LOGO_H, + .width = IMAGE_BITBOX02_NOVA_LOGO_W, + .height = IMAGE_BITBOX02_NOVA_LOGO_H, }, }; return result; @@ -276,17 +276,17 @@ image_logo_data_t image_logo_data(void) image_logo_data_t image_logo_data(void) { switch (memory_get_platform()) { - case MEMORY_PLATFORM_BITBOX02_PLUS: { + case MEMORY_PLATFORM_BITBOX02_NOVA: { image_logo_data_t result = { .buffer = { - .data = IMAGE_BITBOX02_PLUS_LOGO, - .len = sizeof(IMAGE_BITBOX02_PLUS_LOGO), + .data = IMAGE_BITBOX02_NOVA_LOGO, + .len = sizeof(IMAGE_BITBOX02_NOVA_LOGO), }, .dimensions = { - .width = IMAGE_BITBOX02_PLUS_LOGO_W, - .height = IMAGE_BITBOX02_PLUS_LOGO_H, + .width = IMAGE_BITBOX02_NOVA_LOGO_W, + .height = IMAGE_BITBOX02_NOVA_LOGO_H, }, }; return result; diff --git a/src/usb/class/usb_desc_bitbox02plus.h b/src/usb/class/usb_desc_bitbox02nova.h similarity index 80% rename from src/usb/class/usb_desc_bitbox02plus.h rename to src/usb/class/usb_desc_bitbox02nova.h index 2f2a73b28b..113edeb3c7 100644 --- a/src/usb/class/usb_desc_bitbox02plus.h +++ b/src/usb/class/usb_desc_bitbox02nova.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -#ifndef _USB_DESC_BITBOX02_PLUS_H_ -#define _USB_DESC_BITBOX02_PLUS_H_ +#ifndef _USB_DESC_BITBOX02_NOVA_H_ +#define _USB_DESC_BITBOX02_NOVA_H_ #include "usb_desc_common.h" #include "usb_size.h" @@ -14,15 +14,15 @@ #endif #if defined(BOOTLOADER) - #if PRODUCT_BITBOX_PLUS_BTCONLY == 1 - #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \ + #if PRODUCT_BITBOX_NOVA_BTCONLY == 1 + #define USB_DESC_BB02NOVA_IPRODUCT_STR_DESC \ 52, /* bLength */ \ 0x03, /* bDescriptorType */ \ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, \ 'o', 0, 'v', 0, 'a', 0, ' ', 0, 'B', 0, 'T', 0, 'C', 0, '-', 0, 'o', 0, 'n', 0, \ 'l', 0, 'y', 0, ' ', 0, 'b', 0, 'l', 0, #else - #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \ + #define USB_DESC_BB02NOVA_IPRODUCT_STR_DESC \ 46, /* bLength */ \ 0x03, /* bDescriptorType */ \ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, \ @@ -30,34 +30,34 @@ 'b', 0, 'l', 0, #endif #elif FACTORYSETUP == 1 - #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \ + #define USB_DESC_BB02NOVA_IPRODUCT_STR_DESC \ 44, /* bLength */ \ 0x03, /* bDescriptorType */ \ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', \ 0, 'v', 0, 'a', 0, ' ', 0, 'F', 0, 'a', 0, 'c', 0, 't', 0, 'o', 0, 'r', 0, 'y', 0, -#elif PRODUCT_BITBOX_BTCONLY == 1 - #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \ +#elif PRODUCT_BITBOX_NOVA_BTCONLY == 1 + #define USB_DESC_BB02NOVA_IPRODUCT_STR_DESC \ 46, /* bLength */ \ 0x03, /* bDescriptorType */ \ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', \ 0, 'v', 0, 'a', 0, ' ', 0, 'B', 0, 'T', 0, 'C', 0, '-', 0, 'o', 0, 'n', 0, 'l', 0, \ 'y', 0, #else - #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \ + #define USB_DESC_BB02NOVA_IPRODUCT_STR_DESC \ 40, /* bLength */ \ 0x03, /* bDescriptorType */ \ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', \ 0, 'v', 0, 'a', 0, ' ', 0, 'M', 0, 'u', 0, 'l', 0, 't', 0, 'i', 0, #endif -#define USB_STR_DESC_BB02PLUS \ +#define USB_STR_DESC_BB02NOVA \ USB_DESC_LANGID_DESC \ USB_DESC_IMANUFACT_STR_DESC \ - USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \ + USB_DESC_BB02NOVA_IPRODUCT_STR_DESC \ USB_DESC_ISERIALNUM_STR_DESC -#define USB_DESC_BB02PLUS_HWW_REPORT_LEN 34 -#define USB_DESC_BB02PLUS_HWW_REPORT \ +#define USB_DESC_BB02NOVA_HWW_REPORT_LEN 34 +#define USB_DESC_BB02NOVA_HWW_REPORT \ 0x06, 0xff, 0xff, /* USAGE_PAGE (Vendor Defined) */ \ 0x09, 0x01, /* USAGE (HID Generic Device) */ \ 0xa1, 0x01, /* COLLECTION (Application) */ /* In Report */ \ @@ -75,16 +75,16 @@ 0x91, 0x02, /* OUTPUT (Data,Var,Abs) */ \ 0xc0 /* END_COLLECTION */ -// ** If add an interface, adjust USB_DESC_BB02PLUS_WTOTALLEN ** -// TODO: USB_DESC_BB02PLUS_D_MAX_EP_N doesn't exist, but there is CONF_USB_D_NUM_EP_SP +// ** If add an interface, adjust USB_DESC_BB02NOVA_WTOTALLEN ** +// TODO: USB_DESC_BB02NOVA_D_MAX_EP_N doesn't exist, but there is CONF_USB_D_NUM_EP_SP // (= supported endpoints) - is that the one that needs to change? -// ** If add more endpoints, adjust USB_DESC_BB02PLUS_D_MAX_EP_N ** +// ** If add more endpoints, adjust USB_DESC_BB02NOVA_D_MAX_EP_N ** #if APP_U2F == 0 - #define USB_DESC_BB02PLUS_FS \ - USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_STR_DESC_BB02PLUS + #define USB_DESC_BB02NOVA_FS \ + USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_STR_DESC_BB02NOVA #else - #define USB_DESC_BB02PLUS_FS \ - USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_DESC_IFACE_U2F, USB_STR_DESC_BB02PLUS + #define USB_DESC_BB02NOVA_FS \ + USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_DESC_IFACE_U2F, USB_STR_DESC_BB02NOVA #endif #endif diff --git a/src/usb/usb.c b/src/usb/usb.c index 068ae8bb46..35798644aa 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -4,7 +4,7 @@ #ifndef TESTING #include "hid_hww.h" #include "usb_desc.h" - #include "usb_desc_bitbox02plus.h" + #include "usb_desc_bitbox02nova.h" #include "usb_size.h" #include "usbdc.h" #include @@ -31,11 +31,11 @@ static uint8_t _descriptor_bytes[] = { USB_DESC_FS}; // Device descriptors and Configuration descriptors list. static struct usbd_descriptors _descriptor[] = { {_descriptor_bytes, _descriptor_bytes + sizeof(_descriptor_bytes)}}; -static uint8_t _descriptor_bytes_bitbox02plus[] = { - USB_DESC_BB02PLUS_FS}; // Device descriptors and Configuration descriptors list. -static struct usbd_descriptors _descriptor_bitbox02plus[] = { - {_descriptor_bytes_bitbox02plus, - _descriptor_bytes_bitbox02plus + sizeof(_descriptor_bytes_bitbox02plus)}}; +static uint8_t _descriptor_bytes_bitbox02nova[] = { + USB_DESC_BB02NOVA_FS}; // Device descriptors and Configuration descriptors list. +static struct usbd_descriptors _descriptor_bitbox02nova[] = { + {_descriptor_bytes_bitbox02nova, + _descriptor_bytes_bitbox02nova + sizeof(_descriptor_bytes_bitbox02nova)}}; static void _hww_endpoint_available(void); #if APP_U2F == 1 static void _u2f_endpoint_available(void); @@ -101,8 +101,8 @@ int32_t usb_start(void) } #endif switch (memory_get_platform()) { - case MEMORY_PLATFORM_BITBOX02_PLUS: - usbdc_start(_descriptor_bitbox02plus); + case MEMORY_PLATFORM_BITBOX02_NOVA: + usbdc_start(_descriptor_bitbox02nova); break; default: usbdc_start(_descriptor); diff --git a/test/hardware-fakes/src/fake_memory.c b/test/hardware-fakes/src/fake_memory.c index 68a1700353..aef6d9fbc4 100644 --- a/test/hardware-fakes/src/fake_memory.c +++ b/test/hardware-fakes/src/fake_memory.c @@ -70,7 +70,7 @@ bool fake_memory_nova(void) { chunk_shared_t shared = {0}; memory_read_shared_bootdata_fake(shared.bytes); - shared.fields.platform = MEMORY_PLATFORM_BITBOX02_PLUS; + shared.fields.platform = MEMORY_PLATFORM_BITBOX02_NOVA; shared.fields.securechip_type = MEMORY_SECURECHIP_TYPE_OPTIGA; if (!memory_write_to_address_fake(FLASH_SHARED_DATA_START, 0, shared.bytes)) { return false; diff --git a/test/unit-test/test_memory.c b/test/unit-test/test_memory.c index d947e13a98..c6d83ca360 100644 --- a/test/unit-test/test_memory.c +++ b/test/unit-test/test_memory.c @@ -379,12 +379,12 @@ static void _test_memory_reset_hww(void** state) static void _test_memory_reset_hww_ble(void** state) { - // Make the platform BitBox02 Plus so that the BLE branch in + // Make the platform BitBox02 Nova so that the BLE branch in // memory_reset_hww() is executed. EMPTYCHUNK(empty_shared_chunk); chunk_shared_t shared_chunk = {0}; memcpy(shared_chunk.bytes, empty_shared_chunk, CHUNK_SIZE); - shared_chunk.fields.platform = MEMORY_PLATFORM_BITBOX02_PLUS; + shared_chunk.fields.platform = MEMORY_PLATFORM_BITBOX02_NOVA; // First shared bootdata read is used by memory_get_platform() will_return(__wrap_memory_read_shared_bootdata_fake, shared_chunk.bytes); @@ -402,7 +402,7 @@ static void _test_memory_reset_hww_ble(void** state) // Second shared bootdata read is used inside the BLE branch of memory_reset_hww() chunk_shared_t shared_chunk2 = {0}; memcpy(shared_chunk2.bytes, empty_shared_chunk, CHUNK_SIZE); - shared_chunk2.fields.platform = MEMORY_PLATFORM_BITBOX02_PLUS; + shared_chunk2.fields.platform = MEMORY_PLATFORM_BITBOX02_NOVA; will_return(__wrap_memory_read_shared_bootdata_fake, shared_chunk2.bytes); // Build expected shared chunk after BLE re-initialization @@ -460,7 +460,7 @@ static void _test_memory_get_device_name_default_bluetooth(void** state) EMPTYCHUNK(empty_shared_chunk); chunk_shared_t shared_chunk = {0}; memcpy(shared_chunk.bytes, empty_shared_chunk, CHUNK_SIZE); - shared_chunk.fields.platform = MEMORY_PLATFORM_BITBOX02_PLUS; + shared_chunk.fields.platform = MEMORY_PLATFORM_BITBOX02_NOVA; will_return(__wrap_memory_read_shared_bootdata_fake, shared_chunk.bytes); will_return(__wrap_random_32_bytes_mcu, entropy);