diff --git a/boards/esp32-p4-evboard.json b/boards/esp32-p4-evboard.json index f879cf6d1..71551cd14 100644 --- a/boards/esp32-p4-evboard.json +++ b/boards/esp32-p4-evboard.json @@ -9,6 +9,7 @@ "f_psram": "200000000L", "flash_mode": "qio", "mcu": "esp32p4", + "chip_variant": "esp32p4_es", "variant": "esp32p4" }, "arduino": { @@ -25,7 +26,7 @@ "arduino", "espidf" ], - "name": "Espressif ESP32-P4 Function EV Board", + "name": "Espressif ESP32-P4 Function EV Board (ES pre rev.300)", "upload": { "flash_size": "16MB", "maximum_ram_size": 512000, diff --git a/boards/esp32-p4.json b/boards/esp32-p4.json index ec721a807..476079fa9 100644 --- a/boards/esp32-p4.json +++ b/boards/esp32-p4.json @@ -9,6 +9,7 @@ "f_psram": "200000000L", "flash_mode": "qio", "mcu": "esp32p4", + "chip_variant": "esp32p4_es", "variant": "esp32p4" }, "connectivity": [ @@ -22,7 +23,7 @@ "arduino", "espidf" ], - "name": "Espressif ESP32-P4 generic", + "name": "Espressif ESP32-P4 ES (pre rev.300) generic", "upload": { "flash_size": "4MB", "maximum_ram_size": 327680, diff --git a/boards/esp32-p4_r3.json b/boards/esp32-p4_r3.json new file mode 100644 index 000000000..8ed15ecc9 --- /dev/null +++ b/boards/esp32-p4_r3.json @@ -0,0 +1,36 @@ +{ + "build": { + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "400000000L", + "f_flash": "80000000L", + "f_psram": "200000000L", + "flash_mode": "qio", + "mcu": "esp32p4", + "chip_variant": "esp32p4", + "variant": "esp32p4" + }, + "connectivity": [ + "bluetooth", + "openthread" + ], + "debug": { + "openocd_target": "esp32p4.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Espressif ESP32-P4 rev.300 generic", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.espressif.com", + "vendor": "Espressif" +} diff --git a/boards/m5stack-tab5-p4.json b/boards/m5stack-tab5-p4.json index 7c561ca38..ec4fbf8a8 100644 --- a/boards/m5stack-tab5-p4.json +++ b/boards/m5stack-tab5-p4.json @@ -11,6 +11,7 @@ "f_psram": "200000000L", "flash_mode": "qio", "mcu": "esp32p4", + "chip_variant": "esp32p4_es", "variant": "m5stack_tab5" }, "arduino": { @@ -27,7 +28,7 @@ "arduino", "espidf" ], - "name": "M5STACK Tab5 esp32-p4 Board", + "name": "M5STACK Tab5 esp32-p4 Board (ES pre rev.300)", "upload": { "flash_size": "16MB", "maximum_ram_size": 512000, diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 3eb65ccfa..9d56876d3 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -73,7 +73,7 @@ def get_platform_default_threshold(mcu): "esp32s2": 32000, # ESP32-S2 "esp32s3": 32766, # ESP32-S3 "esp32c3": 32000, # ESP32-C3 - "esp32c2": 32000, # ESP32-C2 + "esp32c2": 31600, # ESP32-C2 "esp32c6": 31600, # ESP32-C6 "esp32h2": 32000, # ESP32-H2 "esp32p4": 32000, # ESP32-P4 @@ -236,7 +236,7 @@ def get_threshold_info(env, config, current_env_section): Returns: dict: Information about threshold configuration """ - mcu = env.BoardConfig().get("build.mcu", "esp32") + mcu = env.BoardConfig().get("build.mcu", "esp32").lower() setting_name = "custom_include_path_length_threshold" info = { @@ -285,9 +285,10 @@ def get_threshold_info(env, config, current_env_section): # Cache class for frequently used paths class PathCache: - def __init__(self, platform, mcu): + def __init__(self, platform, mcu, chip_variant): self.platform = platform self.mcu = mcu + self.chip_variant = chip_variant self._framework_dir = None self._framework_lib_dir = None self._sdk_dir = None @@ -310,7 +311,7 @@ def framework_lib_dir(self): def sdk_dir(self): if self._sdk_dir is None: self._sdk_dir = fs.to_unix_path( - str(Path(self.framework_lib_dir) / self.mcu / "include") + str(Path(self.framework_lib_dir) / self.chip_variant / "include") ) return self._sdk_dir @@ -520,9 +521,11 @@ def safe_remove_sdkconfig_files(): # Cached values mcu = board.get("build.mcu", "esp32") +chip_variant = env.BoardConfig().get("build.chip_variant", "").lower() +chip_variant = chip_variant if chip_variant else mcu pioenv = env["PIOENV"] project_dir = env.subst("$PROJECT_DIR") -path_cache = PathCache(platform, mcu) +path_cache = PathCache(platform, mcu, chip_variant) current_env_section = f"env:{pioenv}" # Board configuration @@ -921,13 +924,13 @@ def get_frameworks_in_current_env(): from component_manager import ComponentManager component_manager = ComponentManager(env) component_manager.handle_component_settings() - + # Handle LTO flags if flag_lto is set if flag_lto: # First remove existing -fno-lto flags, then add LTO flags component_manager.remove_no_lto_flags() component_manager.add_lto_flags() - + silent_action = env.Action(component_manager.restore_pioarduino_build_py) # silence scons command output silent_action.strfunction = lambda target, source, env: '' diff --git a/builder/frameworks/component_manager.py b/builder/frameworks/component_manager.py index c73a6e18c..d5eb9d1d6 100644 --- a/builder/frameworks/component_manager.py +++ b/builder/frameworks/component_manager.py @@ -45,6 +45,8 @@ def __init__(self, env): self.board = env.BoardConfig() # Extract MCU type from board configuration, defaulting to esp32 self.mcu = self.board.get("build.mcu", "esp32").lower() + chip_variant = self.board.get("build.chip_variant", "").lower() + self.chip_variant = chip_variant if chip_variant else self.mcu # Get project source directory path self.project_src_dir = env.subst("$PROJECT_SRC_DIR") @@ -74,7 +76,7 @@ def arduino_libs_mcu(self): """ if self._arduino_libs_mcu is None: ald = self.platform.get_package_dir("framework-arduinoespressif32-libs") - self._arduino_libs_mcu = str(Path(ald) / self.mcu) if ald else "" + self._arduino_libs_mcu = str(Path(ald) / self.chip_variant) if ald else "" return self._arduino_libs_mcu diff --git a/builder/frameworks/espidf.py b/builder/frameworks/espidf.py index 2d895b704..442da970b 100644 --- a/builder/frameworks/espidf.py +++ b/builder/frameworks/espidf.py @@ -77,6 +77,8 @@ config = env.GetProjectConfig() board = env.BoardConfig() mcu = board.get("build.mcu", "esp32") +chip_variant = board.get("build.chip_variant", "").lower() +chip_variant = chip_variant if chip_variant else mcu flash_speed = board.get("build.f_flash", "40000000L") flash_frequency = str(flash_speed.replace("000000L", "")) flash_mode = board.get("build.flash_mode", "dio") @@ -180,16 +182,16 @@ def create_silent_action(action_func): ARDUINO_FRMWRK_LIB_DIR = str(ARDUINO_FRMWRK_LIB_DIR_PATH) if mcu == "esp32c2": - ARDUINO_FRMWRK_C2_LIB_DIR = str(ARDUINO_FRMWRK_LIB_DIR_PATH / mcu) + ARDUINO_FRMWRK_C2_LIB_DIR = str(ARDUINO_FRMWRK_LIB_DIR_PATH / chip_variant) if not os.path.exists(ARDUINO_FRMWRK_C2_LIB_DIR): _arduino_c2_dir = platform.get_package_dir("framework-arduino-c2-skeleton-lib") if not _arduino_c2_dir: sys.stderr.write("Error: Missing framework-arduino-c2-skeleton-lib package\n") env.Exit(1) arduino_c2_dir = Path(_arduino_c2_dir) - ARDUINO_C2_DIR = str(arduino_c2_dir / mcu) + ARDUINO_C2_DIR = str(arduino_c2_dir / chip_variant) shutil.copytree(ARDUINO_C2_DIR, ARDUINO_FRMWRK_C2_LIB_DIR, dirs_exist_ok=True) - arduino_libs_mcu = str(ARDUINO_FRMWRK_LIB_DIR_PATH / mcu) + arduino_libs_mcu = str(ARDUINO_FRMWRK_LIB_DIR_PATH / chip_variant) BUILD_DIR = env.subst("$BUILD_DIR") PROJECT_DIR = env.subst("$PROJECT_DIR") @@ -337,7 +339,7 @@ def generate_board_specific_config(): flash_memory_type, psram_memory_type = parts else: flash_memory_type = memory_type - + # Add flash mode to sdkconfig if flash_mode: flash_mode_lower = flash_mode.lower() @@ -348,7 +350,7 @@ def generate_board_specific_config(): for mode in flash_modes: if mode != flash_mode_lower: board_config_flags.append(f"# CONFIG_ESPTOOLPY_FLASHMODE_{mode.upper()} is not set") - + # Override flash_memory_type if boot mode indicates OPI if boot_mode == "opi" or flash_mode in ["dout", "opi"]: if not flash_memory_type or flash_memory_type.lower() != "opi": @@ -2600,9 +2602,9 @@ def _replace_move(src, dst): sdkconfig_h_path = str(Path(env_build) / "config" / "sdkconfig.h") arduino_libs = str(Path(ARDUINO_FRMWRK_LIB_DIR)) lib_src = str(Path(env_build) / "esp-idf") - lib_dst = str(Path(arduino_libs) / mcu / "lib") - ld_dst = str(Path(arduino_libs) / mcu / "ld") - mem_var = str(Path(arduino_libs) / mcu / board.get("build.arduino.memory_type", (board.get("build.flash_mode", "dio") + "_qspi"))) + lib_dst = str(Path(arduino_libs) / chip_variant / "lib") + ld_dst = str(Path(arduino_libs) / chip_variant / "ld") + mem_var = str(Path(arduino_libs) / chip_variant / board.get("build.arduino.memory_type", (board.get("build.flash_mode", "dio") + "_qspi"))) # Ensure destinations exist for d in (lib_dst, ld_dst, mem_var, str(Path(mem_var) / "include")): Path(d).mkdir(parents=True, exist_ok=True) @@ -2625,9 +2627,9 @@ def _replace_move(src, dst): _replace_move(str(Path(lib_dst) / "libesp_lcd.a"), str(Path(mem_var) / "libesp_lcd.a")) shutil.copyfile(sdkconfig_h_path, str(Path(mem_var) / "include" / "sdkconfig.h")) - if not bool(os.path.isfile(str(Path(arduino_libs) / mcu / "sdkconfig.orig"))): - shutil.move(str(Path(arduino_libs) / mcu / "sdkconfig"), str(Path(arduino_libs) / mcu / "sdkconfig.orig")) - shutil.copyfile(str(Path(env.subst("$PROJECT_DIR")) / ("sdkconfig." + env["PIOENV"])), str(Path(arduino_libs) / mcu / "sdkconfig")) + if not bool(os.path.isfile(str(Path(arduino_libs) / chip_variant / "sdkconfig.orig"))): + shutil.move(str(Path(arduino_libs) / chip_variant / "sdkconfig"), str(Path(arduino_libs) / chip_variant / "sdkconfig.orig")) + shutil.copyfile(str(Path(env.subst("$PROJECT_DIR")) / ("sdkconfig." + env["PIOENV"])), str(Path(arduino_libs) / chip_variant / "sdkconfig")) shutil.copyfile(str(Path(env.subst("$PROJECT_DIR")) / ("sdkconfig." + env["PIOENV"])), str(Path(arduino_libs) / "sdkconfig")) try: os.remove(str(Path(env.subst("$PROJECT_DIR")) / "dependencies.lock"))