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

157 lines
5.1 KiB
Makefile
Raw Normal View History

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
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
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
INCLUDES += -I$(RIOTCPU)/esp_common/include
INCLUDES += -I$(RIOTCPU)/esp_common/include/freertos
2019-12-12 13:46:20 +01:00
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/esp
2019-12-12 13:46:20 +01:00
# 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
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
# 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
# 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
# if SPI RAM is enabled, the qout flash mode has to be used
_FLASH_MODE_PREV := $(FLASH_MODE)
2020-06-25 10:17:10 +02:00
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)
2019-12-12 13:46:20 +01:00
ARCHIVES += -lhal -lg -lc
2019-12-12 13:46:20 +01:00
LINKFLAGS += $(CFLAGS_OPT) $(CFLAGS_DBG)
#ifneq ($(CPU),esp8266)
esp8266: Download Espressif RTOS SDK as a new RIOT PKG RIOT-OS uses part of Espressif ESP8266 RTOS SDK to build support for this CPU. The SDK includes some vendor-provided closed source pre-compiled libraries that we need to modify to adapt to RIOT-OS usage. This library modifications was done once and uploaded to a fork of the vendor repository and was provided as an environment variable. This patch changes two things: 1. It installs the SDK as a RIOT PKG from the new pkg/esp8266_sdk directory instead of requiring the user to download it separately. 2. It performs the library modifications (symbol renames) on the pkg Makefile removing the need to use a fork with the modifications applied and simplifying the SDK update and future modifications. This change sets the SDK package version (git SHA) to the same one that our fork was using as a parent in the vendor repository, meaning that the output libraries are exactly the same as before. Tested with ``` ESP8266_RTOS_SDK_DIR=/dev/null USEMODULE=esp_log_startup make -C tests/shell BOARD=esp8266-esp-12x flash ``` and verified that the program works. The boot message now includes: ``` ESP8266-RTOS-SDK Version v3.1-51-g913a06a9 ``` confirming the SDK version used. `/dev/null` in the test is just to make sure that no evaluation of `ESP8266_RTOS_SDK_DIR` in make is affected by the environment variable value which would be set to the SDK for people who followed the set up instructions before this change. Tested the checkout size: ```bash $ du -hs build/pkg/esp8266_sdk/ 124M build/pkg/esp8266_sdk/ ```
2021-05-01 15:39:25 +02:00
# esp8266 flags are added by the SDK pkg in pkg/esp8266_sdk
#LINKFLAGS += -L$(ESP_SDK_DIR)/components/$(CPU)
#LINKFLAGS += -L$(ESP_SDK_DIR)/components/$(CPU)/lib
#endif
2019-12-12 13:46:20 +01:00
LINKFLAGS += -nostdlib -Wl,-gc-sections -Wl,-static
# 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
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
# All ESP are flashed using esptool
PROGRAMMER ?= esptool
# Add esptool in the list supported programmers
PROGRAMMERS_SUPPORTED += esptool
# 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
ESPTOOL ?= $(RIOTTOOLS)/esptool/esptool.py
# 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".
BUILD_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin
TEST_EXTRA_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin
# Default partition table with no OTA. Can be replaced with a custom partition
# table setting PARTITION_TABLE_CSV.
PARTITION_TABLE_CSV ?= $(BINDIR)/partitions.csv
$(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, 0x10000, " >> $@
$(Q)ls -l $< | awk '{ print $$5 }' >> $@
$(BINDIR)/partitions.bin: $(PARTITION_TABLE_CSV)
$(Q)python3 $(RIOTTOOLS)/esptool/gen_esp32part.py --verify $< $@
# 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".
BUILD_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin
TEST_EXTRA_FILES += $(FLASHFILE) $(BINDIR)/partitions.bin