mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
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:
parent
57e1a52a1e
commit
e09ef86d7c
@ -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]
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user