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

MSC: FATFS isn't remounted after USB disconnect (IEC-120) #38

Closed
3 tasks done
toine512 opened this issue Jun 9, 2024 · 3 comments
Closed
3 tasks done

MSC: FATFS isn't remounted after USB disconnect (IEC-120) #38

toine512 opened this issue Jun 9, 2024 · 3 comments
Labels
Type: Bug Bug in esp-usb

Comments

@toine512
Copy link

toine512 commented Jun 9, 2024

Answers checklist.

  • I have read the component documentation ESP-IDF Components and the issue is not addressed there.
  • I am using target and esp-idf version as defined in component's idf_component.yml
  • I have searched the issue tracker for a similar issue and not found any related issue.

Which component are you using? If you choose Other, provide details in More Information.

device/esp_tinyusb

ESP-IDF version.

5.2.1

Development Kit.

ESP32-S3-DevKitC-1 clone

Used Component version.

1.4.4

More Information.

Hello.

Using the flash to MSC flow, the FATFS partition is not remounted after USB host is disconnected because of this abandoned TinyUSB bug: hathach/tinyusb#1592 .
The symptom is that my mount callback passed to tinyusb_msc_storage_init_spiflash() is never called besides startup when I call tinyusb_msc_storage_mount(), while no mount error message appears either.
I verified this is the issue by adding the callback in tusb_msc_storage.c as a copy/paste of tud_umount_cb():

// Invoked when device is unmounted
void tud_umount_cb(void)
{
    if (tinyusb_msc_storage_mount(s_storage_handle->base_path) != ESP_OK) {
        ESP_LOGW(TAG, "tud_umount_cb() mount Fails");
    }
}

void tud_suspend_cb(bool none)
{
    if (tinyusb_msc_storage_mount(s_storage_handle->base_path) != ESP_OK) {
        ESP_LOGW(TAG, "tud_umount_cb() mount Fails");
    }
}
@toine512 toine512 added the Type: Bug Bug in esp-usb label Jun 9, 2024
@github-actions github-actions bot changed the title MSC: FATFS isn't remounted after USB disconnect MSC: FATFS isn't remounted after USB disconnect (IEC-120) Jun 9, 2024
@roma-jam
Copy link
Collaborator

roma-jam commented Jun 9, 2024

Hi @toine512,

May I ask you to:

  1. clarify the version of tinyusb component version you are using (should be something like 0.15.x.x)
  2. have you tired to launch original tusb_msc example from esp-idf ?
  3. for device to be able to detect connect/disconnect events from usb, the several additional steps should be fulfilled (hardware resistor divider on Vbus + software configuration during tinyusb_driver_install() call. More information here: Self-Powered Device

@toine512
Copy link
Author

toine512 commented Jun 9, 2024

  1. I'm using esp_tinyusb 1.4.4 package. By digging into automatically downloaded components I find tinyusb version is 0.15.1. I use PlatformIO, it ships a crippled ESP-IDF, managing components is partly manual.
  2. No. I didn't write any tinyusb code anyway: everything is handled by the call to tinyusb_msc_storage_init_spiflash().
  3. You're absolutely right and I didn't even think of checking that VBUS detection is wired properly on the board. That obviously would explain why it thinks it has been suspended by a SE 0.
    I will do necessary checks and get back to you, thanks for your help.

@toine512
Copy link
Author

Hardware and configuration overlook confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug in esp-usb
Projects
None yet
Development

No branches or pull requests

2 participants