fatfs: fix SPIRAM allocation not used due to Kconfig option name error

Closes https://github.com/espressif/esp-idf/issues/5756
This commit is contained in:
Ivan Grokhotkov 2020-09-10 01:04:32 +02:00
parent 1a1e1911f9
commit c330def25a
3 changed files with 16 additions and 4 deletions

View File

@ -8,7 +8,7 @@
#include <stdlib.h>
#include "ff.h"
#include "sdkconfig.h"
#ifdef CONFIG_FATFS_ALLOC_EXTRAM_FIRST
#ifdef CONFIG_FATFS_ALLOC_PREFER_EXTRAM
#include "esp_heap_caps.h"
#endif
@ -16,8 +16,8 @@ void* ff_memalloc ( /* Returns pointer to the allocated memory block (null on
unsigned msize /* Number of bytes to allocate */
)
{
#ifdef CONFIG_FATFS_ALLOC_EXTRAM_FIRST
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM,
#ifdef CONFIG_FATFS_ALLOC_PREFER_EXTRAM
return heap_caps_malloc_prefer(msize, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM,
MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
#else
return malloc(msize);

View File

@ -223,3 +223,15 @@ TEST_CASE("(WL) opendir, readdir, rewinddir, seekdir work as expected using UTF-
test_teardown();
}
#endif
#ifdef CONFIG_SPIRAM
TEST_CASE("FATFS prefers SPI RAM for allocations", "[fatfs]")
{
test_setup();
DIR* dir = opendir("/spiflash");
TEST_ASSERT_NOT_NULL(dir);
TEST_ASSERT(esp_ptr_external_ram(dir));
closedir(dir);
test_teardown();
}
#endif // CONFIG_SPIRAM

View File

@ -24,6 +24,6 @@ CONFIG_COMPILER_WARN_WRITE_STRINGS=y
CONFIG_SPI_MASTER_IN_IRAM=y
CONFIG_EFUSE_VIRTUAL=y
CONFIG_SPIRAM_BANKSWITCH_ENABLE=n
CONFIG_FATFS_ALLOC_EXTRAM_FIRST=y
CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL=y
CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=n