scripts: allow more time for external flash verification

create ssbl uploader script for SPRacingH7
This commit is contained in:
Andy Piper 2022-02-04 17:56:35 +00:00 committed by Peter Hall
parent 3f7a726970
commit 960c0d0f8b
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,18 @@
#!/bin/sh
# Upload a firmware image to a flight controller using the second-stage bootloader
if [ $# -lt 2 ]; then
echo "Usage: ssbl_uploader.sh BOARD TARGET"
exit 1
fi
BOARD="$1"
TARGET="$2"
TARGET2MB=build/${BOARD}/bin/${TARGET}_2MB.bin
rm -f "${TARGET2MB}-VERIFY.bin"
dd if=/dev/zero ibs=1k count=2048 of=${TARGET2MB}
dd conv=notrunc if=build/${BOARD}/bin/${TARGET}_extf.bin of=${TARGET2MB}
dfu-util -D "${TARGET2MB}" -s 0x90100000:0x200000
dfu-util -U "${TARGET2MB}-VERIFY.bin" -s 0x90100000:0x200000
diff -sb ${TARGET2MB} "${TARGET2MB}-VERIFY.bin"

View File

@ -661,10 +661,33 @@ class uploader(object):
size_bytes = chr(size)
print("\n", end='')
self.__drawProgressBar(label, 1, 100)
expect_crc = fw.extf_crc(size)
self.__send(uploader.EXTF_GET_CRC +
size_bytes + uploader.EOC)
report_crc = self.__recv_int()
# crc can be slow, give it 10s
deadline = time.time() + 10.0
while time.time() < deadline:
# Draw progress bar
estimatedTimeRemaining = deadline-time.time()
if estimatedTimeRemaining >= 4.0:
self.__drawProgressBar(label, 10.0-estimatedTimeRemaining, 4.0)
else:
self.__drawProgressBar(label, 5.0, 5.0)
sys.stdout.write(" (timeout: %d seconds) " % int(deadline-time.time()))
sys.stdout.flush()
try:
report_crc = self.__recv_int()
break
except Exception:
continue
if time.time() >= deadline:
raise RuntimeError("Program CRC timed out")
self.__getSync()
if report_crc != expect_crc:
print("\nExpected 0x%x" % expect_crc)