2018-09-05 02:39:50 +02:00
|
|
|
# check some environment variables first
|
|
|
|
|
2019-10-18 17:45:40 +02:00
|
|
|
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
|
2018-09-05 02:39:50 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Options to control the compilation
|
|
|
|
|
|
|
|
ifeq ($(ENABLE_GDB), 1)
|
|
|
|
USEMODULE += esp_gdb
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(ENABLE_GDBSTUB), 1)
|
|
|
|
USEMODULE += esp_gdbstub
|
2018-12-26 16:03:38 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
# SPECIAL module dependencies
|
|
|
|
# cannot be done in Makefile.dep since Makefile.dep is included too late
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
ifneq (, $(filter esp_now esp_wifi, $(USEMODULE)))
|
2019-01-16 19:30:59 +01:00
|
|
|
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
2019-10-17 13:46:04 +02:00
|
|
|
CFLAGS += -DSCHED_PRIO_LEVELS=32
|
2019-09-05 13:35:58 +02:00
|
|
|
USEMODULE += esp_wifi_any
|
2019-01-16 19:30:59 +01:00
|
|
|
USEMODULE += netopt
|
2019-09-05 13:35:58 +02:00
|
|
|
USEMODULE += xtimer
|
2019-01-16 19:30:59 +01:00
|
|
|
endif
|
|
|
|
|
2018-12-26 16:03:38 +01:00
|
|
|
ifneq (, $(filter esp_gdbstub, $(USEMODULE)))
|
2018-09-05 02:39:50 +02:00
|
|
|
USEMODULE += esp_gdb
|
|
|
|
endif
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
ifneq (, $(filter spiffs, $(USEMODULE)))
|
|
|
|
export RIOT_TEST_TIMEOUT = 300
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (, $(filter littlefs, $(USEMODULE)))
|
|
|
|
export RIOT_TEST_TIMEOUT = 300
|
|
|
|
endif
|
|
|
|
|
2018-09-05 02:39:50 +02:00
|
|
|
# regular Makefile
|
|
|
|
|
2019-10-18 19:06:35 +02:00
|
|
|
export TARGET_ARCH ?= xtensa-esp8266-elf
|
2018-09-05 02:39:50 +02:00
|
|
|
|
|
|
|
# ESP8266 pseudomodules
|
|
|
|
PSEUDOMODULES += esp_gdb
|
2019-09-05 13:35:58 +02:00
|
|
|
PSEUDOMODULES += esp_log_colored
|
|
|
|
PSEUDOMODULES += esp_log_tagged
|
|
|
|
PSEUDOMODULES += esp_qemu
|
2018-09-05 02:39:50 +02:00
|
|
|
PSEUDOMODULES += esp_sw_timer
|
|
|
|
PSEUDOMODULES += esp_spiffs
|
2019-09-05 13:35:58 +02:00
|
|
|
PSEUDOMODULES += esp_wifi_any
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2019-09-05 13:17:47 +02:00
|
|
|
USEMODULE += esp_freertos
|
2019-09-05 13:21:38 +02:00
|
|
|
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
|
2019-09-05 13:35:58 +02:00
|
|
|
USEMODULE += esp_sdk
|
|
|
|
USEMODULE += log
|
2018-12-26 16:03:38 +01:00
|
|
|
USEMODULE += mtd
|
2019-08-31 13:29:21 +02:00
|
|
|
USEMODULE += newlib
|
|
|
|
USEMODULE += newlib_syscalls_default
|
2018-12-26 16:03:38 +01:00
|
|
|
USEMODULE += periph
|
2019-09-05 13:35:58 +02:00
|
|
|
USEMODULE += periph_common
|
|
|
|
USEMODULE += periph_hrng
|
|
|
|
USEMODULE += periph_flash
|
|
|
|
USEMODULE += periph_uart
|
2018-12-26 16:03:38 +01:00
|
|
|
USEMODULE += ps
|
|
|
|
USEMODULE += random
|
2019-08-31 13:29:21 +02:00
|
|
|
USEMODULE += stdio_uart
|
2018-12-26 16:03:38 +01:00
|
|
|
USEMODULE += xtensa
|
|
|
|
|
2018-09-05 02:39:50 +02:00
|
|
|
INCLUDES += -I$(RIOTBOARD)/common/$(CPU)/include
|
2019-01-27 14:39:10 +01:00
|
|
|
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/
|
2018-09-05 02:39:50 +02:00
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)
|
2019-09-05 13:35:58 +02:00
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/include
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/include/freertos
|
2018-09-05 02:39:50 +02:00
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor
|
2019-09-05 13:35:58 +02:00
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/bootloader_support/include
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/esp8266/include
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/esp8266/include/esp8266
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/heap/include
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/log/include
|
2019-10-18 17:45:40 +02:00
|
|
|
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/
|
|
|
|
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/bootloader_support/include/
|
|
|
|
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/esp8266/include
|
|
|
|
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/esp8266/include/esp8266
|
|
|
|
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/heap/include
|
|
|
|
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
|
2019-09-05 13:35:58 +02:00
|
|
|
|
2019-10-22 18:57:39 +02:00
|
|
|
CFLAGS += -D__ESP_FILE__=__FILE__
|
2018-09-05 02:39:50 +02:00
|
|
|
CFLAGS += -Wno-unused-parameter -Wformat=0
|
2019-09-05 13:35:58 +02:00
|
|
|
CFLAGS += -mlongcalls -mtext-section-literals -fstrict-volatile-bitfields
|
|
|
|
CFLAGS += -fdata-sections -ffunction-sections -fzero-initialized-in-bss
|
|
|
|
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -fdiagnostics-color
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-truncation
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -gz
|
|
|
|
|
2018-09-05 02:39:50 +02:00
|
|
|
ASFLAGS += --longcalls --text-section-literals
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
# thin archives trigger a reboot loop - see #12258, #12035, #12346
|
|
|
|
ARFLAGS = rcs
|
2018-09-05 02:39:50 +02:00
|
|
|
|
|
|
|
ifneq (, $(filter esp_gdbstub, $(USEMODULE)))
|
|
|
|
GDBSTUB_DIR ?= $(RIOTCPU)/$(CPU)/vendor/esp-gdbstub
|
2019-09-05 13:35:58 +02:00
|
|
|
CFLAGS += -DGDBSTUB_BREAK_ON_INIT=1
|
2018-09-05 02:39:50 +02:00
|
|
|
INCLUDES += -I$(GDBSTUB_DIR)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (, $(filter esp_gdb, $(USEMODULE)))
|
2019-09-05 13:35:58 +02:00
|
|
|
CFLAGS_OPT ?= -Og -ggdb -g3
|
2018-09-05 02:39:50 +02:00
|
|
|
else
|
2019-09-05 13:35:58 +02:00
|
|
|
# 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
|
2018-09-05 02:39:50 +02:00
|
|
|
endif
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
CFLAGS += $(CFLAGS_OPT)
|
|
|
|
|
2018-09-05 02:39:50 +02:00
|
|
|
ifeq ($(QEMU), 1)
|
2019-09-05 13:35:58 +02:00
|
|
|
USEMODULE += esp_qemu
|
2018-09-05 02:39:50 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(FLASH_MODE), qio)
|
|
|
|
CFLAGS += -DFLASH_MODE_QIO
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(FLASH_MODE), qout)
|
|
|
|
CFLAGS += -DFLASH_MODE_QOUT
|
|
|
|
endif
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
LINKFLAGS += -L$(ESP8266_RTOS_SDK_DIR)/components/esp8266/lib
|
|
|
|
LINKFLAGS += $(CFLAGS_OPT)
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
BASELIBS += -lc -lgcc -lwpa -lcore -lnet80211 -lphy -lpp -lhal -lstdc++
|
|
|
|
|
|
|
|
ifneq (, $(filter esp_now, $(USEMODULE)))
|
|
|
|
BASELIBS += -lespnow
|
2018-09-05 02:39:50 +02:00
|
|
|
endif
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2018-12-19 17:45:41 +01:00
|
|
|
# The ELFFILE is the base one used for flashing
|
|
|
|
FLASHFILE ?= $(ELFFILE)
|
|
|
|
|
2018-09-05 02:39:50 +02:00
|
|
|
# configure preflasher to convert .elf to .bin before flashing
|
2019-09-05 13:35:58 +02:00
|
|
|
FLASH_MODE = dout # FIX configuration, DO NOT CHANGE
|
|
|
|
FLASH_FREQ = 26m # FIX configuration, DO NOT CHANGE
|
|
|
|
FLASH_SIZE ?= 1MB
|
2019-06-05 11:53:00 +02:00
|
|
|
FLASHDEPS += preflash
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2019-10-18 17:45:40 +02:00
|
|
|
PREFLASHER ?= $(ESP8266_RTOS_SDK_DIR)/components/esptool_py/esptool/esptool.py
|
2019-09-05 13:35:58 +02:00
|
|
|
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 += echo "" > $(BINDIR)/partitions.csv;
|
|
|
|
PREFFLAGS += echo "nvs, data, nvs, 0x9000, 0x6000" >> $(BINDIR)/partitions.csv;
|
|
|
|
PREFFLAGS += echo "phy_init, data, phy, 0xf000, 0x1000" >> $(BINDIR)/partitions.csv;
|
|
|
|
PREFFLAGS += echo -n "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 ?= bootloader_dout_115200_color.bin
|
|
|
|
else
|
|
|
|
BOOTLOADER ?= bootloader_dout_115200_no_color.bin
|
|
|
|
endif
|
|
|
|
|
|
|
|
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) 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
|
2018-09-05 02:39:50 +02:00
|
|
|
else
|
|
|
|
export PROGRAMMER_SPEED ?= 460800
|
2019-05-17 13:52:34 +02:00
|
|
|
FLASHER = esptool.py
|
2019-09-05 13:35:58 +02:00
|
|
|
FFLAGS += --chip esp8266 --port $(PORT) --baud $(PROGRAMMER_SPEED)
|
|
|
|
FFLAGS += --before default_reset --after hard_reset write_flash -z
|
|
|
|
FFLAGS += --flash_size detect
|
|
|
|
FFLAGS += --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ)
|
|
|
|
FFLAGS += 0x0000 $(RIOTCPU)/$(CPU)/bin/$(BOOTLOADER)
|
|
|
|
FFLAGS += 0x8000 $(BINDIR)/partitions.bin
|
|
|
|
FFLAGS += 0x10000 $(FLASHFILE).bin
|
2018-09-05 02:39:50 +02:00
|
|
|
endif
|