Skip to content

Commit 6731f12

Browse files
committed
Merge branch 'feat/new_xmc_id_v5.3' into 'release/v5.3'
feat(spi_flash): Add new xmc chip id(backport v5.3) See merge request espressif/esp-idf!34283
2 parents a7c3e8b + 5239bd2 commit 6731f12

File tree

7 files changed

+65
-13
lines changed

7 files changed

+65
-13
lines changed

components/bootloader_support/bootloader_flash/src/bootloader_flash.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ void bootloader_spi_flash_reset(void)
697697
******************************************************************************/
698698

699699
#define XMC_SUPPORT CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT
700-
#define XMC_VENDOR_ID 0x20
700+
#define XMC_VENDOR_ID_1 0x20
701701

702702
#if BOOTLOADER_BUILD
703703
#define BOOTLOADER_FLASH_LOG(level, ...) ESP_EARLY_LOG##level(TAG, ##__VA_ARGS__)
@@ -714,7 +714,7 @@ static IRAM_ATTR bool is_xmc_chip_strict(uint32_t rdid)
714714
uint32_t mfid = BYTESHIFT(rdid, 1);
715715
uint32_t cpid = BYTESHIFT(rdid, 0);
716716

717-
if (vendor_id != XMC_VENDOR_ID) {
717+
if (vendor_id != XMC_VENDOR_ID_1) {
718718
return false;
719719
}
720720

@@ -747,7 +747,7 @@ esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
747747
// Check the Manufacturer ID in SFDP registers (JEDEC standard). If not XMC chip, no need to run the flow
748748
const int sfdp_mfid_addr = 0x10;
749749
uint8_t mf_id = (bootloader_flash_read_sfdp(sfdp_mfid_addr, 1) & 0xff);
750-
if (mf_id != XMC_VENDOR_ID) {
750+
if (mf_id != XMC_VENDOR_ID_1) {
751751
BOOTLOADER_FLASH_LOG(D, "non-XMC chip detected by SFDP Read (%02X), skip.", mf_id);
752752
return ESP_OK;
753753
}
@@ -779,7 +779,7 @@ esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
779779
static IRAM_ATTR bool is_xmc_chip(uint32_t rdid)
780780
{
781781
uint32_t vendor_id = (rdid >> 16) & 0xFF;
782-
return (vendor_id == XMC_VENDOR_ID);
782+
return (vendor_id == XMC_VENDOR_ID_1);
783783
}
784784

785785
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
@@ -116,6 +116,17 @@ menu "Main Flash configuration"
116116
This config is used for setting Tsus parameter. Tsus means CS# high to next command after
117117
suspend. You can refer to the chapter of AC CHARACTERISTICS of flash datasheet.
118118

119+
config SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND
120+
bool "Enable XMC-C series flash chip suspend feature anyway"
121+
default n
122+
help
123+
XMC-C series is regarded as not qualified for the Suspend feature, since its specification
124+
has a tRS >= 1ms restriction. We strongly do not suggest using it for the Suspend feature.
125+
However, if your product in field has enabled this feature, you may still enable this
126+
config option to keep the legacy behavior.
127+
128+
For new users, DO NOT enable this config.
129+
119130
endmenu
120131
endmenu
121132

@@ -250,7 +261,7 @@ menu "SPI Flash driver"
250261
Please use this configuration together with ``SPI_FLASH_ERASE_YIELD_DURATION_MS`` and
251262
``SPI_FLASH_ERASE_YIELD_TICKS`` after carefully checking flash datasheet to avoid a
252263
watchdog timeout.
253-
For more information, please check `SPI Flash API` reference documenation
264+
For more information, please check `SPI Flash API` reference documentation
254265
under section `OS Function`.
255266

256267
config SPI_FLASH_ERASE_YIELD_DURATION_MS
@@ -352,7 +363,7 @@ menu "SPI Flash driver"
352363

353364
config SPI_FLASH_SUPPORT_BOYA_CHIP
354365
bool "BOYA"
355-
# ESP32 doens't usually use this chip, default n to save iram.
366+
# ESP32 doesn't usually use this chip, default n to save iram.
356367
default y if SPI_FLASH_VENDOR_BOYA_SUPPORTED
357368
default n
358369
help
@@ -362,7 +373,7 @@ menu "SPI Flash driver"
362373

363374
config SPI_FLASH_SUPPORT_TH_CHIP
364375
bool "TH"
365-
# ESP32 doens't usually use this chip, default n to save iram.
376+
# ESP32 doesn't usually use this chip, default n to save iram.
366377
default y if SPI_FLASH_VENDOR_TH_SUPPORTED
367378
default n
368379
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: 28 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,10 +599,36 @@ 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-
// XMC support suspend
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)
608+
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.
603628
if (chip->chip_id >> 16 == 0x20) {
604629
caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND;
605630
}
631+
#endif
606632

607633
// FM support suspend
608634
if (chip->chip_id >> 16 == 0xa1) {

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
*/
@@ -115,7 +115,7 @@ static void spi_flash_enable_high_performance_send_cmd(void)
115115
{
116116
uint32_t dummy = 24;
117117
bootloader_flash_execute_command_common(CMD_HPMEN, 0, 0, dummy, 0, 0, 0);
118-
// Delay for T(HPM) refering to datasheet.
118+
// Delay for T(HPM) referring to datasheet.
119119
esp_rom_delay_us(20);
120120
}
121121

@@ -150,6 +150,8 @@ static esp_err_t spi_flash_hpm_probe_chip_with_dummy(uint32_t flash_id)
150150
// XMC chips.
151151
case 0x204017:
152152
case 0x204018:
153+
case 0x464017:
154+
case 0x464018:
153155
break;
154156
// GD chips.
155157
case 0xC84017:
@@ -431,7 +433,7 @@ bool spi_flash_hpm_dummy_adjust(void)
431433
//-----------------------generic functions-------------------------------------//
432434

433435
/**
434-
* @brief Default dummy for almost all flash chips. If your flash does't need to reconfigure dummy,
436+
* @brief Default dummy for almost all flash chips. If your flash doesn't need to reconfigure dummy,
435437
* just call this function.
436438
*/
437439
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.3/storage.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ APIs with `esp_vfs_dev_uart_` prefix are all deprecated, replaced with new APIs
1616
- ``esp_vfs_dev_uart_use_driver`` has been renamed to ``uart_vfs_dev_use_driver``
1717

1818
For compatibility, `vfs` component still registers `esp_driver_uart` as its private dependency. In other words, you do not need to modify the CMake file of an existing project.
19+
20+
SPI Flash Driver
21+
^^^^^^^^^^^^^^^^
22+
23+
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.3/storage.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ VFS 操作符的 UART 具体实现函数从 `vfs` 组件挪到了 `esp_driver_ua
1616
- ``esp_vfs_dev_uart_use_driver`` 更名为 ``uart_vfs_dev_use_driver``
1717

1818
为了兼容性,`vfs` 组件依旧将 `esp_driver_uart` 注册成了其私有依赖。换句话说,你无需修改既有项目的 CMake 文件。
19+
20+
21+
SPI flash 驱动
22+
^^^^^^^^^^^^^^^^^^^^^^
23+
24+
XMC-C 系列闪存 suspend 功能的支持已被移除。根据闪存制造商的反馈,在某些情况下,XMC-C 闪存需要在 resume 和下一条命令之间间隔 1 毫秒。这对于软件请求来说时间太长。基于上述原因,为了安全使用 suspend 功能,我们决定取消对 XMC-C 系列闪存挂起的支持。但是你依旧可以通过打开 `CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND` 来强行使能这个功能。如果您有任何疑问,请联系 espressif 商务支持。

0 commit comments

Comments
 (0)