mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/spi_flash_read_changes_for_less_than_16_bytes_v4.0' into 'release/v4.0'
Bugfix/spi flash read changes for less than 16 bytes v4.0(backport v4.0) See merge request espressif/esp-idf!6247
This commit is contained in:
commit
106f066254
@ -513,7 +513,17 @@ esp_err_t IRAM_ATTR spi_flash_read(size_t src, void *dstv, size_t size)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
COUNTER_ADD_BYTES(read, read_size);
|
COUNTER_ADD_BYTES(read, read_size);
|
||||||
|
#ifdef ESP_PLATFORM
|
||||||
|
if (esp_ptr_external_ram(dstv)) {
|
||||||
|
spi_flash_guard_end();
|
||||||
|
memcpy(dstv, ((uint8_t *) t) + left_off, size);
|
||||||
|
spi_flash_guard_start();
|
||||||
|
} else {
|
||||||
|
memcpy(dstv, ((uint8_t *) t) + left_off, size);
|
||||||
|
}
|
||||||
|
#else
|
||||||
memcpy(dstv, ((uint8_t *) t) + left_off, size);
|
memcpy(dstv, ((uint8_t *) t) + left_off, size);
|
||||||
|
#endif
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
uint8_t *dstc = (uint8_t *) dstv;
|
uint8_t *dstc = (uint8_t *) dstv;
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
idf_component_register(SRC_DIRS "."
|
idf_component_register(SRC_DIRS "."
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES unity test_utils spi_flash bootloader_support app_update)
|
REQUIRES unity test_utils spi_flash bootloader_support app_update)
|
||||||
|
|
||||||
|
if(CONFIG_SPI_FLASH_USE_LEGACY_IMPL)
|
||||||
|
set(COMPONENT_SRCEXCLUDE "test_esp_flash.c" "test_partition_ext.c")
|
||||||
|
endif()
|
||||||
|
@ -3,3 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
|
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
|
||||||
|
|
||||||
|
ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||||
|
COMPONENT_OBJEXCLUDE += test_esp_flash.o test_partition_ext.o
|
||||||
|
endif
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "soc/timer_periph.h"
|
#include "soc/timer_periph.h"
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
|
#define MIN_BLOCK_SIZE 12
|
||||||
/* Base offset in flash for tests. */
|
/* Base offset in flash for tests. */
|
||||||
static size_t start;
|
static size_t start;
|
||||||
|
|
||||||
@ -266,4 +267,36 @@ TEST_CASE("spi_flash_write can write from external RAM buffer", "[spi_flash]")
|
|||||||
free(buf_int);
|
free(buf_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("spi_flash_read less than 16 bytes into buffer in external RAM", "[spi_flash]")
|
||||||
|
{
|
||||||
|
uint8_t *buf_ext_8 = (uint8_t *) heap_caps_malloc(MIN_BLOCK_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||||
|
TEST_ASSERT_NOT_NULL(buf_ext_8);
|
||||||
|
|
||||||
|
uint8_t *buf_int_8 = (uint8_t *) heap_caps_malloc(MIN_BLOCK_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||||
|
TEST_ASSERT_NOT_NULL(buf_int_8);
|
||||||
|
|
||||||
|
uint8_t data_8[MIN_BLOCK_SIZE];
|
||||||
|
for (int i = 0; i < MIN_BLOCK_SIZE; i++) {
|
||||||
|
data_8[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
const esp_partition_t *part = get_test_data_partition();
|
||||||
|
TEST_ESP_OK(spi_flash_erase_range(part->address, SPI_FLASH_SEC_SIZE));
|
||||||
|
TEST_ESP_OK(spi_flash_write(part->address, data_8, MIN_BLOCK_SIZE));
|
||||||
|
TEST_ESP_OK(spi_flash_read(part->address, buf_ext_8, MIN_BLOCK_SIZE));
|
||||||
|
TEST_ESP_OK(spi_flash_read(part->address, buf_int_8, MIN_BLOCK_SIZE));
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL(0, memcmp(buf_ext_8, data_8, MIN_BLOCK_SIZE));
|
||||||
|
TEST_ASSERT_EQUAL(0, memcmp(buf_int_8, data_8, MIN_BLOCK_SIZE));
|
||||||
|
|
||||||
|
if (buf_ext_8) {
|
||||||
|
free(buf_ext_8);
|
||||||
|
buf_ext_8 = NULL;
|
||||||
|
}
|
||||||
|
if (buf_int_8) {
|
||||||
|
free(buf_int_8);
|
||||||
|
buf_int_8 = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CONFIG_ESP32_SPIRAM_SUPPORT
|
#endif // CONFIG_ESP32_SPIRAM_SUPPORT
|
||||||
|
@ -214,7 +214,7 @@ UT_001:
|
|||||||
|
|
||||||
UT_002:
|
UT_002:
|
||||||
extends: .unit_test_template
|
extends: .unit_test_template
|
||||||
parallel: 18
|
parallel: 30
|
||||||
tags:
|
tags:
|
||||||
- ESP32_IDF
|
- ESP32_IDF
|
||||||
- UT_T1_1
|
- UT_T1_1
|
||||||
@ -413,7 +413,7 @@ UT_029:
|
|||||||
# Gitlab parallel max value is 50. We need to create another UT job if parallel is larger than 50.
|
# Gitlab parallel max value is 50. We need to create another UT job if parallel is larger than 50.
|
||||||
UT_030:
|
UT_030:
|
||||||
extends: .unit_test_template
|
extends: .unit_test_template
|
||||||
parallel: 6
|
parallel: 10
|
||||||
tags:
|
tags:
|
||||||
- ESP32_IDF
|
- ESP32_IDF
|
||||||
- UT_T1_1
|
- UT_T1_1
|
||||||
|
3
tools/unit-test-app/configs/spi_flash_legacy
Normal file
3
tools/unit-test-app/configs/spi_flash_legacy
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
TEST_COMPONENTS=spi_flash
|
||||||
|
CONFIG_ESP32_SPIRAM_SUPPORT=y
|
||||||
|
CONFIG_SPI_FLASH_USE_LEGACY_IMPL=y
|
Loading…
Reference in New Issue
Block a user