forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8952 from dhalbert/memento-storage-crash
Espressif: fix handling of single-partition CIRCUITPY (non-CIRCUITPY_STORAGE_EXTEND) - fixes MEMENTO bug
- Loading branch information
Showing
9 changed files
with
81 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
13 changes: 10 additions & 3 deletions
13
...-config/sdkconfig-flash-4MB-1ota.defaults → ...onfig/sdkconfig-flash-4MB-no-ota.defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
# | ||
# Espressif IoT Development Framework Configuration | ||
# | ||
# | ||
# Serial flasher config | ||
# | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set | ||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set | ||
CONFIG_ESPTOOLPY_FLASHSIZE="4MB" | ||
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y | ||
# end of Serial flasher config | ||
|
||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-4MB-1ota.csv" | ||
# | ||
# Partition Table | ||
# | ||
CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-4MB-1ota.csv" | ||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-4MB-no-ota.csv" | ||
CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-4MB-no-ota.csv" | ||
# end of Partition Table | ||
|
||
# end of Espressif IoT Development Framework Configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
|
||
import click | ||
|
||
|
||
def int_or_string(s): | ||
try: | ||
return int(s) | ||
except ValueError: | ||
return s.strip('"') | ||
|
||
|
||
def collect_definitions(file): | ||
"""Collect all definitions in supplied sdkconfig.h.""" | ||
sdk_config = {} | ||
for line in file: | ||
if line.startswith("#define "): | ||
_, k, v = line.strip().split(None, 2) | ||
# Handle transitive definitions like '#define CONFIG_TCP_MSL CONFIG_LWIP_TCP_MSL' | ||
v = sdk_config.get(k, v) | ||
sdk_config[k] = int_or_string(v) | ||
return sdk_config | ||
|
||
|
||
def validate(sdk_config, circuitpy_config): | ||
partition_table = sdk_config.get("CONFIG_PARTITION_TABLE_FILENAME") | ||
for var in ("CIRCUITPY_STORAGE_EXTEND", "CIRCUITPY_DUALBANK"): | ||
if circuitpy_config.get(var): | ||
with open(partition_table) as f: | ||
content = f.read() | ||
if not "ota_1" in content: | ||
raise SystemExit( | ||
f"{var} is incompatible with {partition_table=} (no ota_1 partition)" | ||
) | ||
|
||
# Add more checks here for other things we want to verify. | ||
return | ||
|
||
|
||
@click.command() | ||
@click.argument("definitions", nargs=-1, metavar="CIRCUITPY_X=1 CIRCUITPY_Y=0 ...") | ||
@click.argument( | ||
"sdkconfig_h", required=True, nargs=1, type=click.File("r"), metavar="<path to sdkconfig.h>" | ||
) | ||
def run(definitions, sdkconfig_h): | ||
sdk_config = collect_definitions(sdkconfig_h) | ||
|
||
# Parse definitions arguments | ||
circuitpy_config = {} | ||
for definition in definitions: | ||
k, v = definition.split("=", 1) | ||
circuitpy_config[k] = int_or_string(v) | ||
|
||
# Validate. | ||
validate(sdk_config, circuitpy_config) | ||
|
||
|
||
if __name__ == "__main__": | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters