mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 22:13:52 +01:00
In vendor startup code, initialization function were called as parameters of assert statement. With DEVELHELP, they are not called since the assert macro does nothing.
217 lines
7.2 KiB
Makefile
217 lines
7.2 KiB
Makefile
# 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
|
|
endif
|
|
|
|
# Options to control the compilation
|
|
|
|
ifeq ($(ENABLE_GDB), 1)
|
|
USEMODULE += esp_gdb
|
|
endif
|
|
|
|
ifeq ($(ENABLE_GDBSTUB), 1)
|
|
USEMODULE += esp_gdbstub
|
|
endif
|
|
|
|
# SPECIAL module dependencies
|
|
# cannot be done in Makefile.dep since Makefile.dep is included too late
|
|
|
|
ifneq (, $(filter esp_now esp_wifi, $(USEMODULE)))
|
|
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
|
CFLAGS += -DSCHED_PRIO_LEVELS=32
|
|
USEMODULE += esp_wifi_any
|
|
USEMODULE += netopt
|
|
USEMODULE += xtimer
|
|
endif
|
|
|
|
ifneq (, $(filter esp_gdbstub, $(USEMODULE)))
|
|
USEMODULE += esp_gdb
|
|
endif
|
|
|
|
ifneq (, $(filter spiffs, $(USEMODULE)))
|
|
export RIOT_TEST_TIMEOUT = 300
|
|
endif
|
|
|
|
ifneq (, $(filter littlefs, $(USEMODULE)))
|
|
export RIOT_TEST_TIMEOUT = 300
|
|
endif
|
|
|
|
# regular Makefile
|
|
|
|
export TARGET_ARCH ?= xtensa-esp8266-elf
|
|
|
|
# ESP8266 pseudomodules
|
|
PSEUDOMODULES += esp_gdb
|
|
PSEUDOMODULES += esp_log_colored
|
|
PSEUDOMODULES += esp_log_tagged
|
|
PSEUDOMODULES += esp_qemu
|
|
PSEUDOMODULES += esp_sw_timer
|
|
PSEUDOMODULES += esp_spiffs
|
|
PSEUDOMODULES += esp_wifi_any
|
|
|
|
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
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor
|
|
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
|
|
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
|
|
|
|
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
|
|
|
|
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 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++
|
|
|
|
ifneq (, $(filter esp_now, $(USEMODULE)))
|
|
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
|
|
|
|
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 ?= $(ESP8266_RTOS_SDK_DIR)/components/esptool_py/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 += 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
|
|
else
|
|
export PROGRAMMER_SPEED ?= 460800
|
|
FLASHER = esptool.py
|
|
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
|
|
endif
|