Every example usage of esp_partition_mmap I see is followed by a spi_flash_munmap a few lines later. However,
is there any harm in mmap-ing a partition at the beginning of app_main, using a global variable for out_ptr, and not munmap-ing it for the lifetime of the app?
Permanently mmap-ed partition?
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: Permanently mmap-ed partition?
No, not at all. The only thing to keep in mind is that you only have a limited amount of address space to mmap flash in, so if your program does lots of other mmap/munmapping, you need to make sure the maps fit in the available address space at all times.
-
- Posts: 4
- Joined: Tue Jul 19, 2022 2:59 pm
Re: Permanently mmap-ed partition?
How about if the size of the mmap-ed region is big, say 1MB? Does it have any effect?
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: Permanently mmap-ed partition?
Nope.
The ESP32 has 4MiB of address space for this. Some of this space is used for mapping your application code into (size depends on your application; it's always smaller than the size of the application binary, though). The rest is available for you to mmap() into.
The ESP32-S3 (and I think S2 as well) has 32MiB of address space for this, and it's used both for mapping PSRAM and flash. I think we only have PSRAM chips up to 8MiB, which leaves 24MiB of address space for both mapping your app code itself as well as whatever your app decides to map.
Disregarding fragmentation, as long as all maps active at the same time fit within the remaining space, there's absolutely no bad effect from keeping them mapped.
The ESP32 has 4MiB of address space for this. Some of this space is used for mapping your application code into (size depends on your application; it's always smaller than the size of the application binary, though). The rest is available for you to mmap() into.
The ESP32-S3 (and I think S2 as well) has 32MiB of address space for this, and it's used both for mapping PSRAM and flash. I think we only have PSRAM chips up to 8MiB, which leaves 24MiB of address space for both mapping your app code itself as well as whatever your app decides to map.
Disregarding fragmentation, as long as all maps active at the same time fit within the remaining space, there's absolutely no bad effect from keeping them mapped.
Re: Permanently mmap-ed partition?
Was this issue of 3mb limit ever resolved in software or in silicon? https://github.com/espressif/esp-idf/issues/1184ESP_Sprite wrote: ↑Thu Jul 21, 2022 5:52 amNope.
The ESP32 has 4MiB of address space for this. Some of this space is used for mapping your application code into (size depends on your application; it's always smaller than the size of the application binary, though). The rest is available for you to mmap() into.
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: Permanently mmap-ed partition?
That's not a bug? As I said, the original ESP32 has 4MiB of address space for mmap()ping things, but as the rodata and non-iram instructions are also mapped using that space, you're left with less actual space free for user mappings.
-
- Posts: 4
- Joined: Tue Jul 19, 2022 2:59 pm
Re: Permanently mmap-ed partition?
Ok, thanks for the clarification!
Re: Permanently mmap-ed partition?
Esp32 is supposed to have 12mb of irom mapping plus 4mb of drom mapping though.ESP_Sprite wrote: ↑Fri Jul 22, 2022 1:49 amThat's not a bug? As I said, the original ESP32 has 4MiB of address space for mmap()ping things, but as the rodata and non-iram instructions are also mapped using that space, you're left with less actual space free for user mappings.
-
- Posts: 4
- Joined: Tue Jul 19, 2022 2:59 pm
Re: Permanently mmap-ed partition?
Ok, thanks for the clarification!
Who is online
Users browsing this forum: Google [Bot] and 123 guests