diff --git a/components/partition_table/check_sizes.py b/components/partition_table/check_sizes.py index 8e9efac102..2045155143 100755 --- a/components/partition_table/check_sizes.py +++ b/components/partition_table/check_sizes.py @@ -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] diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 58930858e6..de456fa4b3 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -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