Hi ESP_iggr,
I'm stuck with the SD connection with TinyUSB. After usb_init() I mount and connect the SD card (first tested with the SD card sample if I can access) and initiate storage_mount_fat(). In that function I only use:
Code: Select all
s_fat_mounted = true;
s_base_path = base_path;
If I plug the ESP32-S3 with USB/SD-Card in my computer it initiates the callback functions and windows opens up the explorer. But it can't read the contents. Also the first read outs with sdmmc_read_sectors appear to be empty (formatted SD card), where I expected some MBR info at 0.
I changed the tud_msc_read10_cb as this:
Code: Select all
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void *buffer, uint32_t bufsize)
{
ESP_LOGI(TAG, "tud_msc_read10_cb() invoked, lun=%d, lba=%d, offset=%d, bufsize=%d", lun, lba, offset, bufsize);
size_t addr = lba * storage_get_sector_size() + offset;
ESP_LOGI(TAG,"Address: %d",addr);
//esp_err_t err = storage_read_sector(addr, bufsize, buffer);
esp_err_t err = sdmmc_read_sectors(card,buffer, addr, bufsize/storage_get_sector_size());
if (err != ESP_OK) {
ESP_LOGE(TAG, "storage_read_sector failed: 0x%x", err);
return 0;
}
return bufsize;
}