From 8417083b1381ab1ff269d83c4a703f59c420cf57 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 8 Jun 2021 15:30:05 +0200 Subject: [PATCH] lang/fw-build.sh: check for language data size during build Ensure the language data always fits the reserved space in the XFLASH. The script *should* use the LANG_SIZE definition from "xflash_layout", which can be obtained by preprocessing the source code. At the moment though this step has been omitted since running arduino-builder to preprocess the source requires extra flags passed by build.sh. The size has been hard-coded (and it's unlikely to change given the content size is constant for the architecture). --- lang/fw-build.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lang/fw-build.sh b/lang/fw-build.sh index 12a9ed512..2ba732282 100755 --- a/lang/fw-build.sh +++ b/lang/fw-build.sh @@ -198,6 +198,21 @@ if [ -e lang_nl.bin ]; then cat lang_nl.bin >> lang.bin; fi ## New language #if [ -e lang_qr.bin ]; then cat lang_qr.bin >> lang.bin; fi +# Check that the language data doesn't exceed the reserved XFLASH space +echo " checking language data size:" +lang_size=$(wc -c lang.bin | cut -f1 -d' ') +lang_size_pad=$(($lang_size / 4096 * 4096 + 4096)) + +# TODO: hard-coded! get value by preprocessing LANG_SIZE from xflash_layout.h! +lang_reserved=249856 + +echo " total size usage: $lang_size_pad ($lang_size)" +echo " reserved size: $lang_reserved" +if [ $lang_size_pad -gt $lang_reserved ]; then + echo "NG! - language data too large" >&2 + finish 1 +fi + #convert lang.bin to lang.hex echo -n " converting to hex..." >&2 $OBJCOPY -I binary -O ihex ./lang.bin ./lang.hex