Use PSRAM and write flash possible?

User avatar
bartvanhofwegen
Posts: 5
Joined: Mon Aug 15, 2022 5:25 pm
Location: The Netherlands

Use PSRAM and write flash possible?

Postby bartvanhofwegen » Mon Aug 15, 2022 7:31 pm

Hello, this might have been asked before but it is hard to search the forum, it keeps serving blank pages 80% of the time ...

To the point: The docs state that "When flash cache is disabled (for example, if the flash is being written to), the external RAM also becomes inaccessible; any reads from or writes to it will lead to an illegal cache access exception. This is also the reason why ESP-IDF does not by default allocate any task stacks in external RAM (see below)."

I understand that, and why that is so. But does ESP-IDF have an internal mechanism to synchronize this? I have read somewhere that it does, but also other texts saying differently. In other words:

If I have a few tasks reading from net-if and reading/writing (large) variables in PSRAM and one (or maybe two) tasks that now and then save something (relatively small) to flash using the standard wear leveling and file system components, will those be synchronized ? All tasks have stacks in internal RAM. Or do I need other storage facilities (SDIO) when using PSRAM?

Thanks in advance !
Bart

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Use PSRAM and write flash possible?

Postby ESP_igrr » Mon Aug 15, 2022 11:12 pm

Hi Bart,
The flash driver indeed takes care of this restriction. First, it makes sure that no other tasks are running (on the same CPU or on the other CPU, when running on a dual-core chip). Second, if the source or destination buffer used for flash write or read operation is in external RAM, the driver automatically uses a scratch buffer in the internal RAM instead.
Based on your description of the use case, I think this shouldn't be a problem.

User avatar
bartvanhofwegen
Posts: 5
Joined: Mon Aug 15, 2022 5:25 pm
Location: The Netherlands

Re: Use PSRAM and write flash possible?

Postby bartvanhofwegen » Tue Aug 16, 2022 5:20 am

Hi, thanks for the fast and clear answer! I already thought this would be handled by ESP-IDF because in general I find it well thought through and made.

Who is online

Users browsing this forum: Bing [Bot] and 123 guests