You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- rework member variables when calling begin/umount/format (solves inconsistenies).
begin() means mounting. It must not initialize the block device, as this is global to a partition.
format() is only possbile when FS is not mounted (it makes no sense to call begin()/unmount(),
just to get a valid mbr block device).
-> rework
- When creating partition object and no partition was present on block device, the members of partition object
left uninitialzed.
- add function to free the allocated memory that was returned when calling utils function to create a partition name.
- solve problems, where block devices keept initialized when calling listPartitions().
This function could only be called two times. Other called functions failed because
of the blocked resources. It now calls deinit() to leave it clean.
Copy file name to clipboardExpand all lines: examples/InternalStoragePartitioning/InternalStoragePartitioning.ino
+10-8
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@
4
4
This example demonstrates the usage of the "Arduino_UnifiedStorage" library for retrieving and creating partitions on the internal storage.
5
5
The code should help you understand how to work with partitions and perform file operations in different partitions.
6
6
7
-
It creates the partitions specified in the std::vector<Partitions> you find at the top of the sketch.
7
+
It creates the partitions specified in the std::vector<Partitions> you find at the top of the sketch.
8
8
You can define your own, as long as the size of all partitions doesn't exceed the size of your board's QSPI flash( if you are in doubt about that check docs.arduino.com for more information) and as long as you don't have more than 4 partitions (MBR limitation)
9
9
The Partition struct has two values:
10
10
- `size` the size of your partition in kilobytes
11
11
- 'fileSystemType` which can be either `FS_FAT` or `FS_LITTLEFS`
12
12
13
-
Here are a few examples of valid partitioning schemes:
13
+
Here are a few examples of valid partitioning schemes:
//Arduino_UnifiedStorage::debugPrint("[InternalStorage][INFO] Found " + String(lastPartitionNumber) + " partitions, using last partition as internal storage");
//Arduino_UnifiedStorage::debugPrint("[InternalStorage][INFO] Found " + String(lastPartitionNumber) + " partitions, using last partition as internal storage");
17
+
18
+
this -> partitionNumber = lastPartitionNumber;
19
+
this -> fileSystemType = lastPartitionFileSystem;
20
+
this -> partitionName = (char *)"internal";
21
+
this -> blockDevice = BlockDeviceType::get_default_instance();
22
+
this -> mbrBlockDevice = newMBRBlockDeviceType(this -> blockDevice, this->partitionNumber);
* Initializes the internal storage with the specified file system.
41
-
*
43
+
*
42
44
* @param fs The desired file system (FS_FAT or FS_LITTLEFS).
43
45
* @return true if successful, false if failed.
44
46
*/
45
47
boolbegin(FileSystems fs) override;
46
48
47
49
/**
48
50
* Unmounts the internal storage.
49
-
*
51
+
*
50
52
* @return true if successful, false if failed.
51
53
*/
52
54
boolunmount() override;
53
55
54
56
/**
55
57
* Retrieves the root folder of the internal storage.
56
-
*
58
+
*
57
59
* @return The root folder as a Folder object.
58
60
*/
59
61
Folder getRootFolder() override;
60
62
61
63
62
64
/**
63
65
* Formats the internal storage with the selected file system.
64
-
*
66
+
*
65
67
* @return true if successful, false if failed.
66
68
*/
67
69
boolformat(FileSystems fs) override;
68
70
69
71
70
72
/**
71
73
* Retrieves the block device associated with the internal storage.
72
-
*
74
+
*
73
75
* @return The block device as a BlockDevice object.
74
76
*/
75
77
BlockDeviceType *getBlockDevice();
@@ -86,7 +88,7 @@ class InternalStorage : public Arduino_UnifiedStorage {
86
88
* Creates one partition spanning over the whole size of the internal storage drive erasing the existing partitions.
87
89
* @return true if successful, false if failed.
88
90
*/
89
-
staticboolpartition();
91
+
staticboolpartition();
90
92
91
93
/**
92
94
* Restores the default partitioning scheme (1MB FAT32 for Certificates, 5MB FAT32 for OTA, 8MB user storage) to the internal storage drive erasing the existing partitions.
@@ -96,7 +98,7 @@ class InternalStorage : public Arduino_UnifiedStorage {
96
98
97
99
/**
98
100
* Reads the partitioning scheme from the MBR sector of the internal storage drive and returns a vector of structs of type Partition that represents the partitioning scheme
99
-
* @return vector of structs of type Partition
101
+
* @return vector of structs of type Partition
100
102
*/
101
103
static std::vector<Partition> readPartitions();
102
104
@@ -105,7 +107,7 @@ class InternalStorage : public Arduino_UnifiedStorage {
0 commit comments