diff --git a/components/bootloader_support/src/bootloader_init.c b/components/bootloader_support/src/bootloader_init.c index bab8f2d8..9a48a4b8 100644 --- a/components/bootloader_support/src/bootloader_init.c +++ b/components/bootloader_support/src/bootloader_init.c @@ -621,12 +621,16 @@ static esp_err_t bootloader_main() return ESP_FAIL; } - update_flash_config(&fhdr); - ESP_LOGI(TAG, "ESP-IDF %s 2nd stage bootloader", IDF_VER); ESP_LOGI(TAG, "compile time " __TIME__ ); +#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT) + fhdr.spi_mode = CONFIG_SPI_FLASH_MODE; +#endif + + update_flash_config(&fhdr); + print_flash_info(&fhdr); return ESP_OK; diff --git a/components/esptool_py/Kconfig.projbuild b/components/esptool_py/Kconfig.projbuild index c49eadd7..5e1d028f 100644 --- a/components/esptool_py/Kconfig.projbuild +++ b/components/esptool_py/Kconfig.projbuild @@ -53,6 +53,8 @@ choice FLASHMODE Mode the flash chip is flashed in, as well as the default mode for the binary to run in. + The esptool.py flashes firmware at DIO mode when user select "QIO", "QOUT" or "DIO" mode. + config FLASHMODE_QIO bool "QIO" config FLASHMODE_QOUT @@ -63,21 +65,13 @@ config FLASHMODE_DOUT bool "DOUT" endchoice -config FLASHMODE_SWITCH_TO_QIO - bool "Try to switch to QIO mode at startup" - default y - depends on FLASHMODE_DIO - help - If users use SPI flash DIO mode to download firmware, bootloader or application - can switch to QIO mode by enable this option. - # Note: we use esptool.py to flash bootloader in # dio mode for QIO/QOUT, bootloader then upgrades # itself to quad mode during initialisation config ESPTOOLPY_FLASHMODE string - default "qio" if FLASHMODE_QIO - default "qout" if FLASHMODE_QOUT + default "dio" if FLASHMODE_QIO + default "dio" if FLASHMODE_QOUT default "dio" if FLASHMODE_DIO default "dout" if FLASHMODE_DOUT diff --git a/components/spi_flash/src/spi_flash.c b/components/spi_flash/src/spi_flash.c index 19c0ed97..ae765e64 100644 --- a/components/spi_flash/src/spi_flash.c +++ b/components/spi_flash/src/spi_flash.c @@ -24,6 +24,7 @@ #include "esp_system.h" #include "esp_log.h" #include "esp_task_wdt.h" +#include "esp_image_format.h" #define SPI_FLASH_ISSI_ENABLE_QIO_MODE (BIT(6)) @@ -744,8 +745,9 @@ void esp_spi_flash_init(uint32_t spi_speed, uint32_t spi_mode) } SET_PERI_REG_BITS(PERIPHS_SPI_FLASH_CTRL, 0xfff, freqbits, 0); -#ifndef CONFIG_FLASHMODE_SWITCH_TO_QIO - if (spi_mode == 0) -#endif + if (spi_mode == ESP_IMAGE_SPI_MODE_QIO || spi_mode == ESP_IMAGE_SPI_MODE_QOUT) { user_spi_flash_dio_to_qio_pre_init(); + + ESP_EARLY_LOGI("qio_mode", "Enabling default flash chip QIO"); + } }