|
14 | 14 | This example code is in the public domain. |
15 | 15 | */ |
16 | 16 |
|
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" |
25 | 19 | #include "UsbMsd.h" |
26 | 20 | #include "FATFileSystem.h" |
27 | 21 |
|
28 | 22 | 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"); |
31 | 27 |
|
32 | | -std::string root_folder = std::string("/") + std::string(TEST_FS_NAME); |
| 28 | +int err = 0; |
33 | 29 |
|
34 | 30 | /* -------------------------------------------------------------------------- */ |
35 | 31 | void printDirectoryContent(const char* name) { |
@@ -64,33 +60,39 @@ void printDirectoryContent(const char* name) { |
64 | 60 | /* SETUP */ |
65 | 61 | /* -------------------------------------------------------------------------- */ |
66 | 62 | void setup() { |
67 | | - |
| 63 | + |
68 | 64 | /* SERIAL INITIALIZATION */ |
69 | 65 | Serial.begin(9600); |
70 | | - while(!Serial) { |
71 | | - |
| 66 | + while(!Serial) { |
72 | 67 | } |
73 | 68 |
|
74 | 69 | Serial.println("*** USB Mass Storage DEVICE on QSPI Flash ***"); |
75 | | - |
76 | | - |
| 70 | + |
77 | 71 | /* Mount the partition */ |
78 | | - int err = fs.mount(root); |
| 72 | + err = sys_fs.mount(&sys_bd); |
79 | 73 | if (err) { |
80 | | - Serial.println("Unable to mount filesystem"); |
| 74 | + Serial.println("Unable to mount system filesystem"); |
81 | 75 | while(1) { |
82 | | - |
83 | 76 | } |
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 | + } |
85 | 85 | } |
86 | 86 |
|
87 | 87 | /* -------------------------------------------------------------------------- */ |
88 | 88 | /* LOOP */ |
89 | 89 | /* -------------------------------------------------------------------------- */ |
90 | 90 | 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 | + } |
95 | 97 | delay(2000); |
96 | 98 | } |
0 commit comments