2015-05-22 18:23:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Anti brick check script for Freescale Kinetis MCUs.
|
|
|
|
#
|
|
|
|
# This script is supposed to be called from RIOTs
|
|
|
|
# unified OpenOCD script (dist/tools/openocd/openocd.sh).
|
|
|
|
#
|
|
|
|
# @author Jonas Remmert <j.remmert@phytec.de>
|
|
|
|
# @author Johann Fischer <j.fischer@phytec.de>
|
|
|
|
|
|
|
|
ELFFILE=$1
|
2018-11-27 16:00:42 +01:00
|
|
|
ACTUAL_FCFIELD=$(arm-none-eabi-objdump -j.fcfield -s "${ELFFILE}" | awk '/^ 0400 / {print $2 $3 $4 $5}')
|
|
|
|
# Allow any FOPT flags configuration (".." in the pattern)
|
|
|
|
EXPECTED_FCFIELD="^fffffffffffffffffffffffffe..ffff$"
|
2015-05-22 18:23:38 +02:00
|
|
|
|
2018-11-27 16:00:42 +01:00
|
|
|
if ! printf '%s' "${ACTUAL_FCFIELD}" | grep -q "${EXPECTED_FCFIELD}" ; then
|
2015-05-22 18:23:38 +02:00
|
|
|
echo "Danger of bricking the device during flash!"
|
2018-11-27 16:00:42 +01:00
|
|
|
echo "Flash configuration field of ${ELFFILE}:"
|
|
|
|
arm-none-eabi-objdump -j.fcfield -s "${ELFFILE}"
|
2015-05-22 18:23:38 +02:00
|
|
|
echo "Abort flash procedure!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-11-27 16:00:42 +01:00
|
|
|
echo "${ELFFILE} is fine."
|
2015-05-22 18:23:38 +02:00
|
|
|
exit 0
|