Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabling a partition in front of partition table (IDFGH-11338) #12486

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/esp_partition/partition_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ bool esp_partition_is_flash_region_writable(size_t addr, size_t size)

bool esp_partition_main_flash_region_safe(size_t addr, size_t size)
{
if (addr <= ESP_PARTITION_TABLE_OFFSET + ESP_PARTITION_TABLE_MAX_LEN) {
if ((addr < ESP_PARTITION_TABLE_OFFSET + ESP_PARTITION_TABLE_MAX_LEN) && ((addr + size) > ESP_PARTITION_TABLE_OFFSET)) {
return false;
}
const esp_partition_t *p = esp_ota_get_running_partition();
Expand Down
5 changes: 3 additions & 2 deletions components/partition_table/gen_esp32part.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ def expand_vars(f):
# fix up missing offsets & negative sizes
last_end = offset_part_table + PARTITION_TABLE_SIZE # first offset after partition table
for e in res:
if e.offset is not None and e.offset < last_end:
if e.offset is not None and e.offset < last_end and e.offset + e.size > offset_part_table:

if e == res[0]:
raise InputError('CSV Error at line %d: Partitions overlap. Partition sets offset 0x%x. '
'But partition table occupies the whole sector 0x%x. '
Expand Down Expand Up @@ -260,7 +261,7 @@ def verify(self):
# check for overlaps
last = None
for p in sorted(self, key=lambda x:x.offset):
if p.offset < offset_part_table + PARTITION_TABLE_SIZE:
if p.offset < offset_part_table + PARTITION_TABLE_SIZE and p.offset + p.size > offset_part_table:
raise InputError('Partition offset 0x%x is below 0x%x' % (p.offset, offset_part_table + PARTITION_TABLE_SIZE))
if last is not None and p.offset < last.offset + last.size:
raise InputError('Partition at 0x%x overlaps 0x%x-0x%x' % (p.offset, last.offset, last.offset + last.size - 1))
Expand Down