blob: 766c9adf618ab8de02fe8fa8827254c5ee7d9035 [file] [log] [blame]
############################################################################
# arch/xtensa/src/esp32/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include common/Make.defs
STORAGETMP = $(if $(wildcard $(NXTMPDIR)/.*),y,)
# The start-up, "head", file. May be either a .S or a .c file.
HEAD_CSRC = esp32_start.c esp32_wdt.c
ifeq ($(CONFIG_XTENSA_HAVE_WINDOW_EXCEPTION_HOOKS),y)
HEAD_ASRC += esp32_window_hooks.S
endif
# Required ESP32 files (arch/xtensa/src/esp32)
CHIP_CSRCS = esp32_allocateheap.c esp32_clockconfig.c esp32_gpio.c
CHIP_CSRCS += esp32_systemreset.c esp32_resetcause.c
CHIP_CSRCS += esp32_irq.c esp32_region.c esp32_rtc_gpio.c
CHIP_CSRCS += esp32_user.c esp32_libc_stubs.c
CHIP_CSRCS += esp32_dma.c
ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y)
CHIP_CSRCS += esp32_idle.c
endif
ifeq ($(CONFIG_BUILD_PROTECTED),y)
CHIP_CSRCS += esp32_userspace.c
ifeq ($(CONFIG_ESP32_PID),y)
CHIP_CSRCS += esp32_userspace_pid.c
endif
endif
ifeq ($(CONFIG_SCHED_TICKLESS),y)
CHIP_CSRCS += esp32_tickless.c
else
CHIP_CSRCS += esp32_timerisr.c
endif
ifeq ($(CONFIG_PM),y)
ifneq ($(CONFIG_ARCH_CUSTOM_PMINIT),y)
CHIP_CSRCS += esp32_pminitialize.c
endif
CHIP_CSRCS += esp32_pm.c
endif
ifeq ($(CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP),y)
CHIP_CSRCS += esp32_imm.c
endif
ifeq ($(CONFIG_DAC),y)
CHIP_CSRCS += esp32_dac.c
endif
ifeq ($(CONFIG_ESP32_LEDC),y)
CHIP_CSRCS += esp32_ledc.c
endif
ifeq ($(CONFIG_ESP32_I2C),y)
ifeq ($(CONFIG_ESPRESSIF_I2C_PERIPH_MASTER_MODE),y)
CHIP_CSRCS += esp32_i2c.c
endif
endif
ifeq ($(CONFIG_ESP32_TWAI),y)
CHIP_CSRCS += esp32_twai.c
endif
ifeq ($(CONFIG_ESP32_PCNT_AS_QE),y)
CHIP_CSRCS += esp32_qencoder.c
endif
ifeq ($(CONFIG_ESP32_SPI),y)
CHIP_CSRCS += esp32_spi.c
ifeq ($(CONFIG_SPI_SLAVE),y)
CHIP_CSRCS += esp32_spi_slave.c
endif
endif
ifeq ($(CONFIG_ESP32_SPIRAM),y)
CHIP_CSRCS += esp32_spiram.c
CHIP_CSRCS += esp32_psram.c
CHIP_CSRCS += esp32_himem.c
CHIP_CSRCS += esp32_himem_chardev.c
endif
ifeq ($(CONFIG_ESP32_EMAC),y)
CHIP_CSRCS += esp32_emac.c
endif
# Configuration-dependent ESP32 files
ifeq ($(CONFIG_SMP),y)
CHIP_CSRCS += esp32_cpuidlestack.c esp32_cpustart.c esp32_intercpu_interrupt.c
endif
ifeq ($(CONFIG_ESP32_UART),y)
CHIP_CSRCS += esp32_serial.c
endif
ifeq ($(CONFIG_ESP32_RNG),y)
CHIP_CSRCS += esp32_rng.c
endif
ifeq ($(CONFIG_ESP32_TIMER),y)
CHIP_CSRCS += esp32_tim.c
ifeq ($(CONFIG_TIMER),y)
CHIP_CSRCS += esp32_tim_lowerhalf.c
endif
endif
ifeq ($(CONFIG_ESP32_ONESHOT),y)
CHIP_CSRCS += esp32_oneshot.c
ifeq ($(CONFIG_ONESHOT),y)
CHIP_CSRCS += esp32_oneshot_lowerhalf.c
endif
endif
ifeq ($(CONFIG_ESP32_FREERUN),y)
CHIP_CSRCS += esp32_freerun.c
endif
ifeq ($(CONFIG_ESP32_PARTITION_TABLE),y)
CHIP_CSRCS += esp32_spiflash.c
CHIP_CSRCS += esp32_partition.c
endif
ifeq ($(CONFIG_WATCHDOG),y)
CHIP_CSRCS += esp32_wdt_lowerhalf.c
endif
ifeq ($(CONFIG_ARCH_HAVE_EXTRA_HEAPS),y)
CHIP_CSRCS += esp32_extraheaps.c
endif
ifeq ($(CONFIG_ESP32_RTC_HEAP),y)
CHIP_CSRCS += esp32_rtcheap.c
endif
ifeq ($(CONFIG_ESP32_IRAM_HEAP),y)
CHIP_CSRCS += esp32_iramheap.c
endif
ifeq ($(CONFIG_ARCH_USE_TEXT_HEAP),y)
CHIP_CSRCS += esp32_textheap.c
endif
ifeq ($(CONFIG_ESP32_RT_TIMER),y)
CHIP_CSRCS += esp32_rt_timer.c
endif
ifeq ($(CONFIG_ESP32_TOUCH),y)
CHIP_CSRCS += esp32_touch.c
endif
ifeq ($(CONFIG_ESP32_AES_ACCELERATOR),y)
CHIP_CSRCS += esp32_aes.c
endif
ifeq ($(CONFIG_ESP32_SHA_ACCELERATOR),y)
CHIP_CSRCS += esp32_sha.c
endif
ifeq ($(CONFIG_CRYPTO_CRYPTODEV_HARDWARE),y)
CHIP_CSRCS += esp32_crypto.c
endif
ifeq ($(CONFIG_ESP32_RTC),y)
CHIP_CSRCS += esp32_rtc.c
ifeq ($(CONFIG_RTC_DRIVER),y)
CHIP_CSRCS += esp32_rtc_lowerhalf.c
endif
endif
ifeq ($(CONFIG_ESP32_OPENETH),y)
CHIP_CSRCS += esp_openeth.c
endif
ifeq ($(CONFIG_ESPRESSIF_WIFI),y)
CHIP_CSRCS += esp32_wifi_adapter.c
endif
ifeq ($(CONFIG_ESPRESSIF_BLE),y)
CHIP_CSRCS += esp32_ble_adapter.c esp32_ble.c
EXTRA_LIBS += -lbtdm_app
endif
#############################################################################
# Espressif HAL for 3rd Party Platforms
#############################################################################
# Fetch source files and add them to build
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
ifndef ESP_HAL_3RDPARTY_VERSION
ESP_HAL_3RDPARTY_VERSION = 4eed03a15b2678a81dfd1ed0f3bde042b1fdd4c4
endif
ifndef ESP_HAL_3RDPARTY_URL
ESP_HAL_3RDPARTY_URL = https://github.com/espressif/esp-hal-3rdparty.git
endif
ifndef DISABLE_GIT_DEPTH
ifndef GIT_DEPTH
GIT_DEPTH=1
endif
GIT_DEPTH_PARAMETER = --depth=$(GIT_DEPTH)
endif
# When set USE_NXTMPDIR_ESP_REPO_DIRECTLY=y, will directly use esp-hal-3rdparty
# under nxtmpdir without CHECK_COMMITSHA, reset, checkout and update.
USE_NXTMPDIR_ESP_REPO_DIRECTLY ?= n
ifeq ($(STORAGETMP),y)
ifeq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y)
define CLONE_ESP_HAL_3RDPARTY_REPO
$(call COPYDIR, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),chip/$(ESP_HAL_3RDPARTY_REPO))
endef
else
define CLONE_ESP_HAL_3RDPARTY_REPO
$(call CHECK_COMMITSHA, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),$(ESP_HAL_3RDPARTY_VERSION))
$(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO),$(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO))
endef
endif
else
define CLONE_ESP_HAL_3RDPARTY_REPO
$(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO))
endef
endif
chip/$(ESP_HAL_3RDPARTY_REPO):
$(Q) echo "Cloning Espressif HAL for 3rd Party Platforms"
$(Q) $(call CLONE_ESP_HAL_3RDPARTY_REPO)
ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y)
$(Q) echo "Espressif HAL for 3rd Party Platforms: ${ESP_HAL_3RDPARTY_VERSION}"
$(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) checkout --quiet $(ESP_HAL_3RDPARTY_VERSION)
endif
# Silent preprocessor warnings
CFLAGS += -Wno-undef -Wno-unused-variable -fno-jump-tables -fno-tree-switch-conversion
# Enable strict volatile bitfield access
CFLAGS += -fstrict-volatile-bitfields
# Files that require the HAL recipe
CHIP_SERIES = $(patsubst "%",%,$(CONFIG_ESPRESSIF_CHIP_SERIES))
include chip/Bootloader.mk
include chip/hal.mk
include common/espressif/Make.defs
context:: chip/$(ESP_HAL_3RDPARTY_REPO)
ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y)
$(Q) echo "Espressif HAL for 3rd Party Platforms: initializing submodules..."
$(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/mbedtls/mbedtls components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32 components/esp_coex/lib
$(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls reset --quiet --hard
endif
$(Q) echo "Applying patches..."
$(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && git apply ../../../nuttx/patches/components/mbedtls/mbedtls/*.patch
ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y)
ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y)
$(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32 components/esp_coex/lib
endif
endif
distclean::
$(call DELDIR,chip/$(ESP_HAL_3RDPARTY_REPO))
$(call DELFILE,../../../vefuse.bin)
INCLUDES += ${INCDIR_PREFIX}$(ARCH_SRCDIR)$(DELIM)common$(DELIM)espressif