partition_table: Add warning when partitions are nearly full

This adds a warning in cases where the smallest partition is nearly full.
A test with a specially crafted partition table is created for the smallest partition warning.
If the threshold or the template itself change, change the factory app partition size as well.
This commit is contained in:
Djordje Nedic 2022-04-26 17:24:24 +02:00 committed by BOT
parent 57e1a52a1e
commit e09ef86d7c
2 changed files with 15 additions and 2 deletions

View File

@ -77,8 +77,12 @@ def check_partition(ptype, subtype, partition_table_file, bin_file): # type: (s
smallest_size = min(p.size for p in partitions)
if smallest_size >= bin_size:
free_size = smallest_size - bin_size
print('{} binary size {:#x} bytes. Smallest {} partition is {:#x} bytes. {:#x} bytes ({}%) free.'.format(
bin_name, bin_size, ptype_str, smallest_size, free_size, round(free_size * 100 / smallest_size)))
free_size_relative = free_size / smallest_size
print('{} binary size {:#x} bytes. Smallest {} partition is {:#x} bytes. {:#x} bytes ({:.0%}) free.'.format(
bin_name, bin_size, ptype_str, smallest_size, free_size, free_size_relative))
free_size_relative_critical = 0.05
if free_size_relative < free_size_relative_critical:
print('Warning: The smallest {} partition is nearly full ({:.0%} free space left)!'.format(ptype_str, free_size_relative))
return
too_small_partitions = [p for p in partitions if p.size < bin_size]

View File

@ -814,6 +814,15 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
( idf.py build 2>&1 | grep "does not fit in configured flash size 1MB" ) || failure "Build didn't fail with expected flash size failure message"
mv sdkconfig.bak sdkconfig
print_status "Warning is given if smallest partition is nearly full"
clean_build_dir
cp ${IDF_PATH}/components/partition_table/partitions_singleapp.csv partitions.csv
${SED} -i "s/factory, app, factory, , 1M/factory, app, factory, , 170K/" partitions.csv
echo "CONFIG_PARTITION_TABLE_CUSTOM=y" > sdkconfig
( idf.py build 2>&1 | grep "partition is nearly full" ) || failure "No warning for nearly full smallest partition was given when the condition is fulfilled"
rm -f partitions.csv sdkconfig
( idf.py build 2>&1 | grep "partition is nearly full" ) && failure "Warning for nearly full smallest partition was given when the condition is not fulfilled"
print_status "Flash size is correctly set in the bootloader image header"
# Build with the default 2MB setting
rm sdkconfig