Skip to content

Commit 42e975a

Browse files
committed
UsbMsd: MSD_QSPI example, handle LittleFS user partition
1 parent 21effa1 commit 42e975a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

libraries/UsbMsd/examples/MSD_QSPI/MSD_QSPI.ino

+9-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ MBRBlockDevice user_bd(root, 2);
2525
FATFileSystem sys_fs("sys");
2626
FATFileSystem user_fs("user");
2727

28+
int err = 0;
29+
2830
/* -------------------------------------------------------------------------- */
2931
void printDirectoryContent(const char* name) {
3032
/* -------------------------------------------------------------------------- */
@@ -67,7 +69,7 @@ void setup() {
6769
Serial.println("*** USB Mass Storage DEVICE on QSPI Flash ***");
6870

6971
/* Mount the partition */
70-
int err = sys_fs.mount(&sys_bd);
72+
err = sys_fs.mount(&sys_bd);
7173
if (err) {
7274
Serial.println("Unable to mount system filesystem");
7375
while(1) {
@@ -77,9 +79,8 @@ void setup() {
7779
/* Mount the partition */
7880
err = user_fs.mount(&user_bd);
7981
if (err) {
80-
Serial.println("Unable to mount user filesystem");
81-
while(1) {
82-
}
82+
Serial.println("Unable to mount user filesystem. Only FatFS is supported");
83+
/* Probably the user is using LittleFs. Go on and show only system fs */
8384
}
8485
}
8586

@@ -89,7 +90,9 @@ void setup() {
8990
void loop() {
9091
Serial.println("Content of the system partition:");
9192
printDirectoryContent("/sys");
92-
Serial.println("Content of the user partition:");
93-
printDirectoryContent("/user");
93+
if(!err) {
94+
Serial.println("Content of the user partition:");
95+
printDirectoryContent("/user");
96+
}
9497
delay(2000);
9598
}

0 commit comments

Comments
 (0)