I managed to get usb host msc (mass storage class) running up until detection of the USB stick.
while(true) { os_dly_wait(2); usbh_engine(0); // check for new devices if (!bConnected && usbh_msc_status(0, 0)) { printf("MSC connected"); bConnected = true; } else if (bConnected && !usbh_msc_status(0, 0)) { printf("MSC disconnected"); bConnected = false; } }
When I insert the stick, the "MSC connected" message appears (after some delay). When I remove the stick, the "MSC disconnected" message appears.
However, when I try to read from the stick, no files are found and I get a stack overflow (in void os_error(U32 err_code)).
if (ffind("U0:*.*", &fInfo) == 0) { printf("MSC connected: %s", fInfo.name); // We never get here } // ffind does not find any files // and a stack overflow occurs here // (Note that it does not appear when I remove the ffind() command!
I also tried to open a file by name (which certainly exists on the stick), but fopen() returns NULL.