@@ -595,6 +595,31 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
595
595
rm idf_project.yml
596
596
git checkout main/main.c
597
597
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
+
598
623
print_status " All tests completed"
599
624
if [ -n " ${FAILURES} " ]; then
600
625
echo " Some failures were detected:"
@@ -722,5 +747,17 @@ function clean_build_dir()
722
747
rm -rf $PRESERVE_ROOT_ARG ${BUILD} /* ${BUILD} /.*
723
748
}
724
749
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
+
725
762
cd ${TESTDIR}
726
763
run_tests
0 commit comments