1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/esp32/Makefile.include

148 lines
5.5 KiB
Makefile
Raw Normal View History

2019-12-12 13:46:20 +01:00
# ESP32 specific flashing options
2022-02-01 22:11:43 +01:00
FLASH_CHIP = $(CPU)
2019-12-12 13:46:20 +01:00
FLASH_MODE ?= dout
FLASH_FREQ = 40m # DO NOT CHANGE
FLASH_SIZE ?= 4
BOOTLOADER_POS = 0x1000
2018-10-08 12:20:49 +02:00
ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool_v3.2.py
2019-12-12 13:46:20 +01:00
include $(RIOTCPU)/esp_common/Makefile.include
2019-12-12 13:46:20 +01:00
# regular Makefile
2022-02-01 22:11:43 +01:00
TARGET_ARCH_$(CPU) ?= xtensa-$(CPU)-elf
TARGET_ARCH ?= $(TARGET_ARCH_$(CPU))
2022-02-01 22:11:43 +01:00
CPU_UC = $(shell echo '$(CPU)' | tr '[:lower:]' '[:upper:]')
PSEUDOMODULES += esp_bootloader
2018-10-08 12:20:49 +02:00
PSEUDOMODULES += esp_gdbstub
PSEUDOMODULES += esp_hw_counter
PSEUDOMODULES += esp_i2c_hw
PSEUDOMODULES += esp_jtag
PSEUDOMODULES += esp_rtc_timer_32k
2018-10-08 12:20:49 +02:00
PSEUDOMODULES += esp_spi_ram
PSEUDOMODULES += esp_wifi_enterprise
2018-10-08 12:20:49 +02:00
2022-02-01 22:11:43 +01:00
INCLUDES += -I$(RIOTCPU)/$(CPU)/esp-idf/include
INCLUDES += -I$(RIOTCPU)/$(CPU)/esp-idf/include/log
INCLUDES += -I$(ESP32_SDK_DIR)/components/
INCLUDES += -I$(ESP32_SDK_DIR)/components/driver/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_common/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/include/soc
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/include/$(CPU)
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_timer/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/hal/$(CPU)/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/hal/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/heap/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/log/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/newlib/platform_include
INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/$(CPU)/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/xtensa/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/xtensa/$(CPU)/include
ifneq (,$(filter esp_spi_ram,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/include/soc/$(CPU)
endif
ifneq (,$(filter esp_idf_spi_flash,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/spi_flash/include
endif
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_eth/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_event/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_netif/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_system/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_wifi/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/nvs_flash/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/spi_flash/include
endif
ifneq (,$(filter esp_wifi_enterprise,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/esp_supplicant/include
endif
2018-10-08 12:20:49 +02:00
2020-06-25 10:17:10 +02:00
ifneq (,$(filter esp_eth,$(USEMODULE)))
INCLUDES += -I$(RIOTCPU)/$(CPU)/esp-eth
2022-02-01 22:11:43 +01:00
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_eth/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_event/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_netif/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_wifi/include
2020-06-25 10:17:10 +02:00
endif
2022-02-01 22:11:43 +01:00
# we use ESP32 only in single core mode
CFLAGS += -DCONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
CFLAGS += -DCONFIG_FREERTOS_UNICORE
# other ESP-IDF configurations
CFLAGS += -DCONFIG_IDF_TARGET_$(CPU_UC)
CFLAGS += -DESP_PLATFORM
2019-12-12 13:46:20 +01:00
CFLAGS += -DLOG_TAG_IN_BRACKETS
2022-02-01 22:11:43 +01:00
# shortcuts used by ESP-IDF
CFLAGS += -Dasm=__asm
CFLAGS += -Dtypeof=__typeof__
2022-01-21 14:04:38 +01:00
CFLAGS += -D_CONST=const
2022-02-01 22:11:43 +01:00
LINKFLAGS += -L$(ESP32_SDK_DIR)/components/xtensa/$(CPU)
ARCHIVES += -lxt_hal
2018-10-08 12:20:49 +02:00
LINKFLAGS += -L$(RIOTCPU)/$(CPU)/ld/
2022-02-01 22:11:43 +01:00
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/soc/$(CPU)/ld/$(CPU).peripherals.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU)/ld/$(CPU).rom.api.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU)/ld/$(CPU).rom.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU)/ld/$(CPU).rom.newlib-data.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU)/ld/$(CPU).rom.newlib-funcs.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU)/ld/$(CPU).rom.newlib-time.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU)/ld/$(CPU).rom.spiflash.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU)/ld/$(CPU).rom.redefined.ld
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/memory.ld
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/sections.ld
LINKFLAGS += -nostdlib -lgcc -Wl,-gc-sections
# Libraries needed when using esp_wifi_any pseudomodule
2020-06-25 10:17:10 +02:00
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
2022-02-01 22:11:43 +01:00
LINKFLAGS += -L$(ESP32_SDK_LIB_WIFI_DIR)/$(CPU)
LINKFLAGS += -L$(ESP32_SDK_LIB_PHY_DIR)/$(CPU)
ARCHIVES += -lcore -lrtc -lnet80211 -lpp -lcoexist
ARCHIVES += -lphy -lstdc++
2020-06-25 10:17:10 +02:00
endif
# Libraries needed when using esp_now module
2020-06-25 10:17:10 +02:00
ifneq (,$(filter esp_now,$(USEMODULE)))
ARCHIVES += -lespnow -lmesh
2020-06-25 10:17:10 +02:00
endif
ifneq (,$(filter cpp,$(USEMODULE)))
ARCHIVES += -lstdc++
2020-06-25 10:17:10 +02:00
endif
2022-02-01 22:11:43 +01:00
ifneq (,$(filter esp_bootloader,$(USEMODULE)))
# Bootloader file used by esptool.inc.mk
BOOTLOADER_BIN ?= $(BINDIR)/esp_bootloader/bootloader.bin
endif
ifneq (,$(filter esp_jtag,$(USEMODULE)))
PROGRAMMERS_SUPPORTED += openocd
PARTITION_POS = 0x8000
OPENOCD_PRE_FLASH_CMDS = -c 'echo "Installing Bootloader at $(BOOTLOADER_POS)"' \
2022-02-01 22:11:43 +01:00
-c 'flash write_image erase "$(BOOTLOADER_BIN)" $(BOOTLOADER_POS) bin' \
-c 'echo "Installing partition table at $(PARTITION_POS)"' \
-c 'flash write_image erase "$(BINDIR)/partitions.bin" $(PARTITION_POS) bin'
IMAGE_OFFSET = 0x10000
# Flash checksumming not supported on xtensa
OPENOCD_SKIP_VERIFY = yes
# Without resets debug target fails with 'Target not examined yet'
OPENOCD_DBG_EXTRA_CMD += -c 'reset halt'
endif
2022-02-01 22:11:43 +01:00
$(BOOTLOADER_BIN):