diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-08-04 00:19:09 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-08-04 00:19:09 +0300 |
commit | a621333a4c4fcc161f076980c9147faa555de5de (patch) | |
tree | 5e7e36acff849f0830d83e5b982da2e5847fd7ff | |
parent | efb8aa0ef68acf77e09d53114972c5d638daa14f (diff) | |
download | micropython-a621333a4c4fcc161f076980c9147faa555de5de.tar.gz micropython-a621333a4c4fcc161f076980c9147faa555de5de.zip |
esp8266/makeimg.py: Store firmware size as last 4 bytes of padding area.
-rw-r--r-- | esp8266/makeimg.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/esp8266/makeimg.py b/esp8266/makeimg.py index e63f956bdd..834f778c84 100644 --- a/esp8266/makeimg.py +++ b/esp8266/makeimg.py @@ -1,4 +1,5 @@ import sys +import struct SEGS_MAX_SIZE = 0x9000 @@ -11,13 +12,16 @@ with open(sys.argv[3], 'wb') as fout: fout.write(data_flash) 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]) + fout.write(struct.pack("I", SEGS_MAX_SIZE + len(data_rom))) 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) + print('irom0text', len(data_rom)) print('total ', SEGS_MAX_SIZE + len(data_rom)) |