Aktionen
Script¶
#!/bin/bash
set -e
set -u
handleError()
{
echo "Error: Something went wrong here. $1"
exit 22
}
writeHwInfo()
{
echo "BINARY: $BINARY"
cat << EOF > .gdbinit
set arm abi AAPCS
target remote localhost:3333
monitor reset halt
EOF
cat << EOF > gdb.txt
br main:loop
echo Waiting for application does stop at breakpoint.\n
echo If it does not stop, the given binary file is probably wrong.\n
c
# call (flash)(10,\"mmm\")
print &bringupFirmware
clear main:loop
monitor reset run
EOF
echo $GDB $BINARY -x gdb.txt
# $GDB $O/$B -x gdb.txt -batch-silent -q || handleError "Could not verify bringup firmware. Is bringup firmware flashed?"
$GDB $BINARY -x gdb.txt --batch || handleError "Could not verify bringup firmware. Is bringup firmware flashed?"
echo -n "Please enter serial number in hex or dec (e.g. 0x123): "
read serial
serial=$(printf '0x%x\n' $serial)
serialLong=$(printf '%08X\n' $serial)
# echo -n "Please enter variant in hex or dec (e.g. 0x123): "
# read serial
variant=0
if [ -z "$serial" ]; then hanleError "You did not specify an serial number."; fi
# SEepromMain hwInfoMain
# a=$(nm $O/$B | grep hwInfoMain) || handleError "Could not find 'myStruct'"
# addr=${a%% *}
# echo "Will try x/20xb 0x$addr"
cat << EOF >gdb.txt
echo "Helllooooooo"
br main:loop
# run
echo "### Continue run"
c
echo ### Braked\n
set var \$new = (SEepromMain *)malloc(sizeof(struct SEepromMain))
set var \$new.main.magic='H'
set var \$new.main.articleId=$articleId
set var \$new.main.boardId=$boardId
set var \$new.version.hwVersionMajor=$versionMajor
set var \$new.version.hwVersionMinor=$versionMinor
set var \$new.version.hwVersionPatch=$versionPatch
set var \$new.production.serialNumber=$serial
set var \$new.production.variant=$variant
set var \$new.production.productionDateYear=$year
set var \$new.production.productionDateMonth=$month
set var \$new.production.productionDateDay=$day
set var \$new.production.productionSite=$site
echo ### calling function\n
call (writeHwInfo)(\$new)
# monitor reset run
echo ### Read back\n
call (readHwInfo)()
print/x bringupFirmware
set logging file serial.txt
set logging overwrite
set logging on
print/x $cppObject->hwInfoMain.production.serialNumber
set logging off
set logging file all.txt
set logging overwrite
set logging on
print/x $cppObject->hwInfoMain
print &$cppObject->hwInfoMain
x/28xb \$0
set logging off
echo ### finished\n
clear main:loop
echo "### END"
# must not continue or we stuck here
# c
EOF
echo "### Waiting for application to break to write stuff 2"
echo "### $GDB $BINARY -x gdb.txt -batch-silent -q"
$GDB $BINARY -x gdb.txt --batch || handleError "Could not write HwInfo. Is bringup firmware flashed?"
echo "### Waiting for application to break to write stuff 3"
echo -e "\n"
echo "Serial: "
a=$(cat serial.txt)
isSerial="${a##* = }"
if [ "$serial" == "$isSerial" ]; then
cat all.txt
echo "Serial is OK; $serial == $isSerial"
else
handleError "Serial is NOT OK; $serial != $isSerial"
fi
mv all.txt $opwd/hwinfo_${serialLong}.txt
}
opwd=$PWD
GDB=/opt/tcb-stm32/usr/bin/arm-none-eabi/arm-none-eabi-gdb
month=$(date +"%m")
day=$(date +"%d")
year=$(date +"%y")
#---fin------------------------------------------------------------------------
Von Maximilian Seesslen vor etwa 3 Jahren aktualisiert · 1 Revisionen