Skip to content

Commit 4442c40

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 4442c40

File tree

16 files changed

+107
-147
lines changed

16 files changed

+107
-147
lines changed

.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;

src/qtouch/qtouch.h

Lines changed: 64 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -86,47 +86,63 @@ extern "C" {
8686
* Gain , Digital Gain), filter level}
8787
*/
8888
// Slider 1 buttons
89-
#define NODE_0_PARAMS \
90-
{ \
91-
X_NONE, Y_LINE(26), 0, NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
92-
NODE_GAIN(GAIN_4, GAIN_4), FILTER_LEVEL_512 \
93-
}
94-
#define NODE_1_PARAMS \
95-
{ \
96-
X_NONE, Y_LINE(27), 0, NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
97-
NODE_GAIN(GAIN_4, GAIN_4), FILTER_LEVEL_512 \
98-
}
99-
#define NODE_2_PARAMS \
100-
{ \
101-
X_NONE, Y_LINE(28), 0, NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
102-
NODE_GAIN(GAIN_4, GAIN_4), FILTER_LEVEL_512 \
103-
}
104-
#define NODE_3_PARAMS \
105-
{ \
106-
X_NONE, Y_LINE(29), 0, NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
107-
NODE_GAIN(GAIN_4, GAIN_4), FILTER_LEVEL_512 \
108-
}
89+
#define NODE_0_PARAMS \
90+
{X_NONE, \
91+
Y_LINE(26), \
92+
0, \
93+
NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
94+
NODE_GAIN(GAIN_4, GAIN_4), \
95+
FILTER_LEVEL_512}
96+
#define NODE_1_PARAMS \
97+
{X_NONE, \
98+
Y_LINE(27), \
99+
0, \
100+
NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
101+
NODE_GAIN(GAIN_4, GAIN_4), \
102+
FILTER_LEVEL_512}
103+
#define NODE_2_PARAMS \
104+
{X_NONE, \
105+
Y_LINE(28), \
106+
0, \
107+
NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
108+
NODE_GAIN(GAIN_4, GAIN_4), \
109+
FILTER_LEVEL_512}
110+
#define NODE_3_PARAMS \
111+
{X_NONE, \
112+
Y_LINE(29), \
113+
0, \
114+
NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
115+
NODE_GAIN(GAIN_4, GAIN_4), \
116+
FILTER_LEVEL_512}
109117
// Slider 0 buttons
110-
#define NODE_4_PARAMS \
111-
{ \
112-
X_NONE, Y_LINE(30), 0, NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
113-
NODE_GAIN(GAIN_4, GAIN_4), FILTER_LEVEL_512 \
114-
}
115-
#define NODE_5_PARAMS \
116-
{ \
117-
X_NONE, Y_LINE(31), 0, NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
118-
NODE_GAIN(GAIN_4, GAIN_4), FILTER_LEVEL_512 \
119-
}
120-
#define NODE_6_PARAMS \
121-
{ \
122-
X_NONE, Y_LINE(20), 0, NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
123-
NODE_GAIN(GAIN_4, GAIN_4), FILTER_LEVEL_512 \
124-
}
125-
#define NODE_7_PARAMS \
126-
{ \
127-
X_NONE, Y_LINE(21), 0, NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
128-
NODE_GAIN(GAIN_4, GAIN_4), FILTER_LEVEL_512 \
129-
}
118+
#define NODE_4_PARAMS \
119+
{X_NONE, \
120+
Y_LINE(30), \
121+
0, \
122+
NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
123+
NODE_GAIN(GAIN_4, GAIN_4), \
124+
FILTER_LEVEL_512}
125+
#define NODE_5_PARAMS \
126+
{X_NONE, \
127+
Y_LINE(31), \
128+
0, \
129+
NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
130+
NODE_GAIN(GAIN_4, GAIN_4), \
131+
FILTER_LEVEL_512}
132+
#define NODE_6_PARAMS \
133+
{X_NONE, \
134+
Y_LINE(20), \
135+
0, \
136+
NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
137+
NODE_GAIN(GAIN_4, GAIN_4), \
138+
FILTER_LEVEL_512}
139+
#define NODE_7_PARAMS \
140+
{X_NONE, \
141+
Y_LINE(21), \
142+
0, \
143+
NODE_RSEL_PRSC(RSEL_VAL_20, PRSC_DIV_SEL_1), \
144+
NODE_GAIN(GAIN_4, GAIN_4), \
145+
FILTER_LEVEL_512}
130146

131147
/**********************************************************/
132148
/***************** Key Params ******************/
@@ -141,38 +157,14 @@ extern "C" {
141157
* {Sensor Threshold, Sensor Hysterisis, Sensor AKS}
142158
*/
143159
// 0..3 higher Slider left to right 4..7 lower Slider right to left
144-
#define KEY_0_PARAMS \
145-
{ \
146-
16, HYST_50, NO_AKS_GROUP \
147-
}
148-
#define KEY_1_PARAMS \
149-
{ \
150-
16, HYST_50, NO_AKS_GROUP \
151-
}
152-
#define KEY_2_PARAMS \
153-
{ \
154-
16, HYST_50, NO_AKS_GROUP \
155-
}
156-
#define KEY_3_PARAMS \
157-
{ \
158-
16, HYST_50, NO_AKS_GROUP \
159-
}
160-
#define KEY_4_PARAMS \
161-
{ \
162-
16, HYST_50, NO_AKS_GROUP \
163-
}
164-
#define KEY_5_PARAMS \
165-
{ \
166-
16, HYST_50, NO_AKS_GROUP \
167-
}
168-
#define KEY_6_PARAMS \
169-
{ \
170-
16, HYST_50, NO_AKS_GROUP \
171-
}
172-
#define KEY_7_PARAMS \
173-
{ \
174-
16, HYST_50, NO_AKS_GROUP \
175-
}
160+
#define KEY_0_PARAMS {16, HYST_50, NO_AKS_GROUP}
161+
#define KEY_1_PARAMS {16, HYST_50, NO_AKS_GROUP}
162+
#define KEY_2_PARAMS {16, HYST_50, NO_AKS_GROUP}
163+
#define KEY_3_PARAMS {16, HYST_50, NO_AKS_GROUP}
164+
#define KEY_4_PARAMS {16, HYST_50, NO_AKS_GROUP}
165+
#define KEY_5_PARAMS {16, HYST_50, NO_AKS_GROUP}
166+
#define KEY_6_PARAMS {16, HYST_50, NO_AKS_GROUP}
167+
#define KEY_7_PARAMS {16, HYST_50, NO_AKS_GROUP}
176168

177169
/* De-bounce counter for additional measurements to confirm touch detection
178170
* Range: 0 to 255.

src/rust/bitbox02-rust-c/src/workflow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ pub unsafe extern "C" fn rust_workflow_unlock_poll(result_out: &mut bool) -> boo
100100
/// Returns true if there was a result.
101101
#[no_mangle]
102102
pub unsafe extern "C" fn rust_workflow_confirm_poll(result_out: &mut bool) -> bool {
103-
match &CONFIRM_STATE {
104-
TaskState::ResultAvailable(result) => {
103+
match CONFIRM_STATE {
104+
TaskState::ResultAvailable(ref result) => {
105105
CONFIRM_TITLE = None;
106106
CONFIRM_BODY = None;
107107
CONFIRM_PARAMS = None;

src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,10 @@ async fn hash_struct(
423423
child_formatted_path.push("".into());
424424
for (index, member) in typ.members.iter().enumerate() {
425425
*child_path.last_mut().unwrap() = index as u32;
426-
*child_formatted_path.last_mut().unwrap() = member.name.clone();
426+
child_formatted_path
427+
.last_mut()
428+
.unwrap()
429+
.clone_from(&member.name);
427430
let member_type = member.r#type.as_ref().ok_or(Error::InvalidInput)?;
428431
encode_member(
429432
&mut hasher,

src/rust/rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.76.0
1+
1.78.0

src/ui/oled/sh1107.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "oled_writer.h"
1717

1818
// Specify the column address of display RAM 0-127
19-
#define SH1107_CMD_SET_LOW_COL(column) (0x00 | ((column)&0x0F))
19+
#define SH1107_CMD_SET_LOW_COL(column) (0x00 | ((column) & 0x0F))
2020
#define SH1107_CMD_SET_HIGH_COL(column) (0x10 | (((column) >> 4) & 0x07))
2121

2222
// In page adressing mode, after the display RAM is written to, the column address is
@@ -55,7 +55,7 @@
5555
#define SH1107_CMD_SET_DISPLAY_ON 0xAF
5656
#define SH1107_CMD_SET_DISPLAY_OFF 0xAE
5757

58-
#define SH1107_CMD_SET_PAGE_START_ADDRESS(page) (0xB0 | ((page)&0x0f))
58+
#define SH1107_CMD_SET_PAGE_START_ADDRESS(page) (0xB0 | ((page) & 0x0f))
5959

6060
#define SH1107_CMD_SET_COM_OUTPUT_SCAN_UP 0xC0
6161
#define SH1107_CMD_SET_COM_OUTPUT_SCAN_DOWN 0xC8

0 commit comments

Comments
 (0)