Skip to content

subsys: usb: shell: Added pytest#6

Open
roma-jam wants to merge 6 commits intopr-add-dwc2-uhc-channels-initfrom
pr-add-subsys-usb-shell-test
Open

subsys: usb: shell: Added pytest#6
roma-jam wants to merge 6 commits intopr-add-dwc2-uhc-channels-initfrom
pr-add-subsys-usb-shell-test

Conversation

@roma-jam
Copy link
Copy Markdown
Collaborator

@roma-jam roma-jam commented Mar 3, 2026

Description

Automation of the verification process during uhc_dwc2 driver development.

samples/subsys/usb/shell provides the possibility to send driver commands, such as: init, enable, device list etc.

To verify the current working state of the driver on a hardware usually the test requires manual launch and typing the commands.

To automate the process, the approach of building the twister artifacts on the ubuntu-latest and running them on the self-hosted runner is used.

Changes

This PR adds:

  • test_usbh_shell.py to send the commands and verify the response
  • workflow to build twister artifats, download them on the self-hosted runner with attached hardware and run the twister.

Added:
- Driver API signatures without implementation
- DT miltiinstance definition of uhc dwc2
- Stubbed vendor quirks calls for esp32
- Added the esp32s3 overlay for usb shell example for testing purpose

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
- Added esp32 specific vendor PHY configuration
- Added specific esp32 IRQ configuration

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
- Added port and channel events handler
- Added logic for port conn/dconn debouncing
- Added stubs for the future higher layer notification

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
Added:
- thread channel events CPLT, STALL, DO_RELEASE, ERROR
- channel structure, configuration: claim, submit_ctrl, release
- FIFO pre-calculaction on init and configuration on port reset

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
@roma-jam roma-jam force-pushed the pr-add-subsys-usb-shell-test branch from d33aa8c to f92073d Compare March 4, 2026 09:43
@roma-jam roma-jam changed the base branch from main to pr-add-dwc2-uhc-channels-init March 4, 2026 09:43
@roma-jam roma-jam changed the title subsys: usb: shell: Added pytest [WIP] subsys: usb: shell: Added pytest [part6] Mar 4, 2026
@roma-jam roma-jam changed the title [WIP] subsys: usb: shell: Added pytest [part6] [WIP] subsys: usb: shell: Added pytest [part5.1] Mar 4, 2026
@roma-jam roma-jam force-pushed the pr-add-subsys-usb-shell-test branch 4 times, most recently from 801c8b0 to 0a028a5 Compare March 4, 2026 14:26
@roma-jam roma-jam force-pushed the pr-add-subsys-usb-shell-test branch 2 times, most recently from 9933511 to 13ee027 Compare March 4, 2026 16:16
Added:

- host_prj.conf for the applicaiton (to enable usbh driver on esp32)
- test_usbh_shell.py with basic logical commands

Changed:

- Added the sample.usbh.shell.hil entry in the usbh subsys sample manifest

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
@roma-jam roma-jam force-pushed the pr-add-subsys-usb-shell-test branch 2 times, most recently from 7271103 to 40afb3a Compare March 5, 2026 09:47
@roma-jam roma-jam self-assigned this Mar 5, 2026
@roma-jam roma-jam marked this pull request as ready for review March 5, 2026 09:47
Added:
- Workflow with zephyr container for one subsys usbh sample

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
@roma-jam roma-jam force-pushed the pr-add-subsys-usb-shell-test branch from 40afb3a to 7f16b15 Compare March 5, 2026 09:48
@roma-jam roma-jam changed the title [WIP] subsys: usb: shell: Added pytest [part5.1] subsys: usb: shell: Added pytest [part5.1] Mar 5, 2026
@roma-jam roma-jam changed the title subsys: usb: shell: Added pytest [part5.1] subsys: usb: shell: Added pytest Mar 5, 2026
@roma-jam roma-jam force-pushed the pr-add-dwc2-uhc-channels-init branch from aae36b7 to 0f267aa Compare March 5, 2026 16:49
@roma-jam roma-jam changed the base branch from pr-add-dwc2-uhc-channels-init to main March 5, 2026 21:45
@roma-jam roma-jam changed the base branch from main to pr-add-dwc2-uhc-channels-init March 5, 2026 21:45
Copy link
Copy Markdown

@josuah josuah Mar 6, 2026

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Cool, thanks!

I also want to check the ztest to know what is it better.

Seems it might be worth switch to them to test uhc on hardware instead of running the shell example.

Copy link
Copy Markdown

@josuah josuah Mar 7, 2026

Choose a reason for hiding this comment

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

Twister works the same way for the shell sample and USB test, so it might not need a lot of effort or learning.

I am testing the pytest and for now it did not get the prompt, but very nice setup nonetheless, first time I use pytest with twister.

I am now trying a HIL test that calls the usb_init/enable() and will report here.

Hopefully this can be proposed upstream then, so that we can have it on any PR.

Thanks for the infrastructure effort!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

However interactively it all works without glitch so far.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

shell: bash
run: |
cd "$GITHUB_WORKSPACE"
tar -czf twister-out.tgz twister-out
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe you'd like to try twisters option to prepare packed artifacts? It should store only what is needed for execution --package-artifacts https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/pylib/twister/twisterlib/environment.py#L377C10-L377C29. If you need some extra files you can add --keep-artifacts https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/pylib/twister/twisterlib/environment.py#L654C10-L654C26

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Cool, thanks a lot for a note!

Will definitely try it.

-p esp32s3_devkitc/esp32s3/procpu \
-s sample.usbh.shell.hil \
--build-only \
-j 1 -v \
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why restricting to a single worker?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Interesting question actually....I thought that if I build only one app and I don't need to make it faster, I decided to do it via single worker only.

But there was no error or anything, so it might be removed.

Copy link
Copy Markdown

@PerMac PerMac left a comment

Choose a reason for hiding this comment

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

I just realized I got this comment pending for 2 weeks

. "$GITHUB_WORKSPACE/ws/.venv/bin/activate"
cd "$GITHUB_WORKSPACE/ws/zephyr"

west twister \
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I believe you not using the artifacts, but rebuilding the image. To skip building you'd need also --test-only https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/pylib/twister/twisterlib/environment.py#L382 I suggest you add --log-level debug which will print all the cmake command etc to verify if it was rebuild or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants