2018-10-08 12:20:49 +02:00
|
|
|
# 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
|
|
|
|
endif
|
|
|
|
|
|
|
|
# DEFAULT compile configuration
|
|
|
|
|
|
|
|
# FLASH_MODE=[ dout | dio | qout | qio ]
|
|
|
|
# use flash mode dout by default to keep GPIO9 and GPIO10 free for use
|
|
|
|
export FLASH_MODE ?= dout
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# SPECIAL module dependencies
|
|
|
|
# cannot be done in Makefile.dep since Makefile.dep is included too late
|
|
|
|
|
2018-10-14 13:50:38 +02:00
|
|
|
ifneq (,$(findstring core_thread_flags,$(USEMODULE)))
|
|
|
|
USEMODULE += pthread
|
|
|
|
endif
|
|
|
|
|
2019-08-21 22:55:08 +02:00
|
|
|
ifneq (,$(filter cpp,$(FEATURES_USED)))
|
|
|
|
USEMODULE += esp_cxx
|
|
|
|
endif
|
|
|
|
|
2018-10-08 12:20:49 +02:00
|
|
|
ifneq (,$(filter esp_gdbstub,$(USEMODULE)))
|
|
|
|
USEMODULE += esp_gdb
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$(filter esp_now,$(USEMODULE)))
|
2019-02-02 14:37:21 +01:00
|
|
|
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
2018-10-08 12:20:49 +02:00
|
|
|
USEMODULE += esp_wifi_any
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$(filter esp_wifi,$(USEMODULE)))
|
2019-02-02 14:37:21 +01:00
|
|
|
$(eval GNRC_NETIF_NUMOF=$(shell echo $$(($(GNRC_NETIF_NUMOF)+1))))
|
2018-10-08 12:20:49 +02:00
|
|
|
USEMODULE += esp_wifi_any
|
|
|
|
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_spi_ram
|
|
|
|
PSEUDOMODULES += esp_spiffs
|
|
|
|
PSEUDOMODULES += esp_wifi_any
|
|
|
|
|
|
|
|
export TARGET_ARCH ?= xtensa-esp32-elf
|
|
|
|
export ESPTOOL ?= $(ESP32_SDK_DIR)/components/esptool_py/esptool/esptool.py
|
|
|
|
|
|
|
|
USEMODULE += esp_idf
|
|
|
|
USEMODULE += esp_idf_driver
|
|
|
|
USEMODULE += esp_idf_esp32
|
|
|
|
USEMODULE += esp_idf_soc
|
|
|
|
USEMODULE += log
|
2019-08-19 14:29:28 +02:00
|
|
|
USEMODULE += newlib
|
2018-10-08 12:20:49 +02:00
|
|
|
USEMODULE += periph
|
2019-04-04 00:22:16 +02:00
|
|
|
USEMODULE += periph_adc_ctrl
|
|
|
|
USEMODULE += periph_hwrng
|
|
|
|
USEMODULE += periph_flash
|
|
|
|
USEMODULE += periph_rtc
|
|
|
|
USEMODULE += periph_uart
|
2019-08-05 14:55:00 +02:00
|
|
|
USEMODULE += riot_freertos
|
2018-10-08 12:20:49 +02:00
|
|
|
USEMODULE += random
|
2019-04-11 16:22:47 +02:00
|
|
|
USEMODULE += stdio_uart
|
2018-10-08 12:20:49 +02:00
|
|
|
USEMODULE += xtensa
|
|
|
|
|
2019-01-27 14:38:27 +01:00
|
|
|
INCLUDES += -I$(RIOTCPU)/esp_common/vendor/
|
2018-10-08 12:20:49 +02:00
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/esp32
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/heap
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/spi_flash
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/tcpip_adapter
|
|
|
|
INCLUDES += -I$(ESP32_SDK_DIR)/components/
|
|
|
|
INCLUDES += -I$(ESP32_SDK_DIR)/components/driver/include
|
|
|
|
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)
|
|
|
|
|
|
|
|
CFLAGS += -DSCHED_PRIO_LEVELS=32
|
|
|
|
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
|
2019-08-06 07:39:33 +02:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections -fzero-initialized-in-bss
|
2019-08-28 19:43:17 +02:00
|
|
|
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-truncation
|
2019-08-28 18:40:38 +02:00
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -gz
|
2019-08-28 19:43:17 +02:00
|
|
|
|
2018-10-08 12:20:49 +02:00
|
|
|
ASFLAGS += --longcalls --text-section-literals
|
|
|
|
|
2019-10-01 09:00:56 +02:00
|
|
|
# thin archives trigger a reboot loop - see #12258, #12035, #12346
|
|
|
|
ARFLAGS = rcs
|
|
|
|
|
2018-10-08 12:20:49 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
# LINKFLAGS += -Wl,--verbose
|
|
|
|
|
|
|
|
LINKFLAGS += -L$(ESP32_SDK_DIR)/components/esp32
|
|
|
|
LINKFLAGS += -L$(ESP32_SDK_DIR)/components/esp32/lib
|
|
|
|
|
|
|
|
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
|
2018-11-23 18:04:19 +01:00
|
|
|
BASELIBS += -lcore -lrtc -lnet80211 -lpp -lsmartconfig -lcoexist
|
|
|
|
BASELIBS += -lwps -lwpa -lwpa2 -lespnow -lmesh -lphy -lstdc++
|
2018-10-08 12:20:49 +02:00
|
|
|
endif
|
|
|
|
|
2019-08-06 07:51:39 +02:00
|
|
|
BASELIBS += -lhal -lg -lc
|
|
|
|
|
2018-10-08 12:20:49 +02:00
|
|
|
LINKFLAGS += -L$(RIOTCPU)/$(CPU)/ld/
|
|
|
|
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.ld
|
|
|
|
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.common.ld
|
|
|
|
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.peripherals.ld
|
|
|
|
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.ld
|
|
|
|
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.nanofmt.ld
|
2019-08-06 07:58:10 +02:00
|
|
|
LINKFLAGS += -nostdlib -lgcc -Wl,-gc-sections
|
2019-08-06 07:39:33 +02:00
|
|
|
|
2019-08-21 22:55:08 +02:00
|
|
|
ifneq (,$(filter esp_cxx,$(USEMODULE)))
|
|
|
|
UNDEF += $(BINDIR)/esp_cxx/cxa_guard.o
|
|
|
|
endif
|
|
|
|
|
2018-12-19 17:44:09 +01:00
|
|
|
# The ELFFILE is the base one used for flashing
|
|
|
|
FLASHFILE ?= $(ELFFILE)
|
|
|
|
|
2018-10-08 12:20:49 +02:00
|
|
|
# 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
|
2019-04-18 09:44:29 +02:00
|
|
|
FLASH_SIZE ?= 2MB
|
2019-05-17 13:52:34 +02:00
|
|
|
PREFLASHER = $(ESPTOOL)
|
|
|
|
PREFFLAGS = --chip esp32 elf2image
|
|
|
|
PREFFLAGS += -fm $(FLASH_MODE) -fs $(FLASH_SIZE) -ff $(FLASH_FREQ)
|
2018-12-19 17:44:09 +01:00
|
|
|
PREFFLAGS += -o $(FLASHFILE).bin $(FLASHFILE);
|
2019-09-24 15:34:54 +02:00
|
|
|
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;
|
2018-12-19 17:44:09 +01:00
|
|
|
PREFFLAGS += ls -l $(FLASHFILE).bin | awk '{ print $$5 }' >> $(BINDIR)/partitions.csv;
|
2019-05-17 13:52:34 +02:00
|
|
|
|
2019-09-24 15:34:54 +02:00
|
|
|
|
2019-05-17 13:52:34 +02:00
|
|
|
PREFFLAGS += python $(RIOTCPU)/$(CPU)/gen_esp32part.py --disable-sha256sum
|
|
|
|
PREFFLAGS += --verify $(BINDIR)/partitions.csv $(BINDIR)/partitions.bin
|
2019-06-05 11:53:00 +02:00
|
|
|
FLASHDEPS += preflash
|
2018-10-08 12:20:49 +02:00
|
|
|
|
|
|
|
# flasher configuration
|
|
|
|
ifeq ($(QEMU), 1)
|
2019-05-17 13:52:34 +02:00
|
|
|
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)) |
|
2018-12-19 17:44:09 +01:00
|
|
|
FFLAGS += cat - $(FLASHFILE).bin tmp.bin |
|
2019-05-17 13:52:34 +02:00
|
|
|
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
|
2018-10-08 12:20:49 +02:00
|
|
|
else
|
|
|
|
export PROGRAMMER_SPEED ?= 460800
|
2019-05-17 13:52:34 +02:00
|
|
|
FLASHER = $(ESPTOOL)
|
2019-10-15 14:29:51 +02:00
|
|
|
FFLAGS += --chip esp32 -p $(PROG_DEV) -b $(PROGRAMMER_SPEED)
|
2019-05-17 13:52:34 +02:00
|
|
|
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
|
2018-12-19 17:44:09 +01:00
|
|
|
FFLAGS += 0x10000 $(FLASHFILE).bin
|
2018-10-08 12:20:49 +02:00
|
|
|
endif
|