mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Merge branch 'feat/new_xmc_id_v5.0' into 'release/v5.0'
feat(spi_flash): Add new xmc chip id (backport v5.0) See merge request espressif/esp-idf!34297
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -677,7 +677,7 @@ esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode)
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#define XMC_SUPPORT CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT
|
#define XMC_SUPPORT CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT
|
||||||
#define XMC_VENDOR_ID 0x20
|
#define XMC_VENDOR_ID_1 0x20
|
||||||
|
|
||||||
#if BOOTLOADER_BUILD
|
#if BOOTLOADER_BUILD
|
||||||
#define BOOTLOADER_FLASH_LOG(level, ...) ESP_LOG##level(TAG, ##__VA_ARGS__)
|
#define BOOTLOADER_FLASH_LOG(level, ...) ESP_LOG##level(TAG, ##__VA_ARGS__)
|
||||||
@ -694,7 +694,7 @@ static IRAM_ATTR bool is_xmc_chip_strict(uint32_t rdid)
|
|||||||
uint32_t mfid = BYTESHIFT(rdid, 1);
|
uint32_t mfid = BYTESHIFT(rdid, 1);
|
||||||
uint32_t cpid = BYTESHIFT(rdid, 0);
|
uint32_t cpid = BYTESHIFT(rdid, 0);
|
||||||
|
|
||||||
if (vendor_id != XMC_VENDOR_ID) {
|
if (vendor_id != XMC_VENDOR_ID_1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,7 +727,7 @@ esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
|
|||||||
// Check the Manufacturer ID in SFDP registers (JEDEC standard). If not XMC chip, no need to run the flow
|
// Check the Manufacturer ID in SFDP registers (JEDEC standard). If not XMC chip, no need to run the flow
|
||||||
const int sfdp_mfid_addr = 0x10;
|
const int sfdp_mfid_addr = 0x10;
|
||||||
uint8_t mf_id = (bootloader_flash_read_sfdp(sfdp_mfid_addr, 1) & 0xff);
|
uint8_t mf_id = (bootloader_flash_read_sfdp(sfdp_mfid_addr, 1) & 0xff);
|
||||||
if (mf_id != XMC_VENDOR_ID) {
|
if (mf_id != XMC_VENDOR_ID_1) {
|
||||||
BOOTLOADER_FLASH_LOG(D, "non-XMC chip detected by SFDP Read (%02X), skip.", mf_id);
|
BOOTLOADER_FLASH_LOG(D, "non-XMC chip detected by SFDP Read (%02X), skip.", mf_id);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@ -759,7 +759,7 @@ esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
|
|||||||
static IRAM_ATTR bool is_xmc_chip(uint32_t rdid)
|
static IRAM_ATTR bool is_xmc_chip(uint32_t rdid)
|
||||||
{
|
{
|
||||||
uint32_t vendor_id = (rdid >> 16) & 0xFF;
|
uint32_t vendor_id = (rdid >> 16) & 0xFF;
|
||||||
return (vendor_id == XMC_VENDOR_ID);
|
return (vendor_id == XMC_VENDOR_ID_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
|
esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
|
||||||
|
@ -40,7 +40,7 @@ menu "Main Flash configuration"
|
|||||||
default SPI_FLASH_HPM_AUTO
|
default SPI_FLASH_HPM_AUTO
|
||||||
help
|
help
|
||||||
Whether the High Performance Mode of Flash is enabled. As an optional feature, user needs to manually
|
Whether the High Performance Mode of Flash is enabled. As an optional feature, user needs to manually
|
||||||
enable this option as a confirmation. To be back-compatible with earlier IDF versionn, this option is
|
enable this option as a confirmation. To be back-compatible with earlier IDF version, this option is
|
||||||
automatically enabled with warning when Flash running > 80Mhz.
|
automatically enabled with warning when Flash running > 80Mhz.
|
||||||
|
|
||||||
config SPI_FLASH_HPM_ENA
|
config SPI_FLASH_HPM_ENA
|
||||||
@ -101,6 +101,17 @@ menu "Main Flash configuration"
|
|||||||
Also refer to `Concurrency Constraints for Flash on SPI1` > `Flash Auto Suspend Feature`
|
Also refer to `Concurrency Constraints for Flash on SPI1` > `Flash Auto Suspend Feature`
|
||||||
before enabling this option.
|
before enabling this option.
|
||||||
|
|
||||||
|
config SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND
|
||||||
|
bool "Enable XMC-C series flash chip suspend feature anyway"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
XMC-C series is regarded as not qualified for the Suspend feature, since its specification
|
||||||
|
has a tRS >= 1ms restriction. We strongly do not suggest using it for the Suspend feature.
|
||||||
|
However, if your product in field has enabled this feature, you may still enable this
|
||||||
|
config option to keep the legacy behavior.
|
||||||
|
|
||||||
|
For new users, DO NOT enable this config.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
@ -236,7 +247,7 @@ menu "SPI Flash driver"
|
|||||||
Please use this configuration together with ``SPI_FLASH_ERASE_YIELD_DURATION_MS`` and
|
Please use this configuration together with ``SPI_FLASH_ERASE_YIELD_DURATION_MS`` and
|
||||||
``SPI_FLASH_ERASE_YIELD_TICKS`` after carefully checking flash datasheet to avoid a
|
``SPI_FLASH_ERASE_YIELD_TICKS`` after carefully checking flash datasheet to avoid a
|
||||||
watchdog timeout.
|
watchdog timeout.
|
||||||
For more information, please check `SPI Flash API` reference documenation
|
For more information, please check `SPI Flash API` reference documentation
|
||||||
under section `OS Function`.
|
under section `OS Function`.
|
||||||
|
|
||||||
config SPI_FLASH_ERASE_YIELD_DURATION_MS
|
config SPI_FLASH_ERASE_YIELD_DURATION_MS
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
#define CMD_RST_EN 0x66
|
#define CMD_RST_EN 0x66
|
||||||
#define CMD_RST_DEV 0x99
|
#define CMD_RST_DEV 0x99
|
||||||
|
|
||||||
|
#define CMD_RDSFDP 0x5A /* Read the SFDP of the flash */
|
||||||
|
|
||||||
#define SPI_FLASH_DIO_ADDR_BITLEN 24
|
#define SPI_FLASH_DIO_ADDR_BITLEN 24
|
||||||
#define SPI_FLASH_DIO_DUMMY_BITLEN 4
|
#define SPI_FLASH_DIO_DUMMY_BITLEN 4
|
||||||
#define SPI_FLASH_QIO_ADDR_BITLEN 24
|
#define SPI_FLASH_QIO_ADDR_BITLEN 24
|
||||||
|
@ -510,7 +510,7 @@ esp_err_t spi_flash_chip_generic_write_encrypted(esp_flash_t *chip, const void *
|
|||||||
return ESP_ERR_NOT_SUPPORTED;
|
return ESP_ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the buffer and length can qualify the requirments */
|
/* Check if the buffer and length can qualify the requirements */
|
||||||
if (esp_flash_encryption->flash_encryption_check(address, length) != true) {
|
if (esp_flash_encryption->flash_encryption_check(address, length) != true) {
|
||||||
return ESP_ERR_NOT_SUPPORTED;
|
return ESP_ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
@ -599,8 +599,39 @@ spi_flash_caps_t spi_flash_chip_generic_get_caps(esp_flash_t *chip)
|
|||||||
// 32M-bits address support
|
// 32M-bits address support
|
||||||
|
|
||||||
// flash suspend support
|
// flash suspend support
|
||||||
// Only `XMC` support suspend for now.
|
// XMC-D support suspend
|
||||||
|
if (chip->chip_id >> 16 == 0x46) {
|
||||||
|
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
|
||||||
|
}
|
||||||
|
|
||||||
|
// XMC-D support suspend (some D series flash chip begin with 0x20, difference checked by SFDP)
|
||||||
if (chip->chip_id >> 16 == 0x20) {
|
if (chip->chip_id >> 16 == 0x20) {
|
||||||
|
uint8_t data = 0;
|
||||||
|
spi_flash_trans_t t = {
|
||||||
|
.command = CMD_RDSFDP,
|
||||||
|
.address_bitlen = 24,
|
||||||
|
.address = 0x32,
|
||||||
|
.mosi_len = 0,
|
||||||
|
.mosi_data = 0,
|
||||||
|
.miso_len = 1,
|
||||||
|
.miso_data = &data,
|
||||||
|
.dummy_bitlen = 8,
|
||||||
|
};
|
||||||
|
chip->host->driver->common_command(chip->host, &t);
|
||||||
|
if((data & 0x8) == 0x8) {
|
||||||
|
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND
|
||||||
|
// XMC-C suspend has big risk. But can enable this anyway.
|
||||||
|
if (chip->chip_id >> 16 == 0x20) {
|
||||||
|
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// FM support suspend
|
||||||
|
if (chip->chip_id >> 16 == 0xa1) {
|
||||||
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
|
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
|
||||||
}
|
}
|
||||||
// flash read unique id.
|
// flash read unique id.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -106,7 +106,7 @@ static void spi_flash_enable_high_performance_send_cmd(void)
|
|||||||
{
|
{
|
||||||
uint32_t dummy = 24;
|
uint32_t dummy = 24;
|
||||||
bootloader_flash_execute_command_common(CMD_HPMEN, 0, 0, dummy, 0, 0, 0);
|
bootloader_flash_execute_command_common(CMD_HPMEN, 0, 0, dummy, 0, 0, 0);
|
||||||
// Delay for T(HPM) refering to datasheet.
|
// Delay for T(HPM) referring to datasheet.
|
||||||
esp_rom_delay_us(20);
|
esp_rom_delay_us(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +139,8 @@ static esp_err_t spi_flash_hpm_probe_chip_with_dummy(uint32_t flash_id)
|
|||||||
// XMC chips.
|
// XMC chips.
|
||||||
case 0x204017:
|
case 0x204017:
|
||||||
case 0x204018:
|
case 0x204018:
|
||||||
|
case 0x464017:
|
||||||
|
case 0x464018:
|
||||||
break;
|
break;
|
||||||
// GD chips.
|
// GD chips.
|
||||||
case 0xC84017:
|
case 0xC84017:
|
||||||
@ -387,7 +389,7 @@ bool spi_flash_hpm_dummy_adjust(void)
|
|||||||
//-----------------------generic functions-------------------------------------//
|
//-----------------------generic functions-------------------------------------//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default dummy for almost all flash chips. If your flash does't need to reconfigure dummy,
|
* @brief Default dummy for almost all flash chips. If your flash doesn't need to reconfigure dummy,
|
||||||
* just call this function.
|
* just call this function.
|
||||||
*/
|
*/
|
||||||
void __attribute__((weak)) spi_flash_hpm_get_dummy_generic(spi_flash_hpm_dummy_conf_t *dummy_conf)
|
void __attribute__((weak)) spi_flash_hpm_get_dummy_generic(spi_flash_hpm_dummy_conf_t *dummy_conf)
|
||||||
|
Reference in New Issue
Block a user