Skip to content

Commit d8040da

Browse files
committed
Dockerfile: bump Rust toolchain to 1.78
This reduces the fw binary size by 4176 bytes as compared to the v9.18.0 release. Also bump LLVM 18 - it is unrelated but I did it anyway as the Rust release notes also mentioned that they moved to LLVM 18. The workflow.rs change is due to this deprecation warning: ``` warning: creating a shared reference to mutable static is discouraged --> bitbox02-rust-c/src/workflow.rs:103:11 | 103 | match &CONFIRM_STATE { | ^^^^^^^^^^^^^^ shared reference to mutable static | = note: for more information, see issue #114447 <rust-lang/rust#114447> = note: this will be a hard error in the 2024 edition = note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior = note: `#[warn(static_mut_refs)]` on by default help: use `addr_of!` instead to create a raw pointer | 103 | match addr_of!(CONFIRM_STATE) { ``` The C code changes are clang-format changes.
1 parent 13c527d commit d8040da

File tree

18 files changed

+109
-149
lines changed

18 files changed

+109
-149
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: 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-
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; }

.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/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
}

src/qtouch/qtouch.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -174,35 +174,17 @@ qtm_touch_key_control_t qtlib_key_set1 = {
174174
/**********************************************************/
175175
/**************** Binding Layer Module ******************/
176176
/**********************************************************/
177-
#define LIB_MODULES_INIT_LIST \
178-
{ \
179-
(module_init_t) & qtm_ptc_init_acquisition_module, null \
180-
}
177+
#define LIB_MODULES_INIT_LIST {(module_init_t) & qtm_ptc_init_acquisition_module, null}
181178

182-
#define LIB_MODULES_PROC_LIST \
183-
{ \
184-
(module_proc_t) & qtm_key_sensors_process, null \
185-
}
179+
#define LIB_MODULES_PROC_LIST {(module_proc_t) & qtm_key_sensors_process, null}
186180

187-
#define LIB_INIT_DATA_MODELS_LIST \
188-
{ \
189-
(void*)&qtlib_acq_set1, null \
190-
}
181+
#define LIB_INIT_DATA_MODELS_LIST {(void*)&qtlib_acq_set1, null}
191182

192-
#define LIB_DATA_MODELS_PROC_LIST \
193-
{ \
194-
(void*)&qtlib_key_set1, null \
195-
}
183+
#define LIB_DATA_MODELS_PROC_LIST {(void*)&qtlib_key_set1, null}
196184

197-
#define LIB_MODULES_ACQ_ENGINES_LIST \
198-
{ \
199-
(module_acq_t) & qtm_ptc_start_measurement_seq, null \
200-
}
185+
#define LIB_MODULES_ACQ_ENGINES_LIST {(module_acq_t) & qtm_ptc_start_measurement_seq, null}
201186

202-
#define LIB_MODULES_ACQ_ENGINES_LIST_DM \
203-
{ \
204-
(void*)&qtlib_acq_set1, null \
205-
}
187+
#define LIB_MODULES_ACQ_ENGINES_LIST_DM {(void*)&qtlib_acq_set1, null}
206188

207189
/* QTM run time options */
208190
module_init_t library_modules_init[] = LIB_MODULES_INIT_LIST;

0 commit comments

Comments
 (0)