Page 1 of 1
Cannot access External Flash memory when External SPI Ram enabled
Posted: Thu Mar 05, 2020 6:51 am
by nimeshk
Hello,
My project has a requirement for external flash memory to store some data as well as the internal ram is not sufficient so I have to enable external SPI ram under menuconfig to store .bss data. I referred to the example code
https://github.com/espressif/esp-idf/tr ... lash_fatfs. So when I make changes to example code as per my requirement I get this "ESP_ERR_INVALID_ARG" error from this function "spi_bus_add_flash_device". I am attaching the sdkconfig files with the changes that I have made please use those in the code that you build.
- ext_flash.png (189.44 KiB) Viewed 7971 times
Re: Cannot access External Flash memory when External SPI Ram enabled
Posted: Thu Mar 05, 2020 7:17 am
by devanl
Hi,
It sounds like you've run into an issue that I reported a while back:
https://github.com/espressif/esp-idf/issues/4379
As a work-around until Espressif makes a fix, you can patch
spi_bus_add_flash_device() to always use
MALLOC_CAP_INTERNAL when allocating memory for the SPI bus driver struct.
Re: Cannot access External Flash memory when External SPI Ram enabled
Posted: Thu Mar 05, 2020 10:01 am
by nimeshk
Thanks, it worked.
Re: Cannot access External Flash memory when External SPI Ram enabled
Posted: Thu Mar 05, 2020 2:41 pm
by nimeshk
@devanl will this workaround cause any issues in the heap allocation?
Re: Cannot access External Flash memory when External SPI Ram enabled
Posted: Thu Mar 05, 2020 6:04 pm
by devanl
nimeshk wrote: ↑Thu Mar 05, 2020 2:41 pm
@devanl will this workaround cause any issues in the heap allocation?
Not that I'm aware of - the structs being allocated in spi_bus_add_flash_device() look pretty small to me - just function pointers and other assorted fields, no giant buffers or anything.
Re: Cannot access External Flash memory when External SPI Ram enabled
Posted: Fri Mar 06, 2020 6:51 am
by nimeshk
devanl wrote: ↑Thu Mar 05, 2020 6:04 pm
nimeshk wrote: ↑Thu Mar 05, 2020 2:41 pm
@devanl will this workaround cause any issues in the heap allocation?
Not that I'm aware of - the structs being allocated in spi_bus_add_flash_device() look pretty small to me - just function pointers and other assorted fields, no giant buffers or anything.
Thanks
Re: Cannot access External Flash memory when External SPI Ram enabled
Posted: Mon Aug 24, 2020 2:30 am
by Hydneman
Hi, we have just found that when using SPIRAM_USE_MALLOC, it may call a wrong logic. Your issue is very similar to this. Please take a look on
https://github.com/espressif/esp-idf/issues/4379. I hope the comment following will help you.