Skip to content
Snippets Groups Projects

Draft: Bugfix/nor update fix

Closed Karel Koci requested to merge bugfix/nor-update-fix into hotfix/nor-update
1 unresolved thread
@@ -29,10 +29,10 @@ board_post_hook() {
:
}
# die and v_echo might be used by board configuration
# Note: die and v_echo might be used by board configuration so they are defined early
die() {
echo "${0##*/}: $1" >&2
echo "${0##*/}:" "$@" >&2
exit 1
}
@@ -41,11 +41,17 @@ v_echo() {
[ -z "$VERBOSE" ] || echo "$@" >&2
}
###################################
. "/usr/share/nor-update/config.sh"
###################################
print_usage() {
echo "Usage: ${0##*/} [-d] [-v]"
}
print_help() {
echo "Usage:"
echo " nor-update [-d] [-v]"
print_usage
echo "Turris NOR firmware update utility."
echo
echo "Options:"
echo " -d Use devel version - bleeding edge, but it might brick your device. Proceed with caution!"
@@ -61,20 +67,21 @@ flash() {
shift 2
while [ -n "$1" ] && [ \! -r "$1" ] && shift; do
:
while [ -n "${1:+x}" ] && [ ! -r "$1" ]; do
shift
done
if [ \! -r "$1" ]; then
if [ -z "${1:+x}" ]; then
echo "Can't find anything to flash to '$flashing' partition"
return 0
fi
if [ \! -c "/dev/$part" ]; then
if [ ! -c "/dev/$part" ]; then
die "/dev/$part is missing!"
fi
v_echo "Checking and flashing '$flashing' partition: $1 -> /dev/$part"
return 0 # TODO remove
if mtd verify "$1" "/dev/$part"; then
v_echo "Partition with $flashing was up to date already."
else
@@ -103,20 +110,30 @@ fix_boot_scr() (
die "Can't create boot.scr symlink"
)
while [ -n "$1" ]; do
case "$1" in
"-d") DEVEL="y";;
"-v") VERBOSE="y";;
"-h") print_help
exit 0
;;
*) echo "Invalid usage!!!"
print_help
exit 1
;;
while getopts ':dvh' OPT; do
case "$OPT" in
d)
DEVEL="y"
;;
v)
VERBOSE="y"
;;
h)
print_help
exit 0
;;
\?)
print_usage
Please register or sign in to reply
die "Illegal option '-$OPTARG'"
exit 1
;;
esac
shift
done
shift $(( OPTIND-1 ))
[ $# -eq 0 ] || {
print_usage
die "Provided too many arguments. See help \`-h\`"
}
fix_boot_scr