Skip to content

Commit 7cf3312

Browse files
committed
esp32: Add makeimg.py script to build full firmware; use it in Makefile.
Thanks to Nick Moore for the initial code using dd.
1 parent 8ad6df6 commit 7cf3312

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

esp32/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,16 +538,20 @@ OBJ_ESPIDF += $(addprefix $(BUILD)/, $(ESPIDF_WPA_SUPPLICANT_O))
538538
################################################################################
539539
# Main targets
540540

541-
all: $(BUILD)/bootloader.bin $(BUILD)/partitions.bin $(BUILD)/application.bin
541+
all: $(BUILD)/firmware.bin
542542

543543
.PHONY: idf-version deploy erase
544544

545545
idf-version:
546546
$(ECHO) "ESP IDF supported hash: $(ESPIDF_SUPHASH)"
547547

548-
deploy: $(BUILD)/bootloader.bin $(BUILD)/partitions.bin $(BUILD)/application.bin
548+
$(BUILD)/firmware.bin: $(BUILD)/bootloader.bin $(BUILD)/partitions.bin $(BUILD)/application.bin
549+
$(ECHO) "Create $@"
550+
$(Q)$(PYTHON) makeimg.py $^ $@
551+
552+
deploy: $(BUILD)/firmware.bin
549553
$(ECHO) "Writing $^ to the board"
550-
$(Q)$(ESPTOOL) --chip esp32 --port $(PORT) --baud $(BAUD) write_flash -z --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) --flash_size $(FLASH_SIZE) 0x1000 $(BUILD)/bootloader.bin 0x8000 $(BUILD)/partitions.bin 0x10000 $(BUILD)/application.bin
554+
$(Q)$(ESPTOOL) --chip esp32 --port $(PORT) --baud $(BAUD) write_flash -z --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) --flash_size $(FLASH_SIZE) 0 $^
551555

552556
erase:
553557
$(ECHO) "Erasing flash"

esp32/makeimg.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
3+
OFFSET_BOOTLOADER = 0x1000
4+
OFFSET_PARTITIONS = 0x8000
5+
OFFSET_APPLICATION = 0x10000
6+
7+
files_in = [
8+
('bootloader', OFFSET_BOOTLOADER, sys.argv[1]),
9+
('partitions', OFFSET_PARTITIONS, sys.argv[2]),
10+
('application', OFFSET_APPLICATION, sys.argv[3]),
11+
]
12+
file_out = sys.argv[4]
13+
14+
cur_offset = 0
15+
with open(file_out, 'wb') as fout:
16+
for name, offset, file_in in files_in:
17+
assert offset >= cur_offset
18+
fout.write(b'\xff' * (offset - cur_offset))
19+
cur_offset = offset
20+
with open(file_in, 'rb') as fin:
21+
data = fin.read()
22+
fout.write(data)
23+
cur_offset += len(data)
24+
print('%-12s% 8d' % (name, len(data)))
25+
print('%-12s% 8d' % ('total', cur_offset))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy