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

split polling can_read and reading from USB #4419

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

TychoVrahe
Copy link
Contributor

@TychoVrahe TychoVrahe commented Dec 3, 2024

This PR changes the way reading from USB works: the polling mechanism is only used to detect if there is a new message, the reading itself is done separately.

The emulator implementation is modified a bit, since there is a need to do the PING-PONG and it is undesirable to emit a CAN_READ event due to this- therefore the message is read into buffer during polling, and the read from the buffer upon read.

This should enable some optimized usage of the message buffer, but this is not done in this PR.

@TychoVrahe TychoVrahe self-assigned this Dec 3, 2024
Copy link

github-actions bot commented Dec 3, 2024

core UI changes device test click test persistence test
T2T1 Model T test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T3B1 Safe 3 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T3T1 Safe 5 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
All main(screens)

@TychoVrahe TychoVrahe force-pushed the tychovrahe/refactor/usb_split branch from 86f3140 to e942f8e Compare December 3, 2024 20:32
@prusnak
Copy link
Member

prusnak commented Dec 3, 2024

Tangential: do we still use HID anywhere in Core? Maybe it is time to remove it (in different PR)?

@matejcik
Copy link
Contributor

matejcik commented Dec 4, 2024

Tangential: do we still use HID anywhere in Core? Maybe it is time to remove it (in different PR)?

FIDO runs over HID

prusnak
prusnak previously requested changes Dec 4, 2024
Copy link
Member

@prusnak prusnak left a comment

Choose a reason for hiding this comment

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

nitpicks

core/mocks/generated/trezorio/__init__.pyi Outdated Show resolved Hide resolved
core/mocks/generated/trezorio/__init__.pyi Outdated Show resolved Hide resolved
core/embed/upymod/modtrezorio/modtrezorio-webusb.h Outdated Show resolved Hide resolved
core/embed/upymod/modtrezorio/modtrezorio-hid.h Outdated Show resolved Hide resolved
@TychoVrahe TychoVrahe marked this pull request as ready for review December 4, 2024 13:29
@TychoVrahe TychoVrahe removed the request for review from andrewkozlik December 4, 2024 13:30
@prusnak prusnak self-requested a review December 4, 2024 13:30
@TychoVrahe TychoVrahe requested review from prusnak and matejcik and removed request for prusnak December 4, 2024 13:51
@TychoVrahe TychoVrahe mentioned this pull request Dec 6, 2024
@TychoVrahe TychoVrahe requested a review from matejcik December 13, 2024 14:31
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.

pushed a fixup 6ef3b8b to your branch that implements better buffer handling in codec_v1. Tried to do the same thing for FIDO but backed out because of the frankly insane use of overlay_struct, so a much more careful approach would be needed.

ACK on the new API, just some nits to fix

core/embed/upymod/modtrezorio/modtrezorio-hid.h Outdated Show resolved Hide resolved
core/embed/upymod/modtrezorio/modtrezorio-hid.h Outdated Show resolved Hide resolved
core/embed/upymod/modtrezorio/modtrezorio-webusb.h Outdated Show resolved Hide resolved
@TychoVrahe
Copy link
Contributor Author

@matejcik acking your changes from 6ef3b8b , i just removed the const here edde952 as the compile was complaining.

also did some modification of tests in 296de18 to accommodate the asserts

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.

all good if the CI passes

@TychoVrahe TychoVrahe force-pushed the tychovrahe/refactor/usb_split branch from 7d2f091 to c3e50d6 Compare January 13, 2025 15:56
@TychoVrahe TychoVrahe merged commit e4f4985 into main Jan 13, 2025
95 checks passed
@TychoVrahe TychoVrahe deleted the tychovrahe/refactor/usb_split branch January 13, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🤝 Needs QA
Development

Successfully merging this pull request may close these issues.

3 participants