Cannot access External Flash memory when External SPI Ram enabled

nimeshk
Posts: 5
Joined: Wed Nov 13, 2019 6:37 am

Cannot access External Flash memory when External SPI Ram enabled

Postby nimeshk » Thu Mar 05, 2020 6:51 am

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
ext_flash.png (189.44 KiB) Viewed 1672 times
Attachments
sdkconfig.zip
(11.08 KiB) Downloaded 59 times

devanl
Posts: 11
Joined: Sat Jan 04, 2020 5:26 pm

Re: Cannot access External Flash memory when External SPI Ram enabled

Postby devanl » Thu Mar 05, 2020 7:17 am

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.

nimeshk
Posts: 5
Joined: Wed Nov 13, 2019 6:37 am

Re: Cannot access External Flash memory when External SPI Ram enabled

Postby nimeshk » Thu Mar 05, 2020 10:01 am

Thanks, it worked. :)

nimeshk
Posts: 5
Joined: Wed Nov 13, 2019 6:37 am

Re: Cannot access External Flash memory when External SPI Ram enabled

Postby nimeshk » Thu Mar 05, 2020 2:41 pm

@devanl will this workaround cause any issues in the heap allocation?

devanl
Posts: 11
Joined: Sat Jan 04, 2020 5:26 pm

Re: Cannot access External Flash memory when External SPI Ram enabled

Postby devanl » 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.

nimeshk
Posts: 5
Joined: Wed Nov 13, 2019 6:37 am

Re: Cannot access External Flash memory when External SPI Ram enabled

Postby nimeshk » Fri Mar 06, 2020 6:51 am

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

Hydneman
Posts: 2
Joined: Mon Aug 24, 2020 2:19 am

Re: Cannot access External Flash memory when External SPI Ram enabled

Postby Hydneman » Mon Aug 24, 2020 2:30 am

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.

Who is online

Users browsing this forum: wereworm and 52 guests