Skip to content

Commit

Permalink
Switch IDF projects to a standalone GDB packages
Browse files Browse the repository at this point in the history
Note: This change requires PlatformIO Core >=6.1.11a2
  • Loading branch information
valeros committed Aug 28, 2023
1 parent bf5a65b commit f8518b8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
13 changes: 11 additions & 2 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,16 @@ def __fetch_fs_size(target, source, env):
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,
Expand Down Expand Up @@ -282,7 +291,7 @@ def __fetch_fs_size(target, source, env):
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__)}",
Expand Down
14 changes: 13 additions & 1 deletion platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -79,7 +91,7 @@
"type": "framework",
"optional": true,
"owner": "platformio",
"version": "~3.50101.0",
"version": "~3.50100.0",
"optionalVersions": ["~3.40405.0"]
},
"tool-esptoolpy": {
Expand Down
18 changes: 17 additions & 1 deletion platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def configure_default_packages(self, variables, targets):
"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:
Expand Down Expand Up @@ -93,6 +93,17 @@ def configure_default_packages(self, variables, targets):
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"):
Expand All @@ -113,6 +124,11 @@ def configure_default_packages(self, variables, targets):
):
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
Expand Down

0 comments on commit f8518b8

Please sign in to comment.