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

psram: fix 16mbit psram id read error (backport v3.2)

See merge request espressif/esp-idf!9442
This commit is contained in:
Jiang Jiang Jian 2020-08-19 16:22:59 +08:00
commit 8cd3209f74

View File

@ -398,11 +398,9 @@ static void psram_disable_qio_mode(psram_spi_num_t spi_num)
psram_cmd_end(spi_num);
}
//read psram id
static void psram_read_id(uint64_t* dev_id)
//read psram id, should issue `psram_disable_qio_mode` before calling this
static void psram_read_id(psram_spi_num_t spi_num, uint64_t* dev_id)
{
psram_spi_num_t spi_num = PSRAM_SPI_1;
psram_disable_qio_mode(spi_num);
uint32_t dummy_bits = 0 + extra_dummy;
uint32_t psram_id[2] = {0};
psram_cmd_t ps_cmd;
@ -895,9 +893,20 @@ esp_err_t IRAM_ATTR psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vad
bootloader_common_vddsdio_configure();
// GPIO related settings
psram_gpio_config(&psram_io, mode);
psram_read_id(&s_psram_id);
psram_spi_num_t spi_num = PSRAM_SPI_1;
psram_disable_qio_mode(spi_num);
psram_read_id(spi_num, &s_psram_id);
if (!PSRAM_IS_VALID(s_psram_id)) {
return ESP_FAIL;
/* 16Mbit psram ID read error workaround:
* treat the first read id as a dummy one as the pre-condition,
* Send Read ID command again
*/
psram_read_id(spi_num, &s_psram_id);
if (!PSRAM_IS_VALID(s_psram_id)) {
ESP_EARLY_LOGE(TAG, "PSRAM ID read error: 0x%08x", (uint32_t)s_psram_id);
return ESP_FAIL;
}
}
if (PSRAM_IS_32MBIT_VER0(s_psram_id)) {