1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-06 02:06:08 +00:00

feat(core/prodtest): show device ID in prodtest QR code

This commit is contained in:
tychovrahe 2025-03-05 10:28:01 +01:00
parent d0684a5e28
commit 23301745f4
7 changed files with 14 additions and 22 deletions

View File

@ -0,0 +1 @@
Show device ID in protest QR code.

View File

@ -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();
}

View File

@ -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);

View File

@ -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]

View File

@ -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);
@ -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())

View File

@ -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);
@ -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);

View File

@ -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);