M5Stack Tab5 TinyUSB MSC support implemented (#530)

This commit is contained in:
Shadowtrance
2026-06-11 06:39:36 +10:00
committed by GitHub
parent 543390a977
commit 8dd9bee8d0
6 changed files with 29 additions and 3 deletions
+18
View File
@@ -12,6 +12,10 @@
#include <tusb_msc_storage.h>
#include <wear_levelling.h>
#if CONFIG_IDF_TARGET_ESP32P4
#include "hal/usb_wrap_ll.h"
#endif
#define EPNUM_MSC 1
#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_MSC_DESC_LEN)
#define SECTOR_SIZE 512
@@ -105,6 +109,13 @@ static bool ensureDriverInstalled() {
return true;
}
#if CONFIG_IDF_TARGET_ESP32P4
// Tab5's USB-C port is wired to FSLS PHY0, but the USB_WRAP (FS/FSLS) controller
// used by TinyUSB device mode defaults to FSLS PHY1. Route it to PHY0 before
// installing the TinyUSB driver.
usb_wrap_ll_phy_select(&USB_WRAP, 0);
#endif
const tinyusb_config_t tusb_cfg = {
.device_descriptor = &descriptor_config,
.string_descriptor = string_desc_arr,
@@ -123,6 +134,10 @@ static bool ensureDriverInstalled() {
if (tinyusb_driver_install(&tusb_cfg) != ESP_OK) {
LOGGER.error("Failed to install TinyUSB driver");
#if CONFIG_IDF_TARGET_ESP32P4
// Roll back routing when TinyUSB did not start.
usb_wrap_ll_phy_select(&USB_WRAP, 1);
#endif
return false;
}
@@ -198,6 +213,9 @@ bool tusbStartMassStorageWithFlash() {
void tusbStop() {
tinyusb_msc_storage_deinit();
#if CONFIG_IDF_TARGET_ESP32P4
usb_wrap_ll_phy_select(&USB_WRAP, 1);
#endif
}
bool tusbCanStartMassStorageWithFlash() {