Skip to content

Portenta C33: Msd QSPI examples, mount both partition #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions libraries/UsbMsd/examples/MSD_QSPI/MSD_QSPI.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@
This example code is in the public domain.
*/

/*
* CONFIGURATION DEFINES
*/

/* the name of the filesystem */
#define TEST_FS_NAME "qspi"

#include "QSPIFlashBlockDevice.h"
#include "BlockDevice.h"
#include "MBRBlockDevice.h"
#include "UsbMsd.h"
#include "FATFileSystem.h"

BlockDevice* root = BlockDevice::get_default_instance();
USBMSD msd(root);
FATFileSystem fs(TEST_FS_NAME);
MBRBlockDevice sys_bd(root, 1);
MBRBlockDevice user_bd(root, 2);
FATFileSystem sys_fs("sys");
FATFileSystem user_fs("user");

std::string root_folder = std::string("/") + std::string(TEST_FS_NAME);
int err = 0;

/* -------------------------------------------------------------------------- */
void printDirectoryContent(const char* name) {
Expand Down Expand Up @@ -64,33 +60,39 @@ void printDirectoryContent(const char* name) {
/* SETUP */
/* -------------------------------------------------------------------------- */
void setup() {

/* SERIAL INITIALIZATION */
Serial.begin(9600);
while(!Serial) {

while(!Serial) {
}

Serial.println("*** USB Mass Storage DEVICE on QSPI Flash ***");



/* Mount the partition */
int err = fs.mount(root);
err = sys_fs.mount(&sys_bd);
if (err) {
Serial.println("Unable to mount filesystem");
Serial.println("Unable to mount system filesystem");
while(1) {

}
}
}

/* Mount the partition */
err = user_fs.mount(&user_bd);
if (err) {
Serial.println("Unable to mount user filesystem. Only FatFS is supported");
/* Probably the user is using LittleFs. Go on and show only system fs */
}
}

/* -------------------------------------------------------------------------- */
/* LOOP */
/* -------------------------------------------------------------------------- */
void loop() {
Serial.print("Content of the folder ");
Serial.print(root_folder.c_str());
Serial.println(":");
printDirectoryContent(root_folder.c_str());
Serial.println("Content of the system partition:");
printDirectoryContent("/sys");
if(!err) {
Serial.println("Content of the user partition:");
printDirectoryContent("/user");
}
delay(2000);
}