1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/esp32/Makefile.include
Gunar Schorcht c8de46ddee cpu/{esp_common,esp8266,esp32}: fix default FLASH_* configuration
This commit includes the following changes:
- the default flash mode in bootloader should be dio and not dout
- the default flash configuration for ESP32 has to be exported to be also visible in cpu/esp32/bootloader/Makefile
- the comments in  cpu/esp8266/Makefile.include have to be removed so that the flash configuration do not contain trailing white spaces
2022-08-02 07:24:30 +02:00

196 lines
7.2 KiB
Makefile

# ESP32x specific flashing options
FLASH_CHIP = $(CPU_FAM)
# Serial flasher config as used by the ESP-IDF, be careful when overriding them.
# They have to be exported to use same values in subsequent makefiles.
ifeq (esp32,$(CPU_FAM))
export FLASH_MODE ?= dout
export FLASH_FREQ ?= 40m
export FLASH_SIZE ?= 2
BOOTLOADER_POS = 0x1000
else ifeq (esp32c3,$(CPU_FAM))
export FLASH_MODE ?= dio
export FLASH_FREQ ?= 80m
export FLASH_SIZE ?= 2
BOOTLOADER_POS = 0x0000
else
$(error Unkwnown ESP32x SoC variant (family))
endif
ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool_v3.2.py
include $(RIOTCPU)/esp_common/Makefile.include
# regular Makefile
ifeq (xtensa,$(CPU_ARCH))
TARGET_ARCH ?= xtensa-$(CPU_FAM)-elf
else ifeq (rv32,$(CPU_ARCH))
TARGET_ARCH ?= riscv32-esp-elf
else
$(error Unkwnown ESP32x SoC architecture)
endif
PSEUDOMODULES += esp_bootloader
PSEUDOMODULES += esp_gdbstub
PSEUDOMODULES += esp_hw_counter
PSEUDOMODULES += esp_idf_gpio_hal
PSEUDOMODULES += esp_i2c_hw
PSEUDOMODULES += esp_jtag
PSEUDOMODULES += esp_rtc_timer_32k
PSEUDOMODULES += esp_spi_ram
PSEUDOMODULES += esp_wifi_enterprise
INCLUDES += -I$(RIOTCPU)/$(CPU)/esp-idf/include
INCLUDES += -I$(RIOTCPU)/$(CPU)/esp-idf/include/log
INCLUDES += -I$(ESP32_SDK_DIR)/components
INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/driver/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_common/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/include/soc
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/$(CPU_FAM)
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/include/$(CPU_FAM)
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_system/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_system/port/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_timer/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/hal/$(CPU_FAM)/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/hal/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/hal/platform_port/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/heap/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/log/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/newlib/platform_include
INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/$(CPU_FAM)/include
ifneq (,$(filter riscv32%,$(TARGET_ARCH)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/riscv/include
endif
ifneq (,$(filter xtensa%,$(TARGET_ARCH)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/xtensa/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/xtensa/$(CPU_FAM)/include
endif
ifneq (,$(filter esp_spi_ram,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/include/soc/$(CPU_FAM)
endif
ifneq (,$(filter esp_idf_spi_flash,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/spi_flash/include
endif
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_eth/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_event/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_netif/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_wifi/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/nvs_flash/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/spi_flash/include
endif
ifneq (,$(filter esp_wifi_enterprise,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/esp_supplicant/include
endif
ifneq (,$(filter esp_eth,$(USEMODULE)))
INCLUDES += -I$(RIOTCPU)/$(CPU)/esp-eth
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_eth/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_event/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_netif/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_wifi/include
endif
CFLAGS += -DCPU_FAM_$(call uppercase_and_underscore,$(CPU_FAM))
# we use ESP32 only in single core mode
CFLAGS += -DCONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
CFLAGS += -DCONFIG_FREERTOS_UNICORE
# other ESP-IDF configurations
CFLAGS += -DCONFIG_IDF_TARGET_$(call uppercase_and_underscore,$(CPU_FAM))
CFLAGS += -DESP_PLATFORM
CFLAGS += -DLOG_TAG_IN_BRACKETS
# shortcuts used by ESP-IDF
CFLAGS += -Dasm=__asm
CFLAGS += -Dtypeof=__typeof__
CFLAGS += -D_CONST=const
# TODO no relaxation yet
ifneq (,$(filter riscv%,$(TARGET_ARCH)))
CFLAGS += -mno-relax -march=rv32imc -mabi=ilp32 -DRISCV_NO_RELAX
endif
ifneq (,$(filter xtensa%,$(TARGET_ARCH)))
LINKFLAGS += -L$(ESP32_SDK_DIR)/components/xtensa/$(CPU_FAM)
ARCHIVES += -lxt_hal
endif
LINKFLAGS += -L$(RIOTCPU)/$(CPU)/ld/$(CPU_FAM)/
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/$(CPU_FAM)/memory.ld
LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/$(CPU_FAM)/sections.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/soc/$(CPU_FAM)/ld/$(CPU_FAM).peripherals.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU_FAM)/ld/$(CPU_FAM).rom.api.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU_FAM)/ld/$(CPU_FAM).rom.ld
ifneq (,$(filter xtensa%,$(TARGET_ARCH)))
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU_FAM)/ld/$(CPU_FAM).rom.newlib-data.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU_FAM)/ld/$(CPU_FAM).rom.newlib-funcs.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU_FAM)/ld/$(CPU_FAM).rom.newlib-time.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/$(CPU_FAM)/ld/$(CPU_FAM).rom.spiflash.ld
endif
ifneq (,$(filter riscv%,$(TARGET_ARCH)))
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/esp32c3/ld/esp32c3.rom.libgcc.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/esp32c3/ld/esp32c3.rom.newlib.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/esp32c3/ld/esp32c3.rom.version.ld
LINKFLAGS += -T$(ESP32_SDK_DIR)/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld
endif
LINKFLAGS += -nostdlib -lgcc -Wl,-gc-sections
# Libraries needed when using esp_wifi_any pseudomodule
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
LINKFLAGS += -L$(ESP32_SDK_LIB_WIFI_DIR)/$(CPU_FAM)
LINKFLAGS += -L$(ESP32_SDK_LIB_PHY_DIR)/$(CPU_FAM)
ARCHIVES += -lcoexist -lcore -lmesh -lnet80211 -lpp
ARCHIVES += -lphy -lstdc++
ifneq (,$(filter esp32,$(CPU_FAM)))
ARCHIVES += -lrtc
endif
endif
# Libraries needed when using esp_now module
ifneq (,$(filter esp_now,$(USEMODULE)))
ARCHIVES += -lespnow -lmesh
endif
ifneq (,$(filter cpp,$(USEMODULE)))
ARCHIVES += -lstdc++
endif
ifneq (,$(filter esp_bootloader,$(USEMODULE)))
# Bootloader file used by esptool.inc.mk
BOOTLOADER_BIN ?= $(BINDIR)/esp_bootloader/bootloader.bin
endif
ifneq (,$(filter esp_jtag,$(USEMODULE)))
PROGRAMMERS_SUPPORTED += openocd
PARTITION_POS = 0x8000
OPENOCD_PRE_FLASH_CMDS = -c 'echo "Installing Bootloader at $(BOOTLOADER_POS)"' \
-c 'flash write_image erase "$(BOOTLOADER_BIN)" $(BOOTLOADER_POS) bin' \
-c 'echo "Installing partition table at $(PARTITION_POS)"' \
-c 'flash write_image erase "$(BINDIR)/partitions.bin" $(PARTITION_POS) bin'
IMAGE_OFFSET = 0x10000
# Flash checksumming not supported on xtensa
OPENOCD_SKIP_VERIFY = yes
# Without resets debug target fails with 'Target not examined yet'
OPENOCD_DBG_EXTRA_CMD += -c 'reset halt'
endif
$(BOOTLOADER_BIN):