summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/makeimg.py
diff options
context:
space:
mode:
Diffstat (limited to 'esp8266/makeimg.py')
-rw-r--r--esp8266/makeimg.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/esp8266/makeimg.py b/esp8266/makeimg.py
index e63f956bdd..091854fa4d 100644
--- a/esp8266/makeimg.py
+++ b/esp8266/makeimg.py
@@ -1,23 +1,40 @@
import sys
+import struct
+import hashlib
SEGS_MAX_SIZE = 0x9000
assert len(sys.argv) == 4
+md5 = hashlib.md5()
+
with open(sys.argv[3], 'wb') as fout:
with open(sys.argv[1], 'rb') as f:
data_flash = f.read()
fout.write(data_flash)
+ # First 4 bytes include flash size, etc. which may be changed
+ # by esptool.py, etc.
+ md5.update(data_flash[4:])
print('flash ', len(data_flash))
+ with open(sys.argv[2], 'rb') as f:
+ data_rom = f.read()
+
pad = b'\xff' * (SEGS_MAX_SIZE - len(data_flash))
- fout.write(pad)
+ assert len(pad) >= 4
+ fout.write(pad[:-4])
+ md5.update(pad[:-4])
+ len_data = struct.pack("I", SEGS_MAX_SIZE + len(data_rom))
+ fout.write(len_data)
+ md5.update(len_data)
print('padding ', len(pad))
- with open(sys.argv[2], 'rb') as f:
- data_rom = f.read()
- fout.write(data_rom)
- print('irom0text', len(data_rom))
+ fout.write(data_rom)
+ md5.update(data_rom)
+ print('irom0text', len(data_rom))
+
+ fout.write(md5.digest())
print('total ', SEGS_MAX_SIZE + len(data_rom))
+ print('md5 ', md5.hexdigest())