Skip to content

Commit d4df908

Browse files
authored
prepare support for P4 rev.300 (#340)
1 parent 1316914 commit d4df908

File tree

7 files changed

+68
-22
lines changed

7 files changed

+68
-22
lines changed

boards/esp32-p4-evboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"f_psram": "200000000L",
1010
"flash_mode": "qio",
1111
"mcu": "esp32p4",
12+
"chip_variant": "esp32p4_es",
1213
"variant": "esp32p4"
1314
},
1415
"arduino": {
@@ -25,7 +26,7 @@
2526
"arduino",
2627
"espidf"
2728
],
28-
"name": "Espressif ESP32-P4 Function EV Board",
29+
"name": "Espressif ESP32-P4 Function EV Board (ES pre rev.300)",
2930
"upload": {
3031
"flash_size": "16MB",
3132
"maximum_ram_size": 512000,

boards/esp32-p4.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"f_psram": "200000000L",
1010
"flash_mode": "qio",
1111
"mcu": "esp32p4",
12+
"chip_variant": "esp32p4_es",
1213
"variant": "esp32p4"
1314
},
1415
"connectivity": [
@@ -22,7 +23,7 @@
2223
"arduino",
2324
"espidf"
2425
],
25-
"name": "Espressif ESP32-P4 generic",
26+
"name": "Espressif ESP32-P4 ES (pre rev.300) generic",
2627
"upload": {
2728
"flash_size": "4MB",
2829
"maximum_ram_size": 327680,

boards/esp32-p4_r3.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"build": {
3+
"core": "esp32",
4+
"extra_flags": [
5+
"-DBOARD_HAS_PSRAM"
6+
],
7+
"f_cpu": "400000000L",
8+
"f_flash": "80000000L",
9+
"f_psram": "200000000L",
10+
"flash_mode": "qio",
11+
"mcu": "esp32p4",
12+
"chip_variant": "esp32p4",
13+
"variant": "esp32p4"
14+
},
15+
"connectivity": [
16+
"bluetooth",
17+
"openthread"
18+
],
19+
"debug": {
20+
"openocd_target": "esp32p4.cfg"
21+
},
22+
"frameworks": [
23+
"arduino",
24+
"espidf"
25+
],
26+
"name": "Espressif ESP32-P4 rev.300 generic",
27+
"upload": {
28+
"flash_size": "16MB",
29+
"maximum_ram_size": 327680,
30+
"maximum_size": 16777216,
31+
"require_upload_port": true,
32+
"speed": 460800
33+
},
34+
"url": "https://docs.espressif.com",
35+
"vendor": "Espressif"
36+
}

boards/m5stack-tab5-p4.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"f_psram": "200000000L",
1212
"flash_mode": "qio",
1313
"mcu": "esp32p4",
14+
"chip_variant": "esp32p4_es",
1415
"variant": "m5stack_tab5"
1516
},
1617
"arduino": {
@@ -27,7 +28,7 @@
2728
"arduino",
2829
"espidf"
2930
],
30-
"name": "M5STACK Tab5 esp32-p4 Board",
31+
"name": "M5STACK Tab5 esp32-p4 Board (ES pre rev.300)",
3132
"upload": {
3233
"flash_size": "16MB",
3334
"maximum_ram_size": 512000,

builder/frameworks/arduino.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def get_platform_default_threshold(mcu):
7373
"esp32s2": 32000, # ESP32-S2
7474
"esp32s3": 32766, # ESP32-S3
7575
"esp32c3": 32000, # ESP32-C3
76-
"esp32c2": 32000, # ESP32-C2
76+
"esp32c2": 31600, # ESP32-C2
7777
"esp32c6": 31600, # ESP32-C6
7878
"esp32h2": 32000, # ESP32-H2
7979
"esp32p4": 32000, # ESP32-P4
@@ -236,7 +236,7 @@ def get_threshold_info(env, config, current_env_section):
236236
Returns:
237237
dict: Information about threshold configuration
238238
"""
239-
mcu = env.BoardConfig().get("build.mcu", "esp32")
239+
mcu = env.BoardConfig().get("build.mcu", "esp32").lower()
240240
setting_name = "custom_include_path_length_threshold"
241241

242242
info = {
@@ -285,9 +285,10 @@ def get_threshold_info(env, config, current_env_section):
285285

286286
# Cache class for frequently used paths
287287
class PathCache:
288-
def __init__(self, platform, mcu):
288+
def __init__(self, platform, mcu, chip_variant):
289289
self.platform = platform
290290
self.mcu = mcu
291+
self.chip_variant = chip_variant
291292
self._framework_dir = None
292293
self._framework_lib_dir = None
293294
self._sdk_dir = None
@@ -310,7 +311,7 @@ def framework_lib_dir(self):
310311
def sdk_dir(self):
311312
if self._sdk_dir is None:
312313
self._sdk_dir = fs.to_unix_path(
313-
str(Path(self.framework_lib_dir) / self.mcu / "include")
314+
str(Path(self.framework_lib_dir) / self.chip_variant / "include")
314315
)
315316
return self._sdk_dir
316317

@@ -520,9 +521,11 @@ def safe_remove_sdkconfig_files():
520521

521522
# Cached values
522523
mcu = board.get("build.mcu", "esp32")
524+
chip_variant = env.BoardConfig().get("build.chip_variant", "").lower()
525+
chip_variant = chip_variant if chip_variant else mcu
523526
pioenv = env["PIOENV"]
524527
project_dir = env.subst("$PROJECT_DIR")
525-
path_cache = PathCache(platform, mcu)
528+
path_cache = PathCache(platform, mcu, chip_variant)
526529
current_env_section = f"env:{pioenv}"
527530

528531
# Board configuration
@@ -921,13 +924,13 @@ def get_frameworks_in_current_env():
921924
from component_manager import ComponentManager
922925
component_manager = ComponentManager(env)
923926
component_manager.handle_component_settings()
924-
927+
925928
# Handle LTO flags if flag_lto is set
926929
if flag_lto:
927930
# First remove existing -fno-lto flags, then add LTO flags
928931
component_manager.remove_no_lto_flags()
929932
component_manager.add_lto_flags()
930-
933+
931934
silent_action = env.Action(component_manager.restore_pioarduino_build_py)
932935
# silence scons command output
933936
silent_action.strfunction = lambda target, source, env: ''

builder/frameworks/component_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def __init__(self, env):
4545
self.board = env.BoardConfig()
4646
# Extract MCU type from board configuration, defaulting to esp32
4747
self.mcu = self.board.get("build.mcu", "esp32").lower()
48+
chip_variant = self.board.get("build.chip_variant", "").lower()
49+
self.chip_variant = chip_variant if chip_variant else self.mcu
4850
# Get project source directory path
4951
self.project_src_dir = env.subst("$PROJECT_SRC_DIR")
5052

@@ -74,7 +76,7 @@ def arduino_libs_mcu(self):
7476
"""
7577
if self._arduino_libs_mcu is None:
7678
ald = self.platform.get_package_dir("framework-arduinoespressif32-libs")
77-
self._arduino_libs_mcu = str(Path(ald) / self.mcu) if ald else ""
79+
self._arduino_libs_mcu = str(Path(ald) / self.chip_variant) if ald else ""
7880
return self._arduino_libs_mcu
7981

8082

builder/frameworks/espidf.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
config = env.GetProjectConfig()
7878
board = env.BoardConfig()
7979
mcu = board.get("build.mcu", "esp32")
80+
chip_variant = board.get("build.chip_variant", "").lower()
81+
chip_variant = chip_variant if chip_variant else mcu
8082
flash_speed = board.get("build.f_flash", "40000000L")
8183
flash_frequency = str(flash_speed.replace("000000L", ""))
8284
flash_mode = board.get("build.flash_mode", "dio")
@@ -180,16 +182,16 @@ def create_silent_action(action_func):
180182
ARDUINO_FRMWRK_LIB_DIR = str(ARDUINO_FRMWRK_LIB_DIR_PATH)
181183

182184
if mcu == "esp32c2":
183-
ARDUINO_FRMWRK_C2_LIB_DIR = str(ARDUINO_FRMWRK_LIB_DIR_PATH / mcu)
185+
ARDUINO_FRMWRK_C2_LIB_DIR = str(ARDUINO_FRMWRK_LIB_DIR_PATH / chip_variant)
184186
if not os.path.exists(ARDUINO_FRMWRK_C2_LIB_DIR):
185187
_arduino_c2_dir = platform.get_package_dir("framework-arduino-c2-skeleton-lib")
186188
if not _arduino_c2_dir:
187189
sys.stderr.write("Error: Missing framework-arduino-c2-skeleton-lib package\n")
188190
env.Exit(1)
189191
arduino_c2_dir = Path(_arduino_c2_dir)
190-
ARDUINO_C2_DIR = str(arduino_c2_dir / mcu)
192+
ARDUINO_C2_DIR = str(arduino_c2_dir / chip_variant)
191193
shutil.copytree(ARDUINO_C2_DIR, ARDUINO_FRMWRK_C2_LIB_DIR, dirs_exist_ok=True)
192-
arduino_libs_mcu = str(ARDUINO_FRMWRK_LIB_DIR_PATH / mcu)
194+
arduino_libs_mcu = str(ARDUINO_FRMWRK_LIB_DIR_PATH / chip_variant)
193195

194196
BUILD_DIR = env.subst("$BUILD_DIR")
195197
PROJECT_DIR = env.subst("$PROJECT_DIR")
@@ -337,7 +339,7 @@ def generate_board_specific_config():
337339
flash_memory_type, psram_memory_type = parts
338340
else:
339341
flash_memory_type = memory_type
340-
342+
341343
# Add flash mode to sdkconfig
342344
if flash_mode:
343345
flash_mode_lower = flash_mode.lower()
@@ -348,7 +350,7 @@ def generate_board_specific_config():
348350
for mode in flash_modes:
349351
if mode != flash_mode_lower:
350352
board_config_flags.append(f"# CONFIG_ESPTOOLPY_FLASHMODE_{mode.upper()} is not set")
351-
353+
352354
# Override flash_memory_type if boot mode indicates OPI
353355
if boot_mode == "opi" or flash_mode in ["dout", "opi"]:
354356
if not flash_memory_type or flash_memory_type.lower() != "opi":
@@ -2600,9 +2602,9 @@ def _replace_move(src, dst):
26002602
sdkconfig_h_path = str(Path(env_build) / "config" / "sdkconfig.h")
26012603
arduino_libs = str(Path(ARDUINO_FRMWRK_LIB_DIR))
26022604
lib_src = str(Path(env_build) / "esp-idf")
2603-
lib_dst = str(Path(arduino_libs) / mcu / "lib")
2604-
ld_dst = str(Path(arduino_libs) / mcu / "ld")
2605-
mem_var = str(Path(arduino_libs) / mcu / board.get("build.arduino.memory_type", (board.get("build.flash_mode", "dio") + "_qspi")))
2605+
lib_dst = str(Path(arduino_libs) / chip_variant / "lib")
2606+
ld_dst = str(Path(arduino_libs) / chip_variant / "ld")
2607+
mem_var = str(Path(arduino_libs) / chip_variant / board.get("build.arduino.memory_type", (board.get("build.flash_mode", "dio") + "_qspi")))
26062608
# Ensure destinations exist
26072609
for d in (lib_dst, ld_dst, mem_var, str(Path(mem_var) / "include")):
26082610
Path(d).mkdir(parents=True, exist_ok=True)
@@ -2625,9 +2627,9 @@ def _replace_move(src, dst):
26252627
_replace_move(str(Path(lib_dst) / "libesp_lcd.a"), str(Path(mem_var) / "libesp_lcd.a"))
26262628

26272629
shutil.copyfile(sdkconfig_h_path, str(Path(mem_var) / "include" / "sdkconfig.h"))
2628-
if not bool(os.path.isfile(str(Path(arduino_libs) / mcu / "sdkconfig.orig"))):
2629-
shutil.move(str(Path(arduino_libs) / mcu / "sdkconfig"), str(Path(arduino_libs) / mcu / "sdkconfig.orig"))
2630-
shutil.copyfile(str(Path(env.subst("$PROJECT_DIR")) / ("sdkconfig." + env["PIOENV"])), str(Path(arduino_libs) / mcu / "sdkconfig"))
2630+
if not bool(os.path.isfile(str(Path(arduino_libs) / chip_variant / "sdkconfig.orig"))):
2631+
shutil.move(str(Path(arduino_libs) / chip_variant / "sdkconfig"), str(Path(arduino_libs) / chip_variant / "sdkconfig.orig"))
2632+
shutil.copyfile(str(Path(env.subst("$PROJECT_DIR")) / ("sdkconfig." + env["PIOENV"])), str(Path(arduino_libs) / chip_variant / "sdkconfig"))
26312633
shutil.copyfile(str(Path(env.subst("$PROJECT_DIR")) / ("sdkconfig." + env["PIOENV"])), str(Path(arduino_libs) / "sdkconfig"))
26322634
try:
26332635
os.remove(str(Path(env.subst("$PROJECT_DIR")) / "dependencies.lock"))

0 commit comments

Comments
 (0)