2019-12-12 13:46:20 +01:00
|
|
|
# Default compile configurations
|
|
|
|
|
|
|
|
# FLASH_MODE=[ dout | dio | qout | qio ]
|
|
|
|
# use flash mode dout by default to keep GPIO9 and GPIO10 free for use
|
|
|
|
FLASH_MODE ?= dout
|
|
|
|
|
|
|
|
# ESP* pseudomodules
|
|
|
|
|
|
|
|
PSEUDOMODULES += esp_gdb
|
2019-12-12 15:41:20 +01:00
|
|
|
PSEUDOMODULES += esp_i2c_sw
|
2019-12-12 13:46:20 +01:00
|
|
|
PSEUDOMODULES += esp_log_colored
|
|
|
|
PSEUDOMODULES += esp_log_tagged
|
|
|
|
PSEUDOMODULES += esp_log_startup
|
|
|
|
PSEUDOMODULES += esp_qemu
|
|
|
|
PSEUDOMODULES += esp_spiffs
|
|
|
|
PSEUDOMODULES += esp_wifi_any
|
2020-05-22 15:13:14 +02:00
|
|
|
PSEUDOMODULES += esp_wifi_ap
|
2019-12-12 13:46:20 +01:00
|
|
|
|
|
|
|
# Common includes
|
|
|
|
|
|
|
|
INCLUDES += -I$(RIOTBOARD)/common/$(CPU)/include
|
|
|
|
INCLUDES += -I$(RIOTCPU)/esp_common
|
2019-12-27 10:22:29 +01:00
|
|
|
INCLUDES += -I$(RIOTCPU)/esp_common/include
|
2019-12-13 07:16:48 +01:00
|
|
|
INCLUDES += -I$(RIOTCPU)/esp_common/include/freertos
|
2019-12-12 13:46:20 +01:00
|
|
|
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/
|
2019-12-12 12:02:35 +01:00
|
|
|
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/esp
|
2019-12-12 13:46:20 +01:00
|
|
|
|
|
|
|
# Flags
|
|
|
|
|
2022-03-09 16:50:33 +01:00
|
|
|
CFLAGS += -Wno-unused-parameter
|
|
|
|
CFLAGS += -Wformat=0
|
|
|
|
CFLAGS += -fstrict-volatile-bitfields
|
|
|
|
CFLAGS += -fdata-sections
|
|
|
|
CFLAFS += -ffunction-sections
|
|
|
|
CFLAGS += -fzero-initialized-in-bss
|
|
|
|
|
2022-07-18 08:15:34 +02:00
|
|
|
ifeq (xtensa,$(CPU_ARCH))
|
2022-03-09 16:50:33 +01:00
|
|
|
CFLAGS += -mlongcalls -mtext-section-literals
|
|
|
|
endif
|
2019-12-12 13:46:20 +01:00
|
|
|
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-truncation
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -gz
|
|
|
|
|
|
|
|
ASFLAGS += --longcalls --text-section-literals
|
|
|
|
|
|
|
|
CFLAGS_DBG ?= -ggdb -g3
|
|
|
|
|
|
|
|
# override default CFLAGS_OPT in case module esp_gdb is enabled
|
2020-06-25 10:17:10 +02:00
|
|
|
ifneq (,$(filter esp_gdb,$(USEMODULE)))
|
|
|
|
CFLAGS_OPT ?= -Og
|
|
|
|
else
|
|
|
|
CFLAGS_OPT ?= -Os
|
|
|
|
endif
|
2019-12-12 13:46:20 +01:00
|
|
|
|
|
|
|
CFLAGS += $(CFLAGS_OPT) $(CFLAGS_DBG)
|
|
|
|
|
|
|
|
# add -DQEMU for qemu
|
|
|
|
ifneq (,$(filter esp_qemu,$(USEMODULE)))
|
|
|
|
CFLAGS += -DQEMU
|
|
|
|
endif
|
|
|
|
|
2022-06-17 07:16:48 +02:00
|
|
|
ifneq (,$(filter esp_freertos_common,$(USEMODULE)))
|
|
|
|
# thread_t.name required by FreeRTOS adaptation layer and esp_gdbstub
|
|
|
|
CFLAGS += -DCONFIG_THREAD_NAMES
|
|
|
|
# thread_t.stack_start required by FreeRTOS adaptation layer
|
|
|
|
CFLAGS += -DSCHED_TEST_STACK
|
|
|
|
endif
|
|
|
|
|
2019-12-12 13:46:20 +01:00
|
|
|
# use 32 priority levels if any WiFi interface or the ETH interface is used
|
2020-06-25 10:17:10 +02:00
|
|
|
ifneq (,$(filter esp_wifi_any esp_eth,$(USEMODULE)))
|
|
|
|
CFLAGS += -DSCHED_PRIO_LEVELS=32
|
|
|
|
endif
|
2019-12-16 01:47:44 +01:00
|
|
|
|
|
|
|
# The threads for handling the ESP hardware have the priorities from 2 to 4.
|
|
|
|
# The priority of lwIP TCPIP thread should be lower than these priorities.
|
2019-12-12 13:46:20 +01:00
|
|
|
ifneq (,$(filter lwip,$(USEMODULE)))
|
|
|
|
CFLAGS += -DTCPIP_THREAD_PRIO=5
|
|
|
|
endif
|
|
|
|
|
2022-08-01 15:17:33 +02:00
|
|
|
# extend CFLAGS by the corresponding CONFIG_FLASHMODE_* defines
|
|
|
|
ifeq (dout,$(FLASH_MODE))
|
|
|
|
CFLAGS += -DCONFIG_FLASHMODE_DOUT
|
|
|
|
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHMODE_DOUT
|
|
|
|
else ifeq (dio,$(FLASH_MODE))
|
|
|
|
CFLAGS += -DCONFIG_FLASHMODE_DIO
|
|
|
|
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHMODE_DIO
|
|
|
|
else ifeq (qout,$(FLASH_MODE))
|
|
|
|
CFLAGS += -DCONFIG_FLASHMODE_QOUT
|
|
|
|
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHMODE_QUOT
|
|
|
|
else ifeq (qio,$(FLASH_MODE))
|
|
|
|
CFLAGS += -DCONFIG_FLASHMODE_QIO
|
|
|
|
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHMODE_QIO
|
|
|
|
else
|
|
|
|
$(error Undefined FLASH_MODE, possible values are: dout, dio, qout and qio)
|
|
|
|
endif
|
2019-12-12 13:46:20 +01:00
|
|
|
|
2022-02-01 21:24:43 +01:00
|
|
|
ARCHIVES += -lg -lc
|
2019-12-12 13:46:20 +01:00
|
|
|
|
|
|
|
LINKFLAGS += $(CFLAGS_OPT) $(CFLAGS_DBG)
|
|
|
|
LINKFLAGS += -nostdlib -Wl,-gc-sections -Wl,-static
|
|
|
|
|
2021-12-07 11:27:22 +01:00
|
|
|
# use the wrapper functions for calloc to add correct overflow detection missing
|
|
|
|
# in the newlib's version.
|
|
|
|
LINKFLAGS += -Wl,-wrap,_calloc_r
|
|
|
|
|
|
|
|
ifneq (,$(filter esp_idf_heap,$(USEMODULE)))
|
|
|
|
LINKFLAGS += -Wl,-wrap,_malloc_r
|
|
|
|
LINKFLAGS += -Wl,-wrap,_realloc_r
|
|
|
|
LINKFLAGS += -Wl,-wrap,_free_r
|
2021-05-06 09:23:22 +02:00
|
|
|
endif
|
|
|
|
|
2019-12-12 13:46:20 +01:00
|
|
|
# LINKFLAGS += -Wl,--verbose
|
|
|
|
# LINKFLAGS += -Wl,--print-gc-sections
|
|
|
|
|
|
|
|
# increase the test timeout for file system tests that use the SPI flash drive
|
2020-06-25 10:17:10 +02:00
|
|
|
ifneq (,$(filter spiffs littlefs,$(USEMODULE)))
|
|
|
|
RIOT_TEST_TIMEOUT = 20
|
|
|
|
$(call target-export-variables,test,RIOT_TEST_TIMEOUT)
|
|
|
|
endif
|
2020-12-01 10:36:42 +01:00
|
|
|
|
|
|
|
# All ESP are flashed using esptool
|
|
|
|
PROGRAMMER ?= esptool
|
2021-02-23 15:01:12 +01:00
|
|
|
|
|
|
|
# Add esptool in the list supported programmers
|
|
|
|
PROGRAMMERS_SUPPORTED += esptool
|
2021-09-27 22:53:18 +02:00
|
|
|
|
|
|
|
# The ELFFILE is defined by default in $(RIOTBASE)/Makefile.include but only
|
|
|
|
# after this file is included, so we need ELFFILE defined earlier.
|
|
|
|
# This is used to create new make rules in this file (based on FLASHFILE)
|
|
|
|
# and can't be deferred.
|
|
|
|
ELFFILE ?= $(BINDIR)/$(APPLICATION).elf
|
|
|
|
FLASHFILE ?= $(ELFFILE).bin
|
|
|
|
|
2022-03-04 08:34:19 +01:00
|
|
|
ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool.py
|
2021-09-27 22:53:18 +02:00
|
|
|
|
|
|
|
# This is the binary that ends up programmed in the flash.
|
|
|
|
$(ELFFILE).bin: $(ELFFILE)
|
|
|
|
$(Q)$(ESPTOOL) --chip $(FLASH_CHIP) elf2image --flash_mode $(FLASH_MODE) \
|
|
|
|
--flash_size $(FLASH_SIZE)MB --flash_freq $(FLASH_FREQ) $(FLASH_OPTS) \
|
|
|
|
-o $@ $<
|
|
|
|
|
|
|
|
# Convert .elf and .csv to .bin files at build time, but make them available for
|
|
|
|
# tests at flash time. These can't be added to FLASHDEPS because they depend on
|
|
|
|
# on ELFFILE and would trigger a rebuild with "flash-only".
|
2022-02-01 22:15:47 +01:00
|
|
|
BUILD_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin $(BOOTLOADER_BIN)
|
|
|
|
TEST_EXTRA_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin $(BOOTLOADER_BIN)
|
2021-09-27 22:53:18 +02:00
|
|
|
|
|
|
|
# Default partition table with no OTA. Can be replaced with a custom partition
|
|
|
|
# table setting PARTITION_TABLE_CSV.
|
|
|
|
PARTITION_TABLE_CSV ?= $(BINDIR)/partitions.csv
|
|
|
|
|
2023-01-07 13:11:31 +01:00
|
|
|
ifneq (,$(filter periph_flashpage_in_address_space,$(USEMODULE)))
|
2021-09-27 22:53:18 +02:00
|
|
|
$(BINDIR)/partitions.csv: $(FLASHFILE)
|
|
|
|
$(Q)printf "\n" > $(BINDIR)/partitions.csv
|
|
|
|
$(Q)printf "nvs, data, nvs, 0x9000, 0x6000\n" >> $@
|
|
|
|
$(Q)printf "phy_init, data, phy, 0xf000, 0x1000\n" >> $@
|
2023-01-07 13:11:31 +01:00
|
|
|
$(Q)printf "flashpage, data, phy, $(FLASHPAGE_ADDR_START), $(FLASHPAGE_CAP)\n" >> $@
|
2022-12-27 01:55:28 +01:00
|
|
|
$(Q)printf "factory, app, factory, $(FLASHFILE_POS), " >> $@
|
2021-09-27 22:53:18 +02:00
|
|
|
$(Q)ls -l $< | awk '{ print $$5 }' >> $@
|
2023-01-07 13:11:31 +01:00
|
|
|
else
|
|
|
|
$(BINDIR)/partitions.csv: $(FLASHFILE)
|
|
|
|
$(Q)printf "\n" > $(BINDIR)/partitions.csv
|
|
|
|
$(Q)printf "nvs, data, nvs, 0x9000, 0x6000\n" >> $@
|
|
|
|
$(Q)printf "phy_init, data, phy, 0xf000, 0x1000\n" >> $@
|
|
|
|
$(Q)printf "factory, app, factory, $(FLASHFILE_POS), " >> $@
|
|
|
|
$(Q)ls -l $< | awk '{ print $$5 }' >> $@
|
|
|
|
endif
|
2021-09-27 22:53:18 +02:00
|
|
|
|
|
|
|
$(BINDIR)/partitions.bin: $(PARTITION_TABLE_CSV)
|
2022-03-04 08:34:19 +01:00
|
|
|
$(Q)python3 $(RIOTTOOLS)/esptools/gen_esp32part.py --verify $< $@
|