circuitpython/esp8266/makeimg.py
Paul Sokolovsky 8d2bcaf3cd esp8266: Minimize gap between Inst/DataRAM segments and FlashROM segment.
With .rodata being in FlashROM now, gap can be much smaller now. InstRAM
can be max 32K, and with segment headers, that already makes it more than
32K. Then there's some .data still, and the next Flash page boundary is
0x9000. That figure should be more or less future-proof.

TODO: Refactor makeimg to take FlashROM segment offset from file name.
2016-04-03 15:45:14 +03:00

24 lines
548 B
Python

import sys
SEGS_MAX_SIZE = 0x9000
assert len(sys.argv) == 4
with open(sys.argv[3], 'wb') as fout:
with open(sys.argv[1], 'rb') as f:
data_flash = f.read()
fout.write(data_flash)
print('flash ', len(data_flash))
pad = b'\xff' * (SEGS_MAX_SIZE - len(data_flash))
fout.write(pad)
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))
print('total ', SEGS_MAX_SIZE + len(data_rom))