@@ -15,7 +15,10 @@ _wifiData(_root, 1),
15
15
_wifiFS(" wlan" ),
16
16
_otaData(_root, 2 ),
17
17
_otaFS(" fs" ),
18
- _kvstoreData(_root, 3 )
18
+ _kvstoreData(_root, 3 ),
19
+ _runtimeData(_root, 4 ),
20
+ _runtimeFS(" opt" ),
21
+ _runtimeFormat(false )
19
22
{
20
23
}
21
24
@@ -25,6 +28,7 @@ bool FlashFormatterQSPI::checkPartition()
25
28
return false ;
26
29
}
27
30
31
+ /* check WiFi partition */
28
32
if (_wifiData.init () != BD_ERROR_OK || _wifiFS.mount (&_wifiData) != 0 ) {
29
33
return false ;
30
34
}
@@ -36,6 +40,7 @@ bool FlashFormatterQSPI::checkPartition()
36
40
_wifiFS.unmount ();
37
41
_wifiData.deinit ();
38
42
43
+ /* check OTA partition */
39
44
if (_otaData.init () != BD_ERROR_OK || _otaFS.mount (&_otaData) != 0 ) {
40
45
return false ;
41
46
}
@@ -47,39 +52,63 @@ bool FlashFormatterQSPI::checkPartition()
47
52
_otaFS.unmount ();
48
53
_otaData.deinit ();
49
54
55
+ /* check KVStore partition */
50
56
if (_kvstoreData.init () != BD_ERROR_OK) {
51
57
return false ;
52
58
}
53
59
54
60
if (_kvstoreData.size () < 1 * 1024 * 1024 ) {
55
61
return false ;
56
62
}
57
-
58
63
_kvstoreData.deinit ();
64
+
65
+ /* check PLC runtime partition */
66
+ if (_runtimeData.init () != BD_ERROR_OK) {
67
+ _runtimeFormat = true ;
68
+ return false ;
69
+ }
70
+ _runtimeData.deinit ();
71
+
59
72
_root->deinit ();
60
73
return true ;
61
74
}
62
75
63
76
bool FlashFormatterQSPI::formatPartition () {
64
- _root->erase (0x0 , _root->get_erase_size ());
65
- MBRBlockDevice::partition (_root, 1 , 0x0B , 0 , 1 * 1024 * 1024 );
66
- MBRBlockDevice::partition (_root, 2 , 0x0B , 1 * 1024 * 1024 , 6 * 1024 * 1024 );
67
- MBRBlockDevice::partition (_root, 3 , 0x0B , 6 * 1024 * 1024 , 7 * 1024 * 1024 );
68
77
69
- if (_wifiFS. reformat (&_wifiData ) != 0 ) {
78
+ if (_root-> init ( ) != BD_ERROR_OK ) {
70
79
return false ;
71
80
}
72
81
73
- if (_otaFS. reformat (&_otaData) != 0 ) {
82
+ if (_root-> erase ( 0x0 , _root-> get_erase_size ()) != BD_ERROR_OK ) {
74
83
return false ;
75
84
}
76
85
77
- if (!restoreWifiData ()) {
86
+ MBRBlockDevice::partition (_root, 1 , 0x0B , 0 , 1 * 1024 * 1024 );
87
+ if (_wifiFS.reformat (&_wifiData) != 0 ) {
78
88
return false ;
79
89
}
80
90
91
+ if (!restoreWifiData ()) {
92
+ return false ;
93
+ }
81
94
_wifiFS.unmount ();
95
+
96
+ MBRBlockDevice::partition (_root, 2 , 0x0B , 1 * 1024 * 1024 , 6 * 1024 * 1024 );
97
+ if (_otaFS.reformat (&_otaData) != 0 ) {
98
+ return false ;
99
+ }
82
100
_otaFS.unmount ();
101
+
102
+ MBRBlockDevice::partition (_root, 3 , 0x0B , 6 * 1024 * 1024 , 7 * 1024 * 1024 );
103
+
104
+ if (_runtimeFormat) {
105
+ MBRBlockDevice::partition (_root, 4 , 0x0B , 7 * 1024 * 1024 , 14 * 1024 * 1024 );
106
+ if (_runtimeFS.reformat (&_runtimeData) != 0 ) {
107
+ return false ;
108
+ }
109
+ _runtimeFS.unmount ();
110
+ }
111
+
83
112
_root->deinit ();
84
113
85
114
return true ;
0 commit comments