cpu/esp8266: most .rodata sections are moved from DRAM to IROM (flash)#10981
cpu/esp8266: most .rodata sections are moved from DRAM to IROM (flash)#10981smlng merged 3 commits intoRIOT-OS:masterfrom
Conversation
Usually, the access to the IROM (flash) memory requires 32-bit word aligned reads. Attempts to access data in the IROM (flash) memory less than 32 bits in size triggers a LoadStoreError exception. With the exception handler from esp-open-rtos it becomes possible to access data in IROM (flash) with a size of less than 32 bits and thus to place .rodata sections in the IROM (flash).
Usually, all .rodata sections are placed in RAM by the Espressif SDK since IROM (flash) access requires 32-bit word aligned reads. thanks to the LoadStoreError exception handler from esp-open-rtos which is used now in RIOT-OS, it is also possible to place .rodata sections in IROM (flash) to save RAM resources.
4f0fefd to
cda45fa
Compare
Introduction of LoadStoreError handler requires new .UserExceptionTrampoline.tex section in ld script.
|
@smlng I also would like to get it merged before code freeze since it is an important enhancement which saves a lot of RAM. |
|
if I understand correctly this is only moving memory around but does not safe bytes, right? Because in total I see an increase of 500 bytes compared to master, but I also see the mem shift as you described using Master: This PR: |
|
@smlng Yes, you are right, it does not save any bytes of code. But, code size isn't a problem since you have between 1 MByte and 4 Mbyte flash memory. The problem is that |
|
@sming Thanks a lot for reviewing and testing. |
Contribution description
With this PR most
.rodatasections are moved from DRAM to IROM (flash) which makes more RAM available for applications.Background
Since IROM (flash) access requires 32-bit word aligned reads, usually all
.rodatasections are placed in DRAM by the Espressif SDK.Solution
Using the
LoadStoreErrorexception handler from esp-open-rtos makes it possible to place.rodatasections also in IROM (flash) to save RAM resources.This PR adds the
LoadStoreErrorhandler and moves most of the.rodatasections to IROM, saving 12 kBytes of DRAM for an application such asexamples/gnrc_networking. Since theLoadStoreErrorexception handler may reduce the performance of IROM access, performance-critical parts of.rodatasection, e.g.,core.a,cpu.aandperiph.aare still kept in DRAM.Note
This PR is only relevant for applications that use the SDK version of the RIOT port for ESP8266 where available memory is critical. In non-SDK version available memory is not critical.
Testing procedure
examples/gnrc_networkingwith and without the PR and check the size of.rodatain the output ofsizecommand..rodatahas a size of0x3fb0(16.304 bytes) and is placed at0x3ffe8fa0which is in DRAM. With PR you should get something like:.rodatais much smaller0xfb0(4.016 bytes) and.bssstarts at lower address. That is, much more memory is available for dynamic memory allocation which is essential for the ESP8266 WiFi interface.The difference of about 12 kBytes is additionally available as RAM.
helpIssues/PRs references
This PR depends on #10980.
Changes of this PR have to be ported to PR #10883.