Esp32s2 16Mb Flash

jdwrmailcom
Posts: 8
Joined: Fri Oct 23, 2020 6:47 pm

Esp32s2 16Mb Flash

Postby jdwrmailcom » Fri Oct 23, 2020 7:03 pm

Hello all. My application needs large flash storage for data (not code). I have a 16 MB chip I intend to use. The TRM suggests that I can map 10.5MB flash for data access to DCache. I tried to do that calling the DCache rom functions (similar to the way psram init function works) but reading the memory returns only 0.

Does anybody know if this can be done for ESP32S2 and if so, how?

Thanks!

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Esp32s2 16Mb Flash

Postby ESP_Sprite » Sun Oct 25, 2020 12:42 pm

You might be better off trying the [url="https://docs.espressif.com/projects/esp ... p_handle_t"\]SDK function[/url] for this. However, I'm not sure if you can map more than 4MiB of *contiguous* RAM on the S2, so that may be a limit. For anything under 4MiB (minus whatever rodata your program uses), this should work.

jdwrmailcom
Posts: 8
Joined: Fri Oct 23, 2020 6:47 pm

Re: Esp32s2 16Mb Flash

Postby jdwrmailcom » Mon Oct 26, 2020 9:49 pm

Hi. I know about those functions but as you say they only map in the ICache area of 4MB which is not sufficient.

Nevertheless I dag a bit deeper in the SDK code and I have now code the can map 10MB of the FLASH to DCache. The code seems to work and correctly access all the data.

What I am wondering now is if it is OK to use this functionality and if there are any potential issues/problems/bugs I don't know regarding this approach. Maybe an Esp engineer could help here.

Another worrying thing is that all those cache related functions have this comment in the header file of the SDK: "Please do not call this function in your SDK application."

Below the code that does the mapping

Code: Select all

Cache_Enable_DCache(0);

Cache_Suspend_DCache();

Cache_Dbus_MMU_Set(MMU_ACCESS_FLASH, DRAM0_CACHE_ADDRESS_HIGH - size, paddr, 64, size >> 16, 0);
REG_CLR_BIT(EXTMEM_PRO_DCACHE_CTRL1_REG, EXTMEM_PRO_DCACHE_MASK_DRAM1 | EXTMEM_PRO_DCACHE_MASK_DRAM0 | EXTMEM_PRO_DCACHE_MASK_DPORT);

Cache_Resume_DCache(0);
Cache_Invalidate_DCache_All();

jdwrmailcom
Posts: 8
Joined: Fri Oct 23, 2020 6:47 pm

Re: Esp32s2 16Mb Flash

Postby jdwrmailcom » Thu Nov 05, 2020 6:02 pm

ESP_Sprite wrote: However, I'm not sure if you can map more than 4MiB of *contiguous* RAM on the S2, so that may be a limit.
@ESP_Sprite, I found this statement "PSRAM — 2MB: Supported, 8MB: Not supported (IDF-968)" in the ESP32-S2 support status in ESP-IDF thread (viewtopic.php?t=14532#).

Are you referring to this issue in the above quote? Can you explain what the issue is? Is this issue relevant in the case were DCache is used to map external FLASH memory (so no writes, only reads)?

I really hope we can get an answer in this since it absolutely necessary for our application

Thanks!

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Esp32s2 16Mb Flash

Postby ESP_Sprite » Fri Nov 06, 2020 3:03 am

I have no idea what that issue would be. I'm referring to the memory apertures for RAM and flash only being 4MiB on the ESP32. I'm not sure if that already changed in the -S2, or if it's still the same.

jdwrmailcom
Posts: 8
Joined: Fri Oct 23, 2020 6:47 pm

Re: Esp32s2 16Mb Flash

Postby jdwrmailcom » Fri Nov 06, 2020 6:37 pm

ESP_Sprite wrote: I'm referring to the memory apertures for RAM and flash only being 4MiB on the ESP32
Is this an SDK or a HW limitation? For the Esp32s2 the HW clearly has support for more (and it seems to work).
Also I can see in the SDK code paths for 2,4,8 Mb of PSRAM.

Do you have any suggestions on how to get more information on this matter? Also on how to find out what the IDF-968 is?

Thanks

Who is online

Users browsing this forum: Google [Bot] and 142 guests