Skip to content

Commit

Permalink
Partition Wizard is now able to convert to safeboot from Shelly parti…
Browse files Browse the repository at this point in the history
…tion layout (#19034)
  • Loading branch information
s-hadinger authored Jul 5, 2023
1 parent 41de111 commit 4927595
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
- Support for SGP41 TVOC/NOx Sensor (#18880)
- Command ``BrRestart`` to restart the Berry VM (experimental) (#19003)
- Command ``Restart 9`` to save all changes and go into deepsleep waiting for a reset (#19024)
- Partition Wizard is now able to convert to safeboot from Shelly partition layout

### Breaking Changed
- Berry `bool( [] )` and `bool( {} )` now evaluate as `false` (#18986)
Expand Down
Binary file modified tasmota/berry/modules/Partition_Wizard.tapp
Binary file not shown.
Binary file modified tasmota/berry/modules/Partition_Wizard/partition_wizard.bec
Binary file not shown.
25 changes: 19 additions & 6 deletions tasmota/berry/modules/partition_wizard.be
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class Partition_wizard_UI
# `app0` renamed to `safeboot`
# `app0` changed subtype to `factory`
# `app1` moved to right after `factory` and resized
# `app1` chaned subtype to `app0` and renamed `app0`
# `app1` changed subtype to `app0` and renamed `app0`
#
# Returns:
# - false if READY
Expand Down Expand Up @@ -413,16 +413,29 @@ class Partition_wizard_UI

var step3_state = self.test_step_3(p)
if step3_state == true return true end
if type(step3_state) == 'string)' raise "internal_error", step3_state end
if type(step3_state) == 'string' raise "internal_error", step3_state end

var app0 = p.get_ota_slot(0)
var app1 = p.get_ota_slot(1)
if app0 == nil || app1 == nil raise "internal_error", "there are no `app0` or `app1` partitions" end
var factory_size = self.app_size_min * 1024

var firm0_size = app0.get_image_size()
if firm0_size <= 0 raise "internal_error", "invalid size in app0 partition" end
if firm0_size >= factory_size raise "internal_error", "app0 partition is too big for factory" end
do # open new scope
var firm0_size = app0.get_image_size() # get the size of the partition holding safeboot and check values
if firm0_size <= 0 raise "internal_error", "invalid size in app0 partition" end
if firm0_size >= factory_size raise "internal_error", "app0 partition is too big for factory" end
end

# remove any SPIFFS partition that is not at the end of the partition table
var idx = 1
while idx < size(p.slots) - 1 # skip explicitly the last partition
if p.slots[idx].is_spiffs()
p.slots.remove(idx)
tasmota.log("UPL: removesd unused SPIFFS partition", 2)
else
idx += 1
end
end

# do the change
app0.subtype = 0 # factory subtype
Expand Down Expand Up @@ -621,7 +634,7 @@ class Partition_wizard_UI
# Resize FS to arbitrary size
#---------------------------------------------------------------------#
elif webserver.has_arg("resize_fs")
if !self.has_factory_layout(p) raise "internal_error", "Device does not avec safeboot layout" end
if !self.has_factory_layout(p) raise "internal_error", "Device does not have safeboot layout" end

var fs = p.slots[-1]
var last_app = p.slots[-2]
Expand Down

0 comments on commit 4927595

Please # to comment.