mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 13:38:12 +00:00
perf(core): optimize boot time by removing unnecessary touch initialization delays
This commit is contained in:
parent
30edad0151
commit
8c1425edd5
1
core/embed/bootloader/.changelog.d/3429.changed
Normal file
1
core/embed/bootloader/.changelog.d/3429.changed
Normal file
@ -0,0 +1 @@
|
||||
Speed-up device boot
|
@ -408,6 +408,10 @@ int bootloader_main(void) {
|
||||
|
||||
random_delays_init();
|
||||
|
||||
#if defined TREZOR_MODEL_T
|
||||
set_core_clock(CLOCK_180_MHZ);
|
||||
#endif
|
||||
|
||||
#ifdef STM32U5
|
||||
if (sectrue != flash_configure_sec_area_ob()) {
|
||||
#ifdef STM32U5
|
||||
@ -426,6 +430,15 @@ int bootloader_main(void) {
|
||||
hash_processor_init();
|
||||
#endif
|
||||
|
||||
#ifdef USE_I2C
|
||||
i2c_init();
|
||||
#endif
|
||||
|
||||
#ifdef USE_TOUCH
|
||||
touch_power_on();
|
||||
touch_init();
|
||||
#endif
|
||||
|
||||
#ifdef USE_DMA2D
|
||||
dma2d_init();
|
||||
#endif
|
||||
@ -490,24 +503,10 @@ int bootloader_main(void) {
|
||||
firmware_present_backup = firmware_present;
|
||||
}
|
||||
|
||||
#if defined TREZOR_MODEL_T
|
||||
set_core_clock(CLOCK_180_MHZ);
|
||||
display_set_little_endian();
|
||||
#endif
|
||||
|
||||
#ifdef USE_I2C
|
||||
i2c_init();
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPTIGA
|
||||
optiga_hal_init();
|
||||
#endif
|
||||
|
||||
#ifdef USE_TOUCH
|
||||
touch_power_on();
|
||||
touch_init();
|
||||
#endif
|
||||
|
||||
#ifdef USE_BUTTON
|
||||
button_init();
|
||||
#endif
|
||||
@ -550,7 +549,8 @@ int bootloader_main(void) {
|
||||
uint32_t touched = 0;
|
||||
#ifdef USE_TOUCH
|
||||
if (firmware_present == sectrue && stay_in_bootloader != sectrue) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
touch_wait_until_ready();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
touched = touch_is_detected() | touch_read();
|
||||
if (touched) {
|
||||
break;
|
||||
@ -558,7 +558,7 @@ int bootloader_main(void) {
|
||||
#ifdef TREZOR_EMULATOR
|
||||
hal_delay(25);
|
||||
#else
|
||||
hal_delay(1);
|
||||
hal_delay_us(1000);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,11 @@
|
||||
#define EVENT_OLD_TIMEOUT_MS 50
|
||||
#define EVENT_MISSING_TIMEOUT_MS 50
|
||||
|
||||
static uint32_t touch_init_ticks = 0;
|
||||
|
||||
static void touch_default_pin_state(void) {
|
||||
GPIO_PinState state = HAL_GPIO_ReadPin(TOUCH_ON_PORT, TOUCH_ON_PIN);
|
||||
|
||||
// set power off and other pins as per section 3.5 of FT6236 datasheet
|
||||
HAL_GPIO_WritePin(TOUCH_ON_PORT, TOUCH_ON_PIN,
|
||||
GPIO_PIN_SET); // CTP_ON (active low) i.e.- CTPM power
|
||||
@ -74,7 +78,11 @@ static void touch_default_pin_state(void) {
|
||||
// for these changes to take effect. a reset needs to be low for
|
||||
// a minimum of 5ms. also wait for power circuitry to stabilize (if it
|
||||
// changed).
|
||||
HAL_Delay(100); // 100ms (being conservative)
|
||||
HAL_Delay(10);
|
||||
|
||||
if (state == GPIO_PIN_SET) {
|
||||
HAL_Delay(90); // add 90 ms for circuitry to stabilize (being conservative)
|
||||
}
|
||||
}
|
||||
|
||||
static void touch_active_pin_state(void) {
|
||||
@ -93,8 +101,10 @@ static void touch_active_pin_state(void) {
|
||||
|
||||
HAL_GPIO_WritePin(TOUCH_RST_PORT, TOUCH_RST_PIN,
|
||||
GPIO_PIN_SET); // release CTPM reset
|
||||
HAL_Delay(310); // "Time of starting to report point after resetting" min is
|
||||
// 300ms, giving an extra 10ms
|
||||
|
||||
touch_init_ticks = hal_ticks_ms();
|
||||
|
||||
HAL_Delay(5);
|
||||
}
|
||||
|
||||
void touch_set_mode(void) {
|
||||
@ -118,8 +128,6 @@ void touch_power_on(void) {
|
||||
|
||||
// turn on CTP circuitry
|
||||
touch_active_pin_state();
|
||||
|
||||
HAL_Delay(50);
|
||||
}
|
||||
|
||||
void touch_power_off(void) {
|
||||
@ -143,6 +151,13 @@ void touch_init(void) {
|
||||
touch_sensitivity(TOUCH_SENSITIVITY);
|
||||
}
|
||||
|
||||
void touch_wait_until_ready(void) {
|
||||
// wait for the touch controller to be ready
|
||||
while (hal_ticks_ms() - touch_init_ticks < 310) {
|
||||
HAL_Delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void touch_sensitivity(uint8_t value) {
|
||||
// set panel threshold (TH_GROUP) - default value is 0x12
|
||||
uint8_t touch_panel_threshold[] = {0x80, value};
|
||||
|
@ -699,3 +699,5 @@ uint32_t touch_read(void) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void touch_wait_until_ready(void) {}
|
||||
|
@ -1212,3 +1212,5 @@ uint32_t touch_read(void) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void touch_wait_until_ready(void) {}
|
||||
|
@ -10,6 +10,8 @@
|
||||
void touch_init(void);
|
||||
void touch_power_on(void);
|
||||
void touch_power_off(void);
|
||||
void touch_wait_until_ready(void);
|
||||
|
||||
void touch_sensitivity(uint8_t value);
|
||||
uint32_t touch_read(void);
|
||||
uint32_t touch_click(void);
|
||||
|
@ -84,6 +84,7 @@ uint32_t touch_read(void) {
|
||||
|
||||
void touch_init(void) {}
|
||||
void touch_power_on(void) {}
|
||||
void touch_wait_until_ready(void) {}
|
||||
|
||||
uint32_t touch_is_detected(void) { return _touch_detected; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user