-->
Page 1 of 5

Debugging iram1_0_seg error messages

PostPosted: Tue May 26, 2015 3:45 pm
by coldpenguin
Got some somewhat simple code, it uses an MCP3208 with HSPI to read some values. I then want to sqrt() those values. In addition it uses i2c to connect to a DS3231 module, gets the time and reports time since epoch (from mktime)
Adding the powf() function I get the error message a.text will not fit in iram1_0_seg
How do I work out what uses all of the memory?
Or, how can I increase the size of the segment?

I am using SDK 1.0.1, for some reason the HSPI doesn't work with the 1.1.0 version
Are there some good flags for the compiler that miraculously make things smaller? Running on windows 7.

I haven't even put the code in yet that I will need to use to post the calculated value to a server!
Code: Select allC:/projects/ESP/esp8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -Idriver -Iuser -Idriver/include -Iuser/include -Iinclude -IC:/Projects/ESP/esp_iot_sdk_v1.0.1/include -Os -Os  -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals  -D__ets__ -DICACHE_FLASH  -c user/i2c_master.c -o build/user/i2c_master.o
C:/projects/ESP/esp8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -Idriver -Iuser -Idriver/include -Iuser/include -Iinclude -IC:/Projects/ESP/esp_iot_sdk_v1.0.1/include -Os -Os  -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals  -D__ets__ -DICACHE_FLASH  -c user/spi.c -o build/user/spi.o
C:/projects/ESP/esp8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -Idriver -Iuser -Idriver/include -Iuser/include -Iinclude -IC:/Projects/ESP/esp_iot_sdk_v1.0.1/include -Os -Os  -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals  -D__ets__ -DICACHE_FLASH  -c user/user_main.c -o build/user/user_main.o
C:/projects/ESP/esp8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -Idriver -Iuser -Idriver/include -Iuser/include -Iinclude -IC:/Projects/ESP/esp_iot_sdk_v1.0.1/include -Os -Os  -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals  -D__ets__ -DICACHE_FLASH  -c user/ds3231.c -o build/user/ds3231.o
C:/projects/ESP/esp8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru build/blink_app.a build/user/i2c_master.o build/user/spi.o build/user/user_main.o build/user/ds3231.o
C:/projects/ESP/esp8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -LC:/Projects/ESP/esp_iot_sdk_v1.0.1/lib -TC:/Projects/ESP/esp_iot_sdk_v1.0.1/ld/eagle.app.v6.ld -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lm -lnet80211 -lphy -llwip -lpp -lc -lgcc -lwpa -lmain build/blink_app.a -Wl,--end-group -o build/blink.out
c:/projects/esp/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: build/blink.out section `.text' will not fit in region `iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
Makefile:120: recipe for target 'build/blink.out' failed
make: *** [build/blink.out] Error 1

Re: Debugging iram1_0_seg error messages

PostPosted: Wed May 27, 2015 1:11 pm
by cal
Moin,

you could fake a bigger segment in the ld file and then look at the mapfile to see how space is used.
You can use irom = cached flash and iram for code.
Sizes are fixed by your hardware.

Hope that helps,
Cal

Re: Debugging iram1_0_seg error messages

PostPosted: Wed May 27, 2015 5:21 pm
by projectgus
Hi coldpenguin,

The default storage location for all functions is the iram section, which is only 32KB.

Functions marked with ICACHE_FLASH_ATTR will go into the irom section, which is stored in the SPI flash (size depends on the module but it's least 512KB usually bigger.)

As a rule, you should mark almost all your functions with ICACHE_FLASH_ATTR. The exceptions are functions called from interrupt handlers where the flash cache may be disabled, and functions that you're really sure get called very often. If unsure, mark with ICACHE_FLASH_ATTR.

There's some more information about the various sections, flash caching, etc. on the wiki: https://github.com/esp8266/esp8266-wiki/wiki/Memory-Map

For examples of how to apply ICACHE_FLASH_ATTR, have a dig around in the sources that come with the SDK.

Angus

Re: Debugging iram1_0_seg error messages

PostPosted: Wed May 27, 2015 10:18 pm
by jcmvbkbc
projectgus wrote:The default storage location for all functions is the iram section, which is only 32KB.

Actually there's 64KB, at least OTA boot code uses memory in the upper 32KB, I guess we can use full 64KB if OTA functionality isn't needed.