Skip to content

Commit ff94842

Browse files
committed
Merge branch 'rust-1.78'
2 parents 13c527d + 0cb5cf2 commit ff94842

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+139
-1213
lines changed

.ci/check-style

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88
# Exit on pipe fail
99
set -o pipefail
1010

11-
CLANGFORMAT=${CLANGFORMAT:-clang-format-15}
11+
CLANGFORMAT=${CLANGFORMAT:-clang-format-18}
1212

1313
command -v git >/dev/null 2>&1 || { echo >&2 "git is missing"; exit 1; }
1414
command -v xargs >/dev/null 2>&1 || { echo >&2 "xargs is missing"; exit 1; }

.ci/check-tidy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88
# Exit on pipe fail
99
set -o pipefail
1010

11-
CLANGTIDY=${CLANGTIDY:-clang-tidy-15}
11+
CLANGTIDY=${CLANGTIDY:-clang-tidy-18}
1212

1313
command -v git >/dev/null 2>&1 || { echo >&2 "git is missing"; exit 1; }
1414
command -v xargs >/dev/null 2>&1 || { echo >&2 "xargs is missing"; exit 1; }
@@ -56,5 +56,5 @@ for dir in build build-build; do
5656

5757
echo "Checking $(echo ${SOURCES} | wc -w) files with clang-tidy"
5858
# The list of tidy checks must stay in sync with scripts/tidy
59-
${CLANGTIDY} -quiet -p ${dir} -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*,bugprone-*,performance-*,portability-*,readability-*,-readability-braces-around-statements,-readability-magic-numbers,-readability-isolate-declaration,-readability-identifier-length,-readability-function-cognitive-complexity,-bugprone-reserved-identifier,-bugprone-easily-swappable-parameters,-bugprone-narrowing-conversions,-performance-no-int-to-ptr,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling -warnings-as-errors=* -header-filter '.*' ${SOURCES}
59+
${CLANGTIDY} -quiet -p ${dir} -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*,bugprone-*,performance-*,portability-*,readability-*,-readability-braces-around-statements,-readability-magic-numbers,-readability-isolate-declaration,-readability-identifier-length,-readability-function-cognitive-complexity,-bugprone-reserved-identifier,-bugprone-easily-swappable-parameters,-bugprone-narrowing-conversions,-performance-no-int-to-ptr,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-readability-avoid-unconditional-preprocessor-if -warnings-as-errors=* -header-filter '.*' ${SOURCES}
6060
done

.ci/run-container-ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
set -e
2626
set -x
2727

28-
CONTAINER=shiftcrypto/firmware_v2:37
28+
CONTAINER=shiftcrypto/firmware_v2:38
2929

3030
if [ "$1" == "pull" ] ; then
3131
docker pull "$CONTAINER"

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ ENV DEBIAN_FRONTEND noninteractive
2020
RUN apt-get update && apt-get upgrade -y && apt-get install -y wget nano rsync curl gnupg2 jq unzip bzip2
2121

2222
# for clang-*-15, see https://apt.llvm.org/
23-
RUN echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" >> /etc/apt/sources.list && \
24-
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" >> /etc/apt/sources.list && \
23+
RUN echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
24+
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
2525
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
2626

2727
# Install gcc8-arm-none-eabi
@@ -37,7 +37,7 @@ RUN mkdir ~/Downloads &&\
3737
# Tools for building
3838
RUN apt-get update && apt-get install -y \
3939
build-essential \
40-
llvm-15 \
40+
llvm-18 \
4141
gcc-10 \
4242
binutils \
4343
valgrind \
@@ -68,8 +68,8 @@ RUN update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-10 100
6868
RUN apt-get update && apt-get install -y \
6969
python3 \
7070
python3-pip \
71-
clang-format-15 \
72-
clang-tidy-15
71+
clang-format-18 \
72+
clang-tidy-18
7373

7474
RUN python3 -m pip install --upgrade pip
7575

scripts/format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88
# Exit on pipe fail
99
set -o pipefail
1010

11-
CLANGFORMAT=${CLANGFORMAT:-clang-format-15}
11+
CLANGFORMAT=${CLANGFORMAT:-clang-format-18}
1212
CLANGFORMAT_FLAGS=${CLANGFORMAT_FLAGS:--i}
1313
VERBOSE=${VERBOSE:-NO}
1414

src/CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ else()
213213
# For binary reproducibility, strip path prefixes that can be different depending on environment (e.g. /home/<user>, etc.).
214214
set(RUSTFLAGS "--remap-path-prefix=${CMAKE_CURRENT_SOURCE_DIR}/rust=src --remap-path-prefix=$ENV{HOME}=")
215215
endif()
216+
216217
# Use libsecp256k1 that we link ourselves (included via external/libwally-core).
217218
# See https://github.com/rust-bitcoin/rust-secp256k1/tree/7c8270a8506e31731e540fab7ee1abde1f48314e/secp256k1-sys#linking-to-external-symbols
218219
set(RUSTFLAGS "${RUSTFLAGS} --cfg=rust_secp_no_symbol_renaming")
@@ -244,8 +245,19 @@ set(LIBBITBOX02_RUST ${LIBBITBOX02_RUST} PARENT_SCOPE)
244245

245246
# Generate c-headers for the rust library
246247
add_custom_target(rust-cbindgen
248+
# cbindgen can automatically create the metadata, but it does so without the `--offline` flag.
249+
# The workaround is to manually create and pass the metadata.
250+
COMMAND
251+
${CARGO} metadata --offline > ${CMAKE_CURRENT_BINARY_DIR}/rust-metadata
247252
COMMAND
248-
${CBINDGEN} --quiet --config ${CMAKE_CURRENT_SOURCE_DIR}/rust/bitbox02-cbindgen.toml --output ${CMAKE_CURRENT_BINARY_DIR}/rust/rust.h ${LIBBITBOX02_RUST_SOURCE_DIR}
253+
${CBINDGEN}
254+
--quiet
255+
--config ${CMAKE_CURRENT_SOURCE_DIR}/rust/bitbox02-cbindgen.toml
256+
--output ${CMAKE_CURRENT_BINARY_DIR}/rust/rust.h
257+
--profile release
258+
--metadata ${CMAKE_CURRENT_BINARY_DIR}/rust-metadata
259+
${LIBBITBOX02_RUST_SOURCE_DIR}
260+
WORKING_DIRECTORY ${LIBBITBOX02_RUST_SOURCE_DIR}
249261
BYPRODUCTS
250262
${CMAKE_CURRENT_BINARY_DIR}/rust/rust.h
251263
)
@@ -511,7 +523,7 @@ foreach(type ${RUST_LIBS})
511523
RUSTFLAGS=${RUSTFLAGS}
512524
FIRMWARE_VERSION_SHORT=${FIRMWARE_VERSION}
513525
$<$<BOOL:${SCCACHE_PROGRAM}>:RUSTC_WRAPPER=${SCCACHE_PROGRAM}>
514-
${CARGO} build $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-v> --features target-${type} --target-dir ${RUST_BINARY_DIR}/feature-${type} ${RUST_CARGO_FLAG} ${RUST_TARGET_ARCH_ARG}
526+
${CARGO} build $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-vv> --offline --features target-${type} --target-dir ${RUST_BINARY_DIR}/feature-${type} ${RUST_CARGO_FLAG} ${RUST_TARGET_ARCH_ARG}
515527
COMMAND
516528
${CMAKE_COMMAND} -E copy_if_different ${lib} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib${type}_rust_c.a
517529
# DEPFILES are only supported with the Ninja build tool

src/factorysetup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,5 @@ int main(void)
343343
}
344344
}
345345

346-
while (1)
347-
;
346+
while (1);
348347
}

src/memory/nvmctrl.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
void nvmctrl_exec_cmd(uint16_t cmd)
2020
{
2121
/* Wait until the NVM is ready to accept a new command. */
22-
while (NVMCTRL->STATUS.bit.READY == 0)
23-
;
22+
while (NVMCTRL->STATUS.bit.READY == 0);
2423
NVMCTRL->ADDR.reg = (uint32_t)NVMCTRL_USER;
2524
NVMCTRL->CTRLB.reg = NVMCTRL_CTRLB_CMDEX_KEY | cmd;
26-
while (NVMCTRL->STATUS.bit.READY == 0)
27-
;
25+
while (NVMCTRL->STATUS.bit.READY == 0);
2826
}

src/memory/smarteeprom.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ void smarteeprom_disable(void)
4848
nvmctrl_exec_cmd(NVMCTRL_CTRLB_CMD_PBC); // Clear page buffer
4949
*((uint32_t*)NVMCTRL_FUSES_SEEPSZ_ADDR) = config_word;
5050
nvmctrl_exec_cmd(NVMCTRL_CTRLB_CMD_WQW); // Write a 128-bit word
51-
while (!NVMCTRL->STATUS.bit.READY)
52-
;
53-
while (NVMCTRL->SEESTAT.bit.BUSY)
54-
;
51+
while (!NVMCTRL->STATUS.bit.READY);
52+
while (NVMCTRL->SEESTAT.bit.BUSY);
5553
}
5654

5755
void smarteeprom_setup(void)
@@ -88,10 +86,8 @@ void smarteeprom_setup(void)
8886
nvmctrl_exec_cmd(NVMCTRL_CTRLB_CMD_PBC); // Clear page buffer
8987
*((uint32_t*)NVMCTRL_FUSES_SEEPSZ_ADDR) = config_word;
9088
nvmctrl_exec_cmd(NVMCTRL_CTRLB_CMD_WQW); // Write a 128-bit word
91-
while (!NVMCTRL->STATUS.bit.READY)
92-
;
93-
while (NVMCTRL->SEESTAT.bit.BUSY)
94-
;
89+
while (!NVMCTRL->STATUS.bit.READY);
90+
while (NVMCTRL->SEESTAT.bit.BUSY);
9591
}
9692

9793
void smarteeprom_bb02_config(void)
@@ -122,8 +118,7 @@ void smarteeprom_read(size_t address, size_t bytes, uint8_t* out_buffer)
122118
}
123119

124120
volatile uint8_t* eeprom = (uint8_t*)SEEPROM_ADDR + address;
125-
while (NVMCTRL->SEESTAT.bit.BUSY)
126-
;
121+
while (NVMCTRL->SEESTAT.bit.BUSY);
127122
for (size_t i = 0; i < bytes; ++i) {
128123
out_buffer[i] = *eeprom;
129124
eeprom++;
@@ -136,8 +131,7 @@ void smarteeprom_write(size_t address, size_t bytes, const uint8_t* buffer)
136131
Abort("NULL input buffer in smarteeprom_write.");
137132
}
138133
volatile uint8_t* eeprom = (uint8_t*)SEEPROM_ADDR + address;
139-
while (NVMCTRL->SEESTAT.bit.BUSY)
140-
;
134+
while (NVMCTRL->SEESTAT.bit.BUSY);
141135
/*
142136
* Buffered write of multiple bytes.
143137
* Note that crossing a 32B page will still result in a partial flush
@@ -149,10 +143,8 @@ void smarteeprom_write(size_t address, size_t bytes, const uint8_t* buffer)
149143
}
150144
/* Now, flush the write we have issued. */
151145
nvmctrl_exec_cmd(NVMCTRL_CTRLB_CMD_SEEFLUSH);
152-
while (NVMCTRL->SEESTAT.bit.LOAD != 0)
153-
;
154-
while (NVMCTRL->SEESTAT.bit.BUSY != 0)
155-
;
146+
while (NVMCTRL->SEESTAT.bit.LOAD != 0);
147+
while (NVMCTRL->SEESTAT.bit.BUSY != 0);
156148
/*
157149
* Read back the buffer.
158150
* Check that it matches what we've just written.

src/pukcc/pukcc.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,14 @@ static void pukcc_self_test(void)
177177
{
178178
static bool self_test_run = false;
179179
if (!self_test_run) {
180-
while ((PUKCCSR & BIT_PUKCCSR_CLRRAM_BUSY) != 0)
181-
;
180+
while ((PUKCCSR & BIT_PUKCCSR_CLRRAM_BUSY) != 0);
182181
memset(&PUKCLParam, 0, sizeof(PUKCL_PARAM));
183182
pvPUKCLParam = &PUKCLParam;
184183
vPUKCL_Process(SelfTest, pvPUKCLParam);
185-
while (PUKCL(u2Status) != PUKCL_OK)
186-
;
187-
while (pvPUKCLParam->P.PUKCL_SelfTest.u4Version != PUKCL_VERSION)
188-
;
189-
while (pvPUKCLParam->P.PUKCL_SelfTest.u4CheckNum1 != 0x6E70DDD2)
190-
;
191-
while (pvPUKCLParam->P.PUKCL_SelfTest.u4CheckNum2 != 0x25C8D64F)
192-
;
184+
while (PUKCL(u2Status) != PUKCL_OK);
185+
while (pvPUKCLParam->P.PUKCL_SelfTest.u4Version != PUKCL_VERSION);
186+
while (pvPUKCLParam->P.PUKCL_SelfTest.u4CheckNum1 != 0x6E70DDD2);
187+
while (pvPUKCLParam->P.PUKCL_SelfTest.u4CheckNum2 != 0x25C8D64F);
193188
self_test_run = true;
194189
}
195190
}

0 commit comments

Comments
 (0)