|
22 | 22 | import re
|
23 | 23 | import os
|
24 | 24 | import subprocess
|
| 25 | +import sys |
25 | 26 | import tempfile
|
26 | 27 |
|
27 |
| -fmodeb = { 'DOUT': 3, 'DIO': 2, 'QOUT': 1, 'QIO': 0 } |
| 28 | +fmodeb = { 'dout': 3, 'dio': 2, 'quot': 1, 'qio': 0 } |
28 | 29 | ffreqb = { '40': 0, '26': 1, '20': 2, '80': 15 }
|
29 | 30 | fsizeb = { '512K': 0, '256K': 1, '1M': 2, '2M': 3, '4M': 4, '8M': 8, '16M': 9 }
|
30 | 31 |
|
@@ -87,21 +88,27 @@ def write_bin(out, elf, segments, to_addr, flash_mode, flash_size, flash_freq, p
|
87 | 88 | while total_size < to_addr:
|
88 | 89 | out.write(bytearray([0xaa]))
|
89 | 90 | total_size += 1
|
| 91 | +def main(): |
| 92 | + parser = argparse.ArgumentParser(description='Create a BIN file from eboot.elf and Arduino sketch.elf for upload by esptool.py') |
| 93 | + parser.add_argument('-e', '--eboot', action='store', required=True, help='Path to the Arduino eboot.elf bootloader') |
| 94 | + parser.add_argument('-a', '--app', action='store', required=True, help='Path to the Arduino sketch ELF') |
| 95 | + parser.add_argument('-m', '--flash_mode', action='store', required=True, choices=['dout', 'dio', 'qout', 'qio'], help='SPI flash mode') |
| 96 | + parser.add_argument('-f', '--flash_freq', action='store', required=True, choices=['20', '26', '40', '80'], help='SPI flash speed') |
| 97 | + parser.add_argument('-s', '--flash_size', action='store', required=True, choices=['256K', '512K', '1M', '2M', '4M', '8M', '16M'], help='SPI flash size') |
| 98 | + parser.add_argument('-o', '--out', action='store', required=True, help='Output BIN filename') |
| 99 | + parser.add_argument('-p', '--path', action='store', required=True, help='Path to Xtensa toolchain binaries') |
90 | 100 |
|
91 |
| -parser = argparse.ArgumentParser(description='Create a BIN file from eboot.elf and Arduino sketch.elf for upload by esptool.py') |
92 |
| -parser.add_argument('-e', '--eboot', action='store', required=True, help='Path to the Arduino eboot.elf bootloader') |
93 |
| -parser.add_argument('-a', '--app', action='store', required=True, help='Path to the Arduino sketch ELF') |
94 |
| -parser.add_argument('-m', '--flash_mode', action='store', required=True, choices=['DOUT', 'DIO', 'QOUT', 'QIO'], help='SPI flash mode') |
95 |
| -parser.add_argument('-f', '--flash_freq', action='store', required=True, choices=['20', '26', '40', '80'], help='SPI flash speed') |
96 |
| -parser.add_argument('-s', '--flash_size', action='store', required=True, choices=['256K', '512K', '1M', '2M', '4M', '8M', '16M'], help='SPI flash size') |
97 |
| -parser.add_argument('-o', '--out', action='store', required=True, help='Output BIN filename') |
98 |
| -parser.add_argument('-p', '--path', action='store', required=True, help='Path to Xtensa toolchain binaries') |
| 101 | + args = parser.parse_args() |
99 | 102 |
|
100 |
| -args = parser.parse_args() |
| 103 | + print 'Creating BIN file "' + args.out + '" using "' + args.app + '"' |
101 | 104 |
|
102 |
| -print 'Creating BIN file "' + args.out + '" using "' + args.app + '"' |
| 105 | + out = open(args.out, "wb") |
| 106 | + write_bin(out, args.eboot, ['.text'], 4096, args.flash_mode, args.flash_size, args.flash_freq, args.path) |
| 107 | + write_bin(out, args.app, ['.irom0.text', '.text', '.data', '.rodata'], 0, args.flash_mode, args.flash_size, args.flash_freq, args.path) |
| 108 | + out.close() |
103 | 109 |
|
104 |
| -out = open(args.out, "wb") |
105 |
| -write_bin(out, args.eboot, ['.text'], 4096, args.flash_mode, args.flash_size, args.flash_freq, args.path) |
106 |
| -write_bin(out, args.app, ['.irom0.text', '.text', '.data', '.rodata'], 0, args.flash_mode, args.flash_size, args.flash_freq, args.path) |
107 |
| -out.close() |
| 110 | + return 0 |
| 111 | + |
| 112 | + |
| 113 | +if __name__ == '__main__': |
| 114 | + sys.exit(main()) |
0 commit comments