New ML support - scripts - tunning
+config.sh
This commit is contained in:
parent
77f3160531
commit
4b9ec286db
6 changed files with 150 additions and 45 deletions
64
lang/config.sh
Normal file
64
lang/config.sh
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# config.sh - multi-language support configuration script
|
||||
# Definition of absolute paths etc.
|
||||
# This file is 'included' in all scripts.
|
||||
#
|
||||
# Arduino main folder:
|
||||
export ARDUINO=C:/arduino-1.6.8
|
||||
#
|
||||
# Arduino builder:
|
||||
export BUILDER=$ARDUINO/arduino_debug.exe
|
||||
#
|
||||
# AVR gcc tools:
|
||||
export OBJCOPY=$ARDUINO/hardware/tools/avr/bin/avr-objcopy.exe
|
||||
export OBJDUMP=$ARDUINO/hardware/tools/avr/bin/avr-objdump.exe
|
||||
#
|
||||
# Output folder:
|
||||
export OUTDIR="../../output"
|
||||
#
|
||||
# Objects folder:
|
||||
export OBJDIR="$OUTDIR/sketch"
|
||||
#
|
||||
# Generated elf file:
|
||||
export INOELF="$OUTDIR/Firmware.ino.elf"
|
||||
#
|
||||
# Generated hex file:
|
||||
export INOHEX="$OUTDIR/Firmware.ino.hex"
|
||||
|
||||
|
||||
echo "config.sh started" >&2
|
||||
|
||||
_err=0
|
||||
|
||||
echo -n " Arduino main folder: " >&2
|
||||
if [ -e $ARDUINO ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=1; fi
|
||||
|
||||
echo -n " Arduino builder: " >&2
|
||||
if [ -e $BUILDER ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=2; fi
|
||||
|
||||
echo " AVR gcc tools:" >&2
|
||||
echo -n " objcopy " >&2
|
||||
if [ -e $OBJCOPY ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=3; fi
|
||||
echo -n " objdump " >&2
|
||||
if [ -e $OBJDUMP ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=4; fi
|
||||
|
||||
echo -n " Output folder: " >&2
|
||||
if [ -e $OUTDIR ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=5; fi
|
||||
|
||||
echo -n " Objects folder: " >&2
|
||||
if [ -e $OBJDIR ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=6; fi
|
||||
|
||||
echo -n " Generated elf file: " >&2
|
||||
if [ -e $INOELF ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=7; fi
|
||||
|
||||
echo -n " Generated hex file: " >&2
|
||||
if [ -e $INOHEX ]; then echo 'OK' >&2; else echo 'NG!' >&2; _err=8; fi
|
||||
|
||||
if [ $_err -eq 0 ]; then
|
||||
echo "config.sh finished with success" >&2
|
||||
export CONFIG_OK=1
|
||||
else
|
||||
echo "config.sh finished with errors!" >&2
|
||||
export CONFIG_OK=0
|
||||
fi
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/sh
|
||||
# makelang.sh - multi-language support high-level script
|
||||
#
|
||||
# makelang.sh - multi-language support script
|
||||
# for generating lang_xx.bin (secondary language binary file)
|
||||
#
|
||||
# Input files:
|
||||
|
@ -19,6 +20,15 @@ if [ -z "$LANG" ]; then LANG='cz'; fi
|
|||
#
|
||||
#
|
||||
|
||||
if [ "$LANG" == "all" ]; then
|
||||
./make_lang.sh cz
|
||||
./make_lang.sh de
|
||||
./make_lang.sh es
|
||||
./make_lang.sh it
|
||||
./make_lang.sh pl
|
||||
exit 0
|
||||
fi
|
||||
|
||||
function finish
|
||||
{
|
||||
if [ "$1" == "0" ]; then
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
# postbuild.sh - multi-language support high-level script
|
||||
# for generating binary with secondary language
|
||||
#
|
||||
# postbuild.sh - multi-language support script
|
||||
# Generate binary with secondary language.
|
||||
#
|
||||
# Input files:
|
||||
# $OUTDIR/Firmware.ino.elf
|
||||
|
@ -16,12 +17,10 @@
|
|||
# $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
|
||||
# Config:
|
||||
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
|
||||
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
|
||||
#
|
||||
# Selected language:
|
||||
LANG=$1
|
||||
|
@ -30,6 +29,7 @@ LANG=$1
|
|||
# Params:
|
||||
IGNORE_MISSING_TEXT=1
|
||||
|
||||
|
||||
function finish
|
||||
{
|
||||
echo
|
||||
|
@ -50,9 +50,9 @@ echo "postbuild.sh started" >&2
|
|||
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
|
||||
if [ ! -e $INOELF ]; then echo " elf file '$INOELF' 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
|
||||
if ! ls $OBJDIR/*.o >/dev/null 2>&1; then echo " no object files in '$OBJDIR/'!" >&2; finish 1; fi
|
||||
echo " objects OK" >&2
|
||||
|
||||
#run progmem.sh - examine content of progmem1
|
||||
|
@ -105,12 +105,38 @@ if [ ! -z "$LANG" ]; then
|
|||
echo "OK" >&2
|
||||
finish 0
|
||||
else
|
||||
echo "skipped" >&2
|
||||
echo "Updating languages:" >&2
|
||||
if [ -e lang_cz.bin ]; then
|
||||
echo -n " Czech : " >&2
|
||||
./update_lang.sh cz 2>./update_lang_cz.out 1>/dev/null
|
||||
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
|
||||
fi
|
||||
if [ -e lang_de.bin ]; then
|
||||
echo -n " German : " >&2
|
||||
./update_lang.sh de 2>./update_lang_de.out 1>/dev/null
|
||||
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
|
||||
fi
|
||||
if [ -e lang_it.bin ]; then
|
||||
echo -n " Italian: " >&2
|
||||
./update_lang.sh it 2>./update_lang_it.out 1>/dev/null
|
||||
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
|
||||
fi
|
||||
if [ -e lang_es.bin ]; then
|
||||
echo -n " Spanish: " >&2
|
||||
./update_lang.sh es 2>./update_lang_es.out 1>/dev/null
|
||||
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
|
||||
fi
|
||||
if [ -e lang_pl.bin ]; then
|
||||
echo -n " Polish : " >&2
|
||||
./update_lang.sh pl 2>./update_lang_pl.out 1>/dev/null
|
||||
if [ $? -eq 0 ]; then echo 'OK' >&2; else echo 'NG!' >&2; fi
|
||||
fi
|
||||
# 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
|
||||
#echo -n " converting to hex..." >&2
|
||||
#$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
|
||||
#echo "OK" >&2
|
||||
|
||||
finish 0
|
||||
|
|
|
@ -1,32 +1,34 @@
|
|||
#!/bin/sh
|
||||
# progmem.sh - multi-language support low-level script
|
||||
# for examining content of progmem sections (default is progmem1)
|
||||
#
|
||||
# progmem.sh - multi-language support script
|
||||
# Examine 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
|
||||
# text.sym - formated symbol listing of section '.text'
|
||||
# $PROGMEM.sym - formated symbol listing of section '.progmemX'
|
||||
# $PROGMEM.lss - disassembly listing file
|
||||
# $PROGMEM.hex - variables - hex
|
||||
# $PROGMEM.chr - variables - char escape
|
||||
# $PROGMEM.var - variables - strings
|
||||
# $PROGMEM.txt - text data only
|
||||
#
|
||||
#
|
||||
# Config:
|
||||
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
|
||||
if [ -z "$OUTDIR" ]; then echo 'variable OUTDIR not set!' >&2; exit 1; fi
|
||||
if [ -z "$OBJDIR" ]; then echo 'variable OBJDIR not set!' >&2; exit 1; fi
|
||||
if [ -z "$INOELF" ]; then echo 'variable INOELF not set!' >&2; exit 1; fi
|
||||
if [ -z "$OBJDUMP" ]; then echo 'variable OBJDUMP not set!' >&2; exit 1; fi
|
||||
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
|
||||
#
|
||||
# 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
|
||||
|
@ -43,7 +45,7 @@ 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
|
||||
if [ ! -e $OUTDIR ]; then echo "progmem.sh - file '$INOELF' not found!" >&2; exit 1; fi
|
||||
|
||||
# (1)
|
||||
echo " progmem.sh (1) - removing output files" >&2
|
||||
|
@ -59,12 +61,12 @@ 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
|
||||
$OBJDUMP -t -j ".text" $INOELF | 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
|
||||
ls "$OBJDIR"/*.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
|
||||
|
@ -91,7 +93,7 @@ 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
|
||||
$OBJDUMP -d -j ".text" -w -z --start-address=$PROGMEM_BEG --stop-address=$PROGMEM_END $INOELF | 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)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/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)
|
||||
#
|
||||
# textaddr.sh - multi-language support script
|
||||
# Compile progmem1.var and lang_en.txt files to textaddr.txt file (mapping of progmem addreses to text idenifiers)
|
||||
#
|
||||
# Input files:
|
||||
# progmem1.var
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#!/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
|
||||
# update_lang.sh - multi-language support script
|
||||
# Update secondary language in binary file.
|
||||
#
|
||||
# Config:
|
||||
if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
|
||||
if [ -z "$OBJCOPY" ]; then echo 'variable OBJCOPY not set!' >&2; exit 1; fi
|
||||
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
|
||||
#
|
||||
# Selected language:
|
||||
LANG=$1
|
||||
|
@ -19,7 +22,7 @@ function finish
|
|||
echo "update_lang.sh finished with errors!" >&2
|
||||
fi
|
||||
case "$-" in
|
||||
*i*) echo "press enter key"; read ;;
|
||||
*i*) echo "press enter key" >&2; read ;;
|
||||
esac
|
||||
exit $1
|
||||
}
|
||||
|
@ -56,13 +59,13 @@ printf " lang_table_size =0x%04x (=%d bytes)\n" $lang_table_size $lang_table_si
|
|||
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
|
||||
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
|
||||
echo "converting to hex..." >&2
|
||||
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
|
||||
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware_$LANG.hex
|
||||
|
||||
finish 0
|
||||
|
|
Loading…
Reference in a new issue