stm32_mem: Check file size before flashing(#614)
stm32mem is only meant to flash BMP to a STM32F103x(8|B). No need to decipher the DFU interface string.
This commit is contained in:
parent
2b76ec0ea3
commit
e57792c95e
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import struct
|
import struct
|
||||||
|
import os
|
||||||
from sys import stdout, argv
|
from sys import stdout, argv
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -195,6 +196,10 @@ if __name__ == "__main__":
|
||||||
exit(0)
|
exit(0)
|
||||||
dfudev.make_idle()
|
dfudev.make_idle()
|
||||||
file = open(args.progfile, "rb")
|
file = open(args.progfile, "rb")
|
||||||
|
if (os.path.getsize(args.progfile) > 0x1f800):
|
||||||
|
print("File too large")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
bin = file.read()
|
bin = file.read()
|
||||||
|
|
||||||
product = dfudev.handle.getString(dfudev.dev.iProduct, 64)
|
product = dfudev.handle.getString(dfudev.dev.iProduct, 64)
|
||||||
|
|
Loading…
Reference in New Issue