From 22dfd8638e0c69daf27db6101eb8db0d8bdaa191 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 5 Sep 2021 05:29:17 +0100 Subject: [PATCH] Add DISABLE_NETWORK and SDK_CUSTOM_CONFIG settings (#2362) This PR adds the `DISABLE_NETWORK` setting to explicitly remove network support. When enabled, if performs much like `DISABLE_WIFI` except it now works for ESP32 as well. The behaviour of `DISABLE_WIFI` is now more logical, and can be used with ethernet. The ESP32 build process has been improved. PR #2358 added a separate project for each `ESP_VARIANT`. This is now created dynamically from a template along with the default configuration. The `SDK_CUSTOM_CONFIG` build variable has been added so ESP32 SDK settings may be configured on a per-project basis, if necessary. --- Sming/Arch/Esp32/Components/esp32/.gitignore | 4 +- Sming/Arch/Esp32/Components/esp32/README.rst | 36 ++++---- .../Arch/Esp32/Components/esp32/component.mk | 86 +++++++++++++------ .../project.esp32/sdkconfig.defaults.debug | 47 ---------- .../project.esp32/sdkconfig.defaults.release | 44 ---------- .../esp32/project.esp32c3/CMakeLists.txt | 8 -- .../esp32/project.esp32c3/main/CMakeLists.txt | 2 - .../esp32/project.esp32c3/main/main.c | 3 - .../project.esp32c3/sdkconfig.defaults.debug | 37 -------- .../sdkconfig.defaults.release | 34 -------- .../esp32/project.esp32s2/CMakeLists.txt | 8 -- .../esp32/project.esp32s2/main/CMakeLists.txt | 2 - .../esp32/project.esp32s2/main/main.c | 3 - .../esp32/project.esp32s3/CMakeLists.txt | 8 -- .../esp32/project.esp32s3/main/CMakeLists.txt | 2 - .../esp32/project.esp32s3/main/main.c | 3 - .../project.esp32s3/sdkconfig.defaults.debug | 37 -------- .../sdkconfig.defaults.release | 34 -------- .../Components/esp32/sdk/config/README.rst | 23 +++++ .../Esp32/Components/esp32/sdk/config/common | 28 ++++++ .../config/debug} | 16 +--- .../config/release} | 16 +--- Sming/Arch/Esp32/Components/esp32/sdk/misc.mk | 7 +- .../project}/CMakeLists.txt | 0 .../project}/main/CMakeLists.txt | 0 .../project}/main/main.c | 0 .../Esp32/Components/esp32/src/startup.cpp | 17 +++- Sming/Arch/Esp32/README.rst | 35 +++++--- Sming/Arch/Esp32/build.mk | 3 + .../Arch/Host/Components/hostlib/startup.cpp | 16 ++-- Sming/Arch/Host/System/include/user_config.h | 2 +- .../Arch/Esp32/Platform/EmbeddedEthernet.cpp | 3 + Sming/Core/SmingCore.h | 4 +- Sming/README.rst | 16 +++- .../CommandProcessing/CommandExecutor.cpp | 2 +- .../CommandProcessing/CommandExecutor.h | 4 +- .../CommandProcessing/CommandHandler.cpp | 2 +- .../CommandProcessing/CommandOutput.cpp | 2 +- .../CommandProcessing/CommandOutput.h | 6 +- Sming/System/include/debug_progmem.h | 4 +- Sming/Wiring/WiringFrameworkIncludes.h | 2 +- Sming/component.mk | 12 ++- docs/source/upgrading/4.3-4.4.rst | 15 ++-- samples/Basic_Ethernet/component.mk | 1 + 44 files changed, 235 insertions(+), 399 deletions(-) delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32/sdkconfig.defaults.debug delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32/sdkconfig.defaults.release delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32c3/CMakeLists.txt delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/CMakeLists.txt delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/main.c delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32c3/sdkconfig.defaults.debug delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32c3/sdkconfig.defaults.release delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32s2/CMakeLists.txt delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32s2/main/CMakeLists.txt delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32s2/main/main.c delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32s3/CMakeLists.txt delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32s3/main/CMakeLists.txt delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32s3/main/main.c delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32s3/sdkconfig.defaults.debug delete mode 100644 Sming/Arch/Esp32/Components/esp32/project.esp32s3/sdkconfig.defaults.release create mode 100644 Sming/Arch/Esp32/Components/esp32/sdk/config/README.rst create mode 100644 Sming/Arch/Esp32/Components/esp32/sdk/config/common rename Sming/Arch/Esp32/Components/esp32/{project.esp32s2/sdkconfig.defaults.debug => sdk/config/debug} (70%) rename Sming/Arch/Esp32/Components/esp32/{project.esp32s2/sdkconfig.defaults.release => sdk/config/release} (62%) rename Sming/Arch/Esp32/Components/esp32/{project.esp32 => sdk/project}/CMakeLists.txt (100%) rename Sming/Arch/Esp32/Components/esp32/{project.esp32 => sdk/project}/main/CMakeLists.txt (100%) rename Sming/Arch/Esp32/Components/esp32/{project.esp32 => sdk/project}/main/main.c (100%) create mode 100644 samples/Basic_Ethernet/component.mk diff --git a/Sming/Arch/Esp32/Components/esp32/.gitignore b/Sming/Arch/Esp32/Components/esp32/.gitignore index 33915c150b..5191b607b3 100644 --- a/Sming/Arch/Esp32/Components/esp32/.gitignore +++ b/Sming/Arch/Esp32/Components/esp32/.gitignore @@ -1,3 +1 @@ -sdkconfig -sdkconfig.defaults -sdkconfig.old +project diff --git a/Sming/Arch/Esp32/Components/esp32/README.rst b/Sming/Arch/Esp32/Components/esp32/README.rst index 5017d7f176..94c906a6ee 100644 --- a/Sming/Arch/Esp32/Components/esp32/README.rst +++ b/Sming/Arch/Esp32/Components/esp32/README.rst @@ -21,23 +21,6 @@ Followed by:: Configuration variables ----------------------- -These are read-only debug variables: - -.. envvar:: SDK_INTERNAL - - **READONLY** When compiled using the current (version 3+) Espressif SDK this value is set to 1. - - -.. envvar:: SDK_LIBDIR - - **READONLY** Path to the directory containing SDK archive libraries - - -.. envvar:: SDK_INCDIR - - **READONLY** Path to the directory containing SDK header files - - Option variables: .. envvar:: ESP_VARIANT @@ -68,3 +51,22 @@ or if multiple versions are installed. By default, the most current version will Location of ESP-IDF python. + +Background +---------- + +An empty ESP IDF project is built which generates a set of libraries and headers +which the framework can then be built against. + +The project is located in ``project/{ESP_VARIANT}`. + +The code for this project is copied from ``sdk/project``. + +The default configuration settings are obtained from ``sdk/config`` and written +to ``project/{ESP_VARIANT}/sdkconfig.defaults``. + +When ``sdk-menuconfig`` is run, the ``project/{ESP_VARIANT}/sdkconfig`` is modified. +This can be reset using ``make sdk-config-clean``. + +If custom settings are required for a project then place these in a separate file +and set :envvar:`SDK_CUSTOM_CONFIG` to the location, relative to the project source root directory. diff --git a/Sming/Arch/Esp32/Components/esp32/component.mk b/Sming/Arch/Esp32/Components/esp32/component.mk index d973b6461c..d1347f05e2 100644 --- a/Sming/Arch/Esp32/Components/esp32/component.mk +++ b/Sming/Arch/Esp32/Components/esp32/component.mk @@ -11,8 +11,13 @@ COMPONENT_INCDIRS := src/include include CACHE_VARS += SDK_FULL_BUILD SDK_FULL_BUILD ?= 0 -SDK_BUILD_BASE := $(COMPONENT_BUILD_DIR)/sdk.$(ESP_VARIANT) -SDK_COMPONENT_LIBDIR := $(COMPONENT_BUILD_DIR)/lib.$(ESP_VARIANT) +# Applications can provide file with custom SDK configuration settings +CACHE_VARS += SDK_CUSTOM_CONFIG + +COMPONENT_RELINK_VARS += DISABLE_NETWORK DISABLE_WIFI + +SDK_BUILD_BASE := $(COMPONENT_BUILD_BASE)/$(ESP_VARIANT)/sdk +SDK_COMPONENT_LIBDIR := $(COMPONENT_BUILD_BASE)/$(ESP_VARIANT)/lib SDKCONFIG_H := $(SDK_BUILD_BASE)/config/sdkconfig.h @@ -146,7 +151,6 @@ SDK_COMPONENTS := \ esp-tls \ $(ESP_VARIANT) \ esp_common \ - esp_eth \ esp_event \ esp_gdbstub \ esp_hw_support \ @@ -156,29 +160,35 @@ SDK_COMPONENTS := \ esp_rom \ esp_system \ esp_timer \ - esp_wifi \ espcoredump \ freertos \ hal \ heap \ log \ - lwip \ - mbedtls \ - mbedcrypto \ - esp_netif \ newlib \ nvs_flash \ - openssl \ protobuf-c \ protocomm \ pthread \ soc \ spi_flash \ - tcp_transport \ - tcpip_adapter \ - vfs \ + vfs + +ifneq ($(DISABLE_NETWORK),1) +SDK_COMPONENTS += \ + esp_wifi \ + esp_eth \ + lwip \ + mbedtls \ + mbedcrypto \ + esp_netif \ + openssl +ifneq ($(DISABLE_WIFI),1) +SDK_COMPONENTS += \ wifi_provisioning \ wpa_supplicant +endif +endif ifneq ($(ESP_VARIANT),esp32s3) SDK_COMPONENTS += esp_adc_cal @@ -246,10 +256,13 @@ endif EXTRA_LIBS := \ gcc \ $(SDK_COMPONENTS) \ - $(SDK_ESP_WIFI_LIBS) \ $(SDK_NEWLIB_LIBS) \ $(SDK_TARGET_ARCH_LIBS) +ifneq ($(DISABLE_WIFI),1) +EXTRA_LIBS += $(SDK_ESP_WIFI_LIBS) +endif + LinkerScript = -T $(ESP_VARIANT).$1.ld LDFLAGS_esp32 := \ @@ -298,13 +311,9 @@ FLASH_BOOT_CHUNKS := 0x1000=$(FLASH_BOOT_LOADER) SDK_DEFAULT_PATH := $(COMPONENT_PATH)/sdk -##@Partitions - -SDK_PARTITION_PATH := $(SDK_DEFAULT_PATH)/partitions - ##@SDK -SDK_PROJECT_PATH := $(COMPONENT_PATH)/project.$(ESP_VARIANT) +SDK_PROJECT_PATH := $(COMPONENT_PATH)/project/$(ESP_VARIANT) SDK_CONFIG_DEFAULTS := $(SDK_PROJECT_PATH)/sdkconfig.defaults SDKCONFIG_MAKEFILE := $(SDK_PROJECT_PATH)/sdkconfig @@ -323,7 +332,7 @@ SDK_BUILD_COMPLETE := $(SDK_BUILD_BASE)/.complete CUSTOM_TARGETS += checksdk .PHONY: checksdk -checksdk: $(SDK_BUILD_COMPLETE) +checksdk: $(SDK_PROJECT_PATH) $(SDK_BUILD_COMPLETE) SDK_BUILD = $(ESP32_PYTHON) $(IDF_PATH)/tools/idf.py -C $(SDK_PROJECT_PATH) -B $(SDK_BUILD_BASE) -G Ninja @@ -333,29 +342,52 @@ export SDK_COMPONENT_LIBDIR export SDK_COMPONENTS $(SDK_BUILD_COMPLETE): $(SDKCONFIG_H) $(SDKCONFIG_MAKEFILE) - $(Q) $(SDK_BUILD) bootloader app + $(Q) $(SDK_BUILD) reconfigure + $(Q) $(NINJA) -C $(SDK_BUILD_BASE) bootloader app $(Q) $(MAKE) --no-print-directory -C $(SDK_DEFAULT_PATH) -f misc.mk copylibs touch $(SDK_BUILD_COMPLETE) -$(SDKCONFIG_H) $(SDKCONFIG_MAKEFILE) $(SDK_COMPONENT_LIBS): $(SDK_CONFIG_DEFAULTS) | $(SDK_BUILD_BASE) $(SDK_COMPONENT_LIBDIR) +$(SDKCONFIG_H) $(SDKCONFIG_MAKEFILE) $(SDK_COMPONENT_LIBS): $(SDK_PROJECT_PATH) $(SDK_CONFIG_DEFAULTS) | $(SDK_BUILD_BASE) $(SDK_COMPONENT_LIBDIR) + +$(SDK_PROJECT_PATH): + $(Q) mkdir -p $@ + $(Q) cp -r $(SDK_DEFAULT_PATH)/project/* $@ $(SDK_COMPONENT_LIBS): $(SDK_BUILD_COMPLETE) -$(SDK_CONFIG_DEFAULTS): - $(Q) cp $@.$(BUILD_TYPE) $@ +SDK_CONFIG_FILES := \ + common \ + $(BUILD_TYPE) \ + $(ESP_VARIANT).common \ + $(ESP_VARIANT).$(BUILD_TYPE) + +ifdef SDK_CUSTOM_CONFIG +SDK_CUSTOM_CONFIG_PATH := $(call AbsoluteSourcePath,$(PROJECT_DIR),$(SDK_CUSTOM_CONFIG)) +endif + +SDK_CONFIG_FILES := \ + $(addprefix $(SDK_DEFAULT_PATH)/config/,$(SDK_CONFIG_FILES)) \ + $(SDK_CUSTOM_CONFIG_PATH) + +$(SDK_CONFIG_DEFAULTS): $(SDK_CUSTOM_CONFIG_PATH) + @echo Creating $@ + $(Q) rm -f $@ + $(Q) $(foreach f,$(SDK_CONFIG_FILES),\ + $(if $(wildcard $f),cat $f >> $@;) \ + ) PHONY: sdk-menuconfig sdk-menuconfig: $(SDK_CONFIG_DEFAULTS) | $(SDK_BUILD_BASE) ##Configure SDK options $(Q) $(SDK_BUILD) menuconfig - $(Q) rm $(SDK_BUILD_COMPLETE) + $(Q) rm -f $(SDK_BUILD_COMPLETE) @echo Now run 'make esp32-build' .PHONY: sdk-defconfig sdk-defconfig: $(SDKCONFIG_H) ##Create default SDK config files -.PHONY: sdk-menuconfig-clean -sdk-menuconfig-clean: esp32-clean ##Wipe SDK configuration and revert to defaults - $(Q) rm -f $(SDKCONFIG_MAKEFILE) $(SDK_CONFIG_DEFAULTS) +.PHONY: sdk-config-clean +sdk-config-clean: esp32-clean ##Wipe SDK configuration and revert to defaults + $(Q) rm -rf $(SDK_PROJECT_PATH) .PHONY: sdk-help sdk-help: ##Get SDK build options diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32/sdkconfig.defaults.debug b/Sming/Arch/Esp32/Components/esp32/project.esp32/sdkconfig.defaults.debug deleted file mode 100644 index c7e8dc3728..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32/sdkconfig.defaults.debug +++ /dev/null @@ -1,47 +0,0 @@ -# -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -# SMING DEBUG SETTINGS -# - -# -# SDK tool configuration -# - -CONFIG_COMPILER_OPTIMIZATION_SIZE=y - -# Mandatory LWIP changes -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 - -# Ethernet -#CONFIG_ETH_USE_ESP32_EMAC=y -#CONFIG_ETH_PHY_INTERFACE_RMII=y -#CONFIG_ETH_RMII_CLK_INPUT=y -#CONFIG_ETH_RMII_CLK_IN_GPIO=0 -CONFIG_ETH_USE_SPI_ETHERNET=n - -# Mandatory Sming framework changes -CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 -CONFIG_ESP_TIMER_IMPL_FRC2=y - -# The bootloader logs all type of messages -CONFIG_BOOTLOADER_LOG_LEVEL_NONE= -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR= -CONFIG_BOOTLOADER_LOG_LEVEL_WARN= -CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y -CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG= -CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE= -CONFIG_BOOTLOADER_LOG_LEVEL=3 - -# ESP-IDF logs all type of messages -CONFIG_LOG_DEFAULT_LEVEL_NONE= -CONFIG_LOG_DEFAULT_LEVEL_ERROR= -CONFIG_LOG_DEFAULT_LEVEL_WARN= -CONFIG_LOG_DEFAULT_LEVEL_INFO=y -CONFIG_LOG_DEFAULT_LEVEL_DEBUG= -CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= -CONFIG_LOG_DEFAULT_LEVEL=3 - -# Sets watchpoint index 1 (the second of two) at the end of any task stack. This is the most accurate way to debug task stack overflows. -CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32/sdkconfig.defaults.release b/Sming/Arch/Esp32/Components/esp32/project.esp32/sdkconfig.defaults.release deleted file mode 100644 index 14b10b5611..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32/sdkconfig.defaults.release +++ /dev/null @@ -1,44 +0,0 @@ -# -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -# SMING RELEASE SETTINGS -# - -# -# SDK tool configuration -# - -CONFIG_COMPILER_OPTIMIZATION_SIZE=y - -# Mandatory LWIP changes -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 - -# Ethernet -#CONFIG_ETH_USE_ESP32_EMAC=y -#CONFIG_ETH_PHY_INTERFACE_RMII=y -#CONFIG_ETH_RMII_CLK_INPUT=y -#CONFIG_ETH_RMII_CLK_IN_GPIO=0 -CONFIG_ETH_USE_SPI_ETHERNET=n - -# Mandatory Sming framework changes -CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 -CONFIG_ESP_TIMER_IMPL_FRC2=y - -# The bootloader logs only errors -CONFIG_BOOTLOADER_LOG_LEVEL_NONE= -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y -CONFIG_BOOTLOADER_LOG_LEVEL_WARN= -CONFIG_BOOTLOADER_LOG_LEVEL_INFO= -CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG= -CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE= -CONFIG_BOOTLOADER_LOG_LEVEL=1 - -# ESP-IDF logs only errors -CONFIG_LOG_DEFAULT_LEVEL_NONE= -CONFIG_LOG_DEFAULT_LEVEL_ERROR=y -CONFIG_LOG_DEFAULT_LEVEL_WARN= -CONFIG_LOG_DEFAULT_LEVEL_INFO= -CONFIG_LOG_DEFAULT_LEVEL_DEBUG= -CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= -CONFIG_LOG_DEFAULT_LEVEL=1 diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/CMakeLists.txt b/Sming/Arch/Esp32/Components/esp32/project.esp32c3/CMakeLists.txt deleted file mode 100644 index bd18c8ced4..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# The following five lines of boilerplate have to be in your project's -# CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) - -set(IDF_TARGET "$ENV{ESP_VARIANT}") - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(Sming) diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/CMakeLists.txt b/Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/CMakeLists.txt deleted file mode 100644 index cf2c455cb5..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -idf_component_register(SRCS "main.c" - INCLUDE_DIRS ".") diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/main.c b/Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/main.c deleted file mode 100644 index cb05851571..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/main.c +++ /dev/null @@ -1,3 +0,0 @@ -void app_main(void) -{ -} diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/sdkconfig.defaults.debug b/Sming/Arch/Esp32/Components/esp32/project.esp32c3/sdkconfig.defaults.debug deleted file mode 100644 index 8d660b03c2..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/sdkconfig.defaults.debug +++ /dev/null @@ -1,37 +0,0 @@ -# -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -# SMING DEBUG SETTINGS -# - -# -# SDK tool configuration -# - -# Mandatory LWIP changes -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 - -# Mandatory Sming framework changes -CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 - -# The bootloader logs all type of messages -CONFIG_BOOTLOADER_LOG_LEVEL_NONE= -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR= -CONFIG_BOOTLOADER_LOG_LEVEL_WARN= -CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y -CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG= -CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE= -CONFIG_BOOTLOADER_LOG_LEVEL=3 - -# ESP-IDF logs all type of messages -CONFIG_LOG_DEFAULT_LEVEL_NONE= -CONFIG_LOG_DEFAULT_LEVEL_ERROR= -CONFIG_LOG_DEFAULT_LEVEL_WARN= -CONFIG_LOG_DEFAULT_LEVEL_INFO=y -CONFIG_LOG_DEFAULT_LEVEL_DEBUG= -CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= -CONFIG_LOG_DEFAULT_LEVEL=3 - -# Sets watchpoint index 1 (the second of two) at the end of any task stack. This is the most accurate way to debug task stack overflows. -CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/sdkconfig.defaults.release b/Sming/Arch/Esp32/Components/esp32/project.esp32c3/sdkconfig.defaults.release deleted file mode 100644 index c0346b7594..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32c3/sdkconfig.defaults.release +++ /dev/null @@ -1,34 +0,0 @@ -# -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -# SMING RELEASE SETTINGS -# - -# -# SDK tool configuration -# - -# Mandatory LWIP changes -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 - -# Mandatory Sming framework changes -CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 - -# The bootloader logs only errors -CONFIG_BOOTLOADER_LOG_LEVEL_NONE= -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y -CONFIG_BOOTLOADER_LOG_LEVEL_WARN= -CONFIG_BOOTLOADER_LOG_LEVEL_INFO= -CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG= -CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE= -CONFIG_BOOTLOADER_LOG_LEVEL=1 - -# ESP-IDF logs only errors -CONFIG_LOG_DEFAULT_LEVEL_NONE= -CONFIG_LOG_DEFAULT_LEVEL_ERROR=y -CONFIG_LOG_DEFAULT_LEVEL_WARN= -CONFIG_LOG_DEFAULT_LEVEL_INFO= -CONFIG_LOG_DEFAULT_LEVEL_DEBUG= -CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= -CONFIG_LOG_DEFAULT_LEVEL=1 diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/CMakeLists.txt b/Sming/Arch/Esp32/Components/esp32/project.esp32s2/CMakeLists.txt deleted file mode 100644 index bd18c8ced4..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# The following five lines of boilerplate have to be in your project's -# CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) - -set(IDF_TARGET "$ENV{ESP_VARIANT}") - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(Sming) diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/main/CMakeLists.txt b/Sming/Arch/Esp32/Components/esp32/project.esp32s2/main/CMakeLists.txt deleted file mode 100644 index cf2c455cb5..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/main/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -idf_component_register(SRCS "main.c" - INCLUDE_DIRS ".") diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/main/main.c b/Sming/Arch/Esp32/Components/esp32/project.esp32s2/main/main.c deleted file mode 100644 index cb05851571..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/main/main.c +++ /dev/null @@ -1,3 +0,0 @@ -void app_main(void) -{ -} diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/CMakeLists.txt b/Sming/Arch/Esp32/Components/esp32/project.esp32s3/CMakeLists.txt deleted file mode 100644 index bd18c8ced4..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# The following five lines of boilerplate have to be in your project's -# CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) - -set(IDF_TARGET "$ENV{ESP_VARIANT}") - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(Sming) diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/main/CMakeLists.txt b/Sming/Arch/Esp32/Components/esp32/project.esp32s3/main/CMakeLists.txt deleted file mode 100644 index cf2c455cb5..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/main/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -idf_component_register(SRCS "main.c" - INCLUDE_DIRS ".") diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/main/main.c b/Sming/Arch/Esp32/Components/esp32/project.esp32s3/main/main.c deleted file mode 100644 index cb05851571..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/main/main.c +++ /dev/null @@ -1,3 +0,0 @@ -void app_main(void) -{ -} diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/sdkconfig.defaults.debug b/Sming/Arch/Esp32/Components/esp32/project.esp32s3/sdkconfig.defaults.debug deleted file mode 100644 index 8d660b03c2..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/sdkconfig.defaults.debug +++ /dev/null @@ -1,37 +0,0 @@ -# -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -# SMING DEBUG SETTINGS -# - -# -# SDK tool configuration -# - -# Mandatory LWIP changes -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 - -# Mandatory Sming framework changes -CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 - -# The bootloader logs all type of messages -CONFIG_BOOTLOADER_LOG_LEVEL_NONE= -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR= -CONFIG_BOOTLOADER_LOG_LEVEL_WARN= -CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y -CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG= -CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE= -CONFIG_BOOTLOADER_LOG_LEVEL=3 - -# ESP-IDF logs all type of messages -CONFIG_LOG_DEFAULT_LEVEL_NONE= -CONFIG_LOG_DEFAULT_LEVEL_ERROR= -CONFIG_LOG_DEFAULT_LEVEL_WARN= -CONFIG_LOG_DEFAULT_LEVEL_INFO=y -CONFIG_LOG_DEFAULT_LEVEL_DEBUG= -CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= -CONFIG_LOG_DEFAULT_LEVEL=3 - -# Sets watchpoint index 1 (the second of two) at the end of any task stack. This is the most accurate way to debug task stack overflows. -CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/sdkconfig.defaults.release b/Sming/Arch/Esp32/Components/esp32/project.esp32s3/sdkconfig.defaults.release deleted file mode 100644 index c0346b7594..0000000000 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s3/sdkconfig.defaults.release +++ /dev/null @@ -1,34 +0,0 @@ -# -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -# SMING RELEASE SETTINGS -# - -# -# SDK tool configuration -# - -# Mandatory LWIP changes -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 - -# Mandatory Sming framework changes -CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 - -# The bootloader logs only errors -CONFIG_BOOTLOADER_LOG_LEVEL_NONE= -CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y -CONFIG_BOOTLOADER_LOG_LEVEL_WARN= -CONFIG_BOOTLOADER_LOG_LEVEL_INFO= -CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG= -CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE= -CONFIG_BOOTLOADER_LOG_LEVEL=1 - -# ESP-IDF logs only errors -CONFIG_LOG_DEFAULT_LEVEL_NONE= -CONFIG_LOG_DEFAULT_LEVEL_ERROR=y -CONFIG_LOG_DEFAULT_LEVEL_WARN= -CONFIG_LOG_DEFAULT_LEVEL_INFO= -CONFIG_LOG_DEFAULT_LEVEL_DEBUG= -CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= -CONFIG_LOG_DEFAULT_LEVEL=1 diff --git a/Sming/Arch/Esp32/Components/esp32/sdk/config/README.rst b/Sming/Arch/Esp32/Components/esp32/sdk/config/README.rst new file mode 100644 index 0000000000..404ff46990 --- /dev/null +++ b/Sming/Arch/Esp32/Components/esp32/sdk/config/README.rst @@ -0,0 +1,23 @@ +config +====== + +Default SDK project settings are contained in several files, +which are concatenated into the project's ``sdkconfig.default`` file. + +The following files are assembled, in order: + + common + {BUILD_TYPE} + {ESP_VARIANT}.common + {ESP_VARIANT}.{BUILD_TYPE} + {PROJECT_DIR}/{SDK_CUSTOM_CONFIG} + +Where: + +- ``{BUILD_TYPE}`` is ``debug`` or ``release``. +- ``SDK_CUSTOM_CONFIG`` is optional and is always relative to the project root directory. + +To provide additional settings for a specific variant use the variant prefix such +as ``esp32.debug``, ``esp32c3.release``, ``esp32s2.common``, etc. + +etc. diff --git a/Sming/Arch/Esp32/Components/esp32/sdk/config/common b/Sming/Arch/Esp32/Components/esp32/sdk/config/common new file mode 100644 index 0000000000..929616cf60 --- /dev/null +++ b/Sming/Arch/Esp32/Components/esp32/sdk/config/common @@ -0,0 +1,28 @@ +# +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +# SMING SETTINGS +# + +# +# Common to all ESP32 variants +# + +# +# SDK tool configuration +# + +CONFIG_COMPILER_OPTIMIZATION_SIZE=y + +# Mandatory LWIP changes +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 +CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=n + +# Ethernet +CONFIG_ETH_USE_SPI_ETHERNET=y + +# Mandatory Sming framework changes +CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 +CONFIG_ESP_TIMER_IMPL_FRC2=y + diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/sdkconfig.defaults.debug b/Sming/Arch/Esp32/Components/esp32/sdk/config/debug similarity index 70% rename from Sming/Arch/Esp32/Components/esp32/project.esp32s2/sdkconfig.defaults.debug rename to Sming/Arch/Esp32/Components/esp32/sdk/config/debug index 8d660b03c2..14f1c0a1b3 100644 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/sdkconfig.defaults.debug +++ b/Sming/Arch/Esp32/Components/esp32/sdk/config/debug @@ -1,20 +1,7 @@ # -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -# SMING DEBUG SETTINGS -# - -# -# SDK tool configuration +# DEBUG # -# Mandatory LWIP changes -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 - -# Mandatory Sming framework changes -CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 - # The bootloader logs all type of messages CONFIG_BOOTLOADER_LOG_LEVEL_NONE= CONFIG_BOOTLOADER_LOG_LEVEL_ERROR= @@ -35,3 +22,4 @@ CONFIG_LOG_DEFAULT_LEVEL=3 # Sets watchpoint index 1 (the second of two) at the end of any task stack. This is the most accurate way to debug task stack overflows. CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y + diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/sdkconfig.defaults.release b/Sming/Arch/Esp32/Components/esp32/sdk/config/release similarity index 62% rename from Sming/Arch/Esp32/Components/esp32/project.esp32s2/sdkconfig.defaults.release rename to Sming/Arch/Esp32/Components/esp32/sdk/config/release index c0346b7594..f130372a9e 100644 --- a/Sming/Arch/Esp32/Components/esp32/project.esp32s2/sdkconfig.defaults.release +++ b/Sming/Arch/Esp32/Components/esp32/sdk/config/release @@ -1,20 +1,7 @@ # -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -# SMING RELEASE SETTINGS -# - -# -# SDK tool configuration +# RELEASE # -# Mandatory LWIP changes -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192 - -# Mandatory Sming framework changes -CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 - # The bootloader logs only errors CONFIG_BOOTLOADER_LOG_LEVEL_NONE= CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y @@ -32,3 +19,4 @@ CONFIG_LOG_DEFAULT_LEVEL_INFO= CONFIG_LOG_DEFAULT_LEVEL_DEBUG= CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= CONFIG_LOG_DEFAULT_LEVEL=1 + diff --git a/Sming/Arch/Esp32/Components/esp32/sdk/misc.mk b/Sming/Arch/Esp32/Components/esp32/sdk/misc.mk index e117fafdeb..8783aef1c0 100644 --- a/Sming/Arch/Esp32/Components/esp32/sdk/misc.mk +++ b/Sming/Arch/Esp32/Components/esp32/sdk/misc.mk @@ -7,13 +7,10 @@ include $(SMING_HOME)/build.mk all: # List of all generated SDK libraries -SDK_ARCHIVE_DIRS = $(foreach c,$(SDK_COMPONENTS),$(SDK_BUILD_BASE)/esp-idf/$c) +SDK_ARCHIVE_DIRS = $(wildcard $(SDK_BUILD_BASE)/esp-idf/*) SDK_ARCHIVE_LIST = $(sort $(foreach d,$(SDK_ARCHIVE_DIRS),$(wildcard $d/*.a))) -# -# Need to suppress errors here as there are multiple copies of some libraries -# .PHONY: copylibs copylibs: $(info Copying generated SDK libraries) - $(Q) cp -u $(SDK_ARCHIVE_LIST) $(SDK_COMPONENT_LIBDIR)/ + $(Q) cp $(SDK_ARCHIVE_LIST) $(SDK_COMPONENT_LIBDIR)/ diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32/CMakeLists.txt b/Sming/Arch/Esp32/Components/esp32/sdk/project/CMakeLists.txt similarity index 100% rename from Sming/Arch/Esp32/Components/esp32/project.esp32/CMakeLists.txt rename to Sming/Arch/Esp32/Components/esp32/sdk/project/CMakeLists.txt diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32/main/CMakeLists.txt b/Sming/Arch/Esp32/Components/esp32/sdk/project/main/CMakeLists.txt similarity index 100% rename from Sming/Arch/Esp32/Components/esp32/project.esp32/main/CMakeLists.txt rename to Sming/Arch/Esp32/Components/esp32/sdk/project/main/CMakeLists.txt diff --git a/Sming/Arch/Esp32/Components/esp32/project.esp32/main/main.c b/Sming/Arch/Esp32/Components/esp32/sdk/project/main/main.c similarity index 100% rename from Sming/Arch/Esp32/Components/esp32/project.esp32/main/main.c rename to Sming/Arch/Esp32/Components/esp32/sdk/project/main/main.c diff --git a/Sming/Arch/Esp32/Components/esp32/src/startup.cpp b/Sming/Arch/Esp32/Components/esp32/src/startup.cpp index 917276e375..d185c93ed7 100644 --- a/Sming/Arch/Esp32/Components/esp32/src/startup.cpp +++ b/Sming/Arch/Esp32/Components/esp32/src/startup.cpp @@ -9,12 +9,8 @@ */ #include -#include -#include -#include #include #include -#include #include #include #include @@ -22,6 +18,15 @@ #include #include +#ifndef DISABLE_NETWORK +#include +#ifndef DISABLE_WIFI +#include +#include +#include +#endif +#endif + #ifndef ESP32_STACK_SIZE #define ESP32_STACK_SIZE 16384U #endif @@ -32,6 +37,7 @@ namespace { static constexpr uint32_t WDT_TIMEOUT_MS{8000}; +#ifndef DISABLE_WIFI void esp_init_flash() { esp_err_t ret = nvs_flash_init(); @@ -50,6 +56,7 @@ void esp_init_wifi() wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); } +#endif void main(void*) { @@ -61,8 +68,10 @@ void main(void*) smg_uart_detach_all(); +#ifndef DISABLE_WIFI esp_init_flash(); esp_init_wifi(); +#endif ets_init_tasks(); Storage::initialize(); System.initialize(); diff --git a/Sming/Arch/Esp32/README.rst b/Sming/Arch/Esp32/README.rst index abcc82a6a2..05831e40ba 100644 --- a/Sming/Arch/Esp32/README.rst +++ b/Sming/Arch/Esp32/README.rst @@ -1,6 +1,8 @@ Sming Esp32 Architecture ========================== +.. highlight:: bash + Support building Sming for the Esp32 architecture. @@ -11,11 +13,27 @@ Build variables This contains the base directory for the ESP-IDF toolchain used to build the framework. This variable is required and must be set accordingly. + +.. envvar:: SDK_CUSTOM_CONFIG + + Custom SDK settings for a project can be defined in a separate file + and setting this value to the location, relative to the project source root directory. + + These will be added to the default SDK settings. + + To make the settings current, you must run ``make sdk-config-clean``. + This will discard any changes made via ``make sdk-menuconfig``. + + Requirements ------------ In order to be able to compile for the ESP32 architecture you should have ESP-IDF v4.3 installed. -The Sming installers can do this for you - see :doc:`/getting-started/index`. +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%2Fv4.3 +which you may clone. + +The Sming installers do all this for you - see :doc:`/getting-started/index`. You can find further details in the `ESP-IDF documentation `__. @@ -49,19 +67,13 @@ Sming comes with pre-compiled libraries and configuration files. If needed you c A re-compilation is required after the change of the configuration. This can be done with the following command:: - make SMING_ARCH=Esp32 sdk-build - -If you want to revert to using the default pre-compiled SDK then issue the following command:: + make SMING_ARCH=Esp32 Sming-build all - make SMING_ARCH=Esp32 sdk-default +If you want to revert to using the default SDK settings then issue the following command:: -.. note:: + make SMING_ARCH=Esp32 sdk-config-clean - If you have an ESP32-S2 device you'll need to change :envvar:`ESP_VARIANT`:: - - make ESP_VARIANT=esp32s2 - -See :component-esp32:`esp32` for further details. +You can also configure per-project custom settings via :envvar:`SDK_CUSTOM_CONFIG`. Processor variants @@ -84,6 +96,7 @@ make SMING_ARCH=Esp32 clean components-clean make ESP_VARIANT=esp32c3 ``` +See :component-esp32:`esp32` for further details. Components diff --git a/Sming/Arch/Esp32/build.mk b/Sming/Arch/Esp32/build.mk index 553911d981..73b15f4107 100644 --- a/Sming/Arch/Esp32/build.mk +++ b/Sming/Arch/Esp32/build.mk @@ -99,6 +99,9 @@ endif IDF_PATH_LIST += ESP32_IDFEXE_PATH endif +DEBUG_VARS += NINJA +NINJA := $(if $(ESP32_NINJA_PATH),$(ESP32_NINJA_PATH)/,)ninja + space := space += diff --git a/Sming/Arch/Host/Components/hostlib/startup.cpp b/Sming/Arch/Host/Components/hostlib/startup.cpp index aad178fea9..71ccab74f4 100644 --- a/Sming/Arch/Host/Components/hostlib/startup.cpp +++ b/Sming/Arch/Host/Components/hostlib/startup.cpp @@ -39,7 +39,7 @@ #include #include -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK #include extern void host_wifi_lwip_init_complete(); static bool lwip_initialised; @@ -57,7 +57,7 @@ static void cleanup() host_flashmem_cleanup(); UartServer::shutdown(); sockets_finalise(); -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK host_lwip_shutdown(); #endif host_debug_i("Goodbye!"); @@ -117,7 +117,7 @@ void host_main_loop() { host_service_tasks(); host_service_timers(); -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK if(lwip_initialised && lwipServiceTimer.expired()) { host_lwip_service(); lwipServiceTimer.start(); @@ -137,7 +137,7 @@ int main(int argc, char* argv[]) bool enable_network; UartServer::Config uart; FlashmemConfig flash; -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK struct lwip_param lwip; #endif } config = { @@ -156,7 +156,7 @@ int main(int argc, char* argv[]) .createSize = 0, }, -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK .lwip = { .ifname = nullptr, @@ -200,7 +200,7 @@ int main(int argc, char* argv[]) config.uart.portBase = atoi(arg); break; -#ifdef DISABLE_WIFI +#ifdef DISABLE_NETWORK case opt_ifname: case opt_ipaddr: case opt_gateway: @@ -284,7 +284,7 @@ int main(int argc, char* argv[]) sockets_initialise(); UartServer::startup(config.uart); -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK if(config.enable_network) { lwip_initialised = host_lwip_init(&config.lwip); if(lwip_initialised) { @@ -304,7 +304,7 @@ int main(int argc, char* argv[]) host_init(); -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK lwipServiceTimer.reset(); #endif while(!done) { diff --git a/Sming/Arch/Host/System/include/user_config.h b/Sming/Arch/Host/System/include/user_config.h index e2f3dbcbcd..586fe2f944 100644 --- a/Sming/Arch/Host/System/include/user_config.h +++ b/Sming/Arch/Host/System/include/user_config.h @@ -10,7 +10,7 @@ #include // Network base API -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK #include #include #include diff --git a/Sming/Components/Network/Arch/Esp32/Platform/EmbeddedEthernet.cpp b/Sming/Components/Network/Arch/Esp32/Platform/EmbeddedEthernet.cpp index 826dfd9296..af6d8e7dad 100644 --- a/Sming/Components/Network/Arch/Esp32/Platform/EmbeddedEthernet.cpp +++ b/Sming/Components/Network/Arch/Esp32/Platform/EmbeddedEthernet.cpp @@ -25,6 +25,9 @@ bool EmbeddedEthernet::begin(const Config& config) #else + esp_netif_init(); + esp_event_loop_create_default(); + esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH(); netif = esp_netif_new(&cfg); diff --git a/Sming/Core/SmingCore.h b/Sming/Core/SmingCore.h index d5bf98265a..9e06713097 100644 --- a/Sming/Core/SmingCore.h +++ b/Sming/Core/SmingCore.h @@ -33,10 +33,12 @@ #include "Platform/Timers.h" #include "Platform/WDT.h" +#ifndef DISABLE_NETWORK #ifndef DISABLE_WIFI #include "Platform/WifiEvents.h" #include "Platform/Station.h" #include "Platform/AccessPoint.h" +#endif #include "Network/DnsServer.h" #include "Network/HttpClient.h" @@ -52,7 +54,7 @@ #include "Network/TcpConnection.h" #include "Network/UdpConnection.h" #include "Network/Url.h" -#endif +#endif // DISABLE_NETWORK #include "Data/Stream/FileStream.h" #include "Data/Stream/TemplateFileStream.h" diff --git a/Sming/README.rst b/Sming/README.rst index 0fc35032ef..52b153693f 100644 --- a/Sming/README.rst +++ b/Sming/README.rst @@ -85,12 +85,10 @@ Localisation Networking ~~~~~~~~~~ -.. envvar:: DISABLE_WIFI +.. envvar:: DISABLE_NETWORK .. note:: - EXPERIMENTAL - 0 (Default) 1 - Remove core networking support @@ -101,6 +99,18 @@ Networking Builds will not succeeded if network code has been inadvertently included. +.. envvar:: DISABLE_WIFI + + .. note:: + + EXPERIMENTAL + + 0 (Default) + 1 - Exclude WiFi initialisation code + + Keeps the core :component:`Network` library but excludes WiFi code. + Applications using ethernet can use this to reduce code size. See :sample:`Basic_Ethernet`. + Components ---------- diff --git a/Sming/Services/CommandProcessing/CommandExecutor.cpp b/Sming/Services/CommandProcessing/CommandExecutor.cpp index 46c4c81ddc..fc61202431 100644 --- a/Sming/Services/CommandProcessing/CommandExecutor.cpp +++ b/Sming/Services/CommandProcessing/CommandExecutor.cpp @@ -21,7 +21,7 @@ CommandExecutor::CommandExecutor(Stream* reqStream) : CommandExecutor() } } -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK CommandExecutor::CommandExecutor(TcpClient* cmdClient) : CommandExecutor() { commandOutput = new CommandOutput(cmdClient); diff --git a/Sming/Services/CommandProcessing/CommandExecutor.h b/Sming/Services/CommandProcessing/CommandExecutor.h index a1be0932c6..9bf51f749d 100644 --- a/Sming/Services/CommandProcessing/CommandExecutor.h +++ b/Sming/Services/CommandProcessing/CommandExecutor.h @@ -11,7 +11,7 @@ #include "CommandOutput.h" #include -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK #include #endif @@ -20,7 +20,7 @@ class CommandExecutor { public: -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK CommandExecutor(TcpClient* cmdClient); CommandExecutor(WebsocketConnection* reqSocket); #endif diff --git a/Sming/Services/CommandProcessing/CommandHandler.cpp b/Sming/Services/CommandProcessing/CommandHandler.cpp index 752dd42a25..496a471525 100644 --- a/Sming/Services/CommandProcessing/CommandHandler.cpp +++ b/Sming/Services/CommandProcessing/CommandHandler.cpp @@ -99,7 +99,7 @@ void CommandHandler::procesStatusCommand(String commandLine, CommandOutput* comm commandOutput->print(_F("ESP SDK version : ")); commandOutput->print(system_get_sdk_version()); commandOutput->println(); -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK commandOutput->printf(_F("lwIP version : %d.%d.%d(%s)\r\n"), LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION, LWIP_HASH_STR); #endif diff --git a/Sming/Services/CommandProcessing/CommandOutput.cpp b/Sming/Services/CommandProcessing/CommandOutput.cpp index 66d97d8a5d..604ce4a3ed 100644 --- a/Sming/Services/CommandProcessing/CommandOutput.cpp +++ b/Sming/Services/CommandProcessing/CommandOutput.cpp @@ -23,7 +23,7 @@ size_t CommandOutput::write(uint8_t outChar) return outputStream->write(outChar); } -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK if(outputTcpClient) { char outBuf[1] = {char(outChar)}; return outputTcpClient->write(outBuf, 1); diff --git a/Sming/Services/CommandProcessing/CommandOutput.h b/Sming/Services/CommandProcessing/CommandOutput.h index b1f4cd4b12..774c672e7e 100644 --- a/Sming/Services/CommandProcessing/CommandOutput.h +++ b/Sming/Services/CommandProcessing/CommandOutput.h @@ -10,7 +10,7 @@ #include #include -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK #include #include #endif @@ -18,7 +18,7 @@ class CommandOutput : public Print { public: -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK CommandOutput(TcpClient* reqClient) : outputTcpClient(reqClient) { } @@ -34,7 +34,7 @@ class CommandOutput : public Print size_t write(uint8_t outChar); -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK TcpClient* outputTcpClient = nullptr; WebsocketConnection* outputSocket = nullptr; #endif diff --git a/Sming/System/include/debug_progmem.h b/Sming/System/include/debug_progmem.h index 90cbbbf670..71a011c383 100644 --- a/Sming/System/include/debug_progmem.h +++ b/Sming/System/include/debug_progmem.h @@ -54,6 +54,8 @@ extern "C" { do { \ } while(0) +extern uint32_t system_get_time(); + #if DEBUG_BUILD // http://stackoverflow.com/a/35441900 @@ -62,8 +64,6 @@ extern "C" { #define MACROQUOT(x) #x #define MACROQUOTE(x) MACROQUOT(x) -extern uint32_t system_get_time(); - //A static const char[] is defined having a unique name (log_ prefix, filename and line number) //This will be stored in the irom section(on flash) freeing up the RAM //Next special version of printf from FakePgmSpace is called to fetch and print the message diff --git a/Sming/Wiring/WiringFrameworkIncludes.h b/Sming/Wiring/WiringFrameworkIncludes.h index 8b40ba7660..660e7743d9 100644 --- a/Sming/Wiring/WiringFrameworkIncludes.h +++ b/Sming/Wiring/WiringFrameworkIncludes.h @@ -25,6 +25,6 @@ #include "Display.h" #include "WHashMap.h" -#ifndef DISABLE_WIFI +#ifndef DISABLE_NETWORK #include #endif diff --git a/Sming/component.mk b/Sming/component.mk index e597ce07c6..f97cb98ceb 100644 --- a/Sming/component.mk +++ b/Sming/component.mk @@ -45,13 +45,21 @@ ifeq ($(MQTT_NO_COMPAT),1) GLOBAL_CFLAGS += -DMQTT_NO_COMPAT=1 endif +# +RELINK_VARS += DISABLE_NETWORK +DISABLE_NETWORK ?= 0 +ifeq ($(DISABLE_NETWORK),1) +GLOBAL_CFLAGS += -DDISABLE_NETWORK=1 +DISABLE_WIFI := 1 +else +COMPONENT_DEPENDS += Network +endif + # RELINK_VARS += DISABLE_WIFI DISABLE_WIFI ?= 0 ifeq ($(DISABLE_WIFI),1) GLOBAL_CFLAGS += -DDISABLE_WIFI=1 -else -COMPONENT_DEPENDS += Network endif # WiFi settings may be provide via Environment variables diff --git a/docs/source/upgrading/4.3-4.4.rst b/docs/source/upgrading/4.3-4.4.rst index 6a0d1912f8..a6e32914e7 100644 --- a/docs/source/upgrading/4.3-4.4.rst +++ b/docs/source/upgrading/4.3-4.4.rst @@ -1,23 +1,26 @@ From v4.3 to v4.4 ================= -4.3.1 ------ - .. highlight:: c++ Network support ~~~~~~~~~~~~~~~ -The core network code has been moved out of ``Sming/Core/Network`` and into a separate component at ``Components/Network``. -This is to extend the use of the :envvar:`DISABLE_WIFI` setting to reduce the code required to be built for applications which -do not require networking. +If WiFi is not required then the :envvar:`DISABLE_WIFI` setting can be used to reduce code size. +This has a more pronounced effect for the ESP8266 which uses an experimental library. +The core network code has been moved out of ``Sming/Core/Network`` and into a separate component at ``Components/Network``. Some support code has been moved into ``Core/Data/WebHelpers``: applications should still build OK but you will get a compiler warning advising of the changes. Note that ``Network/WebHelpers/aw-sha1.h`` has been removed in favour of the :component:`crypto` library. +Ethernet support has been added, currently only for the ESP32 embedded MAC. +If WiFi is not used then the :envvar:`DISABLE_WIFI` setting can be used to reduce code size. + +The :envvar:`DISABLE_NETWORK` setting can be used to exclude all networking support for signficant code size reduction. + + ESP32 ~~~~~ diff --git a/samples/Basic_Ethernet/component.mk b/samples/Basic_Ethernet/component.mk new file mode 100644 index 0000000000..f7504e5dd6 --- /dev/null +++ b/samples/Basic_Ethernet/component.mk @@ -0,0 +1 @@ +DISABLE_WIFI := 1