spi_flash: Remove 16KB free internal heap limit for esp_flash_read() into PSRAM

Allocation of the temporary internal buffer will now repeat until a small enough buffer can be
allocated, and only fail if less than a 256 byte block of internal RAM is free.

Adds unit test for the same, and generic test utility for creating memory pressure.
This commit is contained in:
Angus Gratton
2020-02-27 11:57:00 +11:00
committed by Angus Gratton
parent af4c6ac0f3
commit c38c3ff3f0
4 changed files with 136 additions and 18 deletions

View File

@@ -236,3 +236,31 @@ esp_err_t test_utils_set_leak_level(size_t leak_level, esp_type_leak_t type, esp
* return Leak level
*/
size_t test_utils_get_leak_level(esp_type_leak_t type, esp_comp_leak_t component);
typedef struct test_utils_exhaust_memory_record_s *test_utils_exhaust_memory_rec;
/**
* Limit the largest free block of memory with a particular capability set to
* 'limit' bytes (meaning an allocation of 'limit' should succeed at least once,
* but any allocation of more bytes will fail.)
*
* Returns a record pointer which needs to be passed back in to test_utils_free_exhausted_memory
* before the test completes, to avoid a major memory leak.
*
* @param caps Capabilities of memory to exhause
* @param limit The size to limit largest free block to
* @return Record pointer to pass to test_utils_free_exhausted_memory() once done
*/
test_utils_exhaust_memory_rec test_utils_exhaust_memory(uint32_t caps, size_t limit);
/**
* Call to free memory which was taken up by test_utils_exhaust_memory() call
*
* @param rec Result previously returned from test_utils_exhaust_memory()
*/
void test_utils_free_exhausted_memory(test_utils_exhaust_memory_rec rec);