Skip to content

Commit cbb6bec

Browse files
committed
ci: add build system tests for bootloader flash mode/freq/size
1 parent 0995079 commit cbb6bec

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

tools/ci/test_build_system.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,25 @@ function run_tests()
288288
( make 2>&1 | grep "does not fit in configured flash size 1MB" ) || failure "Build didn't fail with expected flash size failure message"
289289
mv sdkconfig.bak sdkconfig
290290

291+
print_status "Flash size is correctly set in the bootloader image header"
292+
# Build with the default 2MB setting
293+
rm sdkconfig
294+
make defconfig && make bootloader || failure "Failed to build bootloader"
295+
bin_header_match build/bootloader/bootloader.bin "0210"
296+
# Change to 4MB
297+
echo "CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y" > sdkconfig
298+
make defconfig && make bootloader || failure "Failed to build bootloader"
299+
bin_header_match build/bootloader/bootloader.bin "0220"
300+
# Change to QIO, bootloader should still be DIO (will change to QIO in 2nd stage bootloader)
301+
echo "CONFIG_FLASHMODE_QIO=y" > sdkconfig
302+
make defconfig && make bootloader || failure "Failed to build bootloader"
303+
bin_header_match build/bootloader/bootloader.bin "0210"
304+
# Change to 80 MHz
305+
echo "CONFIG_ESPTOOLPY_FLASHFREQ_80M=y" > sdkconfig
306+
make defconfig && make bootloader || failure "Failed to build bootloader"
307+
bin_header_match build/bootloader/bootloader.bin "021f"
308+
rm sdkconfig
309+
291310
print_status "sdkconfig should have contents of all files: sdkconfig, sdkconfig.defaults, sdkconfig.defaults.IDF_TARGET"
292311
make clean > /dev/null;
293312
rm -f sdkconfig.defaults;
@@ -491,5 +510,17 @@ function clean_build_dir()
491510
rm -rf --preserve-root ${BUILD}/*
492511
}
493512

513+
# check the bytes 3-4 of the binary image header. e.g.:
514+
# bin_header_match app.bin 0210
515+
function bin_header_match()
516+
{
517+
expected=$2
518+
filename=$1
519+
actual=$(xxd -s 2 -l 2 -ps $1)
520+
if [ ! "$expected" = "$actual" ]; then
521+
failure "Incorrect binary image header, expected $expected got $actual"
522+
fi
523+
}
524+
494525
cd ${TESTDIR}
495526
run_tests

tools/ci/test_build_system_cmake.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,31 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
595595
rm idf_project.yml
596596
git checkout main/main.c
597597

598+
print_status "Build fails if partitions don't fit in flash"
599+
sed -i.bak "s/CONFIG_ESPTOOLPY_FLASHSIZE.\+//" sdkconfig # remove all flashsize config
600+
echo "CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y" >> sdkconfig # introduce undersize flash
601+
( 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"
602+
mv sdkconfig.bak sdkconfig
603+
604+
print_status "Flash size is correctly set in the bootloader image header"
605+
# Build with the default 2MB setting
606+
rm sdkconfig
607+
idf.py bootloader || failure "Failed to build bootloader"
608+
bin_header_match build/bootloader/bootloader.bin "0210"
609+
# Change to 4MB
610+
echo "CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y" > sdkconfig
611+
idf.py bootloader || failure "Failed to build bootloader"
612+
bin_header_match build/bootloader/bootloader.bin "0220"
613+
# Change to QIO, bootloader should still be DIO (will change to QIO in 2nd stage bootloader)
614+
echo "CONFIG_FLASHMODE_QIO=y" > sdkconfig
615+
idf.py bootloader || failure "Failed to build bootloader"
616+
bin_header_match build/bootloader/bootloader.bin "0210"
617+
# Change to 80 MHz
618+
echo "CONFIG_ESPTOOLPY_FLASHFREQ_80M=y" > sdkconfig
619+
idf.py bootloader || failure "Failed to build bootloader"
620+
bin_header_match build/bootloader/bootloader.bin "021f"
621+
rm sdkconfig
622+
598623
print_status "All tests completed"
599624
if [ -n "${FAILURES}" ]; then
600625
echo "Some failures were detected:"
@@ -722,5 +747,17 @@ function clean_build_dir()
722747
rm -rf $PRESERVE_ROOT_ARG ${BUILD}/* ${BUILD}/.*
723748
}
724749

750+
# check the bytes 3-4 of the binary image header. e.g.:
751+
# bin_header_match app.bin 0210
752+
function bin_header_match()
753+
{
754+
expected=$2
755+
filename=$1
756+
actual=$(xxd -s 2 -l 2 -ps $1)
757+
if [ ! "$expected" = "$actual" ]; then
758+
failure "Incorrect binary image header, expected $expected got $actual"
759+
fi
760+
}
761+
725762
cd ${TESTDIR}
726763
run_tests

0 commit comments

Comments
 (0)