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

feature(esp_tinyusb): Added tusb_teardown() call while tinyusb_driver_uninstall() #39

Merged
merged 2 commits into from
Jan 2, 2025

Conversation

roma-jam
Copy link
Collaborator

@roma-jam roma-jam commented Jun 11, 2024

Requirements

  • To uninstall tinyusb driver, a teardown tinyusb stack should be called.
  • tud_deinit() feature was implemented in upstream, starting with version v0.17.0.

Description

  • Added tusb_teardown() call while tinyusb_driver_uninstall()
  • Added test app to verify teardown feature

Testing

  1. Install TinyUSB device without any class
  2. Wait SetConfiguration() (tud_mount_cb)
  3. If attempts == 0 goto step 8
  4. Wait TEARDOWN_DEVICE_DETACH_DELAY_MS
  5. Uninstall TinyUSB device
  6. Wait TEARDOWN_DEVICE_INIT_DELAY_MS
  7. Decrease attempts by 1, goto step 3
  8. Wait TEARDOWN_DEVICE_DETACH_DELAY_MS
  9. Uninstall TinyUSB device

Notes:

  • when amount of teardown configured to 0, then only one install-uninstall routine is fulfilled.
  • device presence used subprocess call "lsusb" and check the Espressif VID/PIN in the output

Related issues

@roma-jam roma-jam self-assigned this Jun 11, 2024
@roma-jam
Copy link
Collaborator Author

roma-jam commented Jun 11, 2024

@tore-espressif , @peter-marcisovsky
This changes unlock the possibility to run usb device tests one by one (espressif/tinyusb#27 should be merged first, though).

I posted two questions for both of you, because it seems that we can make it better and we can use it.

I need that for enumeration driver testing (but maybe I will eliminate esp_tinyusb component from the chain, but anyway), so feel free to check it out when possible.

Meanwhile, I will go and cover the Enum Driver as much as I can.

@roma-jam roma-jam force-pushed the feature/esp_tinyusb_stack_teardown branch 5 times, most recently from d7cb17d to c14eebb Compare June 11, 2024 12:57
@roma-jam roma-jam marked this pull request as ready for review June 11, 2024 13:14
Copy link
Collaborator

@peter-marcisovsky peter-marcisovsky left a comment

Choose a reason for hiding this comment

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

Left some observations from using the test app

device/esp_tinyusb/test_app/sdkconfig.defaults Outdated Show resolved Hide resolved
device/esp_tinyusb/tinyusb.c Show resolved Hide resolved
@finger563
Copy link

Is there a timeline for this feature to be finalized?

@roma-jam
Copy link
Collaborator Author

Hi @finger563 ,

This feature allows the re-configure the driver with these changes: espressif/tinyusb#27
But as far as the same changes are already in the upstream, so we will rebase these changes after updating version to v0.17.0.
For current feature there is no available timeline for now, but the one thing for sure: the update to v0.17.0 will be done first.

Meanwhile, this feature should be available in the upstream of TinyUSB, if anything it is possible to use it.

Sorry for the inconvenience.

@roma-jam roma-jam marked this pull request as draft December 4, 2024 14:08
@roma-jam roma-jam force-pushed the feature/esp_tinyusb_stack_teardown branch from 87ddae1 to 85c3227 Compare December 4, 2024 14:25
@roma-jam roma-jam added this to the esp_tinyusb v1.6.0 milestone Dec 5, 2024
@roma-jam roma-jam force-pushed the feature/esp_tinyusb_stack_teardown branch from ef29b89 to 7bcc554 Compare December 11, 2024 11:40
@roma-jam roma-jam force-pushed the feature/esp_tinyusb_stack_teardown branch 2 times, most recently from da569b5 to 2954367 Compare December 13, 2024 12:09
@roma-jam roma-jam marked this pull request as ready for review December 19, 2024 13:13
@roma-jam roma-jam marked this pull request as draft December 19, 2024 14:16
@roma-jam roma-jam force-pushed the feature/esp_tinyusb_stack_teardown branch 4 times, most recently from f6dc83c to fae1686 Compare December 19, 2024 22:39
@roma-jam roma-jam force-pushed the feature/esp_tinyusb_stack_teardown branch 4 times, most recently from a3bed18 to fd74487 Compare December 22, 2024 19:18
@roma-jam roma-jam marked this pull request as ready for review December 22, 2024 20:16
@roma-jam roma-jam force-pushed the feature/esp_tinyusb_stack_teardown branch from fd74487 to 5922503 Compare December 22, 2024 21:46
@roma-jam
Copy link
Collaborator Author

roma-jam commented Dec 22, 2024

I have updated the test, changing the logic to checking the result of "lsusb" output to verify device attachment and detachment while install/uninstall.

The previous test with teardown + cdc data exchange between host and device moved here: #106

PTAL

Copy link
Collaborator

@tore-espressif tore-espressif left a comment

Choose a reason for hiding this comment

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

@roma-jam Looks good, thank you for the test!

@roma-jam roma-jam force-pushed the feature/esp_tinyusb_stack_teardown branch from be83b3f to a444bcb Compare January 2, 2025 11:19
@roma-jam
Copy link
Collaborator Author

roma-jam commented Jan 2, 2025

Applied several fixes from review in here: #106

Copy link
Collaborator

@peter-marcisovsky peter-marcisovsky left a comment

Choose a reason for hiding this comment

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

LGTM, I could run the test locally on my setup, works fine.

@roma-jam roma-jam merged commit fcd4414 into master Jan 2, 2025
31 checks passed
@roma-jam roma-jam deleted the feature/esp_tinyusb_stack_teardown branch January 2, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants