diff options
author | Michael Hope <michael.hope@linaro.org> | 2010-09-29 20:21:52 +1300 |
---|---|---|
committer | Michael Hope <michael.hope@linaro.org> | 2010-09-29 20:21:52 +1300 |
commit | d470dc6daa46f26fc995ec86929e8209c581ea2d (patch) | |
tree | 09a748c56a2ec8e14dca1a94c125bd7fc78b238c /support | |
parent | 97f6b77b580646f5771ff283a3c586045c0e8425 (diff) | |
download | librambutan-d470dc6daa46f26fc995ec86929e8209c581ea2d.tar.gz librambutan-d470dc6daa46f26fc995ec86929e8209c581ea2d.zip |
Do basic validation on the boot version and chip IDs.
Diffstat (limited to 'support')
-rwxr-xr-x | support/stm32loader.py | 12 |
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() |