1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-01 07:31:51 +00:00
This commit is contained in:
J. Nick Koston
2025-10-20 15:21:11 -10:00
parent 6a042188c1
commit 09951d190c

View File

@@ -16,43 +16,41 @@ def apply_memory_patches(content):
""" """
patches_applied = [] patches_applied = []
# Replace IRAM size from 0x8000 (32KB) to 0x200000 (2MB) # Patch IRAM segment to 2MB (for larger code in IRAM)
# The line looks like: iram1_0_seg : org = 0x40100000, len = 0x8000 # Matches: iram1_0_seg : org = 0x..., len = 0x...
new_content = re.sub( new_content = re.sub(
r"(iram1_0_seg\s*:\s*org\s*=\s*0x40100000\s*,\s*len\s*=\s*)0x8000", r"(iram1_0_seg\s*:\s*org\s*=\s*0x[0-9a-fA-F]+\s*,\s*len\s*=\s*)0x[0-9a-fA-F]+",
r"\g<1>0x200000", r"\g<1>0x200000",
content, content,
) )
if new_content != content: if new_content != content:
patches_applied.append("IRAM: 32KB -> 2MB") patches_applied.append("IRAM")
content = new_content content = new_content
# Replace DRAM (BSS) size to allow larger uninitialized data sections # Patch DRAM segment to 2MB (for larger BSS/data sections)
# The line looks like: dram0_0_seg : org = 0x3FFE8000, len = 0x14000 # Matches: dram0_0_seg : org = 0x..., len = 0x...
# Increase from 0x14000 (80KB) to 0x200000 (2MB)
new_content = re.sub( new_content = re.sub(
r"(dram0_0_seg\s*:\s*org\s*=\s*0x3FFE8000\s*,\s*len\s*=\s*)0x14000", r"(dram0_0_seg\s*:\s*org\s*=\s*0x[0-9a-fA-F]+\s*,\s*len\s*=\s*)0x[0-9a-fA-F]+",
r"\g<1>0x200000", r"\g<1>0x200000",
content, content,
) )
if new_content != content: if new_content != content:
patches_applied.append("DRAM: 80KB -> 2MB") patches_applied.append("DRAM")
content = new_content content = new_content
# Replace Flash/irom0 size to allow larger code sections # Patch Flash segment to 32MB (for larger code sections)
# The line looks like: irom0_0_seg : org = 0x40201010, len = 0xfeff0 # Matches: irom0_0_seg : org = 0x..., len = 0x...
# Increase from 0xfeff0 (~1MB) to 0x2000000 (32MB) - fake huge flash for testing
new_content = re.sub( new_content = re.sub(
r"(irom0_0_seg\s*:\s*org\s*=\s*0x40201010\s*,\s*len\s*=\s*)0x[0-9a-fA-F]+", r"(irom0_0_seg\s*:\s*org\s*=\s*0x[0-9a-fA-F]+\s*,\s*len\s*=\s*)0x[0-9a-fA-F]+",
r"\g<1>0x2000000", r"\g<1>0x2000000",
content, content,
) )
if new_content != content: if new_content != content:
patches_applied.append("Flash: 1MB -> 32MB") patches_applied.append("Flash")
content = new_content content = new_content
if patches_applied: if patches_applied:
print(f" Patches applied: {', '.join(patches_applied)}") print(f" Patched memory segments: {', '.join(patches_applied)} (IRAM/DRAM: 2MB, Flash: 32MB)")
return content return content