Skip to content
Open
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
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ option(COVERAGE "Compile with test coverage flags." OFF)
option(SANITIZE_ADDRESS "Compile with asan." OFF)
option(SANITIZE_UNDEFINED "Compile with ubsan." OFF)
option(CMAKE_VERBOSE_MAKEFILE "Verbose build." OFF)
option(BOOTLOADER_LOCKED "Build bootloaders that lock the bootloader area." OFF)
option(BOOTLOADER_DEVDEVICE "Build bootloaders with the development device menu." OFF)
option(FACTORY_SETUP "Build factory setup firmware." OFF)
set(BITBOX02_EDITION "multi" CACHE STRING "Build BitBox02 edition.")
set_property(CACHE BITBOX02_EDITION PROPERTY STRINGS "multi" "btconly")
if(NOT BITBOX02_EDITION STREQUAL "multi" AND NOT BITBOX02_EDITION STREQUAL "btconly")
message(FATAL_ERROR "Invalid BITBOX02_EDITION ${BITBOX02_EDITION}")
endif()
set(BITBOX02_PLATFORM "classic" CACHE STRING "Build BitBox02 platform.")
set_property(CACHE BITBOX02_PLATFORM PROPERTY STRINGS "classic" "nova")
if(NOT BITBOX02_PLATFORM STREQUAL "classic" AND NOT BITBOX02_PLATFORM STREQUAL "nova")
message(FATAL_ERROR "Invalid BITBOX02_PLATFORM ${BITBOX02_PLATFORM}")
endif()
set(FIRMWARE_TARGET "firmware")
set(BOOTLOADER_TARGET "bootloader")

# Generate compile_command.json (for tidy and other tools)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down Expand Up @@ -215,6 +230,11 @@ message(STATUS "Default EXE LDFLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS " - Options -")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Hardware version: ${HARDWARE}")
message(STATUS "BitBox02 edition: ${BITBOX02_EDITION}")
message(STATUS "BitBox02 platform: ${BITBOX02_PLATFORM}")
message(STATUS "Bootloader locked: ${BOOTLOADER_LOCKED}")
message(STATUS "Bootloader devdevice: ${BOOTLOADER_DEVDEVICE}")
message(STATUS "Factory setup: ${FACTORY_SETUP}")
message(STATUS "Verbose: ${CMAKE_VERBOSE_MAKEFILE}")
message(STATUS "Coverage flags: ${COVERAGE}")
message(STATUS "\n=============================================\n\n")
Expand Down
264 changes: 203 additions & 61 deletions Makefile

Large diffs are not rendered by default.

22 changes: 8 additions & 14 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
# SPDX-License-Identifier: Apache-2.0

if(PYTHONINTERP_FOUND)
# This template flashes with an offset
foreach(target ${FIRMWARES})
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/expand_template ${CMAKE_CURRENT_SOURCE_DIR}/template-firmware.jlink file=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}.bin -o ${target}.jlink
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/expand_template ${CMAKE_CURRENT_SOURCE_DIR}/template.jlink file=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${FIRMWARE_TARGET}.elf -o ${FIRMWARE_TARGET}.jlink
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

# This template flashes without an offset
foreach(target ${BOOTLOADERS})
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/expand_template ${CMAKE_CURRENT_SOURCE_DIR}/template-bootloader.jlink file=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}.bin -o ${target}.jlink
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/expand_template ${CMAKE_CURRENT_SOURCE_DIR}/template.jlink file=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${BOOTLOADER_TARGET}.elf -o ${BOOTLOADER_TARGET}.jlink
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
3 changes: 0 additions & 3 deletions scripts/template-firmware.jlink

This file was deleted.

File renamed without changes.
382 changes: 171 additions & 211 deletions src/CMakeLists.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/da14531/da14531_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <rust/rust.h>
#include <stdlib.h>
#include <utils_assert.h>
#ifndef TESTING
#if (FACTORYSETUP == 1 || !defined(NDEBUG)) && !defined(TESTING)
#include "dap.h"
#endif

Expand Down
44 changes: 11 additions & 33 deletions src/rust/bitbox02-rust-c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,18 @@ bip39 = { workspace = true }
zeroize = { workspace = true }

[features]
# Only one of the "target-" should be activated, which in turn defines/activates the dependent features.
target-bb02-bl-multi = ["bootloader", "platform-bitbox02"]
target-bb02-bl-multi-development = ["bootloader", "platform-bitbox02"]
target-bb02-bl-multi-development-locked = ["bootloader", "platform-bitbox02"]
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-firmware = ["firmware", "platform-bitbox02", "app-bitcoin", "app-litecoin", "app-ethereum", "app-u2f", "app-cardano"]
target-firmware-btc = ["firmware", "platform-bitbox02", "app-bitcoin"]
target-factory-setup = [
# enable these features
"factory-setup",
"firmware",
"platform-bitbox02",
"dep:bitcoin",
]
# add Rust features which are called in the C unit tests (currently there is only one target for C tests).
target-c-unit-tests = [
bitbox02-platform-classic = []
bitbox02-platform-nova = ["util/sha2", "bitbox-noise", "bitbox02-rust"]

bitbox02-edition-btconly = ["app-bitcoin"]
bitbox02-edition-multi = [
"app-bitcoin",
"app-litecoin",
"app-ethereum",
"app-cardano",
"app-u2f",
"firmware",
"c-unit-testing",
"app-cardano",
]

platform-bitbox02 = []
platform-bitbox02plus = ["util/sha2", "bitbox-noise", "bitbox02-rust"]

bootloader = []
firmware = [
"bitbox02-rust",
Expand Down Expand Up @@ -118,6 +92,10 @@ app-cardano = [
"bitbox02-rust/app-cardano",
]

factory-setup = ["bitbox02/factory-setup"]
factory-setup = [
"firmware",
"dep:bitcoin",
"bitbox02/factory-setup",
]

rtt = ["util/rtt"]
6 changes: 3 additions & 3 deletions src/rust/bitbox02-rust-c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "bitbox02-platform-nova")
))]
mod communication_mode;
#[cfg(feature = "firmware")]
Expand All @@ -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 = "bitbox02-platform-nova")
))]
extern crate bitbox02_rust;

Expand All @@ -61,7 +61,7 @@ extern crate util;
#[allow(unused)]
#[cfg(any(
feature = "firmware",
all(feature = "bootloader", feature = "platform-bitbox02plus")
all(feature = "bootloader", feature = "bitbox02-platform-nova")
))]
type HalImpl = bitbox02::hal::BitBox02Hal;

Expand Down
Loading