Skip to content

Commit

Permalink
Fix Esp32 GDB path resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Jan 8, 2024
1 parent 3d5a95d commit b6b5205
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
15 changes: 10 additions & 5 deletions Sming/Arch/Esp32/Tools/idf_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ def get_tool_info(soc):

compiler_prefix = None
compiler_version = None
gcc_path = gdb_path = None
for tool in tools_info['tools']:
if tool.get('install') != 'always':
continue
if soc not in tool['supported_targets']:
continue
desc = tool['description']
if not desc.startswith('Toolchain'):
continue
desc = tool['description'].lower()
export_path = "/".join(tool['export_paths'][0])
tool_name = tool['name']
tool_version = tool['versions'][0]['name']
break
print(f"{tool_name} {tool_version}")
path = f"{tool_name}/{tool_version}/{export_path}"
if 'gcc' in desc and not gcc_path:
gcc_path = path
if 'gdb' in desc and not gdb_path:
gdb_path = path

print(gcc_path, gdb_path)


if __name__ == '__main__':
Expand Down
27 changes: 15 additions & 12 deletions Sming/Arch/Esp32/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ ESP_VARIANT := $(SMING_SOC)
export ESP_VARIANT

IDF_TOOL_INFO := $(shell $(PYTHON) $(ARCH_TOOLS)/idf_tools.py $(SMING_SOC))
ESP32_TOOLSET_PREFIX := $(word 1,$(IDF_TOOL_INFO))
ESP32_COMPILER_VERSION := $(word 2,$(IDF_TOOL_INFO))
ifeq (xtensa-esp-elf,$(ESP32_TOOLSET_PREFIX))
ESP32_GCC_PATH := $(word 1,$(IDF_TOOL_INFO))
ESP32_GDB_PATH := $(word 2,$(IDF_TOOL_INFO))
ESP32_COMPILER_PATH := $(IDF_TOOLS_PATH)/tools/$(ESP32_GCC_PATH)
ifneq (,$(filter xtensa%,$(ESP32_GCC_PATH)))
ESP32_COMPILER_PREFIX := xtensa-$(ESP_VARIANT)-elf
else
ESP32_COMPILER_PREFIX := $(ESP32_TOOLSET_PREFIX)
IDF_TARGET_ARCH_RISCV := $(findstring riscv,$(ESP32_COMPILER_PREFIX))
ESP32_COMPILER_PREFIX := riscv32-esp-elf
IDF_TARGET_ARCH_RISCV := 1
endif

# $1 => Tool sub-path/name
Expand All @@ -49,10 +50,6 @@ endef

DEBUG_VARS += ESP32_COMPILER_PATH ESP32_ULP_PATH ESP32_OPENOCD_PATH ESP32_PYTHON_PATH

ifndef ESP32_COMPILER_PATH
ESP32_COMPILER_PATH := $(IDF_TOOLS_PATH)/tools/$(ESP32_TOOLSET_PREFIX)/$(ESP32_COMPILER_VERSION)/$(ESP32_TOOLSET_PREFIX)
endif

ifndef ESP32_ULP_PATH
ESP32_ULP_PATH := $(call FindTool,tools/$(ESP_VARIANT)ulp-elf/)
endif
Expand All @@ -78,7 +75,7 @@ export IDF_PYTHON_ENV_PATH=$(ESP32_PYTHON_PATH)
# Add ESP-IDF tools to PATH
IDF_PATH_LIST := \
$(IDF_PATH)/tools \
$(ESP32_COMPILER_PATH)/bin \
$(ESP32_COMPILER_PATH) \
$(ESP32_ULP_PATH)/$(ESP_VARIANT)ulp-elf-binutils/bin \
$(ESP32_OPENOCD_PATH)/openocd-esp32/bin \
$(ESP32_PYTHON_PATH)/bin \
Expand Down Expand Up @@ -111,7 +108,7 @@ space:= $(empty) $(empty)

export PATH := $(subst $(space),:,$(IDF_PATH_LIST)):$(PATH)

TOOLSPEC := $(ESP32_COMPILER_PATH)/bin/$(ESP32_COMPILER_PREFIX)
TOOLSPEC := $(ESP32_COMPILER_PATH)/$(ESP32_COMPILER_PREFIX)
AS := $(TOOLSPEC)-gcc
CC := $(TOOLSPEC)-gcc
CXX := $(TOOLSPEC)-g++
Expand All @@ -120,9 +117,15 @@ LD := $(TOOLSPEC)-gcc
NM := $(TOOLSPEC)-nm
OBJCOPY := $(TOOLSPEC)-objcopy
OBJDUMP := $(TOOLSPEC)-objdump
GDB := $(TOOLSPEC)-gdb
SIZE := $(TOOLSPEC)-size

ifeq (None,$(ESP32_GDB_PATH))
GDB := $(TOOLSPEC)-gdb
else
GDB := $(IDF_TOOLS_PATH)/tools/$(ESP32_GDB_PATH)/$(ESP32_COMPILER_PREFIX)-gdb
endif


# [ Sming specific flags ]
DEBUG_VARS += IDF_PATH IDF_VER

Expand Down

0 comments on commit b6b5205

Please sign in to comment.