Skip to content

Commit

Permalink
feat(core/prodtest): show device ID in prodtest QR code
Browse files Browse the repository at this point in the history
  • Loading branch information
TychoVrahe committed Mar 5, 2025
1 parent d0684a5 commit 2330174
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 22 deletions.
1 change: 1 addition & 0 deletions core/embed/projects/prodtest/.changelog.d/4735.changed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show device ID in protest QR code.
12 changes: 5 additions & 7 deletions core/embed/projects/prodtest/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ static void usb_init_all(void) {
}

static void show_welcome_screen(void) {
char dom[32] = {0};
// format: {MODEL_IDENTIFIER}YYMMDD
if ((sectrue ==
flash_otp_read(FLASH_OTP_BLOCK_BATCH, 0, (uint8_t *)dom, 32) &&
dom[31] == 0 && cstr_starts_with(dom, MODEL_IDENTIFIER))) {
screen_prodtest_info(dom, strlen(dom), dom + sizeof(MODEL_IDENTIFIER) - 1,
strlen(dom) - sizeof(MODEL_IDENTIFIER) + 1);
char device_id[32] = {0};
if ((sectrue == flash_otp_read(FLASH_OTP_BLOCK_DEVICE_ID, 0,
(uint8_t *)device_id, 32) &&
device_id[31] == 0)) {
screen_prodtest_info(device_id, strlen(device_id));
} else {
screen_prodtest_welcome();
}
Expand Down
3 changes: 1 addition & 2 deletions core/embed/rust/rust_ui_prodtest.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <trezor_types.h>

void screen_prodtest_info(char* id, uint8_t id_len, char* date,
uint8_t date_len);
void screen_prodtest_info(char* id, uint8_t id_len);

void screen_prodtest_welcome(void);

Expand Down
10 changes: 2 additions & 8 deletions core/embed/rust/src/ui/api/prodtest_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@ extern "C" fn screen_prodtest_welcome() {
}

#[no_mangle]
extern "C" fn screen_prodtest_info(
id: *const cty::c_char,
id_len: u8,
date: *const cty::c_char,
date_len: u8,
) {
extern "C" fn screen_prodtest_info(id: *const cty::c_char, id_len: u8) {
let id = unwrap!(unsafe { from_c_array(id, id_len as usize) });
let date = unwrap!(unsafe { from_c_array(date, date_len as usize) });

ModelUI::screen_prodtest_info(id, date);
ModelUI::screen_prodtest_info(id);
}

#[no_mangle]
Expand Down
4 changes: 2 additions & 2 deletions core/embed/rust/src/ui/layout_bolt/prodtest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ProdtestUI for UIBolt {
display::fade_backlight_duration(theme::backlight::get_backlight_normal(), 150);
}

fn screen_prodtest_info(id: &str, date: &str) {
fn screen_prodtest_info(id: &str) {
display::sync();
let qr = Qr::new(id, true);
let mut qr = unwrap!(qr).with_border(4);
Expand All @@ -50,7 +50,7 @@ impl ProdtestUI for UIBolt {

shape::Text::new(
screen().bottom_center() - Offset::y(10),
date,
id,
fonts::FONT_BOLD_UPPER,
)
.with_fg(Color::white())
Expand Down
4 changes: 2 additions & 2 deletions core/embed/rust/src/ui/layout_caesar/prodtest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl ProdtestUI for UICaesar {
display::refresh();
}

fn screen_prodtest_info(id: &str, date: &str) {
fn screen_prodtest_info(id: &str) {
display::sync();
let qr = Qr::new(id, true);
let mut qr = unwrap!(qr).with_border(1);
Expand All @@ -43,7 +43,7 @@ impl ProdtestUI for UICaesar {
render_on_display(None, Some(Color::black()), |target| {
qr.render(target);

shape::Text::new(screen().bottom_center(), date, fonts::FONT_BOLD_UPPER)
shape::Text::new(screen().bottom_center(), id, fonts::FONT_BOLD_UPPER)
.with_fg(Color::white())
.with_align(Alignment::Center)
.render(target);
Expand Down
2 changes: 1 addition & 1 deletion core/embed/rust/src/ui/ui_prodtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use heapless::Vec;
pub trait ProdtestUI {
fn screen_prodtest_welcome();

fn screen_prodtest_info(id: &str, date: &str);
fn screen_prodtest_info(id: &str);

fn screen_prodtest_show_text(text: &str);

Expand Down

0 comments on commit 2330174

Please sign in to comment.