mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/esp*: common Makfile* added
This commit is contained in:
parent
b132698cd5
commit
53a3756e0c
@ -18,7 +18,7 @@ ifneq (, $(filter esp_wifi, $(USEMODULE)))
|
||||
DIRS += esp-wifi
|
||||
endif
|
||||
|
||||
ifneq (, $(filter riot_freertos, $(USEMODULE)))
|
||||
ifneq (, $(filter esp_freertos, $(USEMODULE)))
|
||||
DIRS += freertos
|
||||
endif
|
||||
|
||||
|
@ -1,46 +1,36 @@
|
||||
# additional modules dependencies
|
||||
|
||||
include $(RIOTCPU)/esp_common/Makefile.dep
|
||||
|
||||
ifneq (,$(filter cpp,$(FEATURES_USED)))
|
||||
USEMODULE += pthread
|
||||
BASELIBS += -lstdc++
|
||||
USEMODULE += pthread
|
||||
BASELIBS += -lstdc++
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_eth,$(USEMODULE)))
|
||||
USEMODULE += esp_idf_eth
|
||||
USEMODULE += esp_idf_eth_phy
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netopt
|
||||
USEMODULE += riot_freertos
|
||||
USEMODULE += xtimer
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/ethernet
|
||||
INCLUDES += -I$(ESP32_SDK_DIR)/components/ethernet/include
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_now,$(USEMODULE)))
|
||||
USEMODULE += esp_wifi_any
|
||||
USEMODULE += netopt
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_wifi,$(USEMODULE)))
|
||||
USEMODULE += esp_wifi_any
|
||||
USEMODULE += netopt
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += esp_freertos
|
||||
USEMODULE += esp_idf_eth
|
||||
USEMODULE += esp_idf_eth_phy
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netopt
|
||||
USEMODULE += xtimer
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/ethernet
|
||||
INCLUDES += -I$(ESP32_SDK_DIR)/components/ethernet/include
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
|
||||
# add additional modules used for any WiFi interface
|
||||
USEMODULE += esp_idf_heap
|
||||
USEMODULE += esp_idf_wpa_supplicant_crypto
|
||||
USEMODULE += esp_idf_wpa_supplicant_port
|
||||
USEMODULE += esp_idf_nvs_flash
|
||||
USEMODULE += riot_freertos
|
||||
USEMODULE += xtimer
|
||||
# add additional modules used for any WiFi interface
|
||||
USEMODULE += esp_freertos
|
||||
USEMODULE += esp_idf_heap
|
||||
USEMODULE += esp_idf_nvs_flash
|
||||
USEMODULE += esp_idf_wpa_supplicant_crypto
|
||||
USEMODULE += esp_idf_wpa_supplicant_port
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_idf_nvs_flash,$(USEMODULE)))
|
||||
# add additional modules required by esp_idf_nvs_flash
|
||||
USEMODULE += mtd
|
||||
USEMODULE += pthread
|
||||
# add additional modules required by esp_idf_nvs_flash
|
||||
USEMODULE += mtd
|
||||
USEMODULE += pthread
|
||||
endif
|
||||
|
||||
ifneq (,$(filter periph_rtc,$(USEMODULE)))
|
||||
@ -56,68 +46,32 @@ ifneq (,$(filter esp_rtc_timer_32k,$(USEMODULE)))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter periph_i2c,$(USEMODULE)))
|
||||
ifneq (,$(filter esp_i2c_hw,$(USEMODULE)))
|
||||
USEMODULE += core_thread_flags
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += periph_i2c_hw
|
||||
else
|
||||
# PLEASE NOTE: because of the very poor and faulty hardware implementation
|
||||
# we use software implementation by default for the moment (if module
|
||||
# esp_i2c_hw is not explicitly used)
|
||||
USEMODULE += esp_i2c_sw
|
||||
USEMODULE += periph_i2c_sw
|
||||
endif
|
||||
ifneq (,$(filter esp_i2c_hw,$(USEMODULE)))
|
||||
USEMODULE += core_thread_flags
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += periph_i2c_hw
|
||||
else
|
||||
# PLEASE NOTE: because of the very poor and faulty hardware implementation
|
||||
# we use software implementation by default for the moment (if module
|
||||
# esp_i2c_hw is not explicitly used)
|
||||
USEMODULE += esp_i2c_sw
|
||||
USEMODULE += periph_i2c_sw
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_spi_ram, $(DISABLE_MODULE)))
|
||||
USEMODULE := $(filter-out esp_spi_ram, $(USEMODULE))
|
||||
endif
|
||||
|
||||
# each device has SPI flash memory, but must be explicitly enabled
|
||||
ifneq (,$(filter esp_spiffs,$(USEMODULE)))
|
||||
USEMODULE += spiffs
|
||||
ifneq (,$(filter esp_spi_ram,$(DISABLE_MODULE)))
|
||||
USEMODULE := $(filter-out esp_spi_ram,$(USEMODULE))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter mtd,$(USEMODULE)))
|
||||
USEMODULE += esp_idf_spi_flash
|
||||
USEMODULE += esp_idf_spi_flash
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ndn-riot,$(USEPKG)))
|
||||
USEMODULE += crypto
|
||||
USEMODULE += cipher_modes
|
||||
USEMODULE += crypto
|
||||
USEMODULE += cipher_modes
|
||||
endif
|
||||
|
||||
ifneq (,$(filter shell,$(USEMODULE)))
|
||||
USEMODULE += ps
|
||||
endif
|
||||
|
||||
ifneq (,$(filter log_color,$(USEMODULE)))
|
||||
USEMODULE += esp_log_colored
|
||||
endif
|
||||
|
||||
# if SPI RAM is enabled, ESP-IDF heap and quot flash mode have to be used
|
||||
ifneq (,$(filter esp_spi_ram,$(USEMODULE)))
|
||||
USEMODULE += esp_idf_heap
|
||||
export FLASH_MODE = qout
|
||||
CFLAGS += -DFLASH_MODE_QOUT=1
|
||||
else
|
||||
ifeq ($(FLASH_MODE), qio)
|
||||
CFLAGS += -DFLASH_MODE_QIO=1
|
||||
endif
|
||||
ifeq ($(FLASH_MODE), qout)
|
||||
CFLAGS += -DFLASH_MODE_QOUT=1
|
||||
endif
|
||||
ifeq ($(FLASH_MODE), dio)
|
||||
CFLAGS += -DFLASH_MODE_DIO=1
|
||||
endif
|
||||
ifeq ($(FLASH_MODE), dout)
|
||||
CFLAGS += -DFLASH_MODE_DOUT=1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_idf_heap,$(USEMODULE)))
|
||||
LINKFLAGS += -Wl,-wrap,_malloc_r
|
||||
LINKFLAGS += -Wl,-wrap,_calloc_r
|
||||
LINKFLAGS += -Wl,-wrap,_realloc_r
|
||||
LINKFLAGS += -Wl,-wrap,_free_r
|
||||
USEMODULE += ps
|
||||
endif
|
||||
|
@ -1,9 +1,6 @@
|
||||
FEATURES_PROVIDED += arch_32bit
|
||||
# MCU defined features that are provided independent on board definitions
|
||||
|
||||
include $(RIOTCPU)/esp_common/Makefile.features
|
||||
|
||||
FEATURES_PROVIDED += arch_esp32
|
||||
FEATURES_PROVIDED += cpp
|
||||
FEATURES_PROVIDED += periph_cpuid
|
||||
FEATURES_PROVIDED += periph_hwrng
|
||||
FEATURES_PROVIDED += periph_pm
|
||||
FEATURES_PROVIDED += periph_rtc
|
||||
FEATURES_PROVIDED += periph_timer
|
||||
FEATURES_PROVIDED += ssp
|
||||
|
@ -1,123 +1,57 @@
|
||||
# check some environment variables first
|
||||
ifndef ESP32_SDK_DIR
|
||||
$(info ESP32_SDK_DIR should be defined as /path/to/esp-idf directory)
|
||||
$(info ESP32_SDK_DIR is set by default to /opt/esp/esp-idf)
|
||||
export ESP32_SDK_DIR=/opt/esp/esp-idf
|
||||
$(info ESP32_SDK_DIR should be defined as /path/to/esp-idf directory)
|
||||
$(info ESP32_SDK_DIR is set by default to /opt/esp/esp-idf)
|
||||
export ESP32_SDK_DIR=/opt/esp/esp-idf
|
||||
endif
|
||||
|
||||
# DEFAULT compile configuration
|
||||
ESP_SDK_DIR = $(ESP32_SDK_DIR)
|
||||
|
||||
# FLASH_MODE=[ dout | dio | qout | qio ]
|
||||
# use flash mode dout by default to keep GPIO9 and GPIO10 free for use
|
||||
export FLASH_MODE ?= dout
|
||||
# With the '-Os' option, the ESP32 hangs sporadically in 'tests/bench*' if
|
||||
# interrupts are disabled too early by benchmark tests.
|
||||
CFLAGS_OPT ?= -O2
|
||||
|
||||
# enable GDBSTUP for debugging on exceptions
|
||||
ifeq ($(ENABLE_GDBSTUB), 1)
|
||||
USEMODULE += esp_gdbstub
|
||||
endif
|
||||
|
||||
# enable GDB for compilation with debug info
|
||||
ifeq ($(ENABLE_GDB), 1)
|
||||
USEMODULE += esp_gdb
|
||||
endif
|
||||
|
||||
# enable modules at command line for testing
|
||||
ifneq ($(USE_MODULES), )
|
||||
USEMODULE += $(USE_MODULES)
|
||||
endif
|
||||
# ESP32 specific flashing options
|
||||
FLASH_CHIP = esp32
|
||||
FLASH_MODE ?= dout
|
||||
FLASH_FREQ = 40m # DO NOT CHANGE
|
||||
FLASH_SIZE ?= 4
|
||||
BOOTLOADER_POS = 0x1000
|
||||
|
||||
# SPECIAL module dependencies
|
||||
# cannot be done in Makefile.dep since Makefile.dep is included too late
|
||||
|
||||
ifneq (,$(findstring core_thread_flags,$(USEMODULE)))
|
||||
USEMODULE += pthread
|
||||
endif
|
||||
|
||||
ifneq (,$(filter cpp,$(FEATURES_USED)))
|
||||
USEMODULE += esp_cxx
|
||||
USEMODULE += esp_cxx
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_gdbstub,$(USEMODULE)))
|
||||
USEMODULE += esp_gdb
|
||||
ifneq (,$(filter esp_now esp_wifi esp_spi_ram,$(USEMODULE)))
|
||||
# the ESP-IDF heap has to be used if any WiFi interface or SPI RAM is used
|
||||
USEMODULE += esp_idf_heap
|
||||
endif
|
||||
|
||||
ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
|
||||
ifneq (,$(filter lwip,$(USEMODULE)))
|
||||
# for lwip, use esp_wifi as default netdev if no other netdev is enabled
|
||||
ifeq (,$(filter esp_eth,$(USEMODULE)))
|
||||
USEMODULE += esp_wifi
|
||||
endif
|
||||
else
|
||||
# otherwise use esp_now as default netdev if no other netdev is enabled
|
||||
ifeq (,$(filter esp_wifi esp_eth,$(USEMODULE)))
|
||||
USEMODULE += esp_now
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
include $(RIOTCPU)/esp_common/Makefile.include
|
||||
|
||||
ifneq (,$(filter esp_now,$(USEMODULE)))
|
||||
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
||||
USEMODULE += esp_wifi_any
|
||||
endif
|
||||
# regular Makefile
|
||||
|
||||
ifneq (,$(filter esp_wifi,$(USEMODULE)))
|
||||
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
||||
USEMODULE += esp_wifi_any
|
||||
endif
|
||||
TARGET_ARCH ?= xtensa-esp32-elf
|
||||
|
||||
ifneq (,$(filter esp_eth,$(USEMODULE)))
|
||||
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter spiffs,$(USEMODULE)))
|
||||
export RIOT_TEST_TIMEOUT = 120
|
||||
endif
|
||||
|
||||
ifneq (,$(filter littlefs,$(USEMODULE)))
|
||||
export RIOT_TEST_TIMEOUT = 120
|
||||
endif
|
||||
|
||||
ifneq (,$(filter 4 5,$(LOG_LEVEL)))
|
||||
USEMODULE += esp_log_startup
|
||||
endif
|
||||
|
||||
# ESP32 pseudomodules
|
||||
PSEUDOMODULES += esp_eth_hw
|
||||
PSEUDOMODULES += esp_gdb
|
||||
PSEUDOMODULES += esp_gdbstub
|
||||
PSEUDOMODULES += esp_hw_counter
|
||||
PSEUDOMODULES += esp_i2c_sw
|
||||
PSEUDOMODULES += esp_i2c_hw
|
||||
PSEUDOMODULES += esp_idf_newlib
|
||||
PSEUDOMODULES += esp_log_colored
|
||||
PSEUDOMODULES += esp_log_tagged
|
||||
PSEUDOMODULES += esp_log_startup
|
||||
PSEUDOMODULES += esp_rtc_timer
|
||||
PSEUDOMODULES += esp_rtc_timer_32k
|
||||
PSEUDOMODULES += esp_spi_ram
|
||||
PSEUDOMODULES += esp_spiffs
|
||||
PSEUDOMODULES += esp_wifi_any
|
||||
|
||||
export TARGET_ARCH ?= xtensa-esp32-elf
|
||||
|
||||
USEMODULE += esp_common
|
||||
USEMODULE += esp_idf
|
||||
USEMODULE += esp_idf_driver
|
||||
USEMODULE += esp_idf_esp32
|
||||
USEMODULE += esp_idf_soc
|
||||
USEMODULE += log
|
||||
USEMODULE += newlib
|
||||
USEMODULE += periph
|
||||
USEMODULE += periph_adc_ctrl
|
||||
USEMODULE += periph_hwrng
|
||||
USEMODULE += periph_flash
|
||||
USEMODULE += periph_uart
|
||||
USEMODULE += riot_freertos
|
||||
USEMODULE += random
|
||||
USEMODULE += stdio_uart
|
||||
USEMODULE += xtensa
|
||||
USEMODULE += periph_rtc
|
||||
|
||||
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/esp32
|
||||
@ -130,76 +64,20 @@ INCLUDES += -I$(ESP32_SDK_DIR)/components/esp32/include
|
||||
INCLUDES += -I$(ESP32_SDK_DIR)/components/heap/include
|
||||
INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/esp32/include
|
||||
INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/include
|
||||
INCLUDES += -I$(RIOTBOARD)/common/$(CPU)/include
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)
|
||||
|
||||
# if any WiFi interface is used, the number of priority levels has to be 32
|
||||
ifneq (,$(filter esp_wifi_any esp_eth,$(USEMODULE)))
|
||||
CFLAGS += -DSCHED_PRIO_LEVELS=32
|
||||
CFLAGS += -DSDK_NOT_USED -DCONFIG_FREERTOS_UNICORE=1 -DESP_PLATFORM
|
||||
CFLAGS += -DLOG_TAG_IN_BRACKETS
|
||||
|
||||
ifneq (,$(filter esp_now esp_wifi,$(USEMODULE)))
|
||||
BASELIBS += -lcore -lrtc -lnet80211 -lpp -lcoexist
|
||||
BASELIBS += -lwps -lwpa -lwpa2 -lphy -lstdc++
|
||||
endif
|
||||
|
||||
ifneq (,$(filter lwip,$(USEMODULE)))
|
||||
# The thread for handling the WiFi hardware has the priority. The priority
|
||||
# of the lwIP TCP/IP thread should be lower than this priority.
|
||||
CFLAGS += -DTCPIP_THREAD_PRIO=2
|
||||
ifneq (,$(filter esp_now,$(USEMODULE)))
|
||||
BASELIBS += -lespnow -lmesh
|
||||
endif
|
||||
|
||||
CFLAGS += -DSDK_NOT_USED -DCONFIG_FREERTOS_UNICORE=1 -DESP_PLATFORM
|
||||
CFLAGS += -DLOG_TAG_IN_BRACKETS
|
||||
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
|
||||
|
||||
ifneq ($(CONFIGS),)
|
||||
CFLAGS += $(CONFIGS)
|
||||
endif
|
||||
|
||||
# if any WiFi interface is used, the number of priority levels has to be 32
|
||||
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
|
||||
CFLAGS += -DSCHED_PRIO_LEVELS=32
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_gdb,$(USEMODULE)))
|
||||
CFLAGS += -Og -ggdb -g3
|
||||
else
|
||||
CFLAGS += -Os
|
||||
endif
|
||||
|
||||
ifeq ($(QEMU), 1)
|
||||
CFLAGS += -DQEMU
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
# LINKFLAGS += -Wl,--verbose
|
||||
|
||||
LINKFLAGS += -L$(ESP32_SDK_DIR)/components/esp32
|
||||
LINKFLAGS += -L$(ESP32_SDK_DIR)/components/esp32/lib
|
||||
|
||||
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
|
||||
BASELIBS += -lcore -lrtc -lnet80211 -lpp -lsmartconfig -lcoexist
|
||||
BASELIBS += -lwps -lwpa -lwpa2 -lespnow -lmesh -lphy -lstdc++
|
||||
endif
|
||||
|
||||
BASELIBS += -lhal -lg -lc
|
||||
|
||||
LINKFLAGS += -L$(RIOTCPU)/$(CPU)/ld/
|
||||
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.ld
|
||||
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.common.ld
|
||||
@ -209,53 +87,11 @@ LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.nanofmt.ld
|
||||
LINKFLAGS += -nostdlib -lgcc -Wl,-gc-sections
|
||||
|
||||
ifneq (,$(filter esp_cxx,$(USEMODULE)))
|
||||
UNDEF += $(BINDIR)/esp_cxx/cxa_guard.o
|
||||
UNDEF += $(BINDIR)/esp_cxx/cxa_guard.o
|
||||
endif
|
||||
|
||||
ESPTOOL ?= $(RIOTBASE)/dist/tools/esptool/esptool.py
|
||||
|
||||
# The ELFFILE is the base one used for flashing
|
||||
FLASHFILE ?= $(ELFFILE)
|
||||
|
||||
# configure preflasher to convert .elf to .bin before flashing
|
||||
FLASH_MODE ?= dout # FIX configuration, DO NOT CHANGE
|
||||
FLASH_FREQ = 40m # FIX configuration, DO NOT CHANGE
|
||||
FLASH_SIZE ?= 2MB
|
||||
|
||||
PREFLASHER = $(ESPTOOL)
|
||||
PREFFLAGS = --chip esp32 elf2image
|
||||
PREFFLAGS += -fm $(FLASH_MODE) -fs $(FLASH_SIZE) -ff $(FLASH_FREQ)
|
||||
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 += python $(RIOTTOOLS)/esptool/gen_esp32part.py
|
||||
PREFFLAGS += --verify $(BINDIR)/partitions.csv $(BINDIR)/partitions.bin
|
||||
FLASHDEPS += preflash
|
||||
|
||||
# flasher configuration
|
||||
ifeq ($(QEMU), 1)
|
||||
FLASHER = dd
|
||||
FFLAGS += if=/dev/zero bs=1M count=4 | tr "\\000" "\\377" > tmp.bin && cat tmp.bin |
|
||||
FFLAGS += head -c $$((0x1000)) |
|
||||
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 $$((0x400000)) > $(BINDIR)/esp32flash.bin && rm tmp.bin &&
|
||||
FFLAGS += cp $(RIOTCPU)/$(CPU)/bin/rom_0x3ff90000_0x00010000.bin $(BINDIR)/rom1.bin &&
|
||||
FFLAGS += cp $(RIOTCPU)/$(CPU)/bin/rom_0x40000000_0x000c2000.bin $(BINDIR)/rom.bin
|
||||
else
|
||||
export PROGRAMMER_SPEED ?= 460800
|
||||
FLASHER = $(ESPTOOL)
|
||||
FFLAGS += --chip esp32 -p $(PROG_DEV) -b $(PROGRAMMER_SPEED)
|
||||
FFLAGS += --before default_reset --after hard_reset write_flash
|
||||
FFLAGS += -z -fm $(FLASH_MODE) -fs detect -ff $(FLASH_FREQ)
|
||||
FFLAGS += 0x1000 $(RIOTCPU)/$(CPU)/bin/$(BOOTLOADER_BIN)
|
||||
FFLAGS += 0x8000 $(BINDIR)/partitions.bin
|
||||
FFLAGS += 0x10000 $(FLASHFILE).bin
|
||||
# additional flasher configuration for ESP32 QEMU
|
||||
ifneq (,$(filter esp_qemu,$(USEMODULE)))
|
||||
FFLAGS += cp $(RIOTCPU)/$(CPU)/bin/rom_0x3ff90000_0x00010000.bin $(BINDIR)/rom1.bin &&
|
||||
FFLAGS += cp $(RIOTCPU)/$(CPU)/bin/rom_0x40000000_0x000c2000.bin $(BINDIR)/rom.bin
|
||||
endif
|
||||
|
@ -1154,19 +1154,18 @@ Therefore, it is often necessary to change some of these default configurations
|
||||
|
||||
There are two ways to give the application the ability to change some of these default configurations:
|
||||
|
||||
- make variable ```CONFIGS```
|
||||
- make variable `CFLAGS`
|
||||
- application-specific board or driver configuration file
|
||||
|
||||
|
||||
## <a name="esp32_config_make_variable"> Make Variable ```CONFIGS``` </a> [[TOC](#esp32_toc)]
|
||||
## <a name="esp32_config_make_variable"> Make Variable `CFLAGS` </a> [[TOC](#esp32_toc)]
|
||||
|
||||
|
||||
Using the ```CONFIGS``` make variable at the command line, board or driver parameter definitions can be overridden.
|
||||
Using the `CFLAGS` make variable at the command line, board or driver parameter definitions can be overridden.
|
||||
|
||||
Example:
|
||||
```
|
||||
CONFIGS='-DESP_LCD_PLUGGED_IN=1 -DLIS3DH_PARAM_INT2=GPIO4'
|
||||
```
|
||||
`
|
||||
CFLAGS='-DESP_LCD_PLUGGED_IN=1 -DLIS3DH_PARAM_INT2=GPIO4'
|
||||
`
|
||||
|
||||
When a larger number of board definitions needs be overridden, this approach becomes impractical. In that case, an application-specific board configuration file located in application directory can be used, see sections below.
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
MODULE=riot_freertos
|
||||
MODULE=esp_freertos
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -1,15 +1,3 @@
|
||||
# additional modules dependencies
|
||||
|
||||
ifneq (, $(filter esp_spiffs, $(USEMODULE)))
|
||||
export SPIFFS_STD_OPTION = -std=c99
|
||||
USEMODULE += spiffs
|
||||
USEMODULE += vfs
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_wifi, $(USEMODULE)))
|
||||
USEMODULE += netdev_eth
|
||||
endif
|
||||
|
||||
ifneq (,$(filter log_color,$(USEMODULE)))
|
||||
USEMODULE += esp_log_colored
|
||||
endif
|
||||
include $(RIOTCPU)/esp_common/Makefile.dep
|
||||
|
@ -1,10 +1,5 @@
|
||||
# MCU defined features that are provided independent on board definitions
|
||||
|
||||
FEATURES_PROVIDED += arch_32bit
|
||||
include $(RIOTCPU)/esp_common/Makefile.features
|
||||
|
||||
FEATURES_PROVIDED += arch_esp8266
|
||||
FEATURES_PROVIDED += cpp
|
||||
FEATURES_PROVIDED += periph_cpuid
|
||||
FEATURES_PROVIDED += periph_hwrng
|
||||
FEATURES_PROVIDED += periph_pm
|
||||
FEATURES_PROVIDED += periph_timer
|
||||
FEATURES_PROVIDED += ssp
|
||||
|
@ -1,111 +1,44 @@
|
||||
# check some environment variables first
|
||||
|
||||
ifndef ESP8266_RTOS_SDK_DIR
|
||||
$(info ESP8266_RTOS_SDK_DIR should be defined as /path/to/sdk directory)
|
||||
$(info ESP8266_RTOS_SDK_DIR is set by default to /opt/esp/ESP8266-RTOS-SDK)
|
||||
export ESP8266_RTOS_SDK_DIR=/opt/esp/ESP8266-RTOS-SDK
|
||||
$(info ESP8266_RTOS_SDK_DIR should be defined as /path/to/sdk directory)
|
||||
$(info ESP8266_RTOS_SDK_DIR is set by default to /opt/esp/ESP8266-RTOS-SDK)
|
||||
export ESP8266_RTOS_SDK_DIR=/opt/esp/ESP8266-RTOS-SDK
|
||||
endif
|
||||
|
||||
# Options to control the compilation
|
||||
ESP_SDK_DIR = $(ESP8266_RTOS_SDK_DIR)
|
||||
|
||||
ifeq ($(ENABLE_GDB), 1)
|
||||
USEMODULE += esp_gdb
|
||||
endif
|
||||
# With the '-Os' option, char arrays have not to be 32-bit word aligned. This
|
||||
# leads to an alignment exception when the address of a char array is assigned
|
||||
# to an 'uint32_t' pointer and the pointer is used for the access.
|
||||
CFLAGS_OPT ?= -O2
|
||||
|
||||
ifeq ($(ENABLE_GDBSTUB), 1)
|
||||
USEMODULE += esp_gdbstub
|
||||
endif
|
||||
# ESP8266 specific flashing options
|
||||
FLASH_CHIP = esp8266
|
||||
FLASH_OPTS = --version 3
|
||||
FLASH_MODE = dout # DO NOT CHANGE, ESP8266/ESP8285 modules only work with dout
|
||||
FLASH_FREQ = 26m # DO NOT CHANGE
|
||||
FLASH_SIZE ?= 1
|
||||
BOOTLOADER_POS = 0x0000
|
||||
|
||||
# SPECIAL module dependencies
|
||||
# cannot be done in Makefile.dep since Makefile.dep is included too late
|
||||
|
||||
ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
|
||||
ifneq (,$(filter lwip,$(USEMODULE)))
|
||||
# for lwip, use esp_wifi as default netdev if no other netdev is enabled
|
||||
USEMODULE += esp_wifi
|
||||
else
|
||||
# otherwise use esp_now as default netdev if no other netdev is enabled
|
||||
ifeq (,$(filter esp_wifi esp_eth,$(USEMODULE)))
|
||||
USEMODULE += esp_now
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_wifi, $(USEMODULE)))
|
||||
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
||||
USEMODULE += esp_wifi_any
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_now, $(USEMODULE)))
|
||||
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
||||
USEMODULE += esp_wifi_any
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_wifi_any, $(USEMODULE)))
|
||||
CFLAGS += -DSCHED_PRIO_LEVELS=32
|
||||
USEMODULE += netopt
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_gdbstub, $(USEMODULE)))
|
||||
USEMODULE += esp_gdb
|
||||
endif
|
||||
|
||||
ifneq (, $(filter spiffs, $(USEMODULE)))
|
||||
export RIOT_TEST_TIMEOUT = 200
|
||||
endif
|
||||
|
||||
ifneq (, $(filter littlefs, $(USEMODULE)))
|
||||
export RIOT_TEST_TIMEOUT = 200
|
||||
endif
|
||||
|
||||
ifneq (,$(filter log_color,$(USEMODULE)))
|
||||
USEMODULE += esp_log_colored
|
||||
endif
|
||||
|
||||
ifneq (,$(filter 4 5,$(LOG_LEVEL)))
|
||||
USEMODULE += esp_log_startup
|
||||
endif
|
||||
include $(RIOTCPU)/esp_common/Makefile.include
|
||||
|
||||
# regular Makefile
|
||||
|
||||
export TARGET_ARCH ?= xtensa-esp8266-elf
|
||||
TARGET_ARCH ?= xtensa-esp8266-elf
|
||||
|
||||
# ESP8266 pseudomodules
|
||||
PSEUDOMODULES += esp_gdb
|
||||
PSEUDOMODULES += esp_log_colored
|
||||
PSEUDOMODULES += esp_log_tagged
|
||||
PSEUDOMODULES += esp_log_startup
|
||||
PSEUDOMODULES += esp_qemu
|
||||
PSEUDOMODULES += esp_sw_timer
|
||||
PSEUDOMODULES += esp_spiffs
|
||||
PSEUDOMODULES += esp_wifi_any
|
||||
|
||||
USEMODULE += esp_common
|
||||
USEMODULE += esp_freertos
|
||||
USEMODULE += esp_idf
|
||||
USEMODULE += esp_idf_esp8266
|
||||
USEMODULE += esp_idf_nvs_flash
|
||||
USEMODULE += esp_idf_spi_flash
|
||||
USEMODULE += esp_idf_util
|
||||
USEMODULE += esp_idf_wpa_supplicant_crypto
|
||||
USEMODULE += esp_sdk
|
||||
USEMODULE += log
|
||||
USEMODULE += mtd
|
||||
USEMODULE += newlib
|
||||
USEMODULE += newlib_syscalls_default
|
||||
USEMODULE += periph
|
||||
USEMODULE += periph_common
|
||||
USEMODULE += periph_hrng
|
||||
USEMODULE += periph_flash
|
||||
USEMODULE += periph_uart
|
||||
USEMODULE += ps
|
||||
USEMODULE += random
|
||||
USEMODULE += stdio_uart
|
||||
USEMODULE += xtensa
|
||||
|
||||
INCLUDES += -I$(RIOTBOARD)/common/$(CPU)/include
|
||||
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)/include
|
||||
INCLUDES += -I$(RIOTCPU)/$(CPU)/include/freertos
|
||||
@ -125,135 +58,23 @@ INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/heap/port/esp8266/include
|
||||
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/nvs_flash/include
|
||||
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/spi_flash/include
|
||||
|
||||
CFLAGS += -D__ESP_FILE__=__FILE__
|
||||
CFLAGS += -Wno-unused-parameter -Wformat=0
|
||||
CFLAGS += -mlongcalls -mtext-section-literals -fstrict-volatile-bitfields
|
||||
CFLAGS += -fdata-sections -ffunction-sections -fzero-initialized-in-bss
|
||||
CFLAGS += -D__ESP_FILE__=__FILE__
|
||||
|
||||
OPTIONAL_CFLAGS_BLACKLIST += -fdiagnostics-color
|
||||
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
|
||||
|
||||
ifneq (,$(filter lwip,$(USEMODULE)))
|
||||
# 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.
|
||||
CFLAGS += -DTCPIP_THREAD_PRIO=5
|
||||
ifneq (,$(filter esp_gdbstub,$(USEMODULE)))
|
||||
GDBSTUB_DIR ?= $(RIOTCPU)/$(CPU)/vendor/esp-gdbstub
|
||||
CFLAGS += -DGDBSTUB_BREAK_ON_INIT=1
|
||||
INCLUDES += -I$(GDBSTUB_DIR)
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_gdbstub, $(USEMODULE)))
|
||||
GDBSTUB_DIR ?= $(RIOTCPU)/$(CPU)/vendor/esp-gdbstub
|
||||
CFLAGS += -DGDBSTUB_BREAK_ON_INIT=1
|
||||
INCLUDES += -I$(GDBSTUB_DIR)
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_gdb, $(USEMODULE)))
|
||||
CFLAGS_OPT ?= -Og -ggdb -g3
|
||||
else
|
||||
# TODO should be -Os
|
||||
# With -Os char arrays have not to be 32-bit word aligned. This leads to
|
||||
# an alignment exception when the address of an char array is assigned to
|
||||
# an uint32_t pointer and the pointer is used for the access.
|
||||
CFLAGS_OPT ?= -O2
|
||||
endif
|
||||
|
||||
CFLAGS += $(CFLAGS_OPT)
|
||||
|
||||
ifeq ($(QEMU), 1)
|
||||
USEMODULE += esp_qemu
|
||||
endif
|
||||
|
||||
ifeq ($(FLASH_MODE), qio)
|
||||
CFLAGS += -DFLASH_MODE_QIO
|
||||
endif
|
||||
|
||||
ifeq ($(FLASH_MODE), qout)
|
||||
CFLAGS += -DFLASH_MODE_QOUT
|
||||
endif
|
||||
|
||||
LINKFLAGS += -L$(ESP8266_RTOS_SDK_DIR)/components/esp8266/lib
|
||||
LINKFLAGS += $(CFLAGS_OPT)
|
||||
|
||||
BASELIBS += -lc -lgcc -lwpa -lcore -lnet80211 -lphy -lpp -lhal -lstdc++
|
||||
BASELIBS += -lgcc -lwpa -lcore -lnet80211 -lphy -lpp -lstdc++
|
||||
|
||||
ifneq (, $(filter esp_now, $(USEMODULE)))
|
||||
BASELIBS += -lespnow
|
||||
BASELIBS += -lespnow
|
||||
endif
|
||||
|
||||
LINKFLAGS += -u _malloc_r
|
||||
LINKFLAGS += -nostdlib -Wl,-gc-sections -Wl,-static # -Wl,--print-gc-sections
|
||||
|
||||
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp8266.rom.ld
|
||||
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp8266.riot-os.ld
|
||||
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp8266.peripherals.ld
|
||||
|
||||
LINKFLAGS += -Wl,-wrap=pp_attach
|
||||
LINKFLAGS += -Wl,-wrap=pm_attach
|
||||
|
||||
ifneq (, $(filter esp_idf_heap, $(USEMODULE)))
|
||||
LINKFLAGS += -Wl,-wrap=_malloc_r
|
||||
LINKFLAGS += -Wl,-wrap=_calloc_r
|
||||
LINKFLAGS += -Wl,-wrap=_free_r
|
||||
LINKFLAGS += -Wl,-wrap=_realloc_r
|
||||
endif
|
||||
|
||||
# The ELFFILE is the base one used for flashing
|
||||
FLASHFILE ?= $(ELFFILE)
|
||||
|
||||
# configure preflasher to convert .elf to .bin before flashing
|
||||
FLASH_MODE = dout # FIX configuration, DO NOT CHANGE
|
||||
FLASH_FREQ = 26m # FIX configuration, DO NOT CHANGE
|
||||
FLASH_SIZE ?= 1MB
|
||||
FLASHDEPS += preflash
|
||||
|
||||
PREFLASHER ?= $(RIOTTOOLS)/esptool/esptool.py
|
||||
PREFFLAGS = --chip esp8266 elf2image
|
||||
PREFFLAGS += --flash_mode $(FLASH_MODE) --flash_size $(FLASH_SIZE)
|
||||
PREFFLAGS += --flash_freq $(FLASH_FREQ) --version 3
|
||||
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 += python $(RIOTCPU)/$(CPU)/vendor/esp-idf/partition_table/gen_esp32part.py
|
||||
PREFFLAGS += --verify $(BINDIR)/partitions.csv $(BINDIR)/partitions.bin
|
||||
|
||||
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
|
||||
|
||||
ifneq (, $(filter esp_qemu, $(USEMODULE)))
|
||||
FLASHER = dd
|
||||
FFLAGS += if=/dev/zero bs=1M count=1 | tr "\\000" "\\377" > tmp.bin &&
|
||||
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 $$((0xfc000)) |
|
||||
FFLAGS += cat - $(RIOTCPU)/$(CPU)/bin/esp_init_data_default.bin tmp.bin |
|
||||
FFLAGS += head -c $$((0x100000)) > $(BINDIR)/esp8266flash.bin && rm tmp.bin
|
||||
else
|
||||
export PROGRAMMER_SPEED ?= 460800
|
||||
FLASHER = $(RIOTBASE)/dist/tools/esptool/esptool.py
|
||||
FFLAGS += --chip esp8266 --port $(PROG_DEV) --baud $(PROGRAMMER_SPEED)
|
||||
FFLAGS += --before default_reset write_flash -z
|
||||
FFLAGS += --flash_size detect
|
||||
FFLAGS += --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ)
|
||||
FFLAGS += 0x0000 $(RIOTCPU)/$(CPU)/bin/$(BOOTLOADER_BIN)
|
||||
FFLAGS += 0x8000 $(BINDIR)/partitions.bin
|
||||
FFLAGS += 0x10000 $(FLASHFILE).bin
|
||||
endif
|
||||
|
27
cpu/esp_common/Makefile.dep
Normal file
27
cpu/esp_common/Makefile.dep
Normal file
@ -0,0 +1,27 @@
|
||||
# additional modules dependencies
|
||||
|
||||
# each device has SPI flash memory, but it has to be enabled explicitly
|
||||
ifneq (,$(filter esp_spiffs, $(USEMODULE)))
|
||||
USEMODULE += spiffs
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_now, $(USEMODULE)))
|
||||
USEMODULE += esp_wifi_any
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_wifi, $(USEMODULE)))
|
||||
USEMODULE += esp_wifi_any
|
||||
USEMODULE += netdev_eth
|
||||
endif
|
||||
|
||||
ifneq (, $(filter esp_wifi_any, $(USEMODULE)))
|
||||
USEMODULE += netopt
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_idf_heap,$(USEMODULE)))
|
||||
LINKFLAGS += -Wl,-wrap,_malloc_r
|
||||
LINKFLAGS += -Wl,-wrap,_calloc_r
|
||||
LINKFLAGS += -Wl,-wrap,_realloc_r
|
||||
LINKFLAGS += -Wl,-wrap,_free_r
|
||||
endif
|
9
cpu/esp_common/Makefile.features
Normal file
9
cpu/esp_common/Makefile.features
Normal file
@ -0,0 +1,9 @@
|
||||
# MCU defined features that are provided independent on board definitions
|
||||
|
||||
FEATURES_PROVIDED += arch_32bit
|
||||
FEATURES_PROVIDED += cpp
|
||||
FEATURES_PROVIDED += periph_cpuid
|
||||
FEATURES_PROVIDED += periph_hwrng
|
||||
FEATURES_PROVIDED += periph_pm
|
||||
FEATURES_PROVIDED += periph_timer
|
||||
FEATURES_PROVIDED += ssp
|
204
cpu/esp_common/Makefile.include
Normal file
204
cpu/esp_common/Makefile.include
Normal file
@ -0,0 +1,204 @@
|
||||
# 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
|
||||
|
||||
# SPECIAL module dependencies
|
||||
# cannot be done in Makefile.dep since Makefile.dep is included too late
|
||||
|
||||
# use esp_now as default netdev if no other netdev module is enabled
|
||||
ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE)))
|
||||
ifeq (,$(filter esp_wifi esp_eth,$(USEMODULE)))
|
||||
USEMODULE += esp_now
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_gdbstub,$(USEMODULE)))
|
||||
USEMODULE += esp_gdb
|
||||
endif
|
||||
|
||||
ifneq (,$(filter log_color,$(USEMODULE)))
|
||||
USEMODULE += esp_log_colored
|
||||
endif
|
||||
|
||||
ifneq (,$(filter 4 5,$(LOG_LEVEL)))
|
||||
USEMODULE += esp_log_startup
|
||||
endif
|
||||
|
||||
# ESP* pseudomodules
|
||||
|
||||
PSEUDOMODULES += esp_gdb
|
||||
PSEUDOMODULES += esp_log_colored
|
||||
PSEUDOMODULES += esp_log_tagged
|
||||
PSEUDOMODULES += esp_log_startup
|
||||
PSEUDOMODULES += esp_qemu
|
||||
PSEUDOMODULES += esp_spiffs
|
||||
PSEUDOMODULES += esp_wifi_any
|
||||
|
||||
# Modules used by ESP*
|
||||
|
||||
USEMODULE += esp_freertos
|
||||
USEMODULE += esp_idf
|
||||
USEMODULE += log
|
||||
USEMODULE += newlib
|
||||
USEMODULE += periph
|
||||
USEMODULE += periph_hwrng
|
||||
USEMODULE += periph_flash
|
||||
USEMODULE += periph_uart
|
||||
USEMODULE += random
|
||||
USEMODULE += stdio_uart
|
||||
USEMODULE += xtensa
|
||||
|
||||
# Common includes
|
||||
|
||||
INCLUDES += -I$(RIOTBOARD)/common/$(CPU)/include
|
||||
INCLUDES += -I$(RIOTCPU)/esp_common
|
||||
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/
|
||||
|
||||
# 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
|
||||
CFLAGS_OPT ?= -Os
|
||||
|
||||
# override default CFLAGS_OPT in case module esp_gdb is enabled
|
||||
ifneq (,$(filter esp_gdb,$(USEMODULE)))
|
||||
CFLAGS_OPT = -Og
|
||||
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 esp_now esp_eth,$(USEMODULE)))
|
||||
CFLAGS += -DSCHED_PRIO_LEVELS=32
|
||||
endif
|
||||
|
||||
# lwIP thread priority has to be lower than that of ESP hardware driver threads
|
||||
ifneq (,$(filter lwip,$(USEMODULE)))
|
||||
CFLAGS += -DTCPIP_THREAD_PRIO=5
|
||||
endif
|
||||
|
||||
# if SPI RAM is enabled, the qout flash mode has to be used
|
||||
ifneq (,$(filter esp_spi_ram,$(USEMODULE)))
|
||||
export FLASH_MODE = qout
|
||||
CFLAGS += -DFLASH_MODE_QOUT=1
|
||||
else
|
||||
ifeq ($(FLASH_MODE), qio)
|
||||
CFLAGS += -DFLASH_MODE_QIO=1
|
||||
endif
|
||||
ifeq ($(FLASH_MODE), qout)
|
||||
CFLAGS += -DFLASH_MODE_QOUT=1
|
||||
endif
|
||||
ifeq ($(FLASH_MODE), dio)
|
||||
CFLAGS += -DFLASH_MODE_DIO=1
|
||||
endif
|
||||
ifeq ($(FLASH_MODE), dout)
|
||||
CFLAGS += -DFLASH_MODE_DOUT=1
|
||||
endif
|
||||
endif
|
||||
|
||||
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 += python $(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,$(USEMODULE)))
|
||||
export RIOT_TEST_TIMEOUT = 120
|
||||
endif
|
||||
|
||||
ifneq (,$(filter littlefs,$(USEMODULE)))
|
||||
export RIOT_TEST_TIMEOUT = 120
|
||||
endif
|
||||
|
||||
# increase the number of netif for each enabled network interface
|
||||
|
||||
ifneq (,$(filter esp_wifi,$(USEMODULE)))
|
||||
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_now,$(USEMODULE)))
|
||||
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_eth,$(USEMODULE)))
|
||||
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
||||
endif
|
Loading…
Reference in New Issue
Block a user