Skip to content

Commit d3536cc

Browse files
authored
Merge pull request #137 from pennam/msd-partitions
Portenta C33: Msd QSPI examples, mount both partition
2 parents b7912da + 42e975a commit d3536cc

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

Diff for: libraries/UsbMsd/examples/MSD_QSPI/MSD_QSPI.ino

+26-24
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,18 @@
1414
This example code is in the public domain.
1515
*/
1616

17-
/*
18-
* CONFIGURATION DEFINES
19-
*/
20-
21-
/* the name of the filesystem */
22-
#define TEST_FS_NAME "qspi"
23-
24-
#include "QSPIFlashBlockDevice.h"
17+
#include "BlockDevice.h"
18+
#include "MBRBlockDevice.h"
2519
#include "UsbMsd.h"
2620
#include "FATFileSystem.h"
2721

2822
BlockDevice* root = BlockDevice::get_default_instance();
29-
USBMSD msd(root);
30-
FATFileSystem fs(TEST_FS_NAME);
23+
MBRBlockDevice sys_bd(root, 1);
24+
MBRBlockDevice user_bd(root, 2);
25+
FATFileSystem sys_fs("sys");
26+
FATFileSystem user_fs("user");
3127

32-
std::string root_folder = std::string("/") + std::string(TEST_FS_NAME);
28+
int err = 0;
3329

3430
/* -------------------------------------------------------------------------- */
3531
void printDirectoryContent(const char* name) {
@@ -64,33 +60,39 @@ void printDirectoryContent(const char* name) {
6460
/* SETUP */
6561
/* -------------------------------------------------------------------------- */
6662
void setup() {
67-
63+
6864
/* SERIAL INITIALIZATION */
6965
Serial.begin(9600);
70-
while(!Serial) {
71-
66+
while(!Serial) {
7267
}
7368

7469
Serial.println("*** USB Mass Storage DEVICE on QSPI Flash ***");
75-
76-
70+
7771
/* Mount the partition */
78-
int err = fs.mount(root);
72+
err = sys_fs.mount(&sys_bd);
7973
if (err) {
80-
Serial.println("Unable to mount filesystem");
74+
Serial.println("Unable to mount system filesystem");
8175
while(1) {
82-
8376
}
84-
}
77+
}
78+
79+
/* Mount the partition */
80+
err = user_fs.mount(&user_bd);
81+
if (err) {
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 */
84+
}
8585
}
8686

8787
/* -------------------------------------------------------------------------- */
8888
/* LOOP */
8989
/* -------------------------------------------------------------------------- */
9090
void loop() {
91-
Serial.print("Content of the folder ");
92-
Serial.print(root_folder.c_str());
93-
Serial.println(":");
94-
printDirectoryContent(root_folder.c_str());
91+
Serial.println("Content of the system partition:");
92+
printDirectoryContent("/sys");
93+
if(!err) {
94+
Serial.println("Content of the user partition:");
95+
printDirectoryContent("/user");
96+
}
9597
delay(2000);
9698
}

0 commit comments

Comments
 (0)