aboutsummaryrefslogtreecommitdiffstats
path: root/support/stm32loader.py
diff options
context:
space:
mode:
authorMichael Hope <michael.hope@linaro.org>2010-09-29 20:21:52 +1300
committerMichael Hope <michael.hope@linaro.org>2010-09-29 20:21:52 +1300
commitd470dc6daa46f26fc995ec86929e8209c581ea2d (patch)
tree09a748c56a2ec8e14dca1a94c125bd7fc78b238c /support/stm32loader.py
parent97f6b77b580646f5771ff283a3c586045c0e8425 (diff)
downloadlibrambutan-d470dc6daa46f26fc995ec86929e8209c581ea2d.tar.gz
librambutan-d470dc6daa46f26fc995ec86929e8209c581ea2d.zip
Do basic validation on the boot version and chip IDs.
Diffstat (limited to 'support/stm32loader.py')
-rwxr-xr-xsupport/stm32loader.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/support/stm32loader.py b/support/stm32loader.py
index 7509871..b7fb96c 100755
--- a/support/stm32loader.py
+++ b/support/stm32loader.py
@@ -426,8 +426,18 @@ if __name__ == "__main__":
print "Can't init. Ensure that BOOT0 is enabled and reset device"
bootversion = cmd.cmdGet()
+
mdebug(0, "Bootloader version %X" % bootversion)
- mdebug(0, "Chip id `%s'" % str(map(lambda c: hex(ord(c)), cmd.cmdGetID())))
+
+ if bootversion < 20 or bootversion >= 100:
+ raise Exception('Unreasonable bootloader version %d' % bootversion)
+
+ id = [ord(x) for x in cmd.cmdGetID()]
+ mdebug(0, "Chip id '%s'" % ' '.join('0x%x' % x for x in id))
+
+ if len(id) < 2 or id[0] != 0x04:
+ raise Exception('Unrecognised chip ID')
+
# cmd.cmdGetVersion()
# cmd.cmdGetID()
# cmd.cmdReadoutUnprotect()