Skip to content

Commit 1ab083f

Browse files
committed
Support target specific kconfig source
1 parent 73e04e8 commit 1ab083f

7 files changed

Lines changed: 98 additions & 23 deletions

File tree

ports/espressif/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ cmake_minimum_required(VERSION 3.16)
55
set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf)
66

77
# The component list here determines what options we get in menuconfig and what the ninja file can build.
8-
set(COMPONENTS bt driver esp-tls esp_adc_cal esp_event esp_netif esp_psram esp_wifi esptool_py freertos log lwip main mbedtls mdns soc ulp usb wpa_supplicant esp32-camera esp_lcd)
9-
set(EXTRA_COMPONENT_DIRS "esp-protocols/components/mdns" "esp32-camera")
8+
set(COMPONENTS bt driver esp-tls esp_adc_cal esp_event esp_netif esp_psram esp_wifi esptool_py freertos log lwip main mbedtls mdns soc ulp usb wpa_supplicant esp-camera esp_lcd)
9+
set(EXTRA_COMPONENT_DIRS "esp-protocols/components/mdns" "esp-camera")
1010

1111
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
1212
project(circuitpython)

ports/espressif/boards/adafruit_esp32s3_camera/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ USB_MANUFACTURER = "Adafruit"
66
IDF_TARGET = esp32s3
77

88
CIRCUITPY_ESP_FLASH_MODE = dio
9-
CIRCUITPY_ESP_FLASH_FREQ = 40m
9+
CIRCUITPY_ESP_FLASH_FREQ = 80m
1010
CIRCUITPY_ESP_FLASH_SIZE = 4MB
1111
CIRCUITPY_ESP_PSRAM_SIZE = 2MB
1212
CIRCUITPY_ESP_PSRAM_MODE = qio

ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ CIRCUITPY_ESP_FLASH_FREQ = 40m
1010
CIRCUITPY_ESP_FLASH_SIZE = 4MB
1111

1212
CIRCUITPY_ESP_PSRAM_SIZE = 2MB
13+
CIRCUITPY_ESP_PSRAM_MODE = qio
14+
CIRCUITPY_ESP_PSRAM_FREQ = 40m

ports/espressif/esp-idf-config/sdkconfig-esp32.defaults

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,32 @@
1616
# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set
1717
# end of TWAI Configuration
1818

19+
#
20+
# PCNT Configuration
21+
#
22+
CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN=y
23+
# end of PCNT Configuration
24+
25+
#
26+
# RMT Configuration
27+
#
28+
CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y
29+
# end of RMT Configuration
30+
31+
#
32+
# I2S Configuration
33+
#
34+
CONFIG_I2S_SUPPRESS_DEPRECATE_WARN=y
35+
# end of I2S Configuration
36+
1937
# end of Driver Configurations
2038

39+
#
40+
# ESP System Settings
41+
#
42+
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
43+
# end of ESP System Settings
44+
2145
#
2246
# IPC (Inter-Processor Call)
2347
#
@@ -47,6 +71,7 @@ CONFIG_SPI_FLASH_SUPPORT_TH_CHIP=y
4771
#
4872
# Ultra Low Power (ULP) Co-processor
4973
#
74+
CONFIG_ULP_COPROC_ENABLED=y
5075
CONFIG_ULP_COPROC_RESERVE_MEM=4080
5176
# end of Ultra Low Power (ULP) Co-processor
5277

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CONFIG_SPIRAM_TYPE_AUTO=y
2-
# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set
1+
# CONFIG_SPIRAM_TYPE_AUTO is not set
2+
CONFIG_SPIRAM_TYPE_ESPPSRAM16=y
33
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
44
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set

ports/espressif/tools/update_sdkconfig.py

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ def update(debug, board, update_all):
248248
default_settings = []
249249
last_default_group = None
250250

251+
target_kconfig_snippets = set()
252+
target_symbols = set()
253+
251254
current_group = []
252255

253256
for sym in kconfig.unique_defined_syms:
@@ -282,26 +285,63 @@ def update(debug, board, update_all):
282285

283286
config_string = item.config_string.strip()
284287
if not config_string:
285-
if matches_group("CONFIG_" + item.name, ALWAYS_INCLUDE):
288+
cp_sym = cp_kconfig_defaults.syms[item.name]
289+
if cp_sym.str_value == "n":
286290
config_string = f"# CONFIG_{item.name} is not set"
287-
print(config_string)
288291
else:
289-
continue
292+
config_string = ""
290293

291294
if node.list:
292295
pending_nodes.append(node.list)
293296

294297
matches_cp_default = cp_kconfig_defaults.syms[item.name].str_value == item.str_value
295298
matches_esp_default = sym_default(item)
296299

297-
if not matches_esp_default:
300+
print_debug = not matches_esp_default
301+
if print_debug:
298302
print(" " * len(current_group), i, config_string.strip())
299303

300-
target_reference = False
304+
# Some files are `rsource`d into another kconfig with $IDF_TARGET as
305+
# part of the path. kconfiglib doesn't show this as a reference so
306+
# we have to look ourselves.
307+
target_reference = target in item.name_and_loc
308+
if target_reference:
309+
loc = item.name_and_loc.split("defined at ")[1].split(":")[0].replace(target, "*")
310+
if loc not in target_kconfig_snippets:
311+
differing_keys = set()
312+
shared_keys = {}
313+
first = True
314+
for path in pathlib.Path(".").glob(loc):
315+
kc = kconfiglib.Kconfig(path)
316+
all_file_syms = set()
317+
for sym in kc.unique_defined_syms:
318+
all_file_syms.add(sym)
319+
if sym.name in differing_keys:
320+
continue
321+
if first:
322+
shared_keys[sym.name] = sym.str_value
323+
elif (
324+
sym.name not in shared_keys
325+
or shared_keys[sym.name] != sym.str_value
326+
):
327+
differing_keys.add(sym.name)
328+
if sym.name in shared_keys:
329+
del shared_keys[sym.name]
330+
# Any settings missing from a file are *not* shared.
331+
shared_syms = set(shared_keys.keys())
332+
for missing in shared_syms - all_file_syms:
333+
differing_keys.add(missing)
334+
del shared_keys[missing]
335+
first = False
336+
target_kconfig_snippets.add(loc)
337+
target_symbols = target_symbols.union(differing_keys)
301338
psram_reference = False
302339
for referenced in item.referenced:
303340
if referenced.name.startswith("IDF_TARGET"):
304-
# print(item.name, "references", referenced.name)
341+
target_reference = True
342+
break
343+
if referenced.name in target_symbols:
344+
# Implicit target symbols
305345
target_reference = True
306346
break
307347
if referenced.name == "SPIRAM":
@@ -335,20 +375,22 @@ def update(debug, board, update_all):
335375
elif matches_group(config_string, PSRAM_MODE_SETTINGS):
336376
print(" " * (len(current_group) + 1), "psram mode")
337377
psram_mode_settings.append(config_string)
338-
elif matches_group(config_string, PSRAM_FREQ_SETTINGS) and not target_setting:
339-
# The ESP32S2 has two frequencies that aren't on the S3 or ESP32. So, put those
340-
# in target settings.
378+
elif (
379+
matches_group(config_string, PSRAM_FREQ_SETTINGS)
380+
and "26M" not in config_string
381+
and "20M" not in config_string
382+
):
383+
# The ESP32S2 has two frequencies (20M and 26M) that aren't on the S3 or ESP32.
384+
# So, put those in target settings.
341385
print(" " * (len(current_group) + 1), "psram freq")
342386
psram_freq_settings.append(config_string)
343387
elif matches_esp_default:
388+
if print_debug:
389+
print(" " * (len(current_group) + 1), "default")
344390
# Always document the above settings. Settings below should
345391
# be non-default.
346392
pass
347-
elif (
348-
(matches_group(config_string, PSRAM_SETTINGS) or psram_reference)
349-
and not target_reference
350-
and not target_setting
351-
):
393+
elif matches_group(config_string, PSRAM_SETTINGS) or psram_reference:
352394
print(" " * (len(current_group) + 1), "psram shared")
353395
last_psram_group = add_group(psram_settings, last_psram_group, current_group)
354396
psram_settings.append(config_string)
@@ -373,12 +415,11 @@ def update(debug, board, update_all):
373415
)
374416
default_settings.append(config_string)
375417

376-
elif kconfiglib.expr_value(node.dep):
418+
else:
377419
if item is kconfiglib.COMMENT:
378420
print("comment", repr(item))
379421
elif item is kconfiglib.MENU:
380-
# This menu isn't visible so skip to the next node.
381-
if kconfiglib.expr_value(node.visibility) and node.list:
422+
if node.list:
382423
current_group.append(node.prompt[0])
383424
pending_nodes.append(None)
384425
pending_nodes.append(node.list)
@@ -398,18 +439,25 @@ def update(debug, board, update_all):
398439

399440
board_config.write_text("\n".join(board_settings))
400441
if update_all:
442+
# Add empty strings to get trailing newlines
443+
flash_mode_settings.append("")
444+
flash_freq_settings.append("")
401445
flash_size_config.write_text("\n".join(flash_size_settings))
402446
flash_mode_config.write_text("\n".join(flash_mode_settings))
403447
flash_freq_config.write_text("\n".join(flash_freq_settings))
404448
if psram_size != "0":
449+
psram_size_settings.append("")
450+
psram_mode_settings.append("")
451+
psram_freq_settings.append("")
405452
psram_config.write_text("\n".join(psram_settings))
406453
psram_size_config.write_text("\n".join(psram_size_settings))
407454
psram_mode_config.write_text("\n".join(psram_mode_settings))
408455
psram_freq_config.write_text("\n".join(psram_freq_settings))
409456
opt_config.write_text("\n".join(opt_settings))
410457
default_config.write_text("\n".join(default_settings))
411458
target_config.write_text("\n".join(target_settings))
412-
ble_config.write_text("\n".join(ble_settings))
459+
if ble_settings:
460+
ble_config.write_text("\n".join(ble_settings))
413461

414462

415463
if __name__ == "__main__":

0 commit comments

Comments
 (0)