Skip to content

Commit

Permalink
Bring back invalidate_spiffs() (#20184)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hadinger authored Dec 6, 2023
1 parent ddb1177 commit 40ed8aa
Show file tree
Hide file tree
Showing 3 changed files with 702 additions and 621 deletions.
13 changes: 13 additions & 0 deletions lib/libesp32/berry_tasmota/src/embedded/partition_core.be
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,19 @@ class Partition
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
def switch_factory(force_ota)
import flash
Expand Down
13 changes: 13 additions & 0 deletions lib/libesp32/berry_tasmota/src/embedded/partition_core_shelly.be
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,19 @@ class Partition
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
def switch_factory(force_ota)
import flash
Expand Down
Loading

0 comments on commit 40ed8aa

Please sign in to comment.