Skip to content

Commit b555d29

Browse files
committed
Wipe and recreate filesystem in case of corruption
1 parent c681843 commit b555d29

File tree

3 files changed

+21
-71
lines changed

3 files changed

+21
-71
lines changed

ports/esp32/modules/_boot.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,27 @@
22
import vfs
33
from flashbdev import bdev
44

5-
try:
6-
if bdev:
7-
vfs.mount(bdev, "/")
8-
except OSError:
9-
import inisetup
105

11-
inisetup.setup()
6+
def _erase_bdev():
7+
from esp import flash_erase
8+
9+
i = bdev.info()
10+
for s in range(i[2] // 4096, (i[2] + i[3]) // 4096):
11+
flash_erase(s)
12+
13+
14+
if bdev:
15+
try:
16+
vfs.mount(bdev, "/")
17+
except OSError:
18+
_erase_bdev()
19+
vfs.VfsLfs2.mkfs(bdev)
20+
try:
21+
vfs.mount(bdev, "/")
22+
except OSError:
23+
print("Failed to make filesystem after wiping")
24+
else:
25+
with open(".mkfs", "wb") as f:
26+
pass
1227

1328
gc.collect()

ports/esp32/modules/apa106.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

ports/esp32/modules/inisetup.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)