I'm relying on the usb_msc component to have an ESP32S3 module read files from an USB drive (FAT32 formatted). I'm working on ESP-IDF v5.1.
For the most part everything works; however today I've stumbled upon a specific USB drive that crashes the internal usb_msc code directly when getting the device information.
The code is from the USB msc example (https://github.com/espressif/esp-idf/tr ... b/host/msc). When connecting the drive, this is the output:
Code: Select all
I (395) example: Waiting for USB stick to be connected
I (845) example: MSC device connected
I (845) example: connection...
*** Device descriptor ***
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0x0
bDeviceSubClass 0x0
bDeviceProtocol 0x0
bMaxPacketSize0 64
idVendor 0x90c
idProduct 0x1000
bcdDevice 1.00
iManufacturer 1
iProduct 2
iSerialNumber 0
bNumConfigurations 1
*** Configuration descriptor ***
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
bMaxPower 500mA
*** Interface descriptor ***
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 0x8
bInterfaceSubClass 0x6
bInterfaceProtocol 0x50
iInterface 0
*** Endpoint descriptor ***
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 0x2 BULK
wMaxPacketSize 64
bInterval 255
*** Endpoint descriptor ***
bLength 7
bDescriptorType 5
bEndpointAddress 0x2 EP 2 OUT
bmAttributes 0x2 BULK
wMaxPacketSize 64
bInterval 255
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4200a409 PS : 0x00060b30 A0 : 0x8200973b A1 : 0x3fc98d00
0x4200a409: msc_host_get_device_info at /home/maldus/Source/esp-idf-v5.1/examples/peripherals/usb/host/msc/managed_components/espressif__usb_host_msc/src/msc_host.c:549 (discriminator 4)
A2 : 0x3fc98db8 A3 : 0x3fc98d68 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000002 A7 : 0x00000000 A8 : 0x8200a3fc A9 : 0x3fc98ce0
A10 : 0x3fc98db4 A11 : 0x00000000 A12 : 0xffffffff A13 : 0xfffffff7
A14 : 0xb33fffff A15 : 0xb33fffff SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x400556d5 LEND : 0x400556e5 LCOUNT : 0xfffffffe
0x400556d5: strlen in ROM
0x400556e5: strlen in ROM
Backtrace: 0x4200a406:0x3fc98d00 0x42009738:0x3fc98d50 0x42031063:0x3fc98ec0 0x4037c37d:0x3fc98ef0
0x4200a406: msc_host_get_device_info at /home/maldus/Source/esp-idf-v5.1/examples/peripherals/usb/host/msc/managed_components/espressif__usb_host_msc/src/msc_host.c:547 (discriminator 4)
0x42009738: app_main at /home/maldus/Source/esp-idf-v5.1/examples/peripherals/usb/host/msc/main/msc_example_main.c:206 (discriminator 2)
0x42031063: main_task at /home/maldus/Source/esp-idf-v5.1/components/freertos/app_startup.c:208 (discriminator 13)
0x4037c37d: vPortTaskWrapper at /home/maldus/Source/esp-idf-v5.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162
ELF file SHA256: 5ad8d65b7b44cff5
Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x2b (SPI_FAST_FLASH_BOOT)
Saved PC:0x4037569c
0x4037569c: esp_restart_noos_dig at /home/maldus/Source/esp-idf-v5.1/components/esp_system/port/esp_system_chip.c:57 (discriminator 1)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x16f8
load:0x403c9700,len:0x4
load:0x403c9704,len:0xc00
load:0x403cc700,len:0x2eb0
entry 0x403c9908
Code: Select all
len = MIN((dev_info.str_desc_product->bLength - USB_STANDARD_DESC_SIZE) / 2, MSC_STR_DESC_SIZE - 1);
wcsncpy(info->iProduct, dev_info.str_desc_product->wData, len);
info->iProduct[len] = 0; // <-----