Sfoglia il codice sorgente

New ML support - checksum - generating scripts (make_lang.sh, update_lang.sh)

Robert Pelnar 6 anni fa
parent
commit
bbbe43f704
2 ha cambiato i file con 13 aggiunte e 1 eliminazioni
  1. 6 1
      lang/make_lang.sh
  2. 7 0
      lang/update_lang.sh

+ 6 - 1
lang/make_lang.sh

@@ -86,7 +86,7 @@ lt_count=$(grep -c '^' lang_$LANG.txt)
 lt_data_size=$(wc -c lang_$LANG.dat | cut -f1 -d' ')
 lt_offs_size=$((2 * $lt_count))
 lt_size=$((16 + $lt_offs_size + $lt_data_size))
-lt_chsum=1
+lt_chsum=0
 lt_code='\xff\xff'
 lt_resv1='\xff\xff\xff\xff'
 
@@ -138,6 +138,11 @@ echo -n "  writing text data ($lt_data_size bytes)..." >&2
 dd if=./lang_$LANG.dat of=./lang_$LANG.bin bs=1 count=$lt_data_size seek=$((16 + $lt_offs_size)) conv=notrunc 2>/dev/null
 echo "OK" >&2
 
+#calculate and update checksum
+lt_chsum=$(cat lang_$LANG.bin | xxd | cut -c11-49 | tr ' ' "\n" | sed '/^$/d' | awk 'BEGIN { sum = 0; } { sum += strtonum("0x"$1); if (sum > 0xffff) sum -= 0x10000; } END { printf("%x\n", sum); }')
+/bin/echo -n -e $(echo -n $((0x$lt_chsum)) | awk "$awk_ui16") |\
+ dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
+
 echo " lang_table details:" >&2
 echo "  lt_count = $lt_count" >&2
 echo "  lt_size  = $lt_size" >&2

+ 7 - 0
lang/update_lang.sh

@@ -40,9 +40,15 @@ echo -n " checking symbols..." >&2
 #find symbol _SEC_LANG in section '.text'
 sec_lang=$(cat text.sym | grep -E "\b_SEC_LANG\b")
 if [ -z "$sec_lang" ]; then echo "NG!\n  symbol _SEC_LANG not found!" >&2; finish 1; fi
+#find symbol _PRI_LANG_SIGNATURE in section '.text'
+pri_lang=$(cat text.sym | grep -E "\b_PRI_LANG_SIGNATURE\b")
+if [ -z "$pri_lang" ]; then echo "NG!\n  symbol _PRI_LANG_SIGNATURE not found!" >&2; finish 1; fi
 echo "OK" >&2
 
 echo " calculating vars:" >&2
+#get pri_lang addres
+pri_lang_addr='0x'$(echo $pri_lang | cut -f1 -d' ')
+echo "  pri_lang_addr   =$pri_lang_addr" >&2
 #get addres and size
 sec_lang_addr='0x'$(echo $sec_lang | cut -f1 -d' ')
 sec_lang_size='0x'$(echo $sec_lang | cut -f2 -d' ')
@@ -62,6 +68,7 @@ printf "  lang_file_size  =0x%04x (=%d bytes)\n" $lang_file_size $lang_file_size
 if [ $lang_file_size -gt $lang_table_size ]; then echo "Lanaguage binary file size too big!" >&2; finish 1; fi
 
 echo "updating 'firmware.bin'..." >&2
+
 dd if=lang_$LANG.bin of=firmware.bin bs=1 seek=$lang_table_addr conv=notrunc 2>/dev/null
 
 #convert bin to hex