Skip to content

Commit

Permalink
Add DISABLE_NETWORK and SDK_CUSTOM_CONFIG settings (#2362)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mikee47 authored Sep 5, 2021
1 parent 5a95a91 commit 22dfd86
Show file tree
Hide file tree
Showing 44 changed files with 235 additions and 399 deletions.
4 changes: 1 addition & 3 deletions Sming/Arch/Esp32/Components/esp32/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
sdkconfig
sdkconfig.defaults
sdkconfig.old
project
36 changes: 19 additions & 17 deletions Sming/Arch/Esp32/Components/esp32/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
86 changes: 59 additions & 27 deletions Sming/Arch/Esp32/Components/esp32/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -146,7 +151,6 @@ SDK_COMPONENTS := \
esp-tls \
$(ESP_VARIANT) \
esp_common \
esp_eth \
esp_event \
esp_gdbstub \
esp_hw_support \
Expand All @@ -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
Expand Down Expand Up @@ -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 := \
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions Sming/Arch/Esp32/Components/esp32/project.esp32c3/main/main.c

This file was deleted.

This file was deleted.

Loading

0 comments on commit 22dfd86

Please sign in to comment.