Skip to content

Commit ec4b5b5

Browse files
committed
Add check on PLC runtime partition
1 parent 9e15bc0 commit ec4b5b5

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

src/flashFormatter/FlashFormatterQSPI.cpp

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ _wifiData(_root, 1),
1515
_wifiFS("wlan"),
1616
_otaData(_root, 2),
1717
_otaFS("fs"),
18-
_kvstoreData(_root, 3)
18+
_kvstoreData(_root, 3),
19+
_runtimeData(_root, 4),
20+
_runtimeFS("opt"),
21+
_runtimeFormat(false)
1922
{
2023
}
2124

@@ -25,6 +28,7 @@ bool FlashFormatterQSPI::checkPartition()
2528
return false;
2629
}
2730

31+
/* check WiFi partition */
2832
if (_wifiData.init() != BD_ERROR_OK || _wifiFS.mount(&_wifiData) != 0) {
2933
return false;
3034
}
@@ -36,6 +40,7 @@ bool FlashFormatterQSPI::checkPartition()
3640
_wifiFS.unmount();
3741
_wifiData.deinit();
3842

43+
/* check OTA partition */
3944
if (_otaData.init() != BD_ERROR_OK || _otaFS.mount(&_otaData) != 0) {
4045
return false;
4146
}
@@ -47,39 +52,64 @@ bool FlashFormatterQSPI::checkPartition()
4752
_otaFS.unmount();
4853
_otaData.deinit();
4954

55+
/* check KVStore partition */
5056
if (_kvstoreData.init() != BD_ERROR_OK) {
5157
return false;
5258
}
5359

5460
if (_kvstoreData.size() < 1 * 1024 * 1024) {
5561
return false;
5662
}
57-
5863
_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+
5973
_root->deinit();
6074
return true;
6175
}
6276

6377
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);
6878

69-
if (_wifiFS.reformat(&_wifiData) != 0) {
79+
if (_root->init() != BD_ERROR_OK) {
7080
return false;
7181
}
7282

73-
if (_otaFS.reformat(&_otaData) != 0) {
83+
if (_root->erase(0x0, _root->get_erase_size()) != BD_ERROR_OK) {
7484
return false;
7585
}
7686

77-
if (!restoreWifiData()) {
87+
MBRBlockDevice::partition(_root, 1, 0x0B, 0, 1 * 1024 * 1024);
88+
if (_wifiFS.reformat(&_wifiData) != 0) {
7889
return false;
7990
}
8091

92+
if (!restoreWifiData()) {
93+
return false;
94+
}
8195
_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+
}
82101
_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+
83113
_root->deinit();
84114

85115
return true;

src/flashFormatter/FlashFormatterQSPI.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ class FlashFormatterQSPI : public FlashFormatterBase {
3636
MBRBlockDevice _otaData;
3737
FATFileSystem _otaFS;
3838
MBRBlockDevice _kvstoreData;
39+
MBRBlockDevice _runtimeData;
40+
FATFileSystem _runtimeFS;
41+
bool _runtimeFormat;
3942
};
4043

0 commit comments

Comments
 (0)