Merge pull request #16453 from s-hadinger/berry_strict_1

Berry fix for stricter mode
This commit is contained in:
s-hadinger 2022-09-06 23:09:56 +02:00 committed by GitHub
commit c1f8ef6909
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 817 additions and 839 deletions

View File

@ -471,7 +471,7 @@ static void new_var(bparser *parser, bstring *name, bexpdesc *var)
bfuncinfo *finfo = parser->finfo; bfuncinfo *finfo = parser->finfo;
if (comp_is_strict(parser->vm)) { if (comp_is_strict(parser->vm)) {
/* check if we are masking a builtin */ /* check if we are masking a builtin */
if (be_builtin_class_find(parser->vm, name) >= 0) { if (be_builtin_find(parser->vm, name) >= 0) {
push_error(parser, "strict: redefinition of builtin '%s'", str(name)); push_error(parser, "strict: redefinition of builtin '%s'", str(name));
} }
} }

View File

@ -132,21 +132,6 @@ int be_builtin_find(bvm *vm, bstring *name)
return -1; /* not found */ return -1; /* not found */
} }
/* find in the list of builtins or classes - used by strict to avoid accidental change of those */
int be_builtin_class_find(bvm *vm, bstring *name)
{
bvalue *res = be_map_findstr(vm, builtin(vm).vtab, name);
if (res) {
return var_toidx(res);
} else {
int idx = global_native_class_find(vm, name);
if (idx >= 0) {
return idx;
}
}
return -1; /* not found */
}
bstring* be_builtin_name(bvm *vm, int index) bstring* be_builtin_name(bvm *vm, int index)
{ {
bmap *map = builtin(vm).vtab; bmap *map = builtin(vm).vtab;

View File

@ -23,7 +23,6 @@ int be_global_new(bvm *vm, bstring *name);
bvalue* be_global_var(bvm *vm, int index); bvalue* be_global_var(bvm *vm, int index);
void be_global_release_space(bvm *vm); void be_global_release_space(bvm *vm);
int be_builtin_find(bvm *vm, bstring *name); int be_builtin_find(bvm *vm, bstring *name);
int be_builtin_class_find(bvm *vm, bstring *name);
bstring* be_builtin_name(bvm *vm, int index); bstring* be_builtin_name(bvm *vm, int index);
int be_builtin_new(bvm *vm, bstring *name); int be_builtin_new(bvm *vm, bstring *name);
void be_bulitin_release_space(bvm *vm); void be_bulitin_release_space(bvm *vm);

View File

@ -105,7 +105,7 @@ struct bvm {
struct bgc gc; struct bgc gc;
bctypefunc ctypefunc; /* handler to ctype_func */ bctypefunc ctypefunc; /* handler to ctype_func */
bbyte compopt; /* compilation options */ bbyte compopt; /* compilation options */
uint32_t bytesmaxsize; /* max allowed size for bytes() object, default 32kb but can be increased */ int32_t bytesmaxsize; /* max allowed size for bytes() object, default 32kb but can be increased */
bobshook obshook; bobshook obshook;
bmicrosfnct microsfnct; /* fucntion to get time as a microsecond resolution */ bmicrosfnct microsfnct; /* fucntion to get time as a microsecond resolution */
#if BE_USE_PERF_COUNTERS #if BE_USE_PERF_COUNTERS

View File

@ -18,7 +18,7 @@ extern "C" {
#endif #endif
/* do not modify the version number! */ /* do not modify the version number! */
#define BERRY_VERSION "1.0.0" #define BERRY_VERSION "1.1.0"
#if BE_STACK_TOTAL_MAX < BE_STACK_FREE_MIN * 2 #if BE_STACK_TOTAL_MAX < BE_STACK_FREE_MIN * 2
#error "The value of the macro BE_STACK_TOTAL_MAX is too small." #error "The value of the macro BE_STACK_TOTAL_MAX is too small."

View File

@ -1,9 +1,9 @@
import os import os
def strfind(str, char) def strfind(st, char)
var len = size(str) var len = size(st)
for i : 0 .. len - 1 for i : 0 .. len - 1
if str[i] == char if st[i] == char
return true return true
end end
end end

View File

@ -2,22 +2,13 @@
def assert_syntax_error(code) def assert_syntax_error(code)
try try
f = compile(code) var f = compile(code)
assert(false, 'unexpected execution flow') assert(false, 'unexpected execution flow')
except .. as e, m except .. as e, m
assert(e == 'syntax_error') assert(e == 'syntax_error')
end end
end end
def assert_attribute_error(f)
try
f()
assert(false, 'unexpected execution flow')
except .. as e, m
assert(e == 'attribute_error')
end
end
def findinlist(l, e) def findinlist(l, e)
var i
for i: 0..size(l)-1 for i: 0..size(l)-1
if l[i] == e return i end if l[i] == e return i end
end end
@ -42,8 +33,8 @@ global.global_c = 3
f = compile("return global_c") f = compile("return global_c")
assert(f() == 3) assert(f() == 3)
#- check that access to non-existent global returns an exception -# #- check that access to non-existent global returns nil (new behavior) -#
assert_attribute_error(/-> global.d) assert(global.d == nil)
#- check the glbal list -# #- check the glbal list -#
assert(findinlist(global(), 'global_a') != nil) assert(findinlist(global(), 'global_a') != nil)

View File

@ -12,10 +12,10 @@ assert(os.path.join('abc', '/de', 'fghij') == '/de/fghij')
assert(os.path.join('abc', 'xyz', '/de', 'fghij') == '/de/fghij') assert(os.path.join('abc', 'xyz', '/de', 'fghij') == '/de/fghij')
# os.path.split test # os.path.split test
def split(str, list) def split(st, lst)
var res = os.path.split(str) var res = os.path.split(st)
assert(res[0] == list[0] && res[1] == list[1], assert(res[0] == lst[0] && res[1] == lst[1],
'unexpected results: ' .. res .. ', reference value: ' .. list) 'unexpected results: ' .. res .. ', reference value: ' .. lst)
end end
split('/', ['/', '']) split('/', ['/', ''])
@ -31,10 +31,10 @@ split('abcd////ef/////', ['abcd////ef', ''])
split('abcd////ef', ['abcd', 'ef']) split('abcd////ef', ['abcd', 'ef'])
# os.path.splitext test # os.path.splitext test
def splitext(str, list) def splitext(st, lst)
var res = os.path.splitext(str) var res = os.path.splitext(st)
assert(res[0] == list[0] && res[1] == list[1], assert(res[0] == lst[0] && res[1] == lst[1],
'unexpected results: ' .. res .. ', reference value: ' .. list) 'unexpected results: ' .. res .. ', reference value: ' .. lst)
end end
splitext('a.b', ['a', '.b']) splitext('a.b', ['a', '.b'])

File diff suppressed because it is too large Load Diff

View File

@ -4,12 +4,12 @@
class Wire class Wire
var bus var bus
def read_bytes(addr,reg,size) def read_bytes(addr,reg,sz)
self._begin_transmission(addr) self._begin_transmission(addr)
self._write(reg) self._write(reg)
self._end_transmission(false) self._end_transmission(false)
self._request_from(addr,size) self._request_from(addr,sz)
var ret=bytes(size) var ret=bytes(sz)
while (self._available()) while (self._available())
ret..self._read() ret..self._read()
end end

View File

@ -29,23 +29,25 @@ class FT3663 : I2C_Driver
def init() def init()
super(self).init("FT3663", 0x38) super(self).init("FT3663", 0x38)
# check that ID from register 0xA8 is 0x11 # check that ID from register 0xA8 is 0x11
var vendid = self.read8(0xA8) if self.wire
var chipid = self.read8(0xA3) var vendid = self.read8(0xA8)
if vendid != 0x11 || chipid != 0x64 var chipid = self.read8(0xA3)
tasmota.log("I2C: ignoring address 0x38, not FT3663", 2) if vendid != 0x11 || chipid != 0x64
self.wire = nil tasmota.log("I2C: ignoring address 0x38, not FT3663", 2)
return self.wire = nil
return
end
# FT3663 is now confirmed
tasmota.log("TS : FT3663 Touch Screen detected")
self.write8(0x00, 0x00) # writeRegister8(FT6X36_REG_DEVICE_MODE, 0x00);
self.write8(0x80, 22) # writeRegister8(FT6X36_REG_THRESHHOLD, FT6X36_DEFAULT_THRESHOLD);
self.write8(0x88, 0x0E) # writeRegister8(FT6X36_REG_TOUCHRATE_ACTIVE, 0x0E);
# register ourself
tasmota.add_driver(self)
end end
# FT3663 is now confirmed
tasmota.log("TS : FT3663 Touch Screen detected")
self.write8(0x00, 0x00) # writeRegister8(FT6X36_REG_DEVICE_MODE, 0x00);
self.write8(0x80, 22) # writeRegister8(FT6X36_REG_THRESHHOLD, FT6X36_DEFAULT_THRESHOLD);
self.write8(0x88, 0x0E) # writeRegister8(FT6X36_REG_TOUCHRATE_ACTIVE, 0x0E);
# register ourself
tasmota.add_driver(self)
end end
# read touch screen and publish result # read touch screen and publish result

View File

@ -4,7 +4,7 @@
# Native commands # Native commands
# 00 : ctor (leds:int, gpio:int[, type:int, rmt:int]) -> void # 00 : ctor (leds:int, gpio:int[, typ:int, rmt:int]) -> void
# 01 : begin void -> void # 01 : begin void -> void
# 02 : show void -> void # 02 : show void -> void
# 03 : CanShow void -> bool # 03 : CanShow void -> bool
@ -28,9 +28,9 @@ class Leds : Leds_ntv
var leds # number of leds var leds # number of leds
# leds:int = number of leds of the strip # leds:int = number of leds of the strip
# gpio:int (optional) = GPIO for NeoPixel. If not specified, takes the WS2812 gpio # gpio:int (optional) = GPIO for NeoPixel. If not specified, takes the WS2812 gpio
# type:int (optional) = Type of LED, defaults to WS2812 RGB # typ:int (optional) = Type of LED, defaults to WS2812 RGB
# rmt:int (optional) = RMT hardware channel to use, leave default unless you have a good reason # rmt:int (optional) = RMT hardware channel to use, leave default unless you have a good reason
def init(leds, gpio_phy, type, rmt) # rmt is optional def init(leds, gpio_phy, typ, rmt) # rmt is optional
self.gamma = true # gamma is enabled by default, it should be disabled explicitly if needed self.gamma = true # gamma is enabled by default, it should be disabled explicitly if needed
self.leds = int(leds) self.leds = int(leds)
@ -40,7 +40,7 @@ class Leds : Leds_ntv
end end
# initialize the structure # initialize the structure
self.ctor(self.leds, gpio_phy, type, rmt) self.ctor(self.leds, gpio_phy, typ, rmt)
if self._p == nil raise "internal_error", "couldn't not initialize noepixelbus" end if self._p == nil raise "internal_error", "couldn't not initialize noepixelbus" end
@ -92,14 +92,14 @@ class Leds : Leds_ntv
self.show() self.show()
end end
def ctor(leds, gpio_phy, type, rmt) def ctor(leds, gpio_phy, typ, rmt)
if type == nil if typ == nil
type = self.WS2812_GRB typ = self.WS2812_GRB
end end
if rmt == nil if rmt == nil
rmt = self.assign_rmt(gpio_phy) rmt = self.assign_rmt(gpio_phy)
end end
self.call_native(0, leds, gpio_phy, type, rmt) self.call_native(0, leds, gpio_phy, typ, rmt)
end end
def begin() def begin()
self.call_native(1) self.call_native(1)

View File

@ -30,7 +30,7 @@ class Partition_info
var type var type
var subtype var subtype
var start var start
var size var sz
var label var label
var flags var flags
@ -54,7 +54,7 @@ class Partition_info
self.type = 0 self.type = 0
self.subtype = 0 self.subtype = 0
self.start = 0 self.start = 0
self.size = 0 self.sz = 0
self.label = '' self.label = ''
self.flags = 0 self.flags = 0
@ -69,7 +69,7 @@ class Partition_info
self.type = raw.get(2,1) self.type = raw.get(2,1)
self.subtype = raw.get(3,1) self.subtype = raw.get(3,1)
self.start = raw.get(4,4) self.start = raw.get(4,4)
self.size = raw.get(8,4) self.sz = raw.get(8,4)
self.label = self.remove_trailing_zeroes(raw[12..27]).asstring() self.label = self.remove_trailing_zeroes(raw[12..27]).asstring()
self.flags = raw.get(28,4) self.flags = raw.get(28,4)
@ -109,7 +109,7 @@ class Partition_info
if self.is_ota() == nil && !self.is_factory() return -1 end if self.is_ota() == nil && !self.is_factory() return -1 end
try try
var addr = self.start var addr = self.start
var size = self.size var sz = self.sz
var magic_byte = flash.read(addr, 1).get(0, 1) var magic_byte = flash.read(addr, 1).get(0, 1)
if magic_byte != 0xE9 return -1 end if magic_byte != 0xE9 return -1 end
@ -124,10 +124,10 @@ class Partition_info
var segment_header = flash.read(seg_offset - 8, 8) var segment_header = flash.read(seg_offset - 8, 8)
var seg_start_addr = segment_header.get(0, 4) var seg_start_addr = segment_header.get(0, 4)
var seg_size = segment_header.get(4,4) var seg_size = segment_header.get(4,4)
# print(string.format("Segment %i: flash_offset=0x%08X start_addr=0x%08X size=0x%08X", seg_num, seg_offset, seg_start_addr, seg_size)) # print(string.format("Segment %i: flash_offset=0x%08X start_addr=0x%08X sz=0x%08X", seg_num, seg_offset, seg_start_addr, seg_size))
seg_offset += seg_size + 8 # add segment_length + sizeof(esp_image_segment_header_t) seg_offset += seg_size + 8 # add segment_length + sizeof(esp_image_segment_header_t)
if seg_offset >= (addr + size) return -1 end if seg_offset >= (addr + sz) return -1 end
seg_num += 1 seg_num += 1
end end
@ -186,7 +186,7 @@ class Partition_info
return string.format("<instance: Partition_info(%d%s,%d%s,0x%08X,0x%08X,'%s',0x%X)>", return string.format("<instance: Partition_info(%d%s,%d%s,0x%08X,0x%08X,'%s',0x%X)>",
self.type, type_s, self.type, type_s,
self.subtype, subtype_s, self.subtype, subtype_s,
self.start, self.size, self.start, self.sz,
self.label, self.flags) self.label, self.flags)
end end
@ -197,7 +197,7 @@ class Partition_info
b.add(self.type, 1) b.add(self.type, 1)
b.add(self.subtype, 1) b.add(self.subtype, 1)
b.add(self.start, 4) b.add(self.start, 4)
b.add(self.size, 4) b.add(self.sz, 4)
var label = bytes().fromstring(self.label) var label = bytes().fromstring(self.label)
label.resize(16) label.resize(16)
b = b + label b = b + label

View File

@ -15,7 +15,7 @@ uint8 = ctypes.u8
uint16 = ctypes.u16 uint16 = ctypes.u16
uint32 = ctypes.u32 uint32 = ctypes.u32
int32 = ctypes.i32 int32 = ctypes.i32
bool = ctypes.u8 bol = ctypes.u8
energy_struct = [ energy_struct = [
[float, "voltage"], [float, "voltage"],
@ -80,16 +80,16 @@ energy_struct = [
[uint8, "phase_count"], [uint8, "phase_count"],
[bool, "voltage_common"], [bol, "voltage_common"],
[bool, "frequency_common"], [bol, "frequency_common"],
[bool, "use_overtemp"], [bol, "use_overtemp"],
[bool, "today_offset_init_kwh"], [bol, "today_offset_init_kwh"],
[bool, "voltage_available"], [bol, "voltage_available"],
[bool, "current_available"], [bol, "current_available"],
[bool, "type_dc"], [bol, "type_dc"],
[bool, "power_on"], [bol, "power_on"],
# #ifdef USE_ENERGY_MARGIN_DETECTION # #ifdef USE_ENERGY_MARGIN_DETECTION
[uint16, "power_history_0"], [uint16, "power_history_0"],
[uint16, "power_history_0_2"], [uint16, "power_history_0_2"],
@ -103,12 +103,12 @@ energy_struct = [
[uint8, "power_steady_counter"], [uint8, "power_steady_counter"],
[bool, "min_power_flag"], [bol, "min_power_flag"],
[bool, "max_power_flag"], [bol, "max_power_flag"],
[bool, "min_voltage_flag"], [bol, "min_voltage_flag"],
[bool, "max_voltage_flag"], [bol, "max_voltage_flag"],
[bool, "min_current_flag"], [bol, "min_current_flag"],
[bool, "max_current_flag"], [bol, "max_current_flag"],
# #ifdef USE_ENERGY_POWER_LIMIT # #ifdef USE_ENERGY_POWER_LIMIT
[uint16, "mplh_counter"], [uint16, "mplh_counter"],

View File

@ -62,7 +62,7 @@ class Partition_wizard_UI
if last_slot.is_spiffs() if last_slot.is_spiffs()
# verify that last slot is filesystem # verify that last slot is filesystem
var flash_size_k = self.get_max_flash_size_k(p) var flash_size_k = self.get_max_flash_size_k(p)
var partition_end_k = (last_slot.start + last_slot.size) / 1024 # last kb used for fs var partition_end_k = (last_slot.start + last_slot.sz) / 1024 # last kb used for fs
if partition_end_k < flash_size_k if partition_end_k < flash_size_k
return flash_size_k - partition_end_k return flash_size_k - partition_end_k
end end
@ -143,7 +143,7 @@ class Partition_wizard_UI
def get_cur_fs_size_k(p) def get_cur_fs_size_k(p)
var last_slot = p.slots[-1] var last_slot = p.slots[-1]
if last_slot.is_spiffs() # verify that last slot is filesystem if last_slot.is_spiffs() # verify that last slot is filesystem
return (last_slot.size + 1023) / 1024 return (last_slot.sz + 1023) / 1024
end end
return 0 return 0
end end
@ -265,7 +265,7 @@ class Partition_wizard_UI
var app0 = p.get_ota_slot(0) var app0 = p.get_ota_slot(0)
var app1 = p.get_ota_slot(0) var app1 = p.get_ota_slot(0)
var app0_firmware_size = (app0 != nil) ? app0.get_image_size() : -1 var app0_firmware_size = (app0 != nil) ? app0.get_image_size() : -1
var app1_size = (app1 != nil) ? app1.size : -1 var app1_size = (app1 != nil) ? app1.sz : -1
if app0_firmware_size < 0 || app1_size < 0 return "can't find app0/1 sizes" end if app0_firmware_size < 0 || app1_size < 0 return "can't find app0/1 sizes" end
if app0_firmware_size >= app1_size return "`app1` is too small" end if app0_firmware_size >= app1_size return "`app1` is too small" end
return false return false
@ -295,7 +295,7 @@ class Partition_wizard_UI
if !self.factory_migrate_eligible(p) return "not eligible to migration" end if !self.factory_migrate_eligible(p) return "not eligible to migration" end
var app0 = p.get_ota_slot(0) var app0 = p.get_ota_slot(0)
if app0.size < (self.app_size_min * 1024) return "`app0` is too small for `safeboot`" end if app0.sz < (self.app_size_min * 1024) return "`app0` is too small for `safeboot`" end
var app0_image_size = app0.get_image_size() var app0_image_size = app0.get_image_size()
if (app0_image_size > 0) && (app0_image_size < (self.app_size_min * 1024)) return true end if (app0_image_size > 0) && (app0_image_size < (self.app_size_min * 1024)) return true end
return false return false
@ -347,13 +347,13 @@ class Partition_wizard_UI
# if app0.get_image_size() > (self.app_size_min * 1024) return "`app0` is too small for `safeboot`" end # if app0.get_image_size() > (self.app_size_min * 1024) return "`app0` is too small for `safeboot`" end
end end
static def copy_ota(from_addr, to_addr, size) static def copy_ota(from_addr, to_addr, sz)
import flash import flash
import string import string
var size_left = size var size_left = sz
var offset = 0 var offset = 0
tasmota.log(string.format("UPL: Copy flash from 0x%06X to 0x%06X (size: %ikB)", from_addr, to_addr, size / 1024), 2) tasmota.log(string.format("UPL: Copy flash from 0x%06X to 0x%06X (size: %ikB)", from_addr, to_addr, sz / 1024), 2)
while size_left > 0 while size_left > 0
var b = flash.read(from_addr + offset, 4096) var b = flash.read(from_addr + offset, 4096)
flash.erase(to_addr + offset, 4096) flash.erase(to_addr + offset, 4096)
@ -376,7 +376,7 @@ class Partition_wizard_UI
var app0 = p.get_ota_slot(0) var app0 = p.get_ota_slot(0)
var app1 = p.get_ota_slot(1) var app1 = p.get_ota_slot(1)
var app0_size = app0.get_image_size() var app0_size = app0.get_image_size()
if app0_size > app1.size raise "internal_error", "`app1` too small to copy firmware form `app0`" end if app0_size > app1.sz raise "internal_error", "`app1` too small to copy firmware form `app0`" end
self.copy_ota(app0.start, app1.start, app0_size) self.copy_ota(app0.start, app1.start, app0_size)
p.set_active(1) p.set_active(1)
@ -433,14 +433,14 @@ class Partition_wizard_UI
# do the change # do the change
app0.subtype = 0 # factory subtype app0.subtype = 0 # factory subtype
app0.size = factory_size app0.sz = factory_size
app0.label = 'safeboot' app0.label = 'safeboot'
app1.subtype = 0x10 # app1 becomes app0 app1.subtype = 0x10 # app1 becomes app0
app1.label = 'app0' app1.label = 'app0'
var f1_start = app1.start var f1_start = app1.start
app1.start = app0.start + factory_size app1.start = app0.start + factory_size
app1.size += f1_start - app1.start app1.sz += f1_start - app1.start
# swicth partitions # swicth partitions
p.set_active(0) p.set_active(0)
@ -526,10 +526,10 @@ class Partition_wizard_UI
var usage_str = "unknown" var usage_str = "unknown"
var used = slot.get_image_size() var used = slot.get_image_size()
if (used >= 0) && (used <= slot.size) if (used >= 0) && (used <= slot.sz)
usage_str = string.format("used %i%%", ((used / 1024) * 100) / (slot.size / 1024)) usage_str = string.format("used %i%%", ((used / 1024) * 100) / (slot.sz / 1024))
end end
var title = string.format("%ssubtype:%s offset:0x%06X size:0x%06X", current_boot_partition ? "booted " : "", slot.subtype_to_string(), slot.start, slot.size) var title = string.format("%ssubtype:%s offset:0x%06X size:0x%06X", current_boot_partition ? "booted " : "", slot.subtype_to_string(), slot.start, slot.sz)
var col_before = "" var col_before = ""
var col_after = "" var col_after = ""
if current_boot_partition if current_boot_partition
@ -538,11 +538,11 @@ class Partition_wizard_UI
end end
# webserver.content_send(string.format("<p><b>%s</b> [%s]: %i KB (%s)</p>", slot.label, slot.subtype_to_string(), slot.size / 1024, usage_str)) # webserver.content_send(string.format("<p><b>%s</b> [%s]: %i KB (%s)</p>", slot.label, slot.subtype_to_string(), slot.size / 1024, usage_str))
webserver.content_send(string.format("<tr><td title='%s'><b>%s%s%s</b>:&nbsp;</td><td align='right'> %i KB </td><td>&nbsp;(%s)</td></tr>", webserver.content_send(string.format("<tr><td title='%s'><b>%s%s%s</b>:&nbsp;</td><td align='right'> %i KB </td><td>&nbsp;(%s)</td></tr>",
title, col_before, slot.label, col_after, slot.size / 1024, usage_str)) title, col_before, slot.label, col_after, slot.sz / 1024, usage_str))
elif slot.is_spiffs() elif slot.is_spiffs()
# spiffs partition # spiffs partition
var title = string.format("subtype:%s offset:0x%06X size:0x%06X", slot.subtype_to_string(), slot.start, slot.size) var title = string.format("subtype:%s offset:0x%06X size:0x%06X", slot.subtype_to_string(), slot.start, slot.sz)
webserver.content_send(string.format("<tr><td title='%s'><b>fs</b>:&nbsp;</td><td align='right'> %i KB</td></tr>", title, slot.size / 1024)) webserver.content_send(string.format("<tr><td title='%s'><b>fs</b>:&nbsp;</td><td align='right'> %i KB</td></tr>", title, slot.sz / 1024))
end end
end end
@ -550,7 +550,7 @@ class Partition_wizard_UI
if unallocated > 0 if unallocated > 0
var last_slot = p.slots[-1] var last_slot = p.slots[-1]
# verify that last slot is file-system # verify that last slot is file-system
var partition_end_k = (last_slot.start + last_slot.size) / 1024 # last kb used for fs var partition_end_k = (last_slot.start + last_slot.sz) / 1024 # last kb used for fs
webserver.content_send(string.format("<tr><td title='offset:0x%06X size:0x%06X'>&lt;free&gt;:&nbsp;</td><td align='right'> %i KB</td></tr>", webserver.content_send(string.format("<tr><td title='offset:0x%06X size:0x%06X'>&lt;free&gt;:&nbsp;</td><td align='right'> %i KB</td></tr>",
partition_end_k * 1024, unallocated * 1024, unallocated)) partition_end_k * 1024, unallocated * 1024, unallocated))
end end
@ -621,7 +621,7 @@ class Partition_wizard_UI
# since unallocated succeeded, we know the last slot is FS # since unallocated succeeded, we know the last slot is FS
var fs_slot = p.slots[-1] var fs_slot = p.slots[-1]
fs_slot.size += unallocated * 1024 fs_slot.sz += unallocated * 1024
p.save() p.save()
p.invalidate_spiffs() # erase SPIFFS or data is corrupt p.invalidate_spiffs() # erase SPIFFS or data is corrupt
@ -649,12 +649,12 @@ class Partition_wizard_UI
# apply the change # apply the change
# shrink last OTA App # shrink last OTA App
var delta = (fs_target * 1024) - fs.size var delta = (fs_target * 1024) - fs.sz
last_app.size -= delta last_app.sz -= delta
# move fs # move fs
fs.start -= delta fs.start -= delta
fs.size += delta fs.sz += delta
p.save() p.save()
p.invalidate_spiffs() p.invalidate_spiffs()