Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize device boot time #3466

Merged

Conversation

TychoVrahe
Copy link
Contributor

This PR optimizes boot times with few improvements:

  • on T3T1/STM32U5, hash processor is used to calculate image hash, the hash algorithm is switched to SHA256
  • checking of empty area after fw image is optimized by comparing words rather than bytes
  • I2C initialization on U5 is sped up by using static value for timing register
  • touch is initialized at the start of bootloader, so that the waiting time is utilized to check fw image. (see Bootloader: calculate image hashes while waiting for touch to come up #3429 )
  • unnecessary delays are removed from touch driver initialization
  • the period for checking touch for bootloader entry is shortened from 200ms to 10ms, which is sufficient as long as the user is swiping before this check, which i think is the point anyway. It might change the UX of entering the bootloader a bit though. Users should not need to enter bootloader that often now that we have interaction less fw update, but for TT we might want to keep the original delay not to mess with users muscle memory

@TychoVrahe TychoVrahe self-assigned this Dec 18, 2023
@TychoVrahe TychoVrahe force-pushed the tychovrahe/T3T1/hw_support_hash2 branch from 89e7d87 to b00bcf4 Compare December 18, 2023 13:01
@TychoVrahe TychoVrahe marked this pull request as ready for review December 18, 2023 20:38
@TychoVrahe TychoVrahe removed the request for review from prusnak December 18, 2023 20:38
core/embed/lib/image.c Outdated Show resolved Hide resolved
@matejcik matejcik requested a review from cepetr December 19, 2023 15:16
Copy link
Contributor

@matejcik matejcik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what the vendor header changes are doing here

otherwise ACK code-wise but not approving yet, I would like more people to play with the shortened bootloader delay

also @cepetr please review too

@TychoVrahe
Copy link
Contributor Author

The vendor headers are regenerated for U5 models because we now use SHA256 to calculate their hash (which is then signed). Unsafe prod signed vendor headers are removed because they are no longer valid after the algo change.

core/embed/bootloader/main.c Show resolved Hide resolved
core/embed/lib/image.c Outdated Show resolved Hide resolved
core/embed/trezorhal/stm32u5/hash_processor.c Show resolved Hide resolved
core/embed/trezorhal/stm32u5/hash_processor.c Show resolved Hide resolved
core/embed/bootloader/main.c Show resolved Hide resolved
@TychoVrahe
Copy link
Contributor Author

added a fix with dma interrupt priority setting, and dma channel security configuration (now allowed in unprivileged mode)

c2beaa4

@Hannsek Hannsek added the blocked Blocked by external force. Third party inputs required. label Jan 25, 2024
@TychoVrahe TychoVrahe force-pushed the tychovrahe/T3T1/hw_support_hash2 branch from fdb7265 to fcd60c5 Compare February 5, 2024 12:39
Base automatically changed from tychovrahe/T3T1/hw_support to tychovrahe/u5/basic_support February 5, 2024 13:50
@TychoVrahe TychoVrahe force-pushed the tychovrahe/T3T1/hw_support_hash2 branch from fcd60c5 to b4723ac Compare February 5, 2024 13:52
@TychoVrahe TychoVrahe merged commit de4e5e2 into tychovrahe/u5/basic_support Feb 5, 2024
56 of 57 checks passed
@TychoVrahe TychoVrahe deleted the tychovrahe/T3T1/hw_support_hash2 branch February 5, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by external force. Third party inputs required.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Bootloader: calculate image hashes while waiting for touch to come up
4 participants