Merge branch 'feature/parttable_improve_doc_and_error' into 'master'

partition_table: Improve an error msg and doc

Closes IDFGH-8377

See merge request espressif/esp-idf!20687
This commit is contained in:
Konstantin Kondrashov
2022-10-24 16:17:34 +08:00
3 changed files with 19 additions and 4 deletions
+5 -3
View File
@@ -175,10 +175,12 @@ class PartitionTable(list):
for e in res:
if e.offset is not None and e.offset < last_end:
if e == res[0]:
raise InputError('CSV Error: First partition offset 0x%x overlaps end of partition table 0x%x'
% (e.offset, last_end))
raise InputError('CSV Error at line %d: Partitions overlap. Partition sets offset 0x%x. '
'But partition table occupies the whole sector 0x%x. '
'Use a free offset 0x%x or higher.'
% (e.line_no, e.offset, offset_part_table, last_end))
else:
raise InputError('CSV Error: Partitions overlap. Partition at line %d sets offset 0x%x. Previous partition ends 0x%x'
raise InputError('CSV Error at line %d: Partitions overlap. Partition sets offset 0x%x. Previous partition ends 0x%x'
% (e.line_no, e.offset, last_end))
if e.offset is None:
pad_to = get_alignment_for_type(e.type)
@@ -409,6 +409,16 @@ factory, app, factory, , 1M,
t = gen_esp32part.PartitionTable.from_csv(csv)
t.verify()
def test_overlap_part_table(self):
csv = """
# Name,Type, SubType,Offset,Size
nvs, data, nvs, 0x0000, 0x6000,
phy_init, data, phy, , 0x1000,
factory, app, factory, , 1M,
"""
with self.assertRaisesRegex(gen_esp32part.InputError, r'CSV Error at line 3: Partitions overlap. Partition sets offset 0x0'):
gen_esp32part.PartitionTable.from_csv(csv)
def test_only_one_otadata(self):
csv_txt = """
# Name,Type, SubType,Offset,Size