Skip to content

Conversation

@peter-marcisovsky
Copy link
Collaborator

@peter-marcisovsky peter-marcisovsky commented Jun 4, 2025

Description

This MR adds Suspend/Resume events for MSC class driver as a follow-up for the Global/Suspend resume feature for usb component.

Added a backward compatibility for older IDF releases, where the suspend/resume will not be backported, by:

// For backward compatibility with IDF versions which do not have suspend/resume api
#ifdef USB_HOST_LIB_EVENT_FLAGS_AUTO_SUSPEND
#define MSC_HOST_SUSPEND_RESUME_API_SUPPORTED
#endif

Related

  • Suspend/Resume support for MSC Class driver

Testing

  • Added tests, which verify the class driver functionality with root port Suspend/Resume events

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

Note

Add global suspend/resume support to MSC host (new events and client handling) with backward-compatible API guard and comprehensive test coverage.

  • MSC Host Driver:
    • Add MSC_DEVICE_SUSPENDED and MSC_DEVICE_RESUMED events; handle USB_HOST_CLIENT_EVENT_DEV_SUSPENDED/DEV_RESUMED in client_event_cb (switch-based refactor, improved logs).
    • Include usb/usb_host.h; update SPDX years.
  • Public API (include/usb/msc_host.h):
    • Gate suspend/resume support with MSC_HOST_SUSPEND_RESUME_API_SUPPORTED (defined if USB_HOST_LIB_EVENT_FLAGS_AUTO_SUSPEND).
    • Extend msc_host_event_t to carry suspended/resumed events and use device handle for them.
  • Tests (test_app/main/test_msc.c):
    • Add suspend/resume suites: suspend_resume, auto_suspend_timer (one-shot/periodic PM), resume_by_transfer_submit, suspended_device_open_close, suspended_device_sudden_disconnect, sudden_suspend, sudden_suspend_from_another_task.
    • Introduce wait_for_app_event, unify base path via BASE_PATH, handle USB_HOST_LIB_EVENT_FLAGS_AUTO_SUSPEND, and minor fixes (typos, cleanup).
  • Changelog:
    • Note added global suspend/resume support.

Written by Cursor Bugbot for commit db50486. This will update automatically on new commits. Configure here.

@peter-marcisovsky peter-marcisovsky self-assigned this Jun 4, 2025
@peter-marcisovsky peter-marcisovsky added the Status: In Progress Issue is being worked on label Jun 4, 2025
@peter-marcisovsky peter-marcisovsky force-pushed the feat/usb_host_msc_suspend_resume_evts branch 3 times, most recently from 45e682b to 2227f73 Compare July 3, 2025 08:00
@peter-marcisovsky peter-marcisovsky force-pushed the feat/usb_host_msc_suspend_resume_evts branch from 2227f73 to 3bb97fc Compare July 14, 2025 12:24
@peter-marcisovsky peter-marcisovsky force-pushed the feat/usb_host_msc_suspend_resume_evts branch from 3bb97fc to f87beb8 Compare August 8, 2025 08:04
@peter-marcisovsky peter-marcisovsky force-pushed the feat/usb_host_msc_suspend_resume_evts branch 2 times, most recently from f87beb8 to d10d377 Compare August 21, 2025 09:20
@peter-marcisovsky peter-marcisovsky added stall PR is stall due to low priority, or blocked by other PR and removed Status: In Progress Issue is being worked on labels Sep 26, 2025
@peter-marcisovsky peter-marcisovsky force-pushed the feat/usb_host_msc_suspend_resume_evts branch from d10d377 to 20a2f37 Compare October 30, 2025 02:03
@peter-marcisovsky peter-marcisovsky added Component: usb_host Issue affects usb_host component and removed stall PR is stall due to low priority, or blocked by other PR labels Oct 30, 2025
@peter-marcisovsky peter-marcisovsky marked this pull request as ready for review October 30, 2025 02:09
    - usb_host lib supports global suspend and resume
    - backward compatibility with older IDF releases
    - MSC Host target tests
@tore-espressif tore-espressif force-pushed the feat/usb_host_msc_suspend_resume_evts branch from 20a2f37 to db50486 Compare November 3, 2025 10:47
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.

LGTM!

@tore-espressif
Copy link
Collaborator

Tested on P4-ECO5, works great, thanks!

@tore-espressif tore-espressif merged commit 63a4825 into master Nov 11, 2025
66 checks passed
@tore-espressif tore-espressif deleted the feat/usb_host_msc_suspend_resume_evts branch November 11, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: usb_host Issue affects usb_host component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants