File tree 1 file changed +27
-0
lines changed
Filter options
libraries/STM32H747_System/examples/QSPIFormat
1 file changed +27
-0
lines changed
Original file line number Diff line number Diff line change @@ -60,6 +60,33 @@ void setup() {
60
60
Serial.println (" Do you want to proceed? Y/[n]" );
61
61
62
62
if (true == waitResponse ()) {
63
+ if (root.init () != QSPIF_BD_ERROR_OK) {
64
+ Serial.println (F (" Error: QSPI init failure." ));
65
+ return ;
66
+ }
67
+
68
+ const size_t pts = 512 ; // MBR partition table size = 512b
69
+ const size_t erase_size = root.get_erase_size (0x0 );
70
+
71
+ size_t remainder = pts % erase_size;
72
+ size_t division = pts / erase_size;
73
+
74
+ uint8_t *buf = nullptr ;
75
+
76
+ // save the data that exceeded the size of MBR partition table and write it back
77
+ if (remainder != 0 ) {
78
+ buf = (uint8_t *) malloc (erase_size - remainder );
79
+ root.read (buf, division*erase_size, sizeof (buf));
80
+ }
81
+
82
+ root.erase (0x0 , erase_size*(division + remainder == 0 ? 0 : 1 )); // clear the MBR partition table
83
+
84
+ if (remainder != 0 ) {
85
+ root.program (buf, division*erase_size, sizeof (buf));
86
+ free (buf);
87
+ buf = nullptr ;
88
+ }
89
+
63
90
mbed::MBRBlockDevice::partition (&root, 1 , 0x0B , 0 , 1024 * 1024 );
64
91
if (default_scheme) {
65
92
mbed::MBRBlockDevice::partition (&root, 3 , 0x0B , 14 * 1024 * 1024 , 14 * 1024 * 1024 );
You can’t perform that action at this time.
0 commit comments