Bring back `invalidate_spiffs()` (#20184)

This commit is contained in:
s-hadinger 2023-12-06 21:39:52 +01:00 committed by GitHub
parent ddb11779fd
commit 40ed8aa10f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 805 additions and 724 deletions

View File

@ -600,6 +600,19 @@ class Partition
end end
end end
#- invalidate SPIFFS partition to force format at next boot -#
#- we simply erase the first byte of the first 2 blocks in the SPIFFS partition -#
def invalidate_spiffs()
import flash
#- we expect the SPIFFS partition to be the last one -#
var spiffs = self.slots[-1]
if !spiffs.is_spiffs() raise 'value_error', 'No FS partition found' end
var b = bytes("00") #- flash memory: we can turn bits from '1' to '0' -#
flash.write(spiffs.start , b) #- block #0 -#
flash.write(spiffs.start + 0x1000, b) #- block #1 -#
end
# switch to safeboot `factory` partition # switch to safeboot `factory` partition
def switch_factory(force_ota) def switch_factory(force_ota)
import flash import flash

View File

@ -602,6 +602,19 @@ class Partition
end end
end end
#- invalidate SPIFFS partition to force format at next boot -#
#- we simply erase the first byte of the first 2 blocks in the SPIFFS partition -#
def invalidate_spiffs()
import flash
#- we expect the SPIFFS partition to be the last one -#
var spiffs = self.slots[-1]
if !spiffs.is_spiffs() raise 'value_error', 'No FS partition found' end
var b = bytes("00") #- flash memory: we can turn bits from '1' to '0' -#
flash.write(spiffs.start , b) #- block #0 -#
flash.write(spiffs.start + 0x1000, b) #- block #1 -#
end
# switch to safeboot `factory` partition # switch to safeboot `factory` partition
def switch_factory(force_ota) def switch_factory(force_ota)
import flash import flash