Merge branch 'bugfix/improve_spi_timing_for_flash_v3.2' into 'release/v3.2'

bugfix(flash): improve spi cs timing settings for flash (backport v3.2)

See merge request espressif/esp-idf!5513
This commit is contained in:
Jiang Jiang Jian 2019-07-31 23:39:07 +08:00
commit 83e5e6b24c
4 changed files with 25 additions and 0 deletions

View File

@ -96,3 +96,11 @@ esp_err_t bootloader_common_get_sha256_of_partition(uint32_t address, uint32_t s
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
*/
void bootloader_common_vddsdio_configure();
/**
* @brief Set the flash CS setup and hold time.
*
* CS setup time is recomemded to be 1.5T, and CS hold time is recommended to be 2.5T.
* cs_setup = 1, cs_setup_time = 0; cs_hold = 1, cs_hold_time = 1
*/
void bootloader_common_set_flash_cs_timing();

View File

@ -29,6 +29,7 @@
#include "soc/gpio_periph.h"
#include "soc/efuse_reg.h"
#include "soc/rtc.h"
#include "soc/spi_reg.h"
#include "esp_image_format.h"
#include "bootloader_sha.h"
@ -209,3 +210,13 @@ void bootloader_common_vddsdio_configure()
}
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
}
void bootloader_common_set_flash_cs_timing()
{
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
SET_PERI_REG_MASK(SPI_USER_REG(1), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
}

View File

@ -397,6 +397,9 @@ static void IRAM_ATTR flash_gpio_configure(const esp_image_header_t* pfhdr)
#endif
}
}
// improve the flash cs timing.
bootloader_common_set_flash_cs_timing();
}
static void uart_console_configure(void)

View File

@ -71,6 +71,7 @@
#include "esp_pm.h"
#include "pm_impl.h"
#include "trax.h"
#include "bootloader_common.h"
#define STRINGIFY(s) STRINGIFY2(s)
#define STRINGIFY2(s) #s
@ -172,6 +173,8 @@ void IRAM_ATTR call_start_cpu0()
abort();
#endif
}
# else // If psram is uninitialized, we need to improve the flash cs timing.
bootloader_common_set_flash_cs_timing();
#endif
ESP_EARLY_LOGI(TAG, "Pro cpu up.");