From cb90ed263d4df90d5cb168a9df25ea93d34909ca Mon Sep 17 00:00:00 2001 From: Armando Date: Fri, 13 Oct 2023 15:43:54 +0800 Subject: [PATCH 1/2] fix(spi): fixed spi master polling mode not mem sync issue on esp32p4 --- components/driver/spi/gpspi/spi_master.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/driver/spi/gpspi/spi_master.c b/components/driver/spi/gpspi/spi_master.c index 0a47c4bddc..592af9d236 100644 --- a/components/driver/spi/gpspi/spi_master.c +++ b/components/driver/spi/gpspi/spi_master.c @@ -1144,6 +1144,19 @@ esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_end(spi_device_handle_t handle, } } +#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE //invalidate here to let user access rx data in post_cb if possible + const spi_bus_attr_t* bus_attr = host->bus_attr; + if (host->cur_trans_buf.buffer_to_rcv) { + uint16_t alignment = bus_attr->internal_mem_align_size; + uint32_t buffer_byte_len = (host->cur_trans_buf.trans->rxlength + 7) / 8; + buffer_byte_len = (buffer_byte_len + alignment - 1) & (~(alignment - 1)); + esp_err_t ret = esp_cache_msync((void *)host->cur_trans_buf.buffer_to_rcv, buffer_byte_len, ESP_CACHE_MSYNC_FLAG_DIR_M2C); + if (ret != ESP_OK) { + return ret; + } + } +#endif + ESP_LOGV(SPI_TAG, "polling trans done"); //deal with the in-flight transaction spi_post_trans(host); From d08518e31034e68c5082ea2716a853c426bcff7f Mon Sep 17 00:00:00 2001 From: Armando Date: Fri, 13 Oct 2023 15:44:15 +0800 Subject: [PATCH 2/2] feat(sdspi): supported sdspi on esp32p4 --- components/driver/spi/gpspi/spi_master.c | 2 +- docs/docs_not_updated/esp32p4.txt | 2 -- examples/storage/.build-test-rules.yml | 6 ++---- examples/storage/sd_card/sdspi/README.md | 4 ++-- examples/storage/sd_card/sdspi/main/Kconfig.projbuild | 4 ++++ 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/driver/spi/gpspi/spi_master.c b/components/driver/spi/gpspi/spi_master.c index 592af9d236..179745bde1 100644 --- a/components/driver/spi/gpspi/spi_master.c +++ b/components/driver/spi/gpspi/spi_master.c @@ -1145,7 +1145,7 @@ esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_end(spi_device_handle_t handle, } #if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE //invalidate here to let user access rx data in post_cb if possible - const spi_bus_attr_t* bus_attr = host->bus_attr; + const spi_bus_attr_t *bus_attr = host->bus_attr; if (host->cur_trans_buf.buffer_to_rcv) { uint16_t alignment = bus_attr->internal_mem_align_size; uint32_t buffer_byte_len = (host->cur_trans_buf.trans->rxlength + 7) / 8; diff --git a/docs/docs_not_updated/esp32p4.txt b/docs/docs_not_updated/esp32p4.txt index 94e6839c95..423dd6460a 100644 --- a/docs/docs_not_updated/esp32p4.txt +++ b/docs/docs_not_updated/esp32p4.txt @@ -93,7 +93,6 @@ api-reference/storage/mass_mfg.rst api-reference/storage/fatfsgen.rst api-reference/storage/index.rst api-reference/storage/nvs_partition_parse.rst -api-reference/peripherals/sdspi_share.rst api-reference/peripherals/gpio/esp32p4.inc api-reference/peripherals/adc_continuous.rst api-reference/peripherals/adc_oneshot.rst @@ -106,7 +105,6 @@ api-reference/peripherals/usb_host/usb_host_notes_design.rst api-reference/peripherals/hmac.rst api-reference/peripherals/usb_device.rst api-reference/peripherals/gpio.rst -api-reference/peripherals/sdspi_host.rst api-reference/peripherals/dac.rst api-reference/peripherals/spi_slave.rst api-reference/peripherals/touch_element.rst diff --git a/examples/storage/.build-test-rules.yml b/examples/storage/.build-test-rules.yml index 2cb0ed84eb..701a5601b1 100644 --- a/examples/storage/.build-test-rules.yml +++ b/examples/storage/.build-test-rules.yml @@ -131,11 +131,9 @@ examples/storage/sd_card/sdmmc: examples/storage/sd_card/sdspi: disable: - - if: IDF_TARGET in ["esp32h2", "esp32p4"] - temporary: true - reason: Not supported + - if: SOC_GPSPI_SUPPORTED != 1 disable_test: - - if: IDF_TARGET in ["esp32s3", "esp32c2", "esp32c6"] + - if: IDF_TARGET in ["esp32s3", "esp32c2", "esp32c6", "esp32h2", "esp32p4"] temporary: true reason: lack of runners diff --git a/examples/storage/sd_card/sdspi/README.md b/examples/storage/sd_card/sdspi/README.md index e5676dd587..334ff29f38 100644 --- a/examples/storage/sd_card/sdspi/README.md +++ b/examples/storage/sd_card/sdspi/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # SD Card example (SDSPI) diff --git a/examples/storage/sd_card/sdspi/main/Kconfig.projbuild b/examples/storage/sd_card/sdspi/main/Kconfig.projbuild index 71d6d10191..7aa77e099c 100644 --- a/examples/storage/sd_card/sdspi/main/Kconfig.projbuild +++ b/examples/storage/sd_card/sdspi/main/Kconfig.projbuild @@ -13,6 +13,7 @@ menu "SD SPI Example Configuration" default 35 if IDF_TARGET_ESP32S2 default 35 if IDF_TARGET_ESP32S3 default 5 if IDF_TARGET_ESP32H2 + default 11 if IDF_TARGET_ESP32P4 default 4 # C3 and others config EXAMPLE_PIN_MISO @@ -21,6 +22,7 @@ menu "SD SPI Example Configuration" default 37 if IDF_TARGET_ESP32S2 default 37 if IDF_TARGET_ESP32S3 default 0 if IDF_TARGET_ESP32H2 + default 13 if IDF_TARGET_ESP32P4 default 6 # C3 and others config EXAMPLE_PIN_CLK @@ -29,6 +31,7 @@ menu "SD SPI Example Configuration" default 36 if IDF_TARGET_ESP32S2 default 36 if IDF_TARGET_ESP32S3 default 4 if IDF_TARGET_ESP32H2 + default 12 if IDF_TARGET_ESP32P4 default 5 # C3 and others config EXAMPLE_PIN_CS @@ -36,6 +39,7 @@ menu "SD SPI Example Configuration" default 13 if IDF_TARGET_ESP32 default 34 if IDF_TARGET_ESP32S2 default 34 if IDF_TARGET_ESP32S3 + default 10 if IDF_TARGET_ESP32P4 default 1 # C3 and others endmenu