diff --git a/components/spi_flash/esp_flash_spi_init.c b/components/spi_flash/esp_flash_spi_init.c index 64cef8c75e..d362b7b354 100644 --- a/components/spi_flash/esp_flash_spi_init.c +++ b/components/spi_flash/esp_flash_spi_init.c @@ -261,13 +261,13 @@ esp_err_t esp_flash_init_default_chip(void) if (default_chip.size < legacy_chip->chip_size) { ESP_EARLY_LOGE(TAG, "Detected size(%dk) smaller than the size in the binary image header(%dk). Probe failed.", default_chip.size/1024, legacy_chip->chip_size/1024); return ESP_ERR_FLASH_SIZE_NOT_MATCH; - } else if (default_chip.size > legacy_chip->chip_size) { - ESP_EARLY_LOGW(TAG, "Detected size(%dk) larger than the size in the binary image header(%dk). Using the size in the binary image header.", default_chip.size/1024, legacy_chip->chip_size/1024); - default_chip.size = legacy_chip->chip_size; - } else { - default_chip.size = legacy_chip->chip_size; } + if (default_chip.size > legacy_chip->chip_size) { + ESP_EARLY_LOGW(TAG, "Detected size(%dk) larger than the size in the binary image header(%dk). Using the size in the binary image header.", default_chip.size/1024, legacy_chip->chip_size/1024); + } + default_chip.size = legacy_chip->chip_size; + esp_flash_default_chip = &default_chip; return ESP_OK; }