diff --git a/.github/workflows/ci-esp32.yml b/.github/workflows/ci-esp32.yml index 4036e42932..4796499abc 100644 --- a/.github/workflows/ci-esp32.yml +++ b/.github/workflows/ci-esp32.yml @@ -13,7 +13,7 @@ jobs: matrix: os: [ubuntu-20.04, windows-latest] variant: [esp32, esp32s2, esp32c3, esp32s3, esp32c2] - idf_version: ["4.3", "4.4", "5.0"] + idf_version: ["4.3", "4.4", "5.0", "5.2"] exclude: - variant: esp32s3 idf_version: "4.3" diff --git a/Sming/Arch/Esp32/Components/driver/uart.cpp b/Sming/Arch/Esp32/Components/driver/uart.cpp index 3e03b60339..c35f7c6aa7 100644 --- a/Sming/Arch/Esp32/Components/driver/uart.cpp +++ b/Sming/Arch/Esp32/Components/driver/uart.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -567,7 +568,11 @@ uint32_t smg_uart_set_baudrate_reg(int uart_nr, uint32_t baud_rate) uart_ll_set_baudrate(dev, baud_rate); return uart_ll_get_baudrate(dev); #else +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0) uart_ll_set_sclk(dev, UART_SCLK_DEFAULT); +#else + uart_ll_set_sclk(dev, soc_module_clk_t(UART_SCLK_DEFAULT)); +#endif uart_ll_set_baudrate(dev, baud_rate, APB_CLK_FREQ); return uart_ll_get_baudrate(dev, APB_CLK_FREQ); #endif diff --git a/Sming/Arch/Esp32/Components/esp32/component.mk b/Sming/Arch/Esp32/Components/esp32/component.mk index 5a83cd1aa1..80a45453de 100644 --- a/Sming/Arch/Esp32/Components/esp32/component.mk +++ b/Sming/Arch/Esp32/Components/esp32/component.mk @@ -14,8 +14,21 @@ ifeq ($(CREATE_EVENT_TASK),1) COMPONENT_CPPFLAGS += -DCREATE_EVENT_TASK endif -IDF_VERSION := $(firstword $(subst -, ,$(IDF_VER))) -IDF_VERSION_4 := $(filter v4%,$(IDF_VERSION)) +ifneq (,$(filter v4.%,$(IDF_VERSION))) +IDF_VERSION_4x := 1 +ifneq (,$(filter v4.3%,$(IDF_VERSION))) +IDF_VERSION_43 := 1 +else ifneq (,$(filter v4.4%,$(IDF_VERSION))) +IDF_VERSION_44 := 1 +endif +else ifneq (,$(filter v5.%,$(IDF_VERSION))) +IDF_VERSION_5x := 1 +endif +ifneq (,$(filter v5.0%,$(IDF_VERSION))) +IDF_VERSION_50 := 1 +else ifneq (,$(filter v5.2%,$(IDF_VERSION))) +IDF_VERSION_52 := 1 +endif ifneq (,$(filter esp32s3-v4.3%,$(ESP_VARIANT)-$(IDF_VER))) $(error esp32s3 requires ESP IDF v4.4 or later) @@ -32,6 +45,7 @@ SDKCONFIG_H := $(SDK_BUILD_BASE)/config/sdkconfig.h SDK_LIBDIRS := \ esp_wifi/lib/$(ESP_VARIANT) \ + esp_coex/lib/$(ESP_VARIANT) \ esp_phy/lib/$(ESP_VARIANT) \ xtensa/$(ESP_VARIANT) \ hal/$(ESP_VARIANT) \ @@ -52,6 +66,12 @@ endif ESP32_COMPONENT_PATH := $(COMPONENT_PATH) SDK_DEFAULT_PATH := $(ESP32_COMPONENT_PATH)/sdk +ifdef IDF_VERSION_52 +GLOBAL_CFLAGS += \ + -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ \ + -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE +endif + LIBDIRS += \ $(SDK_COMPONENT_LIBDIR) \ $(SDK_BUILD_BASE)/esp-idf/mbedtls/mbedtls/library \ @@ -65,13 +85,10 @@ LIBDIRS += \ SDK_INCDIRS := \ app_update/include \ bootloader_support/include \ - bootloader_support/include_bootloader \ - driver/$(ESP_VARIANT)/include \ driver/include \ esp_pm/include \ esp_rom/include/$(ESP_VARIANT) \ esp_rom/include \ - $(ESP_VARIANT)/include \ esp_ringbuf/include \ esp_timer/include \ soc/include \ @@ -82,7 +99,6 @@ SDK_INCDIRS := \ nvs_flash/include \ esp_event/include \ lwip/lwip/src/include \ - lwip/port/esp32/include \ newlib/platform_include \ spi_flash/include \ wpa_supplicant/include \ @@ -90,19 +106,37 @@ SDK_INCDIRS := \ esp_hw_support/include \ esp_hw_support/include/soc \ hal/include \ - hal/platform_port/include \ hal/$(ESP_VARIANT)/include \ esp_system/include \ esp_common/include \ esp_netif/include \ esp_eth/include \ esp_wifi/include \ + lwip/include/apps/sntp + +ifdef IDF_VERSION_4x +SDK_INCDIRS += \ + $(ESP_VARIANT)/include +endif + +ifdef IDF_VERSION_43 +SDK_INCDIRS += \ esp_wifi/esp32/include \ - lwip/include/apps/sntp \ wpa_supplicant/include/esp_supplicant +else +SDK_INCDIRS += \ + hal/platform_port/include +endif -ifdef IDF_VERSION_4 +ifndef IDF_VERSION_52 SDK_INCDIRS += \ + driver/$(ESP_VARIANT)/include \ + lwip/port/esp32/include +endif + +ifdef IDF_VERSION_4x +SDK_INCDIRS += \ + bootloader_support/include_bootloader \ esp_adc_cal/include \ esp_ipc/include \ freertos/include \ @@ -119,13 +153,29 @@ SDK_INCDIRS += \ freertos/esp_additions/include/freertos \ driver/deprecated FREERTOS_PORTABLE := freertos/FreeRTOS-Kernel/portable +ifeq (v5.2,$(IDF_VERSION)) +SDK_INCDIRS += \ + driver/gpio/include \ + driver/ledc/include \ + driver/spi/include \ + lwip/port/include \ + lwip/port/freertos/include \ + lwip/port/esp32xx/include \ + esp_bootloader_format/include \ + esp_adc/$(ESP_VARIANT)/include \ + freertos/config/include \ + freertos/config/include/freertos +endif endif - - ifeq ($(ENABLE_BLUETOOTH),1) +ifeq (esp32s3-v5.2,$(ESP_VARIANT)-$(IDF_VERSION)) +ESP_BT_VARIANT := esp32c3 +else +ESP_BT_VARIANT := $(ESP_VARIANT) +endif SDK_INCDIRS += \ - bt/include/$(ESP_VARIANT)/include \ + bt/include/$(ESP_BT_VARIANT)/include \ bt/common/api/include/api \ bt/common/btc/profile/esp/blufi/include \ bt/common/btc/profile/esp/include \ @@ -148,17 +198,31 @@ SDK_INCDIRS += \ bt/host/nimble/nimble/nimble/host/store/config/include \ bt/host/nimble/esp-hci/include \ bt/host/nimble/port/include +ifdef IDF_VERSION_52 +SDK_INCDIRS += \ + bt/host/nimble/nimble/nimble/transport/include +endif endif ifdef IDF_TARGET_ARCH_RISCV SDK_INCDIRS += \ $(FREERTOS_PORTABLE)/riscv/include \ + $(FREERTOS_PORTABLE)/riscv/include/freertos \ + freertos/config/riscv \ + freertos/config/riscv/include \ riscv/include else SDK_INCDIRS += \ xtensa/include \ xtensa/$(ESP_VARIANT)/include \ - $(FREERTOS_PORTABLE)/xtensa/include + $(FREERTOS_PORTABLE)/xtensa/include \ + $(FREERTOS_PORTABLE)/xtensa/include/freertos +ifdef IDF_VERSION_52 +SDK_INCDIRS += \ + freertos/config/xtensa \ + freertos/config/xtensa/include \ + xtensa/deprecated_include +endif endif @@ -193,13 +257,13 @@ SDK_COMPONENTS := \ soc \ spi_flash -ifneq (,$(filter v4.3%,$(IDF_VERSION))) +ifdef IDF_VERSION_43 SDK_COMPONENTS += $(ESP_VARIANT) else SDK_COMPONENTS += esp_phy endif -ifdef IDF_VERSION_4 +ifdef IDF_VERSION_4x SDK_COMPONENTS += \ esp_ipc \ esp_adc_cal @@ -210,6 +274,12 @@ SDK_COMPONENTS += \ esp_partition endif +ifeq (v5.2,$(IDF_VERSION)) +SDK_COMPONENTS += \ + esp_mm \ + esp_coex +endif + ifneq ($(DISABLE_NETWORK),1) SDK_COMPONENTS += \ @@ -302,10 +372,14 @@ LDFLAGS_esp32s3 := \ LDFLAGS_esp32c2 := \ $(call LinkerScript,rom.newlib) \ $(call LinkerScript,rom.version) \ - $(call LinkerScript,rom.newlib-time) \ $(call LinkerScript,rom.heap) \ $(call LinkerScript,rom.mbedtls) +ifneq (v5.2,$(IDF_VERSION)) +LDFLAGS_esp32c2 += \ + $(call LinkerScript,rom.newlib-time) +endif + SDK_WRAP_SYMBOLS := SDK_UNDEF_SYMBOLS := @@ -329,7 +403,7 @@ EXTRA_LDFLAGS := \ $(call Undef,$(SDK_UNDEF_SYMBOLS)) \ $(call Wrap,$(SDK_WRAP_SYMBOLS)) -ifneq (,$(filter v4.3%,$(IDF_VERSION))) +ifdef IDF_VERSION_43 EXTRA_LDFLAGS += \ -T $(ESP_VARIANT)_out.ld \ $(call LinkerScript,project) @@ -440,3 +514,8 @@ sdk-help: ##Get SDK build options .PHONY: sdk sdk: ##Pass options to IDF builder, e.g. `make sdk -- --help` or `make sdk menuconfig` $(Q) $(SDK_BUILD) $(filter-out sdk,$(MAKECMDGOALS)) + + +.PHONY: check-incdirs +check-incdirs: ##Check IDF include paths and report any not found in this SDK version + $(Q) $(foreach d,$(SDK_INCDIRS),$(if $(wildcard $(SDK_COMPONENTS_PATH)/$d),,$(info $d))) diff --git a/Sming/Arch/Esp32/Components/esp32/src/clk.c b/Sming/Arch/Esp32/Components/esp32/src/clk.c index 724f3def0e..84777f8693 100644 --- a/Sming/Arch/Esp32/Components/esp32/src/clk.c +++ b/Sming/Arch/Esp32/Components/esp32/src/clk.c @@ -2,10 +2,12 @@ #include #include +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0) #define EXPAND(a) a #define CONCAT3a(a, b, c) a##b##c #define CONCAT3(a, b, c) CONCAT3a(a, b, c) -typedef CONCAT3(esp_pm_config_, SMING_SOC, _t) pm_config_t; +typedef CONCAT3(esp_pm_config_, SMING_SOC, _t) esp_pm_config_t; +#endif int esp_clk_cpu_freq(void); @@ -13,7 +15,7 @@ static esp_pm_lock_handle_t handle; bool system_update_cpu_freq(uint32_t freq) { - pm_config_t config = {}; + esp_pm_config_t config = {}; esp_err_t err = esp_pm_get_configuration(&config); if(err != ESP_OK) { debug_e("[PM] Failed to read PM config %u", err); diff --git a/Sming/Arch/Esp32/Core/Digital.cpp b/Sming/Arch/Esp32/Core/Digital.cpp index b5c694018f..48015d79f3 100644 --- a/Sming/Arch/Esp32/Core/Digital.cpp +++ b/Sming/Arch/Esp32/Core/Digital.cpp @@ -15,6 +15,10 @@ #include #if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED #include +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0) +#define RTCIO_LL_FUNC_RTC RTCIO_FUNC_RTC +#define RTCIO_LL_FUNC_DIGITAL RTCIO_FUNC_DIGITAL +#endif #endif void pinMode(uint16_t pin, uint8_t mode) @@ -38,7 +42,7 @@ void pinMode(uint16_t pin, uint8_t mode) return; // Already in ADC mode } - rtcio_ll_function_select(rtc, RTCIO_FUNC_RTC); + rtcio_ll_function_select(rtc, RTCIO_LL_FUNC_RTC); rtcio_ll_input_disable(rtc); rtcio_ll_output_disable(rtc); rtcio_ll_pullup_disable(rtc); @@ -48,7 +52,7 @@ void pinMode(uint16_t pin, uint8_t mode) } if(rtc >= 0) { - rtcio_ll_function_select(rtc, RTCIO_FUNC_DIGITAL); + rtcio_ll_function_select(rtc, RTCIO_LL_FUNC_DIGITAL); rtcio_ll_pulldown_disable(rtc); if(mode == INPUT_PULLUP) { rtcio_ll_pullup_enable(rtc); diff --git a/Sming/Arch/Esp32/README.rst b/Sming/Arch/Esp32/README.rst index bf575ce212..9de7952ad8 100644 --- a/Sming/Arch/Esp32/README.rst +++ b/Sming/Arch/Esp32/README.rst @@ -28,12 +28,12 @@ Build variables Requirements ------------ -In order to be able to compile for the ESP32 architecture you should have ESP-IDF v4.3 installed. -Some slight changes are required to enable code to compile correctly for C++, -so a fork has been created here https://github.com/mikee47/esp-idf/tree/sming/release/v4.3 -which you may clone. +Sming requires a slightly modified version of the Espressif SDK. +You can find the SDK here https://github.com/mikee47/esp-idf/tree/sming/release/v5.2. +See `idf_versions`_ below for further details. -The Sming installers do all this for you - see :doc:`/getting-started/index`. +Using the Sming installation scripts are the recommended way to install these SDK versions. +See :doc:`/getting-started/index`. You can find further details in the `ESP-IDF documentation `__. @@ -101,14 +101,16 @@ Each variant uses a different build directory, e.g. ``out/Esp32/esp32c3/...`` to See :component-esp32:`esp32` for further details. +.. _idf_versions: + IDF versions ------------ -Sming currently supports IDF versions 4.3, 4.4 and 5.0. +Sming currently supports IDF versions 4.3, 4.4, 5.0 and 5.2. The default installed IDF version is 4.4. This can be changed as follows:: - INSTALL_IDF_VER=5.0 $SMING_HOME/../Tools/install.sh esp32 + INSTALL_IDF_VER=5.2 $SMING_HOME/../Tools/install.sh esp32 The installation script creates a soft-link in ``/opt/esp-idf`` pointing to the last version installed. Use the `IDF_PATH` environment variable or change the soft-link to select which one to use. diff --git a/Sming/Arch/Esp32/Tools/ci/build.run.cmd b/Sming/Arch/Esp32/Tools/ci/build.run.cmd index 78de751535..b1d9c8d08e 100644 --- a/Sming/Arch/Esp32/Tools/ci/build.run.cmd +++ b/Sming/Arch/Esp32/Tools/ci/build.run.cmd @@ -1,7 +1,7 @@ REM Esp32 build.run.cmd %MAKE_PARALLEL% Basic_Blink Basic_Ethernet Basic_WiFi HttpServer_ConfigNetwork DEBUG_VERBOSE_LEVEL=3 STRICT=1 || goto :error -%MAKE_PARALLEL% Basic_Ssl ENABLE_SSL=Bearssl DEBUG_VERBOSE_LEVEL=3 STRICT=1 || goto :error +%MAKE_PARALLEL% Basic_Ssl ENABLE_SSL=Axtls DEBUG_VERBOSE_LEVEL=3 STRICT=1 || goto :error REM make sure that the Ota Library sample compiles for ESP32 %MAKE_PARALLEL% -C %SMING_HOME%\Libraries\OtaUpgradeMqtt\samples\Upgrade diff --git a/Sming/Arch/Esp32/Tools/idf_tools.py b/Sming/Arch/Esp32/Tools/idf_tools.py index 8001e98652..38837cd032 100644 --- a/Sming/Arch/Esp32/Tools/idf_tools.py +++ b/Sming/Arch/Esp32/Tools/idf_tools.py @@ -9,19 +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 soc in tool['supported_targets']: - desc = tool['description'] - if desc.startswith('Toolchain'): - compiler_prefix = tool['name'] - compiler_version = tool['versions'][0]['name'] - break - print(f"{compiler_prefix} {compiler_version}") - - # ESP32_COMPILER_PREFIX=compiler_prefix - # IDF_TARGET_ARCH_RISCV=is_riscv - - + if tool.get('install') != 'always': + continue + if soc not in tool['supported_targets']: + continue + desc = tool['description'].lower() + export_path = "/".join(tool['export_paths'][0]) + tool_name = tool['name'] + tool_version = tool['versions'][0]['name'] + 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/Tools/install.cmd b/Sming/Arch/Esp32/Tools/install.cmd index 9f0122949b..cba5358357 100644 --- a/Sming/Arch/Esp32/Tools/install.cmd +++ b/Sming/Arch/Esp32/Tools/install.cmd @@ -16,4 +16,9 @@ set IDF_REQUIREMENTS="%IDF_PATH%\requirements.txt" if not exist "%IDF_REQUIREMENTS%" set IDF_REQUIREMENTS="%IDF_PATH%\tools\requirements\requirements.core.txt" python -m pip install -r "%IDF_REQUIREMENTS%" -if "%INSTALL_IDF_VER%"=="5.0" python "%IDF_PATH%\tools\idf_tools.py" --non-interactive install-python-env +if "%INSTALL_IDF_VER%" == "5.0" goto :install_python +if "%INSTALL_IDF_VER%" == "5.2" goto :install_python +goto :EOF + +:install_python +python "%IDF_PATH%\tools\idf_tools.py" --non-interactive install-python-env diff --git a/Sming/Arch/Esp32/build.mk b/Sming/Arch/Esp32/build.mk index 32d9b6b38a..2c615737e9 100644 --- a/Sming/Arch/Esp32/build.mk +++ b/Sming/Arch/Esp32/build.mk @@ -10,6 +10,12 @@ endif export IDF_PATH := $(call FixPath,$(IDF_PATH)) +# Extract IDF version +ifndef IDF_VER +IDF_VER := $(shell (cd $$IDF_PATH && git describe --always --tags --dirty) | cut -c 1-31) +endif +IDF_VERSION := $(firstword $(subst -, ,$(IDF_VER))) + # By default, downloaded tools will be installed under $HOME/.espressif directory # (%USERPROFILE%/.espressif on Windows). This path can be modified by setting # IDF_TOOLS_PATH variable prior to running this tool. @@ -27,40 +33,40 @@ ESP_VARIANT := $(SMING_SOC) export ESP_VARIANT IDF_TOOL_INFO := $(shell $(PYTHON) $(ARCH_TOOLS)/idf_tools.py $(SMING_SOC)) -ESP32_COMPILER_PREFIX := $(word 1,$(IDF_TOOL_INFO)) -ESP32_COMPILER_VERSION := $(word 2,$(IDF_TOOL_INFO)) -IDF_TARGET_ARCH_RISCV := $(findstring riscv,$(ESP32_COMPILER_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 := riscv32-esp-elf +IDF_TARGET_ARCH_RISCV := 1 +endif -# $1 => Root directory -# $2 => Sub-directory +# $1 => Tool sub-path/name define FindTool -$(lastword $(sort $(wildcard $(IDF_TOOLS_PATH)/$1/*))$2) +$(lastword $(sort $(wildcard $(IDF_TOOLS_PATH)/$1*))) 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_COMPILER_PREFIX)/$(ESP32_COMPILER_VERSION)/$(ESP32_COMPILER_PREFIX) -endif - ifndef ESP32_ULP_PATH -ESP32_ULP_PATH := $(call FindTool,tools/$(ESP_VARIANT)ulp-elf) +ESP32_ULP_PATH := $(call FindTool,tools/$(ESP_VARIANT)ulp-elf/) endif ifndef ESP32_OPENOCD_PATH -ESP32_OPENOCD_PATH := $(call FindTool,tools/openocd-esp32) +ESP32_OPENOCD_PATH := $(call FindTool,tools/openocd-esp32/) endif ifndef ESP32_PYTHON_PATH -ESP32_PYTHON_PATH := $(call FindTool,python_env) -ifneq (,$(wildcard $(ESP32_PYTHON_PATH)/bin)) -ESP32_PYTHON_PATH := $(ESP32_PYTHON_PATH)/bin -else ifneq (,$(wildcard $(ESP32_PYTHON_PATH)/Scripts)) -ESP32_PYTHON_PATH := $(ESP32_PYTHON_PATH)/Scripts +ESP32_PYTHON_PATH := $(call FindTool,python_env/idf$(subst v,,$(IDF_VERSION))) +ifndef ESP32_PYTHON_PATH +ESP32_PYTHON_PATH := $(dir $(PYTHON)) +else ifeq ($(UNAME),Windows) +ESP32_PYTHON := $(ESP32_PYTHON_PATH)/Scripts/python else -$(error Failed to find ESP32 Python installation) +ESP32_PYTHON := $(ESP32_PYTHON_PATH)/bin/python endif -ESP32_PYTHON = $(ESP32_PYTHON_PATH)/python endif # Required by v4.2 SDK @@ -69,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 \ @@ -80,7 +86,7 @@ IDF_PATH_LIST := \ ifeq ($(UNAME),Windows) DEBUG_VARS += ESP32_NINJA_PATH ifndef ESP32_NINJA_PATH -ESP32_NINJA_PATH := $(call FindTool,tools/ninja) +ESP32_NINJA_PATH := $(call FindTool,tools/ninja/) endif ifeq (,$(wildcard $(ESP32_NINJA_PATH)/ninja.exe)) $(error Failed to find NINJA) @@ -89,7 +95,7 @@ IDF_PATH_LIST += $(ESP32_NINJA_PATH) DEBUG_VARS += ESP32_IDFEXE_PATH ifndef ESP32_IDFEXE_PATH -ESP32_IDFEXE_PATH := $(call FindTool,tools/idf-exe) +ESP32_IDFEXE_PATH := $(call FindTool,tools/idf-exe/) endif IDF_PATH_LIST += $(ESP32_IDFEXE_PATH) endif @@ -102,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++ @@ -111,11 +117,14 @@ LD := $(TOOLSPEC)-gcc NM := $(TOOLSPEC)-nm OBJCOPY := $(TOOLSPEC)-objcopy OBJDUMP := $(TOOLSPEC)-objdump -GDB := $(TOOLSPEC)-gdb SIZE := $(TOOLSPEC)-size -# Extracting IDF version -IDF_VER := $(shell (cd $$IDF_PATH && git describe --always --tags --dirty) | cut -c 1-31) +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 diff --git a/Sming/Libraries/SPI/src/Arch/Esp32/SPI.cpp b/Sming/Libraries/SPI/src/Arch/Esp32/SPI.cpp index e09e6b918a..98e883e903 100644 --- a/Sming/Libraries/SPI/src/Arch/Esp32/SPI.cpp +++ b/Sming/Libraries/SPI/src/Arch/Esp32/SPI.cpp @@ -24,6 +24,11 @@ #include #include +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0) +#include +#include +#endif + // Use SPI hardware byte ordering so we don't need to do it in software #if defined(SOC_ESP32) || defined(SOC_ESP32S2) #define BYTE_ORDER_SUPPORTED 1 @@ -110,7 +115,11 @@ struct SpiDevice { { spi_ll_set_mosi_bitlen(info.hw, num_bits); spi_ll_set_miso_bitlen(info.hw, num_bits); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0) spi_ll_master_user_start(info.hw); +#else + spi_ll_user_start(info.hw); +#endif } void set_mode(SpiMode mode) @@ -182,9 +191,17 @@ struct SpiDevice { */ void checkSpeed(SPISpeed& speed) { + uint32_t clock_source_hz; +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0) + clock_source_hz = SPI_LL_PERIPH_CLK_FREQ; +#else + esp_clk_tree_src_get_freq_hz(soc_module_clk_t(SPI_CLK_SRC_DEFAULT), ESP_CLK_TREE_SRC_FREQ_PRECISION_APPROX, + &clock_source_hz); +#endif + constexpr int duty_cycle{127}; spi_ll_clock_val_t clock_reg; - unsigned actual_freq = spi_ll_master_cal_clock(SPI_LL_PERIPH_CLK_FREQ, speed.frequency, duty_cycle, &clock_reg); + unsigned actual_freq = spi_ll_master_cal_clock(clock_source_hz, speed.frequency, duty_cycle, &clock_reg); speed.regVal = clock_reg; #ifdef SPI_DEBUG diff --git a/Tools/ci/build.cmd b/Tools/ci/build.cmd index 4efca9ff24..8744dc8fbf 100644 --- a/Tools/ci/build.cmd +++ b/Tools/ci/build.cmd @@ -30,8 +30,11 @@ cd /d %SMING_PROJECTS_DIR%/samples/Basic_Blink make help make list-config +if "%SMING_ARCH%" == "Esp32" set TEST_FLAGS="DISABLE_NETWORK=1" + REM HostTests must build for all architectures -%MAKE_PARALLEL% -C "%SMING_PROJECTS_DIR%/tests/HostTests" || goto :error +REM Building Bear SSL library causes memory issues with CI builds in Windows, so avoid for now +%MAKE_PARALLEL% -C "%SMING_PROJECTS_DIR%/tests/HostTests" %TEST_FLAGS% || goto :error REM Start Arch-specific tests cd /d %SMING_HOME% diff --git a/Tools/ci/setenv.ps1 b/Tools/ci/setenv.ps1 index e3d84ff351..17b6cbf472 100644 --- a/Tools/ci/setenv.ps1 +++ b/Tools/ci/setenv.ps1 @@ -37,7 +37,6 @@ if ($IsWindows) { $env:PATH = "$env:PYTHON_PATH;$env:PYTHON_PATH\Scripts;$env:PATH" $env:PYTHON = "$env:PYTHON_PATH\python" - $env:ESP32_PYTHON_PATH = "$env:PYTHON_PATH" $env:PATH = "$env:PROGRAMFILES\CMake\bin;$env:PATH" diff --git a/Tools/export.sh b/Tools/export.sh index a695329944..473c449568 100755 --- a/Tools/export.sh +++ b/Tools/export.sh @@ -36,7 +36,6 @@ export ESP_HOME=${ESP_HOME:=/opt/esp-quick-toolchain} # Esp32 export IDF_PATH=${IDF_PATH:=/opt/esp-idf} export IDF_TOOLS_PATH=${IDF_TOOLS_PATH:=/opt/esp32} -export ESP32_PYTHON_PATH=${ESP32_PYTHON_PATH:=/usr/bin} # Rp2040 export PICO_TOOLCHAIN_PATH=${PICO_TOOLCHAIN_PATH:=/opt/rp2040} diff --git a/tests/HostTests/component.mk b/tests/HostTests/component.mk index 3fd335e767..17a42e1746 100644 --- a/tests/HostTests/component.mk +++ b/tests/HostTests/component.mk @@ -14,12 +14,6 @@ COMPONENT_SRCDIRS := \ modules \ Arch/$(SMING_ARCH) -ifneq ($(DISABLE_NETWORK),1) -COMPONENT_SRCDIRS += \ - modules/Network \ - modules/Network/Arch/$(SMING_ARCH) -endif - ARDUINO_LIBRARIES := \ SmingTest \ ArduinoJson5 \ @@ -30,9 +24,16 @@ ifeq ($(SMING_ARCH),Host) endif COMPONENT_DEPENDS := \ - malloc_count \ + malloc_count + +ifneq ($(DISABLE_NETWORK),1) +COMPONENT_SRCDIRS += \ + modules/Network \ + modules/Network/Arch/$(SMING_ARCH) +COMPONENT_DEPENDS += \ axtls-8266 \ bearssl-esp8266 +endif ifeq ($(UNAME),Windows) # Network tests run on Linux only diff --git a/tests/HostTests/include/modules.h b/tests/HostTests/include/modules.h index dd302fb86b..d29f54e112 100644 --- a/tests/HostTests/include/modules.h +++ b/tests/HostTests/include/modules.h @@ -25,7 +25,7 @@ XX(String) \ XX(ArduinoString) \ XX(Wiring) \ - XX(Crypto) \ + XX_NET(Crypto) \ XX(CStringArray) \ XX(Stream) \ XX(TemplateStream) \ diff --git a/tests/HostTests/modules/Crypto.cpp b/tests/HostTests/modules/Network/Crypto.cpp similarity index 100% rename from tests/HostTests/modules/Crypto.cpp rename to tests/HostTests/modules/Network/Crypto.cpp diff --git a/tests/HostTests/modules/Crypto/AxHash.h b/tests/HostTests/modules/Network/Crypto/AxHash.h similarity index 100% rename from tests/HostTests/modules/Crypto/AxHash.h rename to tests/HostTests/modules/Network/Crypto/AxHash.h diff --git a/tests/HostTests/modules/Crypto/BrHash.h b/tests/HostTests/modules/Network/Crypto/BrHash.h similarity index 100% rename from tests/HostTests/modules/Crypto/BrHash.h rename to tests/HostTests/modules/Network/Crypto/BrHash.h diff --git a/tests/HostTests/modules/Crypto/EspHash.h b/tests/HostTests/modules/Network/Crypto/EspHash.h similarity index 100% rename from tests/HostTests/modules/Crypto/EspHash.h rename to tests/HostTests/modules/Network/Crypto/EspHash.h