diff --git a/Sming/Arch/Esp32/Tools/idf_tools.py b/Sming/Arch/Esp32/Tools/idf_tools.py index ba97c6731c..38837cd032 100644 --- a/Sming/Arch/Esp32/Tools/idf_tools.py +++ b/Sming/Arch/Esp32/Tools/idf_tools.py @@ -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__': diff --git a/Sming/Arch/Esp32/build.mk b/Sming/Arch/Esp32/build.mk index f20c7a7803..2c615737e9 100644 --- a/Sming/Arch/Esp32/build.mk +++ b/Sming/Arch/Esp32/build.mk @@ -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 @@ -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 @@ -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 \ @@ -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++ @@ -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