Commit a621333a authored by Paul Sokolovsky's avatar Paul Sokolovsky

esp8266/makeimg.py: Store firmware size as last 4 bytes of padding area.

parent efb8aa0e
import sys import sys
import struct
SEGS_MAX_SIZE = 0x9000 SEGS_MAX_SIZE = 0x9000
...@@ -11,13 +12,16 @@ with open(sys.argv[3], 'wb') as fout: ...@@ -11,13 +12,16 @@ with open(sys.argv[3], 'wb') as fout:
fout.write(data_flash) fout.write(data_flash)
print('flash ', len(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)) 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)) print('padding ', len(pad))
with open(sys.argv[2], 'rb') as f: fout.write(data_rom)
data_rom = f.read() print('irom0text', len(data_rom))
fout.write(data_rom)
print('irom0text', len(data_rom))
print('total ', SEGS_MAX_SIZE + len(data_rom)) print('total ', SEGS_MAX_SIZE + len(data_rom))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment