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

tinyusb_msc_storage: f_mkfs failed (14) (IEC-229) #79

Open
3 tasks done
MatteoRodriguez opened this issue Oct 21, 2024 · 7 comments
Open
3 tasks done

tinyusb_msc_storage: f_mkfs failed (14) (IEC-229) #79

MatteoRodriguez opened this issue Oct 21, 2024 · 7 comments
Labels
Status: Opened Issue is new Type: Bug Bug in esp-usb

Comments

@MatteoRodriguez
Copy link

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.

v5.2.1

Development Kit.

esp32s3 custom board

Used Component version.

v1.4.4

More Information.

Hello,

I have a custom board with an ESP32-S3-WROOM-2 MON32R8V and an EMMC04G-MT32. I am trying to use tinyusb to make this board behave as a MSC device but I have a problem with the emmc. The tinyusb stack seems to fail to format and mount the emmc when there is no partition on it.

I am pretty sure it has nothing to do with the hardware. My whole code runs perfectly when I use the internal storage of the esp (it behaves as a MSC device). I tested the emmc example (using esp_vfs_fat_sdmmc_mount) and it can format and mount and use the emmc without any problem. I also tested the tusb_msc example and this one CANNOT format the emmc. And once the emmc has been formated, my code is working well.

image

As you can see on the log above, the code is able to talk with the emmc. But there is a conflict with the allocation unit size. I tried everything I could in menuconfig to set this parameter to 512 but I failed doing so. It feels to be hardcoded in the tinyusb library.

Or maybe I am missing some initializing steps with vfs_fat... Here are my initializing steps with tinyusb :

image

And this is the details of the storage_init_emmc function :

image

Thanks for your help.

@MatteoRodriguez MatteoRodriguez added the Type: Bug Bug in esp-usb label Oct 21, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Oct 21, 2024
@github-actions github-actions bot changed the title tinyusb_msc_storage: f_mkfs failed (14) tinyusb_msc_storage: f_mkfs failed (14) (IEC-229) Oct 21, 2024
@tore-espressif
Copy link
Collaborator

@MatteoRodriguez thank you for the issue.
Indeed, we did not test USB MSC device with eMMC memory.

And once the emmc has been formated, my code is working well.

Does this mean that you could expose the eMMC memory through USB to USB host (PC)?

@igrr
Copy link
Member

igrr commented Oct 31, 2024

As you can see on the log above, the code is able to talk with the emmc. But there is a conflict with the allocation unit size. I tried everything I could in menuconfig to set this parameter to 512 but I failed doing so. It feels to be hardcoded in the tinyusb library.

Could you please clarify, what leads to the conclusion that allocation unit size is a problem? Allocation unit size, also known as cluster size, is often much larger than sector size. SD cards and eMMC chips formatted by PC will often have allocation unit size (cluster size) set to 16 kB or more.

Could you please capture the logs at verbose level and upload them here as a .txt file?

@MatteoRodriguez
Copy link
Author

MatteoRodriguez commented Oct 31, 2024

@tore-espressif yes.
To be more precise, if I take one of my boards with a clear emmc (no partition, nothing) and I upload either my code or the tusb_msc example code, it won't boot and keeps trying to reboot (keeps logging the content of the log file attached below).
BUT, if I upload the emmc example code, the example runs perfectly : it can boot, the emmc is fully usable and I can do everything the example is made for.
AND, if I upload again either my code or the tusb_msc example code, now it works fine because the emmc has been formatted by the emmc example code.
So there must be at least one difference between the all-in-one esp_vfs_fat_sdmmc_mount function and the way it is initialized and mounted on the tinyusb side.

@igrr well, honestly, I am pretty new to SD Card and EMMC so my only clue comes from this part of the logs :
image
I haven't been able to change this allocation unit size parameter and test it, so it is still a lead for me, but I might be completely looking on the wrong direction. All I'm sure about is that there is a problem during either the formatting step, either during the mounting step. But I would bet on the formatting step as I don't get any errors if the emmc has already been formatted by something else.

log.txt
Here is the log file you asked, I set every log verbosity I found in menuconfig to "verbose". Feel free to ask if you need more informations.

@tore-espressif
Copy link
Collaborator

Hi @MatteoRodriguez,

I'm glad to hear you managed to get it working! We’ll make sure to include this in our future plans to improve the user experience for eMMC developers. However, we can’t commit to a specific timeline just yet.

@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development Status: Opened Issue is new and removed Status: Opened Issue is new Status: Selected for Development Issue is selected for development labels Nov 1, 2024
@MatteoRodriguez
Copy link
Author

@tore-espressif well, I wouldn't say I got it working in a proper way as I first need to flash a code to format my emmc before I can flash my own code, but that will do the trick temporarily.

No problem, I understand about the timeline, the main goal of this issue was first to check if it wasn't due to a misunderstanding from my side, and then to let you know as soon as possible about a potential bug/feature.

I'll keep looking for a cleaner workaround with some esp_vfs_fat_sdmmc functions. I'll keep you updated. Any help/idea would be really appreciated.

@igrr
Copy link
Member

igrr commented Nov 4, 2024

E (3028) tinyusb_msc_storage: f_mkfs failed (14)

Error code 14 is FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */ — which usually happens during argument checking in f_mkfs. Could you please revert allocation_unit_size to the default value (16kB) and try again? (I suppose you will need to wipe the contents of eMMC first.)

@MatteoRodriguez
Copy link
Author

@igrr I used the tusb_msc example and I set allocation_unit_size to 16kB but it didn't changed anything. I got the same logs as before.
log1.txt

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

No branches or pull requests

4 participants