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).
This commit is contained in:
Yuri D'Elia 2021-06-08 15:30:05 +02:00
parent 6dfef76346
commit 8417083b13

View File

@ -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