New ML support - scripts - lineendings changed to LF (unix)
This commit is contained in:
parent
37e575f4bc
commit
e28249a636
6 changed files with 576 additions and 576 deletions
|
@ -1,138 +1,138 @@
|
|||
#!/bin/sh
|
||||
# makelang.sh - multi-language support high-level script
|
||||
# for generating lang_xx.bin (secondary language binary file)
|
||||
#
|
||||
# Input files:
|
||||
# lang_en.txt
|
||||
# lang_en_$LANG.txt
|
||||
#
|
||||
# Output files:
|
||||
# lang_en.tmp (temporary, will be removed when finished)
|
||||
# lang_en_$LANG.tmp ==||==
|
||||
# lang_en_$LANG.dif ==||==
|
||||
# lang_$LANG.txt
|
||||
#
|
||||
#
|
||||
# Selected language:
|
||||
LANG=$1
|
||||
if [ -z "$LANG" ]; then LANG='cz'; fi
|
||||
#
|
||||
#
|
||||
|
||||
function finish
|
||||
{
|
||||
if [ "$1" == "0" ]; then
|
||||
if [ -e lang_en.tmp ]; then rm lang_en.tmp; fi
|
||||
if [ -e lang_en_$LANG.tmp ]; then rm lang_en_$LANG.tmp; fi
|
||||
if [ -e lang_en_$LANG.dif ]; then rm lang_en_$LANG.dif; fi
|
||||
fi
|
||||
echo
|
||||
if [ "$1" == "0" ]; then
|
||||
echo "make_lang.sh finished with success" >&2
|
||||
else
|
||||
echo "make_lang.sh finished with errors!" >&2
|
||||
fi
|
||||
case "$-" in
|
||||
*i*) echo "press enter key"; read ;;
|
||||
esac
|
||||
exit $1
|
||||
}
|
||||
|
||||
echo "make_lang.sh started" >&2
|
||||
echo "selected language=$LANG" >&2
|
||||
|
||||
#check if input files exists
|
||||
echo -n " checking input files..." >&2
|
||||
if [ ! -e lang_en.txt ]; then echo "NG! file lang_en.txt not found!" >&2; exit 1; fi
|
||||
if [ ! -e lang_en_$LANG.txt ]; then echo "NG! file lang_en_$LANG.txt not found!" >&2; exit 1; fi
|
||||
echo "OK" >&2
|
||||
|
||||
#filter comment and empty lines from key and dictionary files, create temporary files
|
||||
echo -n " creating tmp files..." >&2
|
||||
cat lang_en.txt | sed "/^$/d;/^#/d" > lang_en.tmp
|
||||
cat lang_en_$LANG.txt | sed "/^$/d;/^#/d" > lang_en_$LANG.tmp
|
||||
echo "OK" >&2
|
||||
#cat lang_en_$LANG.tmp | sed 'n;d' >test1.txt
|
||||
|
||||
#compare files using diff and check for differences
|
||||
echo -n " comparing tmp files..." >&2
|
||||
if ! cat lang_en_$LANG.tmp | sed 'n;d' | diff lang_en.tmp - > lang_en_$LANG.dif; then
|
||||
echo "NG!" >&2
|
||||
echo "Entries in lang_en_$LANG.txt are different from lang_en.txt!" >&2
|
||||
echo "please check lang_en_$LANG.dif" >&2
|
||||
finish 1
|
||||
fi
|
||||
echo "OK" >&2
|
||||
|
||||
#generate lang_xx.txt (secondary language text data sorted by ids)
|
||||
echo -n " generating lang_$LANG.txt..." >&2
|
||||
cat lang_en_$LANG.tmp | sed '1~2d' | sed "s/^\"\\\\x00/\"/" > lang_$LANG.txt
|
||||
echo "OK" >&2
|
||||
|
||||
#generate lang_xx.dat (secondary language text data in binary form)
|
||||
echo -n " generating lang_$LANG.dat..." >&2
|
||||
cat lang_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do
|
||||
s=${s#\"}
|
||||
s=${s%\"}
|
||||
echo -n -e "$s"'\x00'
|
||||
done >lang_$LANG.dat
|
||||
echo "OK" >&2
|
||||
|
||||
#calculate variables
|
||||
lt_magic='\xa5\x5a\xb4\x4b'
|
||||
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_resv0='\xff\xff'
|
||||
lt_resv1='\xff\xff\xff\xff'
|
||||
|
||||
#generate lang_xx.ofs (secondary language text data offset table)
|
||||
echo -n " generating lang_$LANG.ofs..." >&2
|
||||
cat lang_$LANG.txt | sed "s/\\\\x[0-9a-f][0-9a-f]/\./g;s/\\\\[0-7][0-7][0-7]/\./g" |\
|
||||
awk 'BEGIN { o='$((16 + $lt_offs_size))';} { printf("%d\n",o); o+=(length($0)-1); }' > lang_$LANG.ofs
|
||||
echo "OK" >&2
|
||||
|
||||
#generate lang_xx.bin (secondary language result binary file)
|
||||
echo " generating lang_$LANG.bin:" >&2
|
||||
#create empty file
|
||||
dd if=/dev/zero of=lang_$LANG.bin bs=1 count=$lt_size 2>/dev/null
|
||||
#awk code to format ui16 variables for dd
|
||||
awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
|
||||
|
||||
#write data to binary file with dd
|
||||
|
||||
echo -n " writing header (16 bytes)..." >&2
|
||||
echo -n -e "$lt_magic" |\
|
||||
dd of=lang_$LANG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null
|
||||
echo -n -e $(echo -n "$lt_size" | awk "$awk_ui16") |\
|
||||
dd of=lang_$LANG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null
|
||||
echo -n -e $(echo -n "$lt_count" | awk "$awk_ui16") |\
|
||||
dd of=lang_$LANG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null
|
||||
echo -n -e $(echo -n "$lt_chsum" | awk "$awk_ui16") |\
|
||||
dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
|
||||
echo -n -e "$lt_resv0" |\
|
||||
dd of=lang_$LANG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null
|
||||
echo -n -e "$lt_resv1" |\
|
||||
dd of=lang_$LANG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null
|
||||
echo "OK" >&2
|
||||
|
||||
echo -n " writing offset table ($lt_offs_size bytes)..." >&2
|
||||
echo -n -e $(cat lang_$LANG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\
|
||||
dd of=./lang_$LANG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null
|
||||
echo "OK" >&2
|
||||
|
||||
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
|
||||
|
||||
echo " lang_table details:" >&2
|
||||
echo " lt_count = $lt_count" >&2
|
||||
echo " lt_size = $lt_size" >&2
|
||||
echo " lt_chsum = $lt_chsum" >&2
|
||||
|
||||
finish 0
|
||||
|
||||
|
||||
|
||||
#!/bin/sh
|
||||
# makelang.sh - multi-language support high-level script
|
||||
# for generating lang_xx.bin (secondary language binary file)
|
||||
#
|
||||
# Input files:
|
||||
# lang_en.txt
|
||||
# lang_en_$LANG.txt
|
||||
#
|
||||
# Output files:
|
||||
# lang_en.tmp (temporary, will be removed when finished)
|
||||
# lang_en_$LANG.tmp ==||==
|
||||
# lang_en_$LANG.dif ==||==
|
||||
# lang_$LANG.txt
|
||||
#
|
||||
#
|
||||
# Selected language:
|
||||
LANG=$1
|
||||
if [ -z "$LANG" ]; then LANG='cz'; fi
|
||||
#
|
||||
#
|
||||
|
||||
function finish
|
||||
{
|
||||
if [ "$1" == "0" ]; then
|
||||
if [ -e lang_en.tmp ]; then rm lang_en.tmp; fi
|
||||
if [ -e lang_en_$LANG.tmp ]; then rm lang_en_$LANG.tmp; fi
|
||||
if [ -e lang_en_$LANG.dif ]; then rm lang_en_$LANG.dif; fi
|
||||
fi
|
||||
echo
|
||||
if [ "$1" == "0" ]; then
|
||||
echo "make_lang.sh finished with success" >&2
|
||||
else
|
||||
echo "make_lang.sh finished with errors!" >&2
|
||||
fi
|
||||
case "$-" in
|
||||
*i*) echo "press enter key"; read ;;
|
||||
esac
|
||||
exit $1
|
||||
}
|
||||
|
||||
echo "make_lang.sh started" >&2
|
||||
echo "selected language=$LANG" >&2
|
||||
|
||||
#check if input files exists
|
||||
echo -n " checking input files..." >&2
|
||||
if [ ! -e lang_en.txt ]; then echo "NG! file lang_en.txt not found!" >&2; exit 1; fi
|
||||
if [ ! -e lang_en_$LANG.txt ]; then echo "NG! file lang_en_$LANG.txt not found!" >&2; exit 1; fi
|
||||
echo "OK" >&2
|
||||
|
||||
#filter comment and empty lines from key and dictionary files, create temporary files
|
||||
echo -n " creating tmp files..." >&2
|
||||
cat lang_en.txt | sed "/^$/d;/^#/d" > lang_en.tmp
|
||||
cat lang_en_$LANG.txt | sed "/^$/d;/^#/d" > lang_en_$LANG.tmp
|
||||
echo "OK" >&2
|
||||
#cat lang_en_$LANG.tmp | sed 'n;d' >test1.txt
|
||||
|
||||
#compare files using diff and check for differences
|
||||
echo -n " comparing tmp files..." >&2
|
||||
if ! cat lang_en_$LANG.tmp | sed 'n;d' | diff lang_en.tmp - > lang_en_$LANG.dif; then
|
||||
echo "NG!" >&2
|
||||
echo "Entries in lang_en_$LANG.txt are different from lang_en.txt!" >&2
|
||||
echo "please check lang_en_$LANG.dif" >&2
|
||||
finish 1
|
||||
fi
|
||||
echo "OK" >&2
|
||||
|
||||
#generate lang_xx.txt (secondary language text data sorted by ids)
|
||||
echo -n " generating lang_$LANG.txt..." >&2
|
||||
cat lang_en_$LANG.tmp | sed '1~2d' | sed "s/^\"\\\\x00/\"/" > lang_$LANG.txt
|
||||
echo "OK" >&2
|
||||
|
||||
#generate lang_xx.dat (secondary language text data in binary form)
|
||||
echo -n " generating lang_$LANG.dat..." >&2
|
||||
cat lang_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do
|
||||
s=${s#\"}
|
||||
s=${s%\"}
|
||||
echo -n -e "$s"'\x00'
|
||||
done >lang_$LANG.dat
|
||||
echo "OK" >&2
|
||||
|
||||
#calculate variables
|
||||
lt_magic='\xa5\x5a\xb4\x4b'
|
||||
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_resv0='\xff\xff'
|
||||
lt_resv1='\xff\xff\xff\xff'
|
||||
|
||||
#generate lang_xx.ofs (secondary language text data offset table)
|
||||
echo -n " generating lang_$LANG.ofs..." >&2
|
||||
cat lang_$LANG.txt | sed "s/\\\\x[0-9a-f][0-9a-f]/\./g;s/\\\\[0-7][0-7][0-7]/\./g" |\
|
||||
awk 'BEGIN { o='$((16 + $lt_offs_size))';} { printf("%d\n",o); o+=(length($0)-1); }' > lang_$LANG.ofs
|
||||
echo "OK" >&2
|
||||
|
||||
#generate lang_xx.bin (secondary language result binary file)
|
||||
echo " generating lang_$LANG.bin:" >&2
|
||||
#create empty file
|
||||
dd if=/dev/zero of=lang_$LANG.bin bs=1 count=$lt_size 2>/dev/null
|
||||
#awk code to format ui16 variables for dd
|
||||
awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
|
||||
|
||||
#write data to binary file with dd
|
||||
|
||||
echo -n " writing header (16 bytes)..." >&2
|
||||
echo -n -e "$lt_magic" |\
|
||||
dd of=lang_$LANG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null
|
||||
echo -n -e $(echo -n "$lt_size" | awk "$awk_ui16") |\
|
||||
dd of=lang_$LANG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null
|
||||
echo -n -e $(echo -n "$lt_count" | awk "$awk_ui16") |\
|
||||
dd of=lang_$LANG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null
|
||||
echo -n -e $(echo -n "$lt_chsum" | awk "$awk_ui16") |\
|
||||
dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
|
||||
echo -n -e "$lt_resv0" |\
|
||||
dd of=lang_$LANG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null
|
||||
echo -n -e "$lt_resv1" |\
|
||||
dd of=lang_$LANG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null
|
||||
echo "OK" >&2
|
||||
|
||||
echo -n " writing offset table ($lt_offs_size bytes)..." >&2
|
||||
echo -n -e $(cat lang_$LANG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\
|
||||
dd of=./lang_$LANG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null
|
||||
echo "OK" >&2
|
||||
|
||||
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
|
||||
|
||||
echo " lang_table details:" >&2
|
||||
echo " lt_count = $lt_count" >&2
|
||||
echo " lt_size = $lt_size" >&2
|
||||
echo " lt_chsum = $lt_chsum" >&2
|
||||
|
||||
finish 0
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,61 +1,61 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# make_po.sh - multi-language support script
|
||||
# for generating lang_xx.po
|
||||
#
|
||||
SRCDIR="../../Firmware"
|
||||
#
|
||||
LANG=$1
|
||||
if [ -z "$LANG" ]; then LANG=cz; fi
|
||||
#
|
||||
|
||||
echo "make_po.sh started" >&2
|
||||
|
||||
#remove output file if exists
|
||||
if [ -e lang_$LANG.po ]; then rm lang_$LANG.po; fi
|
||||
|
||||
langname=$(\
|
||||
case "$LANG" in
|
||||
*en*) echo "English" ;;
|
||||
*cz*) echo "Czech" ;;
|
||||
*de*) echo "German" ;;
|
||||
*it*) echo "Italian" ;;
|
||||
*es*) echo "Spanish" ;;
|
||||
*pl*) echo "Polish" ;;
|
||||
esac)
|
||||
|
||||
#write po header
|
||||
echo "# Translation into $langname." > lang_$LANG.po
|
||||
echo "#" >> lang_$LANG.po
|
||||
echo 'msgid ""' >> lang_$LANG.po
|
||||
echo 'msgstr ""' >> lang_$LANG.po
|
||||
echo '"MIME-Version: 1.0\n"' >> lang_$LANG.po
|
||||
echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LANG.po
|
||||
echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LANG.po
|
||||
echo >> lang_$LANG.po
|
||||
|
||||
#list .cpp, .c and .h files
|
||||
files=$(ls "$SRCDIR"/*.cpp "$SRCDIR"/*.c "$SRCDIR"/*.h)
|
||||
|
||||
#loop over all messages, print only untranslated (=="\x00")
|
||||
s0=''
|
||||
s1=''
|
||||
s2=''
|
||||
cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g;s/^#/#: /" | while read -r s; do
|
||||
if [ "$s" == "" ]; then
|
||||
if [ "$s0" == "\"\\\\x00\"" ]; then
|
||||
search=$(echo -e "$s1")
|
||||
found=$(grep -m1 -n -F "$search" $files | head -n1 | cut -f1-2 -d':' | sed "s/^.*\///")
|
||||
echo "#: $found"
|
||||
echo -e "msgid $s1"
|
||||
echo 'msgstr ""'
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
s2=$s1
|
||||
s1=$s0
|
||||
s0=$s
|
||||
done >> lang_$LANG.po
|
||||
|
||||
echo "make_po.sh finished" >&2
|
||||
exit 0
|
||||
#!/bin/sh
|
||||
#
|
||||
# make_po.sh - multi-language support script
|
||||
# for generating lang_xx.po
|
||||
#
|
||||
SRCDIR="../../Firmware"
|
||||
#
|
||||
LANG=$1
|
||||
if [ -z "$LANG" ]; then LANG=cz; fi
|
||||
#
|
||||
|
||||
echo "make_po.sh started" >&2
|
||||
|
||||
#remove output file if exists
|
||||
if [ -e lang_$LANG.po ]; then rm lang_$LANG.po; fi
|
||||
|
||||
langname=$(\
|
||||
case "$LANG" in
|
||||
*en*) echo "English" ;;
|
||||
*cz*) echo "Czech" ;;
|
||||
*de*) echo "German" ;;
|
||||
*it*) echo "Italian" ;;
|
||||
*es*) echo "Spanish" ;;
|
||||
*pl*) echo "Polish" ;;
|
||||
esac)
|
||||
|
||||
#write po header
|
||||
echo "# Translation into $langname." > lang_$LANG.po
|
||||
echo "#" >> lang_$LANG.po
|
||||
echo 'msgid ""' >> lang_$LANG.po
|
||||
echo 'msgstr ""' >> lang_$LANG.po
|
||||
echo '"MIME-Version: 1.0\n"' >> lang_$LANG.po
|
||||
echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LANG.po
|
||||
echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LANG.po
|
||||
echo >> lang_$LANG.po
|
||||
|
||||
#list .cpp, .c and .h files
|
||||
files=$(ls "$SRCDIR"/*.cpp "$SRCDIR"/*.c "$SRCDIR"/*.h)
|
||||
|
||||
#loop over all messages, print only untranslated (=="\x00")
|
||||
s0=''
|
||||
s1=''
|
||||
s2=''
|
||||
cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g;s/^#/#: /" | while read -r s; do
|
||||
if [ "$s" == "" ]; then
|
||||
if [ "$s0" == "\"\\\\x00\"" ]; then
|
||||
search=$(echo -e "$s1")
|
||||
found=$(grep -m1 -n -F "$search" $files | head -n1 | cut -f1-2 -d':' | sed "s/^.*\///")
|
||||
echo "#: $found"
|
||||
echo -e "msgid $s1"
|
||||
echo 'msgstr ""'
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
s2=$s1
|
||||
s1=$s0
|
||||
s0=$s
|
||||
done >> lang_$LANG.po
|
||||
|
||||
echo "make_po.sh finished" >&2
|
||||
exit 0
|
||||
|
|
|
@ -1,116 +1,116 @@
|
|||
#!/bin/sh
|
||||
# postbuild.sh - multi-language support high-level script
|
||||
# for generating binary with secondary language
|
||||
#
|
||||
# Input files:
|
||||
# $OUTDIR/Firmware.ino.elf
|
||||
# $OUTDIR/sketch/*.o (all object files)
|
||||
#
|
||||
# Output files:
|
||||
# text.sym
|
||||
# $PROGMEM.sym (progmem1.sym)
|
||||
# $PROGMEM.lss (...)
|
||||
# $PROGMEM.hex
|
||||
# $PROGMEM.chr
|
||||
# $PROGMEM.var
|
||||
# $PROGMEM.txt
|
||||
# textaddr.txt
|
||||
#
|
||||
# Output folder and elf file:
|
||||
OUTDIR="../../output"
|
||||
OUTELF="$OUTDIR/Firmware.ino.elf"
|
||||
#
|
||||
# AVR gcc tools used:
|
||||
OBJCOPY=C:/arduino-1.6.8/hardware/tools/avr/bin/avr-objcopy.exe
|
||||
#
|
||||
# Selected language:
|
||||
LANG=$1
|
||||
#if [ -z "$LANG" ]; then LANG='cz'; fi
|
||||
#
|
||||
# Params:
|
||||
IGNORE_MISSING_TEXT=1
|
||||
|
||||
function finish
|
||||
{
|
||||
echo
|
||||
if [ "$1" == "0" ]; then
|
||||
echo "postbuild.sh finished with success" >&2
|
||||
else
|
||||
echo "postbuild.sh finished with errors!" >&2
|
||||
fi
|
||||
case "$-" in
|
||||
*i*) echo "press enter key"; read ;;
|
||||
esac
|
||||
exit $1
|
||||
}
|
||||
|
||||
echo "postbuild.sh started" >&2
|
||||
|
||||
#check input files
|
||||
echo " checking files:" >&2
|
||||
if [ ! -e $OUTDIR ]; then echo " folder '$OUTDIR' not found!" >&2; finish 1; fi
|
||||
echo " folder OK" >&2
|
||||
if [ ! -e $OUTELF ]; then echo " elf file '$OUTELF' not found!" >&2; finish 1; fi
|
||||
echo " elf OK" >&2
|
||||
if ! ls $OUTDIR/sketch/*.o >/dev/null 2>&1; then echo " no object files in '$OUTDIR/sketch/'!" >&2; finish 1; fi
|
||||
echo " objects OK" >&2
|
||||
|
||||
#run progmem.sh - examine content of progmem1
|
||||
echo -n " running progmem.sh..." >&2
|
||||
./progmem.sh 1 2>progmem.out
|
||||
if [ $? -ne 0 ]; then echo "NG! - check progmem.out file" >&2; finish 1; fi
|
||||
echo "OK" >&2
|
||||
|
||||
#run textaddr.sh - map progmem addreses to text identifiers
|
||||
echo -n " running textaddr.sh..." >&2
|
||||
./textaddr.sh 2>textaddr.out
|
||||
if [ $? -ne 0 ]; then echo "NG! - check progmem.out file" >&2; finish 1; fi
|
||||
echo "OK" >&2
|
||||
|
||||
#check for messages declared in progmem1, but not found in lang_en.txt
|
||||
echo -n " checking textaddr.txt..." >&2
|
||||
if cat textaddr.txt | grep "^ADDR NF" >/dev/null; then
|
||||
echo "NG! - some texts not found in lang_en.txt!"
|
||||
if [ $(("0$IGNORE_MISSING_TEXT")) -eq 0 ]; then
|
||||
finish 1
|
||||
else
|
||||
echo " missing text ignored!" >&2
|
||||
fi
|
||||
else
|
||||
echo "OK" >&2
|
||||
fi
|
||||
|
||||
#update progmem1 id entries in binary file
|
||||
echo -n " extracting binary..." >&2
|
||||
$OBJCOPY -I ihex -O binary $OUTDIR/Firmware.ino.hex ./firmware.bin
|
||||
echo "OK" >&2
|
||||
|
||||
#update binary file
|
||||
echo " updating binary:" >&2
|
||||
|
||||
#update progmem1 id entries in binary file
|
||||
echo -n " primary language ids..." >&2
|
||||
cat textaddr.txt | grep "^ADDR OK" | cut -f3- -d' ' | sed "s/^0000/0x/" |\
|
||||
awk '{ id = $2 - 1; hi = int(id / 256); lo = int(id - 256 * hi); printf("%d \\\\x%02x\\\\x%02x\n", strtonum($1), lo, hi); }' |\
|
||||
while read addr data; do
|
||||
echo -n -e $data | dd of=./firmware.bin bs=1 count=2 seek=$addr conv=notrunc oflag=nonblock 2>/dev/null
|
||||
done
|
||||
echo "OK" >&2
|
||||
|
||||
#update _SEC_LANG in binary file if language is selected
|
||||
echo -n " secondary language data..." >&2
|
||||
if [ ! -z "$LANG" ]; then
|
||||
./update_lang.sh $LANG 2>./update_lang.out
|
||||
if [ $? -ne 0 ]; then echo "NG! - check update_lang.out file" >&2; finish 1; fi
|
||||
echo "OK" >&2
|
||||
finish 0
|
||||
else
|
||||
echo "skipped" >&2
|
||||
fi
|
||||
|
||||
#convert bin to hex
|
||||
echo -n " converting to hex..." >&2
|
||||
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
|
||||
echo "OK" >&2
|
||||
|
||||
finish 0
|
||||
#!/bin/sh
|
||||
# postbuild.sh - multi-language support high-level script
|
||||
# for generating binary with secondary language
|
||||
#
|
||||
# Input files:
|
||||
# $OUTDIR/Firmware.ino.elf
|
||||
# $OUTDIR/sketch/*.o (all object files)
|
||||
#
|
||||
# Output files:
|
||||
# text.sym
|
||||
# $PROGMEM.sym (progmem1.sym)
|
||||
# $PROGMEM.lss (...)
|
||||
# $PROGMEM.hex
|
||||
# $PROGMEM.chr
|
||||
# $PROGMEM.var
|
||||
# $PROGMEM.txt
|
||||
# textaddr.txt
|
||||
#
|
||||
# Output folder and elf file:
|
||||
OUTDIR="../../output"
|
||||
OUTELF="$OUTDIR/Firmware.ino.elf"
|
||||
#
|
||||
# AVR gcc tools used:
|
||||
OBJCOPY=C:/arduino-1.6.8/hardware/tools/avr/bin/avr-objcopy.exe
|
||||
#
|
||||
# Selected language:
|
||||
LANG=$1
|
||||
#if [ -z "$LANG" ]; then LANG='cz'; fi
|
||||
#
|
||||
# Params:
|
||||
IGNORE_MISSING_TEXT=1
|
||||
|
||||
function finish
|
||||
{
|
||||
echo
|
||||
if [ "$1" == "0" ]; then
|
||||
echo "postbuild.sh finished with success" >&2
|
||||
else
|
||||
echo "postbuild.sh finished with errors!" >&2
|
||||
fi
|
||||
case "$-" in
|
||||
*i*) echo "press enter key"; read ;;
|
||||
esac
|
||||
exit $1
|
||||
}
|
||||
|
||||
echo "postbuild.sh started" >&2
|
||||
|
||||
#check input files
|
||||
echo " checking files:" >&2
|
||||
if [ ! -e $OUTDIR ]; then echo " folder '$OUTDIR' not found!" >&2; finish 1; fi
|
||||
echo " folder OK" >&2
|
||||
if [ ! -e $OUTELF ]; then echo " elf file '$OUTELF' not found!" >&2; finish 1; fi
|
||||
echo " elf OK" >&2
|
||||
if ! ls $OUTDIR/sketch/*.o >/dev/null 2>&1; then echo " no object files in '$OUTDIR/sketch/'!" >&2; finish 1; fi
|
||||
echo " objects OK" >&2
|
||||
|
||||
#run progmem.sh - examine content of progmem1
|
||||
echo -n " running progmem.sh..." >&2
|
||||
./progmem.sh 1 2>progmem.out
|
||||
if [ $? -ne 0 ]; then echo "NG! - check progmem.out file" >&2; finish 1; fi
|
||||
echo "OK" >&2
|
||||
|
||||
#run textaddr.sh - map progmem addreses to text identifiers
|
||||
echo -n " running textaddr.sh..." >&2
|
||||
./textaddr.sh 2>textaddr.out
|
||||
if [ $? -ne 0 ]; then echo "NG! - check progmem.out file" >&2; finish 1; fi
|
||||
echo "OK" >&2
|
||||
|
||||
#check for messages declared in progmem1, but not found in lang_en.txt
|
||||
echo -n " checking textaddr.txt..." >&2
|
||||
if cat textaddr.txt | grep "^ADDR NF" >/dev/null; then
|
||||
echo "NG! - some texts not found in lang_en.txt!"
|
||||
if [ $(("0$IGNORE_MISSING_TEXT")) -eq 0 ]; then
|
||||
finish 1
|
||||
else
|
||||
echo " missing text ignored!" >&2
|
||||
fi
|
||||
else
|
||||
echo "OK" >&2
|
||||
fi
|
||||
|
||||
#update progmem1 id entries in binary file
|
||||
echo -n " extracting binary..." >&2
|
||||
$OBJCOPY -I ihex -O binary $OUTDIR/Firmware.ino.hex ./firmware.bin
|
||||
echo "OK" >&2
|
||||
|
||||
#update binary file
|
||||
echo " updating binary:" >&2
|
||||
|
||||
#update progmem1 id entries in binary file
|
||||
echo -n " primary language ids..." >&2
|
||||
cat textaddr.txt | grep "^ADDR OK" | cut -f3- -d' ' | sed "s/^0000/0x/" |\
|
||||
awk '{ id = $2 - 1; hi = int(id / 256); lo = int(id - 256 * hi); printf("%d \\\\x%02x\\\\x%02x\n", strtonum($1), lo, hi); }' |\
|
||||
while read addr data; do
|
||||
echo -n -e $data | dd of=./firmware.bin bs=1 count=2 seek=$addr conv=notrunc oflag=nonblock 2>/dev/null
|
||||
done
|
||||
echo "OK" >&2
|
||||
|
||||
#update _SEC_LANG in binary file if language is selected
|
||||
echo -n " secondary language data..." >&2
|
||||
if [ ! -z "$LANG" ]; then
|
||||
./update_lang.sh $LANG 2>./update_lang.out
|
||||
if [ $? -ne 0 ]; then echo "NG! - check update_lang.out file" >&2; finish 1; fi
|
||||
echo "OK" >&2
|
||||
finish 0
|
||||
else
|
||||
echo "skipped" >&2
|
||||
fi
|
||||
|
||||
#convert bin to hex
|
||||
echo -n " converting to hex..." >&2
|
||||
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
|
||||
echo "OK" >&2
|
||||
|
||||
finish 0
|
||||
|
|
252
lang/progmem.sh
252
lang/progmem.sh
|
@ -1,127 +1,127 @@
|
|||
#!/bin/sh
|
||||
# progmem.sh - multi-language support low-level script
|
||||
# for examining content of progmem sections (default is progmem1)
|
||||
#
|
||||
# Input files:
|
||||
# $OUTDIR/Firmware.ino.elf
|
||||
# $OUTDIR/sketch/*.o (all object files)
|
||||
#
|
||||
# Output files:
|
||||
# text.sym
|
||||
# $PROGMEM.sym
|
||||
# $PROGMEM.lss
|
||||
# $PROGMEM.hex
|
||||
# $PROGMEM.chr
|
||||
# $PROGMEM.var
|
||||
# $PROGMEM.txt
|
||||
#
|
||||
# Program memory used
|
||||
PROGMEM=progmem$1
|
||||
if [ -z "$1" ]; then PROGMEM=progmem1; fi
|
||||
#
|
||||
# Output folder and elf file:
|
||||
OUTDIR="../../output"
|
||||
OUTELF="$OUTDIR/Firmware.ino.elf"
|
||||
#
|
||||
# AVR gcc tools used:
|
||||
OBJDUMP=C:/arduino-1.6.8/hardware/tools/avr/bin/avr-objdump.exe
|
||||
#
|
||||
#
|
||||
# Description of process:
|
||||
# 0. check input files
|
||||
# 1. remove output files
|
||||
# 2. list symbol table of section '.text' from output elf file to text.sym (sorted by address)
|
||||
# 3. list symbol table of section '.$PROGMEM' from all output object files to $PROGMEM.sym
|
||||
# 4. filter only $PROGMEM symbols from text.sym and store it back to $PROGMEM.sym with absolute address
|
||||
# 5. calculate start and stop address of section '.$PROGMEM'
|
||||
# 6. extract string data from elf file to $PROGMEM.hex
|
||||
# 7. prepare string data for character check and conversion (output to $PROGMEM.chr)
|
||||
# 8. perform character check and conversion (output to $PROGMEM.var and $PROGMEM.txt)
|
||||
#
|
||||
|
||||
echo "progmem.sh started" >&2
|
||||
|
||||
# (0)
|
||||
echo " progmem.sh (0) - checking input files" >&2
|
||||
if [ ! -e $OUTDIR ]; then echo "progmem.sh - file '$OUTELF' not found!" >&2; exit 1; fi
|
||||
|
||||
# (1)
|
||||
echo " progmem.sh (1) - removing output files" >&2
|
||||
#remove output files if exists
|
||||
if [ -e text.sym ]; then rm text.sym; fi
|
||||
if [ -e $PROGMEM.sym ]; then rm $PROGMEM.sym; fi
|
||||
if [ -e $PROGMEM.lss ]; then rm $PROGMEM.lss; fi
|
||||
if [ -e $PROGMEM.hex ]; then rm $PROGMEM.hex; fi
|
||||
if [ -e $PROGMEM.chr ]; then rm $PROGMEM.chr; fi
|
||||
if [ -e $PROGMEM.var ]; then rm $PROGMEM.var; fi
|
||||
if [ -e $PROGMEM.txt ]; then rm $PROGMEM.txt; fi
|
||||
|
||||
# (2)
|
||||
echo " progmem.sh (2) - listing symbol table of section '.text'" >&2
|
||||
#list symbols from section '.text' into file text.sym (only address, size and name)
|
||||
$OBJDUMP -t -j ".text" $OUTELF | tail -n +5 | grep -E "^[0-9a-f]{8} [gl] O" | cut -c1-9,28-36,37- | sed "/^$/d" | sort >> text.sym
|
||||
|
||||
# (3)
|
||||
echo " progmem.sh (3) - listing symbol table of section '.$PROGMEM'" >&2
|
||||
#loop over all object files
|
||||
ls "$OUTDIR"/sketch/*.o | while read fn; do
|
||||
echo " processing $fn" >&2
|
||||
#list symbols from section $PROGMEM (only address, size and name)
|
||||
$OBJDUMP -t -j ".$PROGMEM" $fn 2>/dev/null | tail -n +5 | cut -c1-9,28-36,37- | sed "/^$/d" | sort >> $PROGMEM.sym
|
||||
done
|
||||
|
||||
# (4)
|
||||
echo " progmem.sh (4) - filtering $PROGMEM symbols" >&2
|
||||
#create list of $PROGMEM symbol names separated by '\|'
|
||||
progmem=$(cut -c19- $PROGMEM.sym)
|
||||
progmem=$(echo $progmem | sed "s/ /\\\b\\\|\\\b/g")
|
||||
progmem='\b'$progmem'\b'
|
||||
#filter $PROGMEM symbols from section '.text' (result file will contain list sorted by absolute address)
|
||||
cat text.sym | grep $progmem > $PROGMEM.sym
|
||||
|
||||
# (5)
|
||||
echo " progmem.sh (5) - calculating start and stop address" >&2
|
||||
#calculate start addres of section ".$PROGMEM"
|
||||
PROGMEM_BEG=$(head -n1 $PROGMEM.sym | while read offs size name; do echo "0x"$offs; done)
|
||||
#calculate stop addres of section ".$PROGMEM"
|
||||
PROGMEM_END=$(tail -n1 $PROGMEM.sym | while read offs size name; do printf "0x%x" $(("0x"$offs + "0x"$size)); done)
|
||||
echo " START address = "$PROGMEM_BEG >&2
|
||||
echo " STOP address = "$PROGMEM_END >&2
|
||||
|
||||
# (6)
|
||||
echo " progmem.sh (6) - extracting string data from elf" >&2
|
||||
#dump $PROGMEM data in hex format, cut textual data (keep hex data only)
|
||||
$OBJDUMP -d -j ".text" -w -z --start-address=$PROGMEM_BEG --stop-address=$PROGMEM_END $OUTELF | cut -c1-57 > $PROGMEM.lss
|
||||
#convert $PROGMEM.lss to $PROGMEM.hex:
|
||||
# replace empty lines with '|' (variables separated by empty lines)
|
||||
# remove address from multiline variables (keep address at first variable line only)
|
||||
# remove '<' and '>:', remove whitespace at end of lines
|
||||
# remove line-endings, replace separator with '\n' (join hex data lines - each line will contain single variable)
|
||||
# filter progmem symbols
|
||||
cat $PROGMEM.lss | tail -n +7 | sed -E 's/^$/|/;s/^........:\t/ /;s/<//g;s/>:/ /g;s/[ \t]*$//' |\
|
||||
tr -d '\n' | sed "s/[|]/\n/g" | grep $progmem > $PROGMEM.hex
|
||||
|
||||
# (7)
|
||||
echo " progmem.sh (7) - preparing string data" >&2
|
||||
#convert $PROGMEM.hex to $PROGMEM.chr (prepare string data for character check and conversion)
|
||||
# replace first space with tab
|
||||
# replace second space with tab and space
|
||||
# replace all remaining spaces with '\x'
|
||||
# replace all tabs with spaces
|
||||
cat $PROGMEM.hex | sed 's/ /\t/;s/ /\t /;s/ /\\x/g;s/\t/ /g' > $PROGMEM.chr
|
||||
|
||||
# (8)
|
||||
#convert $PROGMEM.chr to $PROGMEM.var (convert data to text)
|
||||
echo " progmem.sh (8) - converting string data" >&2
|
||||
cat $PROGMEM.chr | \
|
||||
sed 's/ \\xff\\xff/ /;' | \
|
||||
sed 's/\\x22/\\\\\\x22/g;' | \
|
||||
sed 's/\\x1b/\\\\\\x1b/g;' | \
|
||||
sed 's/\\x01/\\\\\\x01/g;' | \
|
||||
sed 's/\\xf8/\\\\\\xf8/g;' | \
|
||||
sed 's/\\x00$/\\x0a/;s/^/printf "/;s/$/"/' | sh > $PROGMEM.var
|
||||
cat $PROGMEM.var | sed 's/\r/\n/g' |sed -E 's/^[0-9a-f]{8} [^ ]* //' >$PROGMEM.txt
|
||||
|
||||
echo "progmem.sh finished" >&2
|
||||
|
||||
#!/bin/sh
|
||||
# progmem.sh - multi-language support low-level script
|
||||
# for examining content of progmem sections (default is progmem1)
|
||||
#
|
||||
# Input files:
|
||||
# $OUTDIR/Firmware.ino.elf
|
||||
# $OUTDIR/sketch/*.o (all object files)
|
||||
#
|
||||
# Output files:
|
||||
# text.sym
|
||||
# $PROGMEM.sym
|
||||
# $PROGMEM.lss
|
||||
# $PROGMEM.hex
|
||||
# $PROGMEM.chr
|
||||
# $PROGMEM.var
|
||||
# $PROGMEM.txt
|
||||
#
|
||||
# Program memory used
|
||||
PROGMEM=progmem$1
|
||||
if [ -z "$1" ]; then PROGMEM=progmem1; fi
|
||||
#
|
||||
# Output folder and elf file:
|
||||
OUTDIR="../../output"
|
||||
OUTELF="$OUTDIR/Firmware.ino.elf"
|
||||
#
|
||||
# AVR gcc tools used:
|
||||
OBJDUMP=C:/arduino-1.6.8/hardware/tools/avr/bin/avr-objdump.exe
|
||||
#
|
||||
#
|
||||
# Description of process:
|
||||
# 0. check input files
|
||||
# 1. remove output files
|
||||
# 2. list symbol table of section '.text' from output elf file to text.sym (sorted by address)
|
||||
# 3. list symbol table of section '.$PROGMEM' from all output object files to $PROGMEM.sym
|
||||
# 4. filter only $PROGMEM symbols from text.sym and store it back to $PROGMEM.sym with absolute address
|
||||
# 5. calculate start and stop address of section '.$PROGMEM'
|
||||
# 6. extract string data from elf file to $PROGMEM.hex
|
||||
# 7. prepare string data for character check and conversion (output to $PROGMEM.chr)
|
||||
# 8. perform character check and conversion (output to $PROGMEM.var and $PROGMEM.txt)
|
||||
#
|
||||
|
||||
echo "progmem.sh started" >&2
|
||||
|
||||
# (0)
|
||||
echo " progmem.sh (0) - checking input files" >&2
|
||||
if [ ! -e $OUTDIR ]; then echo "progmem.sh - file '$OUTELF' not found!" >&2; exit 1; fi
|
||||
|
||||
# (1)
|
||||
echo " progmem.sh (1) - removing output files" >&2
|
||||
#remove output files if exists
|
||||
if [ -e text.sym ]; then rm text.sym; fi
|
||||
if [ -e $PROGMEM.sym ]; then rm $PROGMEM.sym; fi
|
||||
if [ -e $PROGMEM.lss ]; then rm $PROGMEM.lss; fi
|
||||
if [ -e $PROGMEM.hex ]; then rm $PROGMEM.hex; fi
|
||||
if [ -e $PROGMEM.chr ]; then rm $PROGMEM.chr; fi
|
||||
if [ -e $PROGMEM.var ]; then rm $PROGMEM.var; fi
|
||||
if [ -e $PROGMEM.txt ]; then rm $PROGMEM.txt; fi
|
||||
|
||||
# (2)
|
||||
echo " progmem.sh (2) - listing symbol table of section '.text'" >&2
|
||||
#list symbols from section '.text' into file text.sym (only address, size and name)
|
||||
$OBJDUMP -t -j ".text" $OUTELF | tail -n +5 | grep -E "^[0-9a-f]{8} [gl] O" | cut -c1-9,28-36,37- | sed "/^$/d" | sort >> text.sym
|
||||
|
||||
# (3)
|
||||
echo " progmem.sh (3) - listing symbol table of section '.$PROGMEM'" >&2
|
||||
#loop over all object files
|
||||
ls "$OUTDIR"/sketch/*.o | while read fn; do
|
||||
echo " processing $fn" >&2
|
||||
#list symbols from section $PROGMEM (only address, size and name)
|
||||
$OBJDUMP -t -j ".$PROGMEM" $fn 2>/dev/null | tail -n +5 | cut -c1-9,28-36,37- | sed "/^$/d" | sort >> $PROGMEM.sym
|
||||
done
|
||||
|
||||
# (4)
|
||||
echo " progmem.sh (4) - filtering $PROGMEM symbols" >&2
|
||||
#create list of $PROGMEM symbol names separated by '\|'
|
||||
progmem=$(cut -c19- $PROGMEM.sym)
|
||||
progmem=$(echo $progmem | sed "s/ /\\\b\\\|\\\b/g")
|
||||
progmem='\b'$progmem'\b'
|
||||
#filter $PROGMEM symbols from section '.text' (result file will contain list sorted by absolute address)
|
||||
cat text.sym | grep $progmem > $PROGMEM.sym
|
||||
|
||||
# (5)
|
||||
echo " progmem.sh (5) - calculating start and stop address" >&2
|
||||
#calculate start addres of section ".$PROGMEM"
|
||||
PROGMEM_BEG=$(head -n1 $PROGMEM.sym | while read offs size name; do echo "0x"$offs; done)
|
||||
#calculate stop addres of section ".$PROGMEM"
|
||||
PROGMEM_END=$(tail -n1 $PROGMEM.sym | while read offs size name; do printf "0x%x" $(("0x"$offs + "0x"$size)); done)
|
||||
echo " START address = "$PROGMEM_BEG >&2
|
||||
echo " STOP address = "$PROGMEM_END >&2
|
||||
|
||||
# (6)
|
||||
echo " progmem.sh (6) - extracting string data from elf" >&2
|
||||
#dump $PROGMEM data in hex format, cut textual data (keep hex data only)
|
||||
$OBJDUMP -d -j ".text" -w -z --start-address=$PROGMEM_BEG --stop-address=$PROGMEM_END $OUTELF | cut -c1-57 > $PROGMEM.lss
|
||||
#convert $PROGMEM.lss to $PROGMEM.hex:
|
||||
# replace empty lines with '|' (variables separated by empty lines)
|
||||
# remove address from multiline variables (keep address at first variable line only)
|
||||
# remove '<' and '>:', remove whitespace at end of lines
|
||||
# remove line-endings, replace separator with '\n' (join hex data lines - each line will contain single variable)
|
||||
# filter progmem symbols
|
||||
cat $PROGMEM.lss | tail -n +7 | sed -E 's/^$/|/;s/^........:\t/ /;s/<//g;s/>:/ /g;s/[ \t]*$//' |\
|
||||
tr -d '\n' | sed "s/[|]/\n/g" | grep $progmem > $PROGMEM.hex
|
||||
|
||||
# (7)
|
||||
echo " progmem.sh (7) - preparing string data" >&2
|
||||
#convert $PROGMEM.hex to $PROGMEM.chr (prepare string data for character check and conversion)
|
||||
# replace first space with tab
|
||||
# replace second space with tab and space
|
||||
# replace all remaining spaces with '\x'
|
||||
# replace all tabs with spaces
|
||||
cat $PROGMEM.hex | sed 's/ /\t/;s/ /\t /;s/ /\\x/g;s/\t/ /g' > $PROGMEM.chr
|
||||
|
||||
# (8)
|
||||
#convert $PROGMEM.chr to $PROGMEM.var (convert data to text)
|
||||
echo " progmem.sh (8) - converting string data" >&2
|
||||
cat $PROGMEM.chr | \
|
||||
sed 's/ \\xff\\xff/ /;' | \
|
||||
sed 's/\\x22/\\\\\\x22/g;' | \
|
||||
sed 's/\\x1b/\\\\\\x1b/g;' | \
|
||||
sed 's/\\x01/\\\\\\x01/g;' | \
|
||||
sed 's/\\xf8/\\\\\\xf8/g;' | \
|
||||
sed 's/\\x00$/\\x0a/;s/^/printf "/;s/$/"/' | sh > $PROGMEM.var
|
||||
cat $PROGMEM.var | sed 's/\r/\n/g' |sed -E 's/^[0-9a-f]{8} [^ ]* //' >$PROGMEM.txt
|
||||
|
||||
echo "progmem.sh finished" >&2
|
||||
|
||||
exit 0
|
134
lang/textaddr.sh
134
lang/textaddr.sh
|
@ -1,68 +1,68 @@
|
|||
#!/bin/sh
|
||||
# textaddr.sh - multi-language support low level script
|
||||
# for compiling progmem1.var and lang_en.txt files
|
||||
# to textaddr.txt file (mapping of progmem addreses to text idenifiers)
|
||||
#
|
||||
# Input files:
|
||||
# progmem1.var
|
||||
# lang_en.txt
|
||||
#
|
||||
# Output files:
|
||||
# textaddr.txt
|
||||
#
|
||||
#
|
||||
# Dscription of process:
|
||||
# check if input files exists
|
||||
# create sorted list of strings from progmem1.var and lang_en.txt
|
||||
# lines from progmem1.var will contain addres (8 chars) and english text
|
||||
# lines from lang_en.txt will contain linenumber and english text
|
||||
# after sort this will generate pairs of lines (line from progmem1 first)
|
||||
# result of sort is compiled with simple script and stored into file textaddr.txt
|
||||
#
|
||||
|
||||
echo "textaddr.sh started" >&2
|
||||
|
||||
if [ ! -e progmem1.var ]; then echo 'textaddr.sh - file progmem1.var not found!' >&2; exit 1; fi
|
||||
if [ ! -e lang_en.txt ]; then echo 'textaddr.sh - file lang_en.txt not found!' >&2; exit 1; fi
|
||||
addr=''
|
||||
text=''
|
||||
(cat progmem1.var | sed -E "s/^([^ ]*) ([^ ]*) (.*)/\1 \"\3\"/";\
|
||||
cat lang_en.txt | sed "/^$/d;/^#/d" | sed = | sed '{N;s/\n/ /}') |\
|
||||
sort -k2 |\
|
||||
sed "s/\\\/\\\\\\\/g" | while read num txt; do
|
||||
if [ ${#num} -eq 8 ]; then
|
||||
if [ -z "$addr" ]; then
|
||||
addr=$num
|
||||
else
|
||||
if [ "$text" == "$txt" ]; then
|
||||
addr="$addr $num"
|
||||
else
|
||||
echo "ADDR NF $addr $text"
|
||||
addr=$num
|
||||
fi
|
||||
fi
|
||||
text=$txt
|
||||
else
|
||||
if [ -z "$addr" ]; then
|
||||
echo "TEXT NF $num $txt"
|
||||
else
|
||||
if [ "$text" == "$txt" ]; then
|
||||
if [ ${#addr} -eq 8 ]; then
|
||||
echo "ADDR OK $addr $num"
|
||||
else
|
||||
echo "$addr" | sed "s/ /\n/g" | while read ad; do
|
||||
echo "ADDR OK $ad $num"
|
||||
done
|
||||
fi
|
||||
addr=''
|
||||
text=''
|
||||
else
|
||||
echo "TEXT NF $num $txt"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done > textaddr.txt
|
||||
|
||||
echo "textaddr.sh finished" >&2
|
||||
|
||||
#!/bin/sh
|
||||
# textaddr.sh - multi-language support low level script
|
||||
# for compiling progmem1.var and lang_en.txt files
|
||||
# to textaddr.txt file (mapping of progmem addreses to text idenifiers)
|
||||
#
|
||||
# Input files:
|
||||
# progmem1.var
|
||||
# lang_en.txt
|
||||
#
|
||||
# Output files:
|
||||
# textaddr.txt
|
||||
#
|
||||
#
|
||||
# Dscription of process:
|
||||
# check if input files exists
|
||||
# create sorted list of strings from progmem1.var and lang_en.txt
|
||||
# lines from progmem1.var will contain addres (8 chars) and english text
|
||||
# lines from lang_en.txt will contain linenumber and english text
|
||||
# after sort this will generate pairs of lines (line from progmem1 first)
|
||||
# result of sort is compiled with simple script and stored into file textaddr.txt
|
||||
#
|
||||
|
||||
echo "textaddr.sh started" >&2
|
||||
|
||||
if [ ! -e progmem1.var ]; then echo 'textaddr.sh - file progmem1.var not found!' >&2; exit 1; fi
|
||||
if [ ! -e lang_en.txt ]; then echo 'textaddr.sh - file lang_en.txt not found!' >&2; exit 1; fi
|
||||
addr=''
|
||||
text=''
|
||||
(cat progmem1.var | sed -E "s/^([^ ]*) ([^ ]*) (.*)/\1 \"\3\"/";\
|
||||
cat lang_en.txt | sed "/^$/d;/^#/d" | sed = | sed '{N;s/\n/ /}') |\
|
||||
sort -k2 |\
|
||||
sed "s/\\\/\\\\\\\/g" | while read num txt; do
|
||||
if [ ${#num} -eq 8 ]; then
|
||||
if [ -z "$addr" ]; then
|
||||
addr=$num
|
||||
else
|
||||
if [ "$text" == "$txt" ]; then
|
||||
addr="$addr $num"
|
||||
else
|
||||
echo "ADDR NF $addr $text"
|
||||
addr=$num
|
||||
fi
|
||||
fi
|
||||
text=$txt
|
||||
else
|
||||
if [ -z "$addr" ]; then
|
||||
echo "TEXT NF $num $txt"
|
||||
else
|
||||
if [ "$text" == "$txt" ]; then
|
||||
if [ ${#addr} -eq 8 ]; then
|
||||
echo "ADDR OK $addr $num"
|
||||
else
|
||||
echo "$addr" | sed "s/ /\n/g" | while read ad; do
|
||||
echo "ADDR OK $ad $num"
|
||||
done
|
||||
fi
|
||||
addr=''
|
||||
text=''
|
||||
else
|
||||
echo "TEXT NF $num $txt"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done > textaddr.txt
|
||||
|
||||
echo "textaddr.sh finished" >&2
|
||||
|
||||
exit 0
|
|
@ -1,68 +1,68 @@
|
|||
#!/bin/sh
|
||||
# update_lang.sh - multi-language support low level script
|
||||
# for updating secondary language in binary file
|
||||
#
|
||||
# AVR gcc tools used:
|
||||
OBJCOPY=C:/arduino-1.6.8/hardware/tools/avr/bin/avr-objcopy.exe
|
||||
#
|
||||
# Selected language:
|
||||
LANG=$1
|
||||
if [ -z "$LANG" ]; then LANG='cz'; fi
|
||||
#
|
||||
|
||||
function finish
|
||||
{
|
||||
echo
|
||||
if [ "$1" == "0" ]; then
|
||||
echo "update_lang.sh finished with success" >&2
|
||||
else
|
||||
echo "update_lang.sh finished with errors!" >&2
|
||||
fi
|
||||
case "$-" in
|
||||
*i*) echo "press enter key"; read ;;
|
||||
esac
|
||||
exit $1
|
||||
}
|
||||
|
||||
echo "update_lang.sh started" >&2
|
||||
echo "selected language=$LANG" >&2
|
||||
|
||||
echo -n " checking files..." >&2
|
||||
if [ ! -e text.sym ]; then echo "NG! file text.sym not found!" >&2; finish 1; fi
|
||||
if [ ! -e lang_$LANG.bin ]; then echo "NG! file lang_$LANG.bin not found!" >&2; finish 1; fi
|
||||
if [ ! -e firmware.bin ]; then echo "NG! file firmware.bin not found!" >&2; finish 1; fi
|
||||
echo "OK" >&2
|
||||
|
||||
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
|
||||
echo "OK" >&2
|
||||
|
||||
echo " calculating vars:" >&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' ')
|
||||
echo " sec_lang_addr =$sec_lang_addr" >&2
|
||||
echo " sec_lang_size =$sec_lang_size" >&2
|
||||
#calculate lang_table_addr (aligned to 256byte page)
|
||||
lang_table_addr=$((256*$((($sec_lang_addr + 255) / 256))))
|
||||
printf " lang_table_addr =0x%04x\n" $lang_table_addr >&2
|
||||
#calculate lang_table_size
|
||||
lang_table_size=$((256*$((($sec_lang_size - ($lang_table_addr - $sec_lang_addr))/256))))
|
||||
printf " lang_table_size =0x%04x (=%d bytes)\n" $lang_table_size $lang_table_size >&2
|
||||
|
||||
#get lang_xx.bin file size
|
||||
lang_file_size=$(wc -c lang_$LANG.bin | cut -f1 -d' ')
|
||||
printf " lang_file_size =0x%04x (=%d bytes)\n" $lang_file_size $lang_file_size >&2
|
||||
|
||||
if [ $lang_file_size -gt $lang_table_size ]; then echo "Lanaguage binary file size too big!"; 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
|
||||
echo "converting to hex..." >&2
|
||||
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
|
||||
|
||||
finish 0
|
||||
#!/bin/sh
|
||||
# update_lang.sh - multi-language support low level script
|
||||
# for updating secondary language in binary file
|
||||
#
|
||||
# AVR gcc tools used:
|
||||
OBJCOPY=C:/arduino-1.6.8/hardware/tools/avr/bin/avr-objcopy.exe
|
||||
#
|
||||
# Selected language:
|
||||
LANG=$1
|
||||
if [ -z "$LANG" ]; then LANG='cz'; fi
|
||||
#
|
||||
|
||||
function finish
|
||||
{
|
||||
echo
|
||||
if [ "$1" == "0" ]; then
|
||||
echo "update_lang.sh finished with success" >&2
|
||||
else
|
||||
echo "update_lang.sh finished with errors!" >&2
|
||||
fi
|
||||
case "$-" in
|
||||
*i*) echo "press enter key"; read ;;
|
||||
esac
|
||||
exit $1
|
||||
}
|
||||
|
||||
echo "update_lang.sh started" >&2
|
||||
echo "selected language=$LANG" >&2
|
||||
|
||||
echo -n " checking files..." >&2
|
||||
if [ ! -e text.sym ]; then echo "NG! file text.sym not found!" >&2; finish 1; fi
|
||||
if [ ! -e lang_$LANG.bin ]; then echo "NG! file lang_$LANG.bin not found!" >&2; finish 1; fi
|
||||
if [ ! -e firmware.bin ]; then echo "NG! file firmware.bin not found!" >&2; finish 1; fi
|
||||
echo "OK" >&2
|
||||
|
||||
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
|
||||
echo "OK" >&2
|
||||
|
||||
echo " calculating vars:" >&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' ')
|
||||
echo " sec_lang_addr =$sec_lang_addr" >&2
|
||||
echo " sec_lang_size =$sec_lang_size" >&2
|
||||
#calculate lang_table_addr (aligned to 256byte page)
|
||||
lang_table_addr=$((256*$((($sec_lang_addr + 255) / 256))))
|
||||
printf " lang_table_addr =0x%04x\n" $lang_table_addr >&2
|
||||
#calculate lang_table_size
|
||||
lang_table_size=$((256*$((($sec_lang_size - ($lang_table_addr - $sec_lang_addr))/256))))
|
||||
printf " lang_table_size =0x%04x (=%d bytes)\n" $lang_table_size $lang_table_size >&2
|
||||
|
||||
#get lang_xx.bin file size
|
||||
lang_file_size=$(wc -c lang_$LANG.bin | cut -f1 -d' ')
|
||||
printf " lang_file_size =0x%04x (=%d bytes)\n" $lang_file_size $lang_file_size >&2
|
||||
|
||||
if [ $lang_file_size -gt $lang_table_size ]; then echo "Lanaguage binary file size too big!"; 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
|
||||
echo "converting to hex..." >&2
|
||||
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
|
||||
|
||||
finish 0
|
||||
|
|
Loading…
Add table
Reference in a new issue