Skip to content

Commit 5b6aa19

Browse files
committed
Merge branch 'feat/new_xmc_id_v5.1' into 'release/v5.1'
feat(spi_flash): Add new xmc chip id (backport v5.1) See merge request espressif/esp-idf!34286
2 parents 122462f + f93199c commit 5b6aa19

File tree

7 files changed

+70
-14
lines changed

7 files changed

+70
-14
lines changed

components/bootloader_support/bootloader_flash/src/bootloader_flash.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -643,7 +643,7 @@ void bootloader_spi_flash_reset(void)
643643
******************************************************************************/
644644

645645
#define XMC_SUPPORT CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT
646-
#define XMC_VENDOR_ID 0x20
646+
#define XMC_VENDOR_ID_1 0x20
647647

648648
#if BOOTLOADER_BUILD
649649
#define BOOTLOADER_FLASH_LOG(level, ...) ESP_EARLY_LOG##level(TAG, ##__VA_ARGS__)
@@ -660,7 +660,7 @@ static IRAM_ATTR bool is_xmc_chip_strict(uint32_t rdid)
660660
uint32_t mfid = BYTESHIFT(rdid, 1);
661661
uint32_t cpid = BYTESHIFT(rdid, 0);
662662

663-
if (vendor_id != XMC_VENDOR_ID) {
663+
if (vendor_id != XMC_VENDOR_ID_1) {
664664
return false;
665665
}
666666

@@ -693,7 +693,7 @@ esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
693693
// Check the Manufacturer ID in SFDP registers (JEDEC standard). If not XMC chip, no need to run the flow
694694
const int sfdp_mfid_addr = 0x10;
695695
uint8_t mf_id = (bootloader_flash_read_sfdp(sfdp_mfid_addr, 1) & 0xff);
696-
if (mf_id != XMC_VENDOR_ID) {
696+
if (mf_id != XMC_VENDOR_ID_1) {
697697
BOOTLOADER_FLASH_LOG(D, "non-XMC chip detected by SFDP Read (%02X), skip.", mf_id);
698698
return ESP_OK;
699699
}
@@ -725,7 +725,7 @@ esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
725725
static IRAM_ATTR bool is_xmc_chip(uint32_t rdid)
726726
{
727727
uint32_t vendor_id = (rdid >> 16) & 0xFF;
728-
return (vendor_id == XMC_VENDOR_ID);
728+
return (vendor_id == XMC_VENDOR_ID_1);
729729
}
730730

731731
esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)

components/spi_flash/Kconfig

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ menu "Main Flash configuration"
4040
default SPI_FLASH_HPM_AUTO
4141
help
4242
Whether the High Performance Mode of Flash is enabled. As an optional feature, user needs to manually
43-
enable this option as a confirmation. To be back-compatible with earlier IDF versionn, this option is
43+
enable this option as a confirmation. To be back-compatible with earlier IDF version, this option is
4444
automatically enabled with warning when Flash running > 80Mhz.
4545

4646
config SPI_FLASH_HPM_ENA
@@ -101,6 +101,17 @@ menu "Main Flash configuration"
101101
Also refer to `Concurrency Constraints for Flash on SPI1` > `Flash Auto Suspend Feature`
102102
before enabling this option.
103103

104+
config SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND
105+
bool "Enable XMC-C series flash chip suspend feature anyway"
106+
default n
107+
help
108+
XMC-C series is regarded as not qualified for the Suspend feature, since its specification
109+
has a tRS >= 1ms restriction. We strongly do not suggest using it for the Suspend feature.
110+
However, if your product in field has enabled this feature, you may still enable this
111+
config option to keep the legacy behavior.
112+
113+
For new users, DO NOT enable this config.
114+
104115
endmenu
105116
endmenu
106117

@@ -235,7 +246,7 @@ menu "SPI Flash driver"
235246
Please use this configuration together with ``SPI_FLASH_ERASE_YIELD_DURATION_MS`` and
236247
``SPI_FLASH_ERASE_YIELD_TICKS`` after carefully checking flash datasheet to avoid a
237248
watchdog timeout.
238-
For more information, please check `SPI Flash API` reference documenation
249+
For more information, please check `SPI Flash API` reference documentation
239250
under section `OS Function`.
240251

241252
config SPI_FLASH_ERASE_YIELD_DURATION_MS
@@ -337,7 +348,7 @@ menu "SPI Flash driver"
337348

338349
config SPI_FLASH_SUPPORT_BOYA_CHIP
339350
bool "BOYA"
340-
# ESP32 doens't usually use this chip, default n to save iram.
351+
# ESP32 doesn't usually use this chip, default n to save iram.
341352
default y if SPI_FLASH_VENDOR_BOYA_SUPPORTED
342353
default n
343354
help
@@ -347,7 +358,7 @@ menu "SPI Flash driver"
347358

348359
config SPI_FLASH_SUPPORT_TH_CHIP
349360
bool "TH"
350-
# ESP32 doens't usually use this chip, default n to save iram.
361+
# ESP32 doesn't usually use this chip, default n to save iram.
351362
default y if SPI_FLASH_VENDOR_TH_SUPPORTED
352363
default n
353364
help

components/spi_flash/include/spi_flash/spi_flash_defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
#define CMD_RST_EN 0x66
5454
#define CMD_RST_DEV 0x99
5555

56+
#define CMD_RDSFDP 0x5A /* Read the SFDP of the flash */
57+
5658
#define SPI_FLASH_DIO_ADDR_BITLEN 24
5759
#define SPI_FLASH_DIO_DUMMY_BITLEN 4
5860
#define SPI_FLASH_QIO_ADDR_BITLEN 24

components/spi_flash/spi_flash_chip_generic.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ esp_err_t spi_flash_chip_generic_write_encrypted(esp_flash_t *chip, const void *
510510
return ESP_ERR_NOT_SUPPORTED;
511511
}
512512

513-
/* Check if the buffer and length can qualify the requirments */
513+
/* Check if the buffer and length can qualify the requirements */
514514
if (esp_flash_encryption->flash_encryption_check(address, length) != true) {
515515
return ESP_ERR_NOT_SUPPORTED;
516516
}
@@ -599,8 +599,39 @@ spi_flash_caps_t spi_flash_chip_generic_get_caps(esp_flash_t *chip)
599599
// 32M-bits address support
600600

601601
// flash suspend support
602-
// Only `XMC` support suspend for now.
602+
// XMC-D support suspend
603+
if (chip->chip_id >> 16 == 0x46) {
604+
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
605+
}
606+
607+
// XMC-D support suspend (some D series flash chip begin with 0x20, difference checked by SFDP)
603608
if (chip->chip_id >> 16 == 0x20) {
609+
uint8_t data = 0;
610+
spi_flash_trans_t t = {
611+
.command = CMD_RDSFDP,
612+
.address_bitlen = 24,
613+
.address = 0x32,
614+
.mosi_len = 0,
615+
.mosi_data = 0,
616+
.miso_len = 1,
617+
.miso_data = &data,
618+
.dummy_bitlen = 8,
619+
};
620+
chip->host->driver->common_command(chip->host, &t);
621+
if((data & 0x8) == 0x8) {
622+
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
623+
}
624+
}
625+
626+
#if CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND
627+
// XMC-C suspend has big risk. But can enable this anyway.
628+
if (chip->chip_id >> 16 == 0x20) {
629+
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
630+
}
631+
#endif
632+
633+
// FM support suspend
634+
if (chip->chip_id >> 16 == 0xa1) {
604635
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
605636
}
606637
// flash read unique id.

components/spi_flash/spi_flash_hpm_enable.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -114,7 +114,7 @@ static void spi_flash_enable_high_performance_send_cmd(void)
114114
{
115115
uint32_t dummy = 24;
116116
bootloader_flash_execute_command_common(CMD_HPMEN, 0, 0, dummy, 0, 0, 0);
117-
// Delay for T(HPM) refering to datasheet.
117+
// Delay for T(HPM) referring to datasheet.
118118
esp_rom_delay_us(20);
119119
}
120120

@@ -149,6 +149,8 @@ static esp_err_t spi_flash_hpm_probe_chip_with_dummy(uint32_t flash_id)
149149
// XMC chips.
150150
case 0x204017:
151151
case 0x204018:
152+
case 0x464017:
153+
case 0x464018:
152154
break;
153155
// GD chips.
154156
case 0xC84017:
@@ -397,7 +399,7 @@ bool spi_flash_hpm_dummy_adjust(void)
397399
//-----------------------generic functions-------------------------------------//
398400

399401
/**
400-
* @brief Default dummy for almost all flash chips. If your flash does't need to reconfigure dummy,
402+
* @brief Default dummy for almost all flash chips. If your flash doesn't need to reconfigure dummy,
401403
* just call this function.
402404
*/
403405
void __attribute__((weak)) spi_flash_hpm_get_dummy_generic(spi_flash_hpm_dummy_conf_t *dummy_conf)

docs/en/migration-guides/release-5.x/5.1/storage.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ SPI_FLASH
1515
- :cpp:func:`spi_flash_get_counters` is deprecated, please use :cpp:func:`esp_flash_get_counters` instead.
1616
- :cpp:func:`spi_flash_dump_counters` is deprecated, please use :cpp:func:`esp_flash_dump_counters` instead.
1717
- :cpp:func:`spi_flash_reset_counters` is deprecated, please use :cpp:func:`esp_flash_reset_counters` instead.
18+
19+
SPI Flash Driver
20+
^^^^^^^^^^^^^^^^
21+
22+
XMC-C series flash suspend support has been removed. According to feedback from the flash manufacturer, in some situations the XMC-C flash would require a 1ms interval between resume and next command. This is too long for a software request. Based on the above reason, in order to use suspend safely, we decide to remove flash suspend support from XMC-C series. But you can still force enable it via `CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND`. If you have any questions, please contact espressif business support.

docs/zh_CN/migration-guides/release-5.x/5.1/storage.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ FatFs
77
-----
88

99
``esp_vfs_fat_sdmmc_unmount()`` 已被弃用。 您可以使用 :cpp:func:`esp_vfs_fat_sdcard_unmount()` 代替。 此接口在更早的 IDF 版本中已被弃用, 但是尚未添加弃用警告。 自 IDF v5.1 起, 调用这个 ``esp_vfs_fat_sdmmc_unmount()`` 接口将会产生 deprecation 警告。
10+
11+
SPI flash 驱动
12+
^^^^^^^^^^^^^^^^^^^^^^
13+
14+
XMC-C 系列闪存 suspend 功能的支持已被移除。根据闪存制造商的反馈,在某些情况下,XMC-C 闪存需要在 resume 和下一条命令之间间隔 1 毫秒。这对于软件请求来说时间太长。基于上述原因,为了安全使用 suspend 功能,我们决定取消对 XMC-C 系列闪存挂起的支持。但是你依旧可以通过打开 `CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND` 来强行使能这个功能。如果您有任何疑问,请联系 espressif 商务支持。

0 commit comments

Comments
 (0)