mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-15 14:10:38 +02:00
m1nor: accept multiple file arguments; clarified diagnostics
One can now pass all files to flash in the same invocation. m1nor does a first pass to verify the argument, a second pass to do the flashing, and a third pass to report that it has done. Diagnostics now begin with the file name followed by a description of the problem encountered.
This commit is contained in:
parent
a946aac7ba
commit
037be5062e
@ -27,35 +27,39 @@
|
|||||||
# (data) 0x00D2 0000 19328k
|
# (data) 0x00D2 0000 19328k
|
||||||
#
|
#
|
||||||
|
|
||||||
|
classify()
|
||||||
|
{
|
||||||
|
if [ ! -r "$1" ]; then
|
||||||
|
echo "$1: cannot read" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
b=${1##*/}
|
||||||
|
if [ "${b#standby}" != "$b" ]; then off=0x0; ext=.fpg
|
||||||
|
elif [ "${b#soc-rescue}" != "$b" ]; then off=0xa0000; ext=.fpg
|
||||||
|
elif [ "${b#bios-rescue}" != "$b" ]; then off=0x220000; ext=.bin
|
||||||
|
elif [ "${b#splash-rescue}" != "$b" ]; then off=0x240000; ext=.raw
|
||||||
|
elif [ "${b#flickernoise-rescue}" != "$b" ]; then off=0x2e0000; ext=.fbi
|
||||||
|
elif [ "${b#soc}" != "$b" ]; then off=0x6e0000; ext=.fpg
|
||||||
|
elif [ "${b#system}" != "$b" ]; then off=0x6e0000; ext=.fpg
|
||||||
|
elif [ "${b#bios}" != "$b" ]; then off=0x860000; ext=.bin
|
||||||
|
elif [ "${b#splash}" != "$b" ]; then off=0x880000; ext=.raw
|
||||||
|
elif [ "${b#flickernoise}" != "$b" ]; then off=0x920000; ext=.fbi
|
||||||
|
elif [ "${b#data}" != "$b" ]; then off=0xd20000; ext=
|
||||||
|
else
|
||||||
|
echo "$1: unrecognized file name" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ext" -a "${1%$ext}" = "$1" ]; then
|
||||||
|
echo "$1: extension mismatch (expected $ext)" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "usage: $0 filename" 1>&2
|
echo "usage: $0 filename ..." 1>&2
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -r "$1" ]; then
|
|
||||||
echo "cannot read $1" 1>&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
n=${1##*/}
|
|
||||||
if [ "${n#standby}" != "$n" ]; then off=0x0; ext=.fpg
|
|
||||||
elif [ "${n#soc-rescue}" != "$n" ]; then off=0xa0000; ext=.fpg
|
|
||||||
elif [ "${n#bios-rescue}" != "$n" ]; then off=0x220000; ext=.bin
|
|
||||||
elif [ "${n#splash-rescue}" != "$n" ]; then off=0x240000; ext=.raw
|
|
||||||
elif [ "${n#flickernoise-rescue}" != "$n" ]; then off=0x2e0000; ext=.fbi
|
|
||||||
elif [ "${n#soc}" != "$n" ]; then off=0x6e0000; ext=.fpg
|
|
||||||
elif [ "${n#system}" != "$n" ]; then off=0x6e0000; ext=.fpg
|
|
||||||
elif [ "${n#bios}" != "$n" ]; then off=0x860000; ext=.bin
|
|
||||||
elif [ "${n#splash}" != "$n" ]; then off=0x880000; ext=.raw
|
|
||||||
elif [ "${n#flickernoise}" != "$n" ]; then off=0x920000; ext=.fbi
|
|
||||||
elif [ "${n#data}" != "$n" ]; then off=0xd20000; ext=
|
|
||||||
else
|
|
||||||
echo "unrecognized file name" 1>&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ext" -a "${1%$ext}" = "$1" ]; then
|
|
||||||
echo "extension mismatch (expected $ext)" 1>&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -76,7 +80,12 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jtag <<EOF
|
for n in "$@"; do
|
||||||
|
classify "$n"
|
||||||
|
done
|
||||||
|
|
||||||
|
(
|
||||||
|
cat <<EOF
|
||||||
cable milkymist
|
cable milkymist
|
||||||
detect
|
detect
|
||||||
instruction CFG_OUT 000100 BYPASS
|
instruction CFG_OUT 000100 BYPASS
|
||||||
@ -86,8 +95,27 @@ initbus fjmem opcode=000010
|
|||||||
frequency 6000000
|
frequency 6000000
|
||||||
detectflash 0
|
detectflash 0
|
||||||
endian big
|
endian big
|
||||||
flashmem "$off" "$1" noverify
|
|
||||||
pld reconfigure
|
|
||||||
EOF
|
EOF
|
||||||
|
for n in "$@"; do
|
||||||
|
classify "$n"
|
||||||
|
echo flashmem "$off" "$n" noverify
|
||||||
|
done
|
||||||
|
echo pld reconfigure
|
||||||
|
) | jtag -q || exit
|
||||||
|
|
||||||
echo "Flashed $1 at offset $off using $fjmem" 1>&2
|
#
|
||||||
|
# FIXME: the exit code of "jtag" doesn't indicate whether the session was
|
||||||
|
# successful.
|
||||||
|
#
|
||||||
|
|
||||||
|
first=true
|
||||||
|
for n in "$@"; do
|
||||||
|
classify "$n"
|
||||||
|
echo -n "Flashed $n at offset $off" 1>&2
|
||||||
|
if $first; then
|
||||||
|
echo " using $fjmem" 1>&2
|
||||||
|
else
|
||||||
|
echo 1>&2
|
||||||
|
fi
|
||||||
|
first=false
|
||||||
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user