Skip to content

Commit c64630a

Browse files
jeplerdhalbert
authored andcommitted
espressif: add a script to check for incompatibilities...
betweek sdkconfig and circuitpython. For now there's a single check, for CIRCUITPY_STORAGE_EXTEND & CIRCUITPY_DUALBANK that require there to be an ota_1 partition.
1 parent 3871899 commit c64630a

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

ports/espressif/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,12 @@ endif
417417
do-sdkconfig: $(BUILD)/esp-idf/config/sdkconfig.h
418418
QSTR_GLOBAL_REQUIREMENTS += $(BUILD)/esp-idf/config/sdkconfig.h
419419
$(BUILD)/esp-idf/config/sdkconfig.h: boards/$(BOARD)/sdkconfig boards/$(BOARD)/mpconfigboard.mk CMakeLists.txt | $(BUILD)/esp-idf
420-
IDF_PATH=$(IDF_PATH) cmake -S . -B $(BUILD)/esp-idf -DSDKCONFIG=$(BUILD)/esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS="$(SDKCONFIGS)" -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH)/tools/cmake/toolchain-$(IDF_TARGET).cmake -DIDF_TARGET=$(IDF_TARGET) -GNinja
420+
$(STEPECHO) "LINK $@"
421+
$(Q)env IDF_PATH=$(IDF_PATH) cmake -S . -B $(BUILD)/esp-idf -DSDKCONFIG=$(BUILD)/esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS="$(SDKCONFIGS)" -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH)/tools/cmake/toolchain-$(IDF_TARGET).cmake -DIDF_TARGET=$(IDF_TARGET) -GNinja
422+
$(Q)$(PYTHON) tools/check-sdkconfig.py \
423+
CIRCUITPY_DUALBANK=$(CIRCUITPY_DUALBANK) \
424+
CIRCUITPY_STORAGE_EXTEND=$(CIRCUITPY_STORAGE_EXTEND) \
425+
$@
421426

422427
# build a lib
423428
# Adding -d explain -j 1 -v to the ninja line will output debug info
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
4+
sdk_config = {}
5+
6+
config_h = sys.argv[-1]
7+
with open(config_h) as f:
8+
for row in f:
9+
if row.startswith("#define "):
10+
_, k, v = row.strip().split(None, 2)
11+
# ad-hoc handle lines like '#define CONFIG_TCP_MSL CONFIG_LWIP_TCP_MSL'
12+
v = sdk_config.get(k, v)
13+
if v[0] == '"':
14+
v = eval(v) # Assume it is a simple C string
15+
16+
# ad-hoc convert to integer
17+
try:
18+
v = int(v)
19+
except ValueError:
20+
pass
21+
sdk_config[k] = v
22+
23+
del sys.argv[-1]
24+
25+
circuitpy_config = {}
26+
for arg in sys.argv[1:]:
27+
k, v = arg.split("=", 1)
28+
circuitpy_config[k] = int(v)
29+
30+
partition_table = sdk_config.get("CONFIG_PARTITION_TABLE_FILENAME")
31+
for var in ("CIRCUITPY_STORAGE_EXTEND", "CIRCUITPY_DUALBANK"):
32+
if circuitpy_config.get(var):
33+
with open(partition_table) as f:
34+
content = f.read()
35+
if not "ota_1" in content:
36+
raise SystemExit(f"{var} is incompatible with {partition_table=} (no ota_1 partition)")
37+
38+
# Add more checks here

0 commit comments

Comments
 (0)