From f8518b861bd9d7d07821f663ed67ccf6c92113a2 Mon Sep 17 00:00:00 2001 From: valeros Date: Mon, 28 Aug 2023 16:10:48 +0300 Subject: [PATCH] Switch IDF projects to a standalone GDB packages Note: This change requires PlatformIO Core >=6.1.11a2 --- builder/main.py | 13 +++++++++++-- platform.json | 14 +++++++++++++- platform.py | 18 +++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/builder/main.py b/builder/main.py index bc0e4fe..d6706ae 100644 --- a/builder/main.py +++ b/builder/main.py @@ -230,7 +230,16 @@ env.Replace( AS="%s-elf-as" % toolchain_arch, CC="%s-elf-gcc" % toolchain_arch, CXX="%s-elf-g++" % toolchain_arch, - GDB="%s-elf-gdb" % toolchain_arch, + GDB=join( + platform.get_package_dir( + "tool-riscv32-esp-elf-gdb" + if mcu in ("esp32c3", "esp32c6") + else "tool-xtensa-esp-elf-gdb" + ) + or "", + "bin", + "%s-elf-gdb" % toolchain_arch, + ) if env.get("PIOFRAMEWORK") == ["espidf"] else "%s-elf-gdb" % toolchain_arch, OBJCOPY=join( platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"), RANLIB="%s-elf-ranlib" % toolchain_arch, @@ -282,7 +291,7 @@ env.Append( BUILDERS=dict( ElfToBin=Builder( action=env.VerboseAction(" ".join([ - '"$PYTHONEXE" "$OBJCOPY"', + '"$PYTHONEXE" "$OBJCOPY"', "--chip", mcu, "elf2image", "--flash_mode", "${__get_board_flash_mode(__env__)}", "--flash_freq", "${__get_board_f_flash(__env__)}", diff --git a/platform.json b/platform.json index 7ff99d5..cf1f58e 100644 --- a/platform.json +++ b/platform.json @@ -63,6 +63,18 @@ "owner": "platformio", "version": "~1.23500.0" }, + "tool-xtensa-esp-elf-gdb": { + "type": "debugger", + "optional": true, + "owner": "espressif", + "version": "~12.1.0+20221002" + }, + "tool-riscv32-esp-elf-gdb": { + "type": "debugger", + "optional": true, + "owner": "espressif", + "version": "~12.1.0+20221002" + }, "framework-arduinoespressif32": { "type": "framework", "optional": true, @@ -79,7 +91,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~3.50101.0", + "version": "~3.50100.0", "optionalVersions": ["~3.40405.0"] }, "tool-esptoolpy": { diff --git a/platform.py b/platform.py index cc45624..dfdb7c7 100644 --- a/platform.py +++ b/platform.py @@ -56,7 +56,7 @@ class Espressif32Platform(PlatformBase): "board_build.core", board_config.get("build.core", "arduino") ).lower() - if len(frameworks) == 1 and "arduino" in frameworks and build_core == "esp32": + if frameworks == ["arduino"] and build_core == "esp32": # In case the upstream Arduino framework is specified in the configuration # file then we need to dynamically extract toolchain versions from the # Arduino index file. This feature can be disabled via a special option: @@ -93,6 +93,17 @@ class Espressif32Platform(PlatformBase): sys.exit(1) if "espidf" in frameworks: + if frameworks == ["espidf"]: + # Starting from v12, Espressif's toolchains are shipped without + # bundled GDB. Instead, it's distributed as separate packages for Xtensa + # and RISC-V targets. Currently only IDF depends on the latest toolchain + for gdb_package in ("tool-xtensa-esp-elf-gdb", "tool-riscv32-esp-elf-gdb"): + self.packages[gdb_package]["optional"] = False + if IS_WINDOWS: + # Note: On Windows GDB v12 is not able to + # launch a GDB server in pipe mode while v11 works fine + self.packages[gdb_package]["version"] = "~11.2.0" + # Common packages for IDF and mixed Arduino+IDF projects for p in self.packages: if p in ("tool-cmake", "tool-ninja", "toolchain-esp32ulp"): @@ -113,6 +124,11 @@ class Espressif32Platform(PlatformBase): ): self.packages["toolchain-%s" % target]["version"] = "12.2.0+20230208" + if "arduino" in frameworks: + # Disable standalone GDB packages for Arduino and Arduino/IDF projects + for gdb_package in ("tool-xtensa-esp-elf-gdb", "tool-riscv32-esp-elf-gdb"): + self.packages.pop(gdb_package, None) + for available_mcu in ("esp32", "esp32s2", "esp32s3"): if available_mcu == mcu: self.packages["toolchain-xtensa-%s" % mcu]["optional"] = False