Skip to content

Commit f8518b8

Browse files
committed
Switch IDF projects to a standalone GDB packages
Note: This change requires PlatformIO Core >=6.1.11a2
1 parent bf5a65b commit f8518b8

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

builder/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,16 @@ def __fetch_fs_size(target, source, env):
230230
AS="%s-elf-as" % toolchain_arch,
231231
CC="%s-elf-gcc" % toolchain_arch,
232232
CXX="%s-elf-g++" % toolchain_arch,
233-
GDB="%s-elf-gdb" % toolchain_arch,
233+
GDB=join(
234+
platform.get_package_dir(
235+
"tool-riscv32-esp-elf-gdb"
236+
if mcu in ("esp32c3", "esp32c6")
237+
else "tool-xtensa-esp-elf-gdb"
238+
)
239+
or "",
240+
"bin",
241+
"%s-elf-gdb" % toolchain_arch,
242+
) if env.get("PIOFRAMEWORK") == ["espidf"] else "%s-elf-gdb" % toolchain_arch,
234243
OBJCOPY=join(
235244
platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"),
236245
RANLIB="%s-elf-ranlib" % toolchain_arch,
@@ -282,7 +291,7 @@ def __fetch_fs_size(target, source, env):
282291
BUILDERS=dict(
283292
ElfToBin=Builder(
284293
action=env.VerboseAction(" ".join([
285-
'"$PYTHONEXE" "$OBJCOPY"',
294+
'"$PYTHONEXE" "$OBJCOPY"',
286295
"--chip", mcu, "elf2image",
287296
"--flash_mode", "${__get_board_flash_mode(__env__)}",
288297
"--flash_freq", "${__get_board_f_flash(__env__)}",

platform.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@
6363
"owner": "platformio",
6464
"version": "~1.23500.0"
6565
},
66+
"tool-xtensa-esp-elf-gdb": {
67+
"type": "debugger",
68+
"optional": true,
69+
"owner": "espressif",
70+
"version": "~12.1.0+20221002"
71+
},
72+
"tool-riscv32-esp-elf-gdb": {
73+
"type": "debugger",
74+
"optional": true,
75+
"owner": "espressif",
76+
"version": "~12.1.0+20221002"
77+
},
6678
"framework-arduinoespressif32": {
6779
"type": "framework",
6880
"optional": true,
@@ -79,7 +91,7 @@
7991
"type": "framework",
8092
"optional": true,
8193
"owner": "platformio",
82-
"version": "~3.50101.0",
94+
"version": "~3.50100.0",
8395
"optionalVersions": ["~3.40405.0"]
8496
},
8597
"tool-esptoolpy": {

platform.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def configure_default_packages(self, variables, targets):
5656
"board_build.core", board_config.get("build.core", "arduino")
5757
).lower()
5858

59-
if len(frameworks) == 1 and "arduino" in frameworks and build_core == "esp32":
59+
if frameworks == ["arduino"] and build_core == "esp32":
6060
# In case the upstream Arduino framework is specified in the configuration
6161
# file then we need to dynamically extract toolchain versions from the
6262
# Arduino index file. This feature can be disabled via a special option:
@@ -93,6 +93,17 @@ def configure_default_packages(self, variables, targets):
9393
sys.exit(1)
9494

9595
if "espidf" in frameworks:
96+
if frameworks == ["espidf"]:
97+
# Starting from v12, Espressif's toolchains are shipped without
98+
# bundled GDB. Instead, it's distributed as separate packages for Xtensa
99+
# and RISC-V targets. Currently only IDF depends on the latest toolchain
100+
for gdb_package in ("tool-xtensa-esp-elf-gdb", "tool-riscv32-esp-elf-gdb"):
101+
self.packages[gdb_package]["optional"] = False
102+
if IS_WINDOWS:
103+
# Note: On Windows GDB v12 is not able to
104+
# launch a GDB server in pipe mode while v11 works fine
105+
self.packages[gdb_package]["version"] = "~11.2.0"
106+
96107
# Common packages for IDF and mixed Arduino+IDF projects
97108
for p in self.packages:
98109
if p in ("tool-cmake", "tool-ninja", "toolchain-esp32ulp"):
@@ -113,6 +124,11 @@ def configure_default_packages(self, variables, targets):
113124
):
114125
self.packages["toolchain-%s" % target]["version"] = "12.2.0+20230208"
115126

127+
if "arduino" in frameworks:
128+
# Disable standalone GDB packages for Arduino and Arduino/IDF projects
129+
for gdb_package in ("tool-xtensa-esp-elf-gdb", "tool-riscv32-esp-elf-gdb"):
130+
self.packages.pop(gdb_package, None)
131+
116132
for available_mcu in ("esp32", "esp32s2", "esp32s3"):
117133
if available_mcu == mcu:
118134
self.packages["toolchain-xtensa-%s" % mcu]["optional"] = False

0 commit comments

Comments
 (0)