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 1 commit
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
Next Next commit
UsbMsd: MSD_QSPI example, mount both QSPI partitions
  • Loading branch information
pennam committed Sep 18, 2023
commit 21effa19610acea9198106e0aaa0b0d0ee34a83a
49 changes: 24 additions & 25 deletions libraries/UsbMsd/examples/MSD_QSPI/MSD_QSPI.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@
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);

std::string root_folder = std::string("/") + std::string(TEST_FS_NAME);
MBRBlockDevice sys_bd(root, 1);
MBRBlockDevice user_bd(root, 2);
FATFileSystem sys_fs("sys");
FATFileSystem user_fs("user");

/* -------------------------------------------------------------------------- */
void printDirectoryContent(const char* name) {
Expand Down Expand Up @@ -64,33 +58,38 @@ 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);
int 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");
while(1) {
}
}
}

/* -------------------------------------------------------------------------- */
/* 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");
Serial.println("Content of the user partition:");
printDirectoryContent("/user");
delay(2000);
}