-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to fit my program in IRAM? Section .iram0.text will not fit in region iram0_0_seg. (IDFGH-408) #2566
Comments
Placement into IRAM can happen either at compile time or at link time. To check that the problematic component does not get placed into IRAM at compile time, run xtensa-esp32-elf-objdump -h build/component/libcomponent.a (substituting the component name). This will give you the section sizes for this component before linking. For placement into IRAM at link time, this is mostly done by archive file name or object file name. Can you possibly disclose the actual name of this component, and source file(s) inside it? |
The component The component is then used in There is no custom compilation, just a simple
Directory listing of
Directory listing of
By Results of xtensa-esp32-elf-objdump.exe -h build/hal/libhal.a (too large to paste in the issue). |
Indeed component name is the issue. It conflicts with Xtensa HAL library used in ESP-IDF (components/esp32/libhal.a). Linker script has a line which places contents of libhal.a into IRAM: esp-idf/components/esp32/ld/esp32.common.ld Line 166 in 221eced
Can you rename the component to something else? |
Thank you, didn't think of that. Changing the directory name fixed the issue. Now I have got almost 6K free. Perhaps the list of taken component names should be documented? I thought of looking at collisions with something at |
I have the same problem, except I don't think that I have a component name issue. Seeing that this was the only post I could find with the same issue, I suspect it must be either a bug or that I did something wrong with my configuration. The size-components, after changing to release, gives this output:
Can someone see what the problem could be? |
You could reduce the IRAM consumption by disabling the next options in menuconfig: |
We're in the process of adding a new Performance Guide section to the ESP-IDF Programmers Guide that includes a list of options to reduce IRAM usage of a project. This issue will be updated when it has merged. |
On latest master we've added a kconfig option for using parts of SRAM1 as IRAM in 5cbd311 which will help with this issue. We've also focused on reducing IRAM usage/making placement optional for several components. For an full overview of all such option see Optimizing-iram-usage. All new options for saving IRAM we add will be listed in this chapter. |
After an upgrade to ESP-IDF 3.1 my code stopped fitting into IRAM:
The issues were always there, but only I have recently upgraded ESP-IDF to 3.1, my code started to have issues fitting into IRAM (in pre 3.0 I had 5K left, now I'm 2K over the limit).
Because my code wouldn't link,
make size-components
was unavailable.To gather more information, I changed the linker scripts with this change to IDF:
And found what took so much of my space (sorted by IRAM usage):
The interesting components are
diagnostic tool that has all of it's functions/methods with an explicit IRAM_ATTR -
it should be in IRAM and it mostly is with 1765 bytes in IRAM and 1420 in flash.
This is correct behavior, provided as a counter example to the following component.
a C++ component with a few abstract classes and classes that implement them using virtual methods.
Some minor templates (shiv for
std::make_unique
andstd::to_string
).No static variables, no use of malloc -
new
andmake_unique
only.Using
std::stack
,std::istringstream
andstd::ostringstream
.There are no calls to anything ESP specific - this code is a logic-only component that also compiles in other compilers.
This component uses 8657 bytes of IRAM and 0 of flash. Why?
libfreertos.a
-IRAM_ATTR
is mentioned only once, but the all of the code is in IRAM.My question is: How does the ESP-IDF (the linker?) decide where will the code end in? How can I tweak it?
I do not want [MY COMPONENT WITH IRAM ISSUE] to end up in IRAM, it's large and there is absolutely no need for it.
Please correct me If I misunderstood some of the architecture and what is IRAM.
NB. Changing from release to debug saves a few kilobytes of memory, but it is still very tight - plus I'd like to be able to use the debug version.
The text was updated successfully, but these errors were encountered: