Browse Source

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).
Yuri D'Elia 3 years ago
parent
commit
8417083b13
1 changed files with 15 additions and 0 deletions
  1. 15 0
      lang/fw-build.sh

+ 15 - 0
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