1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #18387 from gschorcht/cpu/esp32/cleanup_spi_flash_mode

cpu/{esp8266,esp32}: cleanup of SPI Flash configuration
This commit is contained in:
benpicco 2022-08-05 12:24:45 +02:00 committed by GitHub
commit cf745e954e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 73 additions and 61 deletions

View File

@ -152,7 +152,7 @@
#define UART0_TXD GPIO1 /**< direct I/O pin for UART_DEV(0) TxD, can't be changed */
#define UART0_RXD GPIO3 /**< direct I/O pin for UART_DEV(0) RxD, can't be changed */
#if FLASH_MODE_DOUT || FLASH_MODE_DIO || DOXYGEN
#if CONFIG_FLASHMODE_DOUT || CONFIG_FLASHMODE_DIO || DOXYGEN
#ifndef UART1_TXD
#define UART1_TXD GPIO10 /**< direct I/O pin for UART_DEV(1) TxD */
#endif

View File

@ -145,7 +145,7 @@
#define UART0_TXD GPIO1 /**< direct I/O pin for UART_DEV(0) TxD, can't be changed */
#define UART0_RXD GPIO3 /**< direct I/O pin for UART_DEV(0) RxD, can't be changed */
#if FLASH_MODE_DOUT || FLASH_MODE_DIO || DOXYGEN
#if CONFIG_FLASHMODE_DOUT || CONFIG_FLASHMODE_DIO || DOXYGEN
#ifndef UART1_TXD
#define UART1_TXD GPIO10 /**< direct I/O pin for UART_DEV(1) TxD */
#endif

View File

@ -129,7 +129,7 @@ extern "C" {
* as PWM channels with `PWM_DEV(0)`.
*/
#ifndef PWM0_GPIOS
#if FLASH_MODE_DOUT || FLASH_MODE_DIO || DOXYGEN
#if CONFIG_FLASHMODE_DOUT || CONFIG_FLASHMODE_DIO || DOXYGEN
#define PWM0_GPIOS { GPIO9, GPIO10 }
#else
#error Configuration problem: Flash mode qio or qout is used, \

View File

@ -182,7 +182,7 @@ extern "C" {
#define UART0_TXD GPIO1 /**< direct I/O pin for UART_DEV(0) TxD, can't be changed */
#define UART0_RXD GPIO3 /**< direct I/O pin for UART_DEV(0) RxD, can't be changed */
#if FLASH_MODE_DOUT || FLASH_MODE_DIO || DOXYGEN
#if CONFIG_FLASHMODE_DOUT || CONFIG_FLASHMODE_DIO || DOXYGEN
#ifndef UART1_TXD
#define UART1_TXD GPIO10 /**< direct I/O pin for UART_DEV(1) TxD */
#endif

View File

@ -39,7 +39,7 @@ static const gpio_t arduino_pinmap[] = {
GPIO3, /* ARDUINO_PIN_1 (TxD) */
GPIO0, /* ARDUINO_PIN_2 */
GPIO2, /* ARDUINO_PIN_3 */
#if defined(FLASH_MODE_QIO) || defined(FLASH_MODE_QOUT)
#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT)
GPIO9, /* ARDUINO_PIN_4 */
GPIO10, /* ARDUINO_PIN_5 */
#else

View File

@ -37,7 +37,7 @@ static const gpio_t arduino_pinmap[] = {
GPIO3, /* ARDUINO_PIN_1 (TxD) */
GPIO0, /* ARDUINO_PIN_2 */
GPIO4, /* ARDUINO_PIN_3 */
#if defined(FLASH_MODE_QIO) || defined(FLASH_MODE_QOUT)
#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT)
GPIO9, /* ARDUINO_PIN_4 */
GPIO10, /* ARDUINO_PIN_5 */
#else

View File

@ -37,7 +37,7 @@ static const gpio_t arduino_pinmap[] = {
GPIO3, /* ARDUINO_PIN_1 (TxD) */
GPIO0, /* ARDUINO_PIN_2 */
GPIO4, /* ARDUINO_PIN_3 */
#if defined(FLASH_MODE_QIO) || defined(FLASH_MODE_QOUT)
#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT)
GPIO9, /* ARDUINO_PIN_4 */
GPIO10, /* ARDUINO_PIN_5 */
#else

View File

@ -1,14 +1,17 @@
# 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))
FLASH_MODE ?= dout
FLASH_FREQ = 40m # DO NOT CHANGE
FLASH_SIZE ?= 4
export FLASH_MODE ?= dout
export FLASH_FREQ ?= 40m
export FLASH_SIZE ?= 2
BOOTLOADER_POS = 0x1000
else ifeq (esp32c3,$(CPU_FAM))
FLASH_MODE ?= dio
FLASH_FREQ = 80m # DO NOT CHANGE
FLASH_SIZE ?= 4
export FLASH_MODE ?= dio
export FLASH_FREQ ?= 80m
export FLASH_SIZE ?= 2
BOOTLOADER_POS = 0x0000
else
$(error Unkwnown ESP32x SoC variant (family))
@ -112,6 +115,19 @@ CFLAGS += -DCONFIG_IDF_TARGET_$(call uppercase_and_underscore,$(CPU_FAM))
CFLAGS += -DESP_PLATFORM
CFLAGS += -DLOG_TAG_IN_BRACKETS
# extend CFLAGS by the corresponding FLASH_FREQ
ifeq (20m,$(FLASH_FREQ))
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHFREQ_20M
else ifeq (26m,$(FLASH_FREQ))
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHFREQ_26M
else ifeq (40m,$(FLASH_FREQ))
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHFREQ_40M
else ifeq (80m,$(FLASH_FREQ))
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHFREQ_80M
else ifeq (120m,$(FLASH_FREQ))
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHFREQ_120M
endif
# shortcuts used by ESP-IDF
CFLAGS += -Dasm=__asm
CFLAGS += -Dtypeof=__typeof__

View File

@ -155,6 +155,8 @@ INCLUDES = \
-I$(ESP32_SDK_DIR)/components/spi_flash/include/spi_flash \
#
# include CFLAGS from cpu/esp_common/Makefile.include including the defines of
# CONFIG_ESPTOOLPY_FLASHFREQ_* and CONFIG_FLASHMODE_*
CFLAGS = -include '$(RIOTBUILD_CONFIG_HEADER_C)' \
ifneq (,$(filter riscv32%,$(TARGET_ARCH)))
@ -313,9 +315,9 @@ FLASH_CHIP = $(CPU_FAM)
ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool_v3.2.py
# TODO: These should be exported/configurable from the app side. That would
# require to export these values.
FLASH_MODE ?= dout
FLASH_FREQ ?= 40m
FLASH_SIZE ?= 4
FLASH_MODE ?= dio # ESP-IDF uses dio as default flash mode for the bootloader
FLASH_FREQ ?= 40m # lowest frequency all ESP32x SoC support
FLASH_SIZE ?= 2 # smallesrt size all ESP32x SoC support
# We use esptool to extract a version 1 app from the bootloader.elf. This is
# like the regular objdump binary file but it contains a 16 byte header which

View File

@ -63,20 +63,14 @@ extern "C" {
#endif
#endif
#if FLASH_MODE_QIO
#define CONFIG_FLASHMODE_QIO 1
#define CONFIG_ESPTOOLPY_FLASHMODE_QIO 1
#elif FLASH_MODE_QOUT
#define CONFIG_FLASHMODE_QOUT 1
#define CONFIG_ESPTOOLPY_FLASHMODE_QOUT 1
#elif FLASH_MODE_DIO
#define CONFIG_FLASHMODE_DIO 1
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
#elif FLASH_MODE_DOUT
#define CONFIG_FLASHMODE_DOUT 1
#define CONFIG_ESPTOOLPY_FLASHMODE_DOUT 1
#else
#error "Unknown flash mode selected."
/**
* Serial flasher config (defined by CFLAGS, only sanity check here)
*/
#if !defined(CONFIG_FLASHMODE_DOUT) && \
!defined(CONFIG_FLASHMODE_DIO) && \
!defined(CONFIG_FLASHMODE_QOUT) && \
!defined(CONFIG_FLASHMODE_QIO)
#error "Flash mode not configured"
#endif
/*

View File

@ -183,23 +183,13 @@ extern "C" {
#define CONFIG_ETH_DMA_TX_BUFFER_NUM 10
/**
* Serial flasher config (DO NOT CHANGE)
* Serial flasher config (defined by CFLAGS, only sanity check here)
*/
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
#if defined(FLASH_MODE_QIO)
#define CONFIG_FLASHMODE_QIO 1
#define CONFIG_ESPTOOLPY_FLASHMODE_QIO 1
#elif defined(FLASH_MODE_QOUT)
#define CONFIG_FLASHMODE_QOUT 1
#define CONFIG_ESPTOOLPY_FLASHMODE_QOUT 1
#elif defined(FLASH_MODE_DIO)
#define CONFIG_FLASHMODE_DIO 1
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
#elif defined(FLASH_MODE_DOUT)
#define CONFIG_FLASHMODE_DOUT 1
#define CONFIG_ESPTOOLPY_FLASHMODE_DOUT 1
#else
#error "Unknown flash mode selected."
#if !defined(CONFIG_FLASHMODE_DOUT) && \
!defined(CONFIG_FLASHMODE_DIO) && \
!defined(CONFIG_FLASHMODE_QOUT) && \
!defined(CONFIG_FLASHMODE_QIO)
#error "Flash mode not configured"
#endif
/**

View File

@ -83,7 +83,7 @@ gpio_pin_usage_t _gpio_pin_usage [GPIO_PIN_NUMOF] = {
_SPIF, /* GPIO6 is used as direct I/O SPI SCK for Flash */
_SPIF, /* GPIO7 is used as direct I/O SPI MISO for Flash */
_SPIF, /* GPIO8 is used as direct I/O SPI MOSI for Flash */
#if defined(FLASH_MODE_QIO) || defined(FLASH_MODE_QOUT)
#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT)
/* in qio and qout mode these pins are used in Flash */
_SPIF, /* GPIO9 is used as direct I/O SPI HD for Flash */
_SPIF, /* GPIO10 is used as direct I/O SPI WP for Flash */

View File

@ -4,10 +4,11 @@
CFLAGS_OPT ?= -O2
# ESP8266 specific flashing options
# DO NOT CHANGE, ESP8266/ESP8285 modules only work with dout and 26m
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_MODE = dout
FLASH_FREQ = 26m
FLASH_SIZE ?= 1
BOOTLOADER_POS = 0x0000

View File

@ -62,7 +62,7 @@ gpio_pin_usage_t _gpio_pin_usage [GPIO_PIN_NUMOF] =
_SPIF, /* gpio6 SPI flash CLK */
_SPIF, /* gpio7 SPI flash MISO */
_SPIF, /* gpio8 SPI flash MOSI */
#if defined(FLASH_MODE_QIO) || defined(FLASH_MODE_QOUT)
#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT)
_SPIF, /* gpio9 SPI flash HD (qio/qout flash mode) */
_SPIF, /* gpio10 SPI flash WP (qio/qout flash mode) */
#else

View File

@ -78,20 +78,23 @@ ifneq (,$(filter lwip,$(USEMODULE)))
CFLAGS += -DTCPIP_THREAD_PRIO=5
endif
# if SPI RAM is enabled, the qout flash mode has to be used
_FLASH_MODE_PREV := $(FLASH_MODE)
ifneq (,$(filter esp_spi_ram,$(USEMODULE)))
FLASH_MODE = qout
# extend CFLAGS by the corresponding CONFIG_FLASHMODE_* defines
ifeq (dout,$(FLASH_MODE))
CFLAGS += -DCONFIG_FLASHMODE_DOUT
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHMODE_DOUT
else ifeq (dio,$(FLASH_MODE))
CFLAGS += -DCONFIG_FLASHMODE_DIO
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHMODE_DIO
else ifeq (qout,$(FLASH_MODE))
CFLAGS += -DCONFIG_FLASHMODE_QOUT
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHMODE_QUOT
else ifeq (qio,$(FLASH_MODE))
CFLAGS += -DCONFIG_FLASHMODE_QIO
CFLAGS += -DCONFIG_ESPTOOLPY_FLASHMODE_QIO
else
FLASH_MODE = $(_FLASH_MODE_PREV)
$(error Undefined FLASH_MODE, possible values are: dout, dio, qout and qio)
endif
# set CFLAG for the correspondant FLASH_MODE
CFLAGS += $(if $(findstring qout,$(FLASH_MODE)),-DFLASH_MODE_QOUT=1)
CFLAGS += $(if $(findstring qio,$(FLASH_MODE)),-DFLASH_MODE_QIO=1)
CFLAGS += $(if $(findstring dio,$(FLASH_MODE)),-DFLASH_MODE_DIO=1)
CFLAGS += $(if $(findstring dout,$(FLASH_MODE)),-DFLASH_MODE_DOUT=1)
ARCHIVES += -lg -lc
LINKFLAGS += $(CFLAGS_OPT) $(CFLAGS_DBG)

View File

@ -8,6 +8,12 @@ ifeq ($(CPU),esp8266)
# Full path to the bootloader binary. In the ESP32 case this is set by the
# esp_bootloader module.
BOOTLOADER_BIN ?= $(RIOTCPU)/$(CPU)/bin/bootloader$(BOOTLOADER_COLOR)$(BOOTLOADER_INFO).bin
else
# ESP-IDF uses dio as flash mode for esptool.py when qout or qio mode are
# configured to always boot in dual SPI mode
ifneq (,$(filter qout qio,$(FLASH_MODE)))
FLASH_MODE = dio
endif
endif
ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool.py