diff --git a/tools/ci/test_build_system.sh b/tools/ci/test_build_system.sh index ebe459dd5..0239a1029 100755 --- a/tools/ci/test_build_system.sh +++ b/tools/ci/test_build_system.sh @@ -288,6 +288,25 @@ function run_tests() ( make 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 "Flash size is correctly set in the bootloader image header" + # Build with the default 2MB setting + rm sdkconfig + make defconfig && make bootloader || failure "Failed to build bootloader" + bin_header_match build/bootloader/bootloader.bin "0210" + # Change to 4MB + echo "CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y" > sdkconfig + make defconfig && make bootloader || failure "Failed to build bootloader" + bin_header_match build/bootloader/bootloader.bin "0220" + # Change to QIO, bootloader should still be DIO (will change to QIO in 2nd stage bootloader) + echo "CONFIG_FLASHMODE_QIO=y" > sdkconfig + make defconfig && make bootloader || failure "Failed to build bootloader" + bin_header_match build/bootloader/bootloader.bin "0210" + # Change to 80 MHz + echo "CONFIG_ESPTOOLPY_FLASHFREQ_80M=y" > sdkconfig + make defconfig && make bootloader || failure "Failed to build bootloader" + bin_header_match build/bootloader/bootloader.bin "021f" + rm sdkconfig + print_status "sdkconfig should have contents of all files: sdkconfig, sdkconfig.defaults, sdkconfig.defaults.IDF_TARGET" make clean > /dev/null; rm -f sdkconfig.defaults; @@ -491,5 +510,17 @@ function clean_build_dir() rm -rf --preserve-root ${BUILD}/* } +# check the bytes 3-4 of the binary image header. e.g.: +# bin_header_match app.bin 0210 +function bin_header_match() +{ + expected=$2 + filename=$1 + actual=$(xxd -s 2 -l 2 -ps $1) + if [ ! "$expected" = "$actual" ]; then + failure "Incorrect binary image header, expected $expected got $actual" + fi +} + cd ${TESTDIR} run_tests diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 339aa008e..00b15274b 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -595,6 +595,31 @@ endmenu\n" >> ${IDF_PATH}/Kconfig rm idf_project.yml git checkout main/main.c + print_status "Build fails if partitions don't fit in flash" + sed -i.bak "s/CONFIG_ESPTOOLPY_FLASHSIZE.\+//" sdkconfig # remove all flashsize config + echo "CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y" >> sdkconfig # introduce undersize flash + ( 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 "Flash size is correctly set in the bootloader image header" + # Build with the default 2MB setting + rm sdkconfig + idf.py bootloader || failure "Failed to build bootloader" + bin_header_match build/bootloader/bootloader.bin "0210" + # Change to 4MB + echo "CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y" > sdkconfig + idf.py bootloader || failure "Failed to build bootloader" + bin_header_match build/bootloader/bootloader.bin "0220" + # Change to QIO, bootloader should still be DIO (will change to QIO in 2nd stage bootloader) + echo "CONFIG_FLASHMODE_QIO=y" > sdkconfig + idf.py bootloader || failure "Failed to build bootloader" + bin_header_match build/bootloader/bootloader.bin "0210" + # Change to 80 MHz + echo "CONFIG_ESPTOOLPY_FLASHFREQ_80M=y" > sdkconfig + idf.py bootloader || failure "Failed to build bootloader" + bin_header_match build/bootloader/bootloader.bin "021f" + rm sdkconfig + print_status "All tests completed" if [ -n "${FAILURES}" ]; then echo "Some failures were detected:" @@ -722,5 +747,17 @@ function clean_build_dir() rm -rf $PRESERVE_ROOT_ARG ${BUILD}/* ${BUILD}/.* } +# check the bytes 3-4 of the binary image header. e.g.: +# bin_header_match app.bin 0210 +function bin_header_match() +{ + expected=$2 + filename=$1 + actual=$(xxd -s 2 -l 2 -ps $1) + if [ ! "$expected" = "$actual" ]; then + failure "Incorrect binary image header, expected $expected got $actual" + fi +} + cd ${TESTDIR} run_tests