I'm trying to mount another recovery partition in addition to the default one mounted on "/flash".
I'm doing this because I want to restore a configuration file (json), in case of corruption of the primary partition.
I can't mount the second volume because I can't see it using uos.listdir() and I can't move in using uos.chdir("/recovery").
I've an ESP32 with Micropython 1.9.4.
This is my partition table:
Code: Select all
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
factory, app, factory, 0x10000, 1144k
ota_0, app, ota_0, 0x130000,1144k
ota_1, app, ota_1, 0x250000,1144k
internalfs, data,spiffs, 0x36e000,76k
recovery, data,spiffs, 0x381000,4k
Code: Select all
# Mount primary partition
uos.VfsFat.mkfs(flashbdev.bdev)
vfsFlash = uos.VfsFat(flashbdev.bdev)
uos.mount(vfsFlash, '/flash')
uos.chdir("/flash")
uos.mkdir("resources")
# Write config file into primary partition
with open("resources/config.json", 'w') as f:
f.write("...")
# Mount recovery partition
bdevRecovery = FlashBdev(2048 * 1024 // FlashBdev.SEC_SIZE)
bdevRecovery.START_SEC = 3674112 // SEC_SIZE
vfsRecovery = uos.VfsFat(bdevRecovery)
uos.mount(vfsRecovery, '/recovery')
uos.chdir("/recovery")
uos.mkdir("recovery")
# Write config file into recovery partition
with open("resources/config.json", 'w') as f:
f.write("...")
I didn't understand well VfsFat:
- what's the point of the calculation 2048 * 1024 // FlashBdev.SEC_SIZE which is done at the object allocation?
- how's the starting address of the partition calculated? (3674112 // SEC_SIZE)
Thank you in advance.