mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 10:46:31 +00:00
Added features
This commit is contained in:
parent
247db4f360
commit
032ca2f56c
@ -119,6 +119,42 @@ class Partition_info
|
||||
end
|
||||
end
|
||||
|
||||
# check if the parition is a SPIFFS partition
|
||||
# returns bool
|
||||
def is_spiffs()
|
||||
return self.type == 1 && self.subtype == 130
|
||||
end
|
||||
|
||||
# get the actual image size give of the partition
|
||||
# returns -1 if the partition is not an app ota partition
|
||||
def get_image_size()
|
||||
if self.is_ota() == nil return -1 end
|
||||
var addr = self.start
|
||||
var magic_byte = flash.read(addr, 1).get(0, 1)
|
||||
if magic_byte != 0xE9 raise "internal_error", string.format("Invalid magic_byte 0x%02X (should be 0xE9)", magic_byte) end
|
||||
|
||||
var seg_count = flash.read(addr+1, 1).get(0, 1)
|
||||
# print("Segment count", seg_count)
|
||||
|
||||
var seg_offset = addr + 0x20 # sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) = 24 + 8
|
||||
var seg_size = 0
|
||||
|
||||
for seg_num:0..seg_count-1
|
||||
# print(string.format("Reading 0x%08X", seg_offset))
|
||||
var segment_header = flash.read(seg_offset - 8, 8)
|
||||
var seg_start_addr = segment_header.get(0, 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))
|
||||
|
||||
seg_offset += seg_size + 8 # add segment_length + sizeof(esp_image_segment_header_t)
|
||||
end
|
||||
var total_size = seg_offset - addr + 1 # add 1KB for safety
|
||||
|
||||
# print(string.format("Total size = %i KB", total_size/1024))
|
||||
|
||||
return total_size
|
||||
end
|
||||
|
||||
def tostring()
|
||||
import string
|
||||
var type_s = ""
|
||||
|
@ -63,7 +63,7 @@ class Partition_manager : Driver
|
||||
if ota_num != nil
|
||||
# we have an OTA partition
|
||||
self.page_show_partition(slot, ota_num == p.otadata.active_otadata)
|
||||
elif slot.type == 1 && slot.subtype == 130
|
||||
elif slot.is_spiffs()
|
||||
var flash_size = tasmota.memory()['flash'] * 1024
|
||||
var used_size = (slot.start + slot.size)
|
||||
self.page_show_spiffs(slot, slot == p.slots[-1] ? flash_size - used_size : nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user