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:
parent
d0684a5e28
commit
23301745f4
1
core/embed/projects/prodtest/.changelog.d/4735.changed
Normal file
1
core/embed/projects/prodtest/.changelog.d/4735.changed
Normal file
@ -0,0 +1 @@
|
||||
Show device ID in protest QR code.
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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())
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user