Skip to content
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

image.elf section .irom0.text' will not fit in region irom0_0_seg' #34

Open
KaDw opened this issue Aug 30, 2016 · 17 comments
Open

image.elf section .irom0.text' will not fit in region irom0_0_seg' #34

KaDw opened this issue Aug 30, 2016 · 17 comments

Comments

@KaDw
Copy link

KaDw commented Aug 30, 2016

I'm using ESP8266-12E. I needed to make a http get request so i found httpclient code. I fixed some warnings but then I got this:

/home/karol/git/esp8266/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: image.elf section .irom0.text' will not fit in region irom0_0_seg' /home/karol/git/esp8266/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: region irom0_0_seg' overflowed by 6576 bytes`

How can I fix this? As far I as know you modified a bit memory layout. We are using 32Mb flash but in makefile there is a -fs 8m flag. I'm also curious about OTA. Could you explaing a little bit how it is different from espressif way?

@con-f-use
Copy link
Collaborator

Which version of the SDK do you use? It should be <=1.5.2

@KaDw
Copy link
Author

KaDw commented Aug 30, 2016

I'm using 1.5.4, I will try with 1.5.2

@con-f-use
Copy link
Collaborator

con-f-use commented Aug 30, 2016

You can try, but my guess is, the extra code for httpclient doesn't fit in the IRAM of the esp. There is alot of http stuff implemented in esp82xx, of which I have currently no idea. It would suprise me if get is already or would be easy to implement.

@KaDw
Copy link
Author

KaDw commented Aug 30, 2016

This is a noob question but the httpclient code is running from flash. There is a ICACHE_FLASH_ATTR. How can I run out of IRAM?

Edit:
Why 1.5.4 is not supported? Is there any way I can help to fix this? There is a really nice system_adc_read_fast function

@cnlohr
Copy link
Owner

cnlohr commented Aug 30, 2016

We need to add the /really/ fast ADC function to esp82xx. I tried out the 1.5.4 one and it wasn't sufficient for handling regular audio processing from what I remember.

The code is split into "IRAM" which is loaded into the core, and is super duper fast. The rest is loaded into IROM which stays on the flash chip, but is cached, so it's still pretty quick. One of the biggest problems is Espressif for some reason decided to start gobbling up the precious IRAM. Whenever handling interrupts or modifying flash code, that code needs to (unfortunately) live in IRAM.

Sticking ICACHE_FLASH_ATTR in front of the function names of functions will place them into IROM and free up the IRAM :)

@KaDw
Copy link
Author

KaDw commented Aug 30, 2016

Ok I'm a bit lost. I used ICACHE_FLASH_ATTR on every function httpclient is using and it needs IROM not IRAM, If I edit eagle.app.v6.ld irom0_0_seg from org = 0x40240000, len = 0x3C000 to org = 0x40210000, len = 0x6C000 it compiles but then esp8266 crashes. I just need more IROM

Edit:
Are you using this layout? I think It is possible to extend IROM by moving Device Configuration elsewhere. As ESP_Faye says we can do it with no problem. Now i think org = 0x40210000, len = 0x6C000 might work.

@cnlohr
Copy link
Owner

cnlohr commented Sep 4, 2016

The bigger problems is the ESP strictly has no more than 40kB IRAM. The Espressif SDK was compiled for use in IRAM.

@KaDw
Copy link
Author

KaDw commented Sep 4, 2016

Correct me if I'm wrong. If function has ICACHE_FLASH_ATTR it goes to SPI Flash (IROM). Otherwise it is placed in IRAM section (also on SPI Flash but it is copied at the beginning to embedded esp memory). I know that IRAM is full of their SDK things and there is no space for my own code. But there is still one thing that I dont get. All the functions in httpclient.c are with ICACHE_FLASH_ATTR, so how is it possible I ran out of IRAM?

@cnlohr
Copy link
Owner

cnlohr commented Sep 5, 2016

So, just checking: what version of the SDK are you using now? Older versions have tons of free space.

@KaDw
Copy link
Author

KaDw commented Sep 6, 2016

On 1.5.2 I still need 4212 bytes, on 1.5.4 i needed 6576 bytes.

@cnlohr
Copy link
Owner

cnlohr commented Sep 6, 2016

Something is definitely going on here with where your functions and/or data is residing. There should be a lot more free room than that on 1.5.2. Can you c&p the build output?

@KaDw
Copy link
Author

KaDw commented Sep 7, 2016

Here it is:
karol@karol-VB ~/git/esp $ make burn
esp82xx/common.mf:28: Warning: No shell variable 'ESP_ROOT', using '/home/karol/esp8266/esp-open-sdk' fatal: bad revision 'HEAD' /home/karol/esp8266/esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -mlongcalls -Os -I/home/karol/esp8266/esp-open-sdk/sdk/include -Iesp82xx/include -I. -Iesp82xx/fwsrc -Iuser -DICACHE_FLASH -DWEB_PORT=80 -DCOM_PORT=7777 -DBACKEND_PORT=7878 -DVERSSTR='"Version: - Build śro, 7 wrz 2016, 23:09:31 CEST with -DICACHE_FLASH -DWEB_PORT=80 -DCOM_PORT=7777 -DBACKEND_PORT=7878 "' esp82xx/fwsrc/uart.c esp82xx/fwsrc/esp82xxutil.c esp82xx/fwsrc/flash_rewriter.c esp82xx/fwsrc/http.c esp82xx/fwsrc/commonservices.c esp82xx/fwsrc/http_custom.c esp82xx/fwsrc/mdns.c esp82xx/fwsrc/mfs.c user/custom_commands.c user/user_main.c user/httpclient.c -flto -Wl,--relax -Wl,--gc-sections -nostdlib -L/home/karol/esp8266/esp-open-sdk/sdk/lib -L/home/karol/esp8266/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/libgcc.a /home/karol/esp8266/esp-open-sdk/sdk/lib/libmain.a /home/karol/esp8266/esp-open-sdk/sdk/lib/liblwip.a /home/karol/esp8266/esp-open-sdk/sdk/lib/libssl.a /home/karol/esp8266/esp-open-sdk/sdk/lib/libupgrade.a /home/karol/esp8266/esp-open-sdk/sdk/lib/libnet80211.a /home/karol/esp8266/esp-open-sdk/sdk/lib/libwpa.a /home/karol/esp8266/esp-open-sdk/sdk/lib/libphy.a /home/karol/esp8266/esp-open-sdk/sdk/lib/liblwip.a /home/karol/esp8266/esp-open-sdk/sdk/lib/libpp.a /home/karol/esp8266/esp-open-sdk/sdk/lib/libcrypto.a /home/karol/esp8266/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/libgcc.a -T /home/karol/esp8266/esp-open-sdk/sdk/ld/eagle.app.v6.ld -B/home/karol/esp8266/esp-open-sdk/sdk/lib -o image.elf /home/karol/esp8266/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: image.elf section .irom0.text' will not fit in region irom0_0_seg' /home/karol/esp8266/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: region irom0_0_seg' overflowed by 4212 bytes
collect2: error: ld returned 1 exit status
esp82xx/main.mf:72: polecenia dla obiektu 'image.elf' nie powiodły się
make: *** [image.elf] Błąd 1`

@cnlohr
Copy link
Owner

cnlohr commented Sep 8, 2016

Those bums. Looks like they just bumped everything to 2.0. You will need to use 1.5.2. Though I am still very surprised by how MUCH it's overflowing. Most of my projects will still fit in 2.0, but just barely.

I was looking for -DICACHE_FLASH which is in there. Can you post your user/httpclient.c?

@KaDw
Copy link
Author

KaDw commented Sep 8, 2016

@cnlohr
Copy link
Owner

cnlohr commented Sep 8, 2016

Ok, that is very odd, it should work. Just wondering do you have this in a forked repo that I can try building?

@KaDw
Copy link
Author

KaDw commented Sep 8, 2016

Here is repo: https://github.com/Def152/esp1 , I followed this instructions

@cnlohr
Copy link
Owner

cnlohr commented Sep 9, 2016

Well, this is unfortunate. It appears espconn_gethostbyname poisons the whole thing. @con-f-use do you have any idea why inclusion of this function increases the size of the .iram (.text) area by what seems to be almost 6kB?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants