# 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 PSEUDOMODULES += esp_i2c_sw PSEUDOMODULES += esp_log_colored PSEUDOMODULES += esp_log_tagged PSEUDOMODULES += esp_log_startup PSEUDOMODULES += esp_qemu PSEUDOMODULES += esp_spiffs PSEUDOMODULES += esp_wifi_any # Common includes INCLUDES += -I$(RIOTBOARD)/common/$(CPU)/include INCLUDES += -I$(RIOTCPU)/esp_common INCLUDES += -I$(RIOTCPU)/esp_common/include INCLUDES += -I$(RIOTCPU)/esp_common/include/freertos INCLUDES += -I$(RIOTCPU)/esp_common/vendor/ INCLUDES += -I$(RIOTCPU)/esp_common/vendor/esp # Flags CFLAGS += -Wno-unused-parameter -Wformat=0 CFLAGS += -mlongcalls -mtext-section-literals -fstrict-volatile-bitfields CFLAGS += -fdata-sections -ffunction-sections -fzero-initialized-in-bss OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow OPTIONAL_CFLAGS_BLACKLIST += -Wformat-truncation OPTIONAL_CFLAGS_BLACKLIST += -gz ASFLAGS += --longcalls --text-section-literals # thin archives trigger a reboot loop - see #12258, #12035, #12346 ARFLAGS = rcs CFLAGS_DBG ?= -ggdb -g3 # override default CFLAGS_OPT in case module esp_gdb is enabled ifneq (,$(filter esp_gdb,$(USEMODULE))) CFLAGS_OPT ?= -Og else CFLAGS_OPT ?= -Os endif CFLAGS += $(CFLAGS_OPT) $(CFLAGS_DBG) # add -DQEMU for qemu ifneq (,$(filter esp_qemu,$(USEMODULE))) CFLAGS += -DQEMU endif # use 32 priority levels if any WiFi interface or the ETH interface is used ifneq (,$(filter esp_wifi_any esp_eth,$(USEMODULE))) CFLAGS += -DSCHED_PRIO_LEVELS=32 endif # 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. ifneq (,$(filter lwip,$(USEMODULE))) CFLAGS += -DTCPIP_THREAD_PRIO=5 endif # if SPI RAM is enabled, the qout flash mode has to be used _FLASH_MODE_PREV := $(FLASH_MODE) ifneq (,$(filter esp_spi_ram,$(USEMODULE))) FLASH_MODE = qout else FLASH_MODE = $(_FLASH_MODE_PREV) endif # set CFLAG for the correspondant FLASH_MODE CFLAGS += $(if $(findstring qout,$(FLASH_MODE)),-DFLASH_MODE_QOUT=1) CFLAGS += $(if $(findstring qio,$(FLASH_MODE)),-DFLASH_MODE_QIO=1) CFLAGS += $(if $(findstring dio,$(FLASH_MODE)),-DFLASH_MODE_DIO=1) CFLAGS += $(if $(findstring dout,$(FLASH_MODE)),-DFLASH_MODE_DOUT=1) BASELIBS += -lhal -lg -lc LINKFLAGS += $(CFLAGS_OPT) $(CFLAGS_DBG) LINKFLAGS += -L$(ESP_SDK_DIR)/components/$(CPU) LINKFLAGS += -L$(ESP_SDK_DIR)/components/$(CPU)/lib LINKFLAGS += -nostdlib -Wl,-gc-sections -Wl,-static # LINKFLAGS += -Wl,--verbose # LINKFLAGS += -Wl,--print-gc-sections ifneq (,$(filter esp_log_colored,$(USEMODULE))) BOOTLOADER_COLOR = _colors endif ifneq (,$(filter esp_log_startup,$(USEMODULE))) BOOTLOADER_INFO = _info endif BOOTLOADER_BIN = bootloader$(BOOTLOADER_COLOR)$(BOOTLOADER_INFO).bin ESPTOOL ?= $(RIOTTOOLS)/esptool/esptool.py # The ELFFILE is the base one used for flashing FLASHFILE ?= $(ELFFILE) # configure preflasher to convert .elf to .bin before flashing PREFLASHER = $(ESPTOOL) PREFFLAGS = --chip $(FLASH_CHIP) elf2image PREFFLAGS += --flash_mode $(FLASH_MODE) --flash_size $(FLASH_SIZE)MB PREFFLAGS += --flash_freq $(FLASH_FREQ) $(FLASH_OPTS) PREFFLAGS += -o $(FLASHFILE).bin $(FLASHFILE); PREFFLAGS += printf "\n" > $(BINDIR)/partitions.csv; PREFFLAGS += printf "nvs, data, nvs, 0x9000, 0x6000\n" >> $(BINDIR)/partitions.csv; PREFFLAGS += printf "phy_init, data, phy, 0xf000, 0x1000\n" >> $(BINDIR)/partitions.csv; PREFFLAGS += printf "factory, app, factory, 0x10000, " >> $(BINDIR)/partitions.csv; PREFFLAGS += ls -l $(FLASHFILE).bin | awk '{ print $$5 }' >> $(BINDIR)/partitions.csv; PREFFLAGS += python3 $(RIOTTOOLS)/esptool/gen_esp32part.py PREFFLAGS += --verify $(BINDIR)/partitions.csv $(BINDIR)/partitions.bin FLASHDEPS += preflash # flasher configuration ifneq (,$(filter esp_qemu,$(USEMODULE))) FLASHER = dd FFLAGS += if=/dev/zero bs=1M count=$(FLASH_SIZE) | FFLAGS += tr "\\000" "\\377" > tmp.bin && cat tmp.bin | FFLAGS += head -c $$(($(BOOTLOADER_POS))) | FFLAGS += cat - $(RIOTCPU)/$(CPU)/bin/$(BOOTLOADER_BIN) tmp.bin | FFLAGS += head -c $$((0x8000)) | FFLAGS += cat - $(BINDIR)/partitions.bin tmp.bin | FFLAGS += head -c $$((0x10000)) | FFLAGS += cat - $(FLASHFILE).bin tmp.bin | FFLAGS += head -c $(FLASH_SIZE)MB > $(BINDIR)/$(CPU)flash.bin && rm tmp.bin; else PROGRAMMER_SPEED ?= 460800 FLASHER = $(ESPTOOL) FFLAGS += --chip $(FLASH_CHIP) --port $(PROG_DEV) --baud $(PROGRAMMER_SPEED) FFLAGS += --before default_reset write_flash -z FFLAGS += --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) FFLAGS += $(BOOTLOADER_POS) $(RIOTCPU)/$(CPU)/bin/$(BOOTLOADER_BIN) FFLAGS += 0x8000 $(BINDIR)/partitions.bin FFLAGS += 0x10000 $(FLASHFILE).bin endif # increase the test timeout for file system tests that use the SPI flash drive ifneq (,$(filter spiffs littlefs,$(USEMODULE))) RIOT_TEST_TIMEOUT = 20 $(call target-export-variables,test,RIOT_TEST_TIMEOUT) endif