Skip to content

Commit cb6b834

Browse files
committed
Merge remote-tracking branch 'origin/main' into main
2 parents 323b8b7 + d79d687 commit cb6b834

File tree

3 files changed

+87
-3
lines changed

3 files changed

+87
-3
lines changed

ports/esp32s2/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
build*
1+
build*/
22
sdkconfig.old

ports/esp32s2/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,11 @@ esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
316316
$(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp
317317
$(STEPECHO) "LINK $@"
318318
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(ESP_IDF_COMPONENTS_EXPANDED) $(BINARY_BLOBS) $(MBEDTLS_COMPONENTS_LINK_EXPANDED) build-$(BOARD)/esp-idf/esp-idf/newlib/libnewlib.a -Wl,--end-group -u newlib_include_pthread_impl -Wl,--start-group $(LIBS) -Wl,--end-group build-$(BOARD)/esp-idf/esp-idf/pthread/libpthread.a -u __cxx_fatal_exception
319-
# $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(BUILD)/esp-idf/esp-idf/esp32s2/esp32s2_out.ld
320319

321-
$(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf
320+
$(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf | tools/build_memory_info.py
322321
$(STEPECHO) "Create $@"
323322
$(Q)esptool.py --chip esp32s2 elf2image $(FLASH_FLAGS) --elf-sha256-offset 0xb0 -o $@ $^
323+
$(Q)$(PYTHON3) tools/build_memory_info.py $< $(BUILD)/esp-idf/sdkconfig $@
324324

325325
$(BUILD)/firmware.bin: $(BUILD)/circuitpython-firmware.bin | esp-idf-stamp
326326
$(Q)$(PYTHON) ../../tools/join_bins.py $@ 0x1000 $(BUILD)/esp-idf/bootloader/bootloader.bin 0x8000 $(BUILD)/esp-idf/partition_table/partition-table.bin 0x10000 $(BUILD)/circuitpython-firmware.bin
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python3
2+
3+
# SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
4+
# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
5+
#
6+
# SPDX-License-Identifier: MIT
7+
8+
import os
9+
import re
10+
import sys
11+
12+
from elftools.elf.elffile import ELFFile
13+
14+
print()
15+
16+
internal_memory = [
17+
# Name, Start, Length
18+
("RTC Fast Memory", (0x3FF9_E000, 0x4007_0000), 8 * 1024),
19+
("RTC Slow Memory", (0x5000_0000,), 8 * 1024),
20+
("Internal SRAM 0", (0x3FFB_0000, 0x4002_0000), 32 * 1024),
21+
("Internal SRAM 1", (0x3FFB_8000, 0x4002_8000), 288 * 1024),
22+
]
23+
24+
25+
def partition_size(arg):
26+
if "4MB" in arg:
27+
return 1408 * 1024
28+
else:
29+
return 2048 * 1024
30+
31+
32+
def align(n, m):
33+
return m * ((n + m - 1) // m)
34+
35+
36+
regions = dict((name, 0) for name, _, _ in internal_memory)
37+
38+
# This file is the elf
39+
with open(sys.argv[1], "rb") as stream:
40+
elffile = ELFFile(stream)
41+
for section in elffile.iter_sections():
42+
start = section["sh_addr"]
43+
size = section["sh_size"]
44+
offset = section["sh_offset"]
45+
if not size or not start:
46+
continue
47+
for name, starts, length in internal_memory:
48+
for mem_start in starts:
49+
mem_end = mem_start + length
50+
if start >= mem_start and start < mem_end:
51+
regions[name] = max(regions.get(name, 0), size)
52+
# print("# putting %s in %s (start=0x%x, size=%d)" % (section.name, name, start, size))
53+
54+
# This file is the sdkconfig
55+
with open(sys.argv[2], "r") as f:
56+
for line in f:
57+
line = line.strip()
58+
if line.startswith("CONFIG_PARTITION_TABLE_FILENAME"):
59+
firmware_region = int(partition_size(line.split("=")[-1]))
60+
61+
# This file is the bin
62+
used_flash = os.stat(sys.argv[3]).st_size
63+
64+
free_flash = firmware_region - used_flash
65+
print(
66+
"{:7} bytes used, {:7} bytes free in flash firmware space out of {} bytes ({}kB).".format(
67+
used_flash, free_flash, firmware_region, firmware_region / 1024
68+
)
69+
)
70+
for name, mem_start, length in internal_memory:
71+
if name in regions:
72+
print(
73+
"{:7} bytes used, {:7} bytes free in '{}' out of {} bytes ({}kB).".format(
74+
regions[name], length - regions[name], name, length, length / 1024
75+
)
76+
)
77+
print()
78+
79+
# Check that we have free flash space. GCC doesn't fail when the text + data
80+
# sections don't fit in FLASH. It only counts data in RAM.
81+
if free_flash < 0:
82+
print("Too little flash!!!")
83+
print()
84+
sys.exit(-1)

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