Open
Description
Several of us (@bobthedog, @KurtE and me) have been experimenting with the USBHost Mass Storage Example:
#include <DigitalOut.h>
#include <FATFileSystem.h>
#include <Arduino_USBHostMbed5.h>
USBHostMSD msd;
mbed::FATFileSystem usb("usb");
void setup()
{
Serial.begin(115200);
pinMode(PA_15, OUTPUT); //enable the USB-A port
digitalWrite(PA_15, HIGH);
while (!Serial)
;
Serial.println("Starting USB Dir List example...");
// if you are using a Max Carrier uncomment the following line
// start_hub();
while (!msd.connect()) {
//while (!port.connected()) {
delay(1000);
}
Serial.print("Mounting USB device... ");
int err = usb.mount(&msd);
if (err) {
Serial.print("Error mounting USB device ");
Serial.println(err);
while (1);
}
Serial.println("done.");
char buf[256];
// Display the root directory
Serial.print("Opening the root directory... ");
DIR* d = opendir("/usb/");
Serial.println(!d ? "Fail :(" : "Done");
if (!d) {
snprintf(buf, sizeof(buf), "error: %s (%d)\r\n", strerror(errno), -errno);
Serial.print(buf);
}
Serial.println("done.");
Serial.println("Root directory:");
unsigned int count { 0 };
while (true) {
struct dirent* e = readdir(d);
if (!e) {
break;
}
count++;
snprintf(buf, sizeof(buf), " %s\r\n", e->d_name);
Serial.print(buf);
}
Serial.print(count);
Serial.println(" files found!");
snprintf(buf, sizeof(buf), "Closing the root directory... ");
Serial.print(buf);
fflush(stdout);
err = closedir(d);
snprintf(buf, sizeof(buf), "%s\r\n", (err < 0 ? "Fail :(" : "OK"));
Serial.print(buf);
if (err < 0) {
snprintf(buf, sizeof(buf), "error: %s (%d)\r\n", strerror(errno), -errno);
Serial.print(buf);
}
}
void loop()
{
}
So far as a Bottom Line Up Front:
Windows 10 with 2.2.1 IDE : Red lights of doom.
Windows 10 with 1.8.19 IDE : Works.Windows 11 with 2.2.1 IDE : Red lights of doom.
Windows 11 with 1.8.19 IDE : Works.Linux: MacOsX and RPI4
IDE 2.2.1 worksIDE 2.2.1 on Windows 11
Using Serial: Red lights of doom.
Using Serial1: WorksExample works if using release 0.0.3
Posts 31, 37, and 38 show and discuss debug outputs.
Believe in all cases with we are using GIGA version 4.0.8 (installed via boards manager).
As for memory sticks a number have been tested: I have used an old SansDisk Cruzer 2GB and a generic Microcenter 64Gb.
Metadata
Metadata
Assignees
Labels
No labels