@@ -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,64 @@ 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
+ _runtimeFormat = false ;
67
+ if (_runtimeData.init () != BD_ERROR_OK) {
68
+ _runtimeFormat = true ;
69
+ return false ;
70
+ }
71
+ _runtimeData.deinit ();
72
+
59
73
_root->deinit ();
60
74
return true ;
61
75
}
62
76
63
77
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
78
69
- if (_wifiFS. reformat (&_wifiData ) != 0 ) {
79
+ if (_root-> init ( ) != BD_ERROR_OK ) {
70
80
return false ;
71
81
}
72
82
73
- if (_otaFS. reformat (&_otaData) != 0 ) {
83
+ if (_root-> erase ( 0x0 , _root-> get_erase_size ()) != BD_ERROR_OK ) {
74
84
return false ;
75
85
}
76
86
77
- if (!restoreWifiData ()) {
87
+ MBRBlockDevice::partition (_root, 1 , 0x0B , 0 , 1 * 1024 * 1024 );
88
+ if (_wifiFS.reformat (&_wifiData) != 0 ) {
78
89
return false ;
79
90
}
80
91
92
+ if (!restoreWifiData ()) {
93
+ return false ;
94
+ }
81
95
_wifiFS.unmount ();
96
+
97
+ MBRBlockDevice::partition (_root, 2 , 0x0B , 1 * 1024 * 1024 , 6 * 1024 * 1024 );
98
+ if (_otaFS.reformat (&_otaData) != 0 ) {
99
+ return false ;
100
+ }
82
101
_otaFS.unmount ();
102
+
103
+ MBRBlockDevice::partition (_root, 3 , 0x0B , 6 * 1024 * 1024 , 7 * 1024 * 1024 );
104
+
105
+ if (_runtimeFormat) {
106
+ MBRBlockDevice::partition (_root, 4 , 0x0B , 7 * 1024 * 1024 , 14 * 1024 * 1024 );
107
+ if (_runtimeFS.reformat (&_runtimeData) != 0 ) {
108
+ return false ;
109
+ }
110
+ _runtimeFS.unmount ();
111
+ }
112
+
83
113
_root->deinit ();
84
114
85
115
return true ;
0 commit comments