编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby bobo_zhou » Mon Jun 29, 2015 7:46 pm
make[2]: Entering directory `/mnt/Share/esp_iot_sdk_v1.1.1/app/user'
DEPEND: xt-xcc -M -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle user_main.c
DEPEND: xt-xcc -M -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle global_unit.c
make[2]: Leaving directory `/mnt/Share/esp_iot_sdk_v1.1.1/app/user'
make[2]: Entering directory `/mnt/Share/esp_iot_sdk_v1.1.1/app/user'
xt-xcc -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle -o .output/eagle/debug/obj/global_unit.o -c global_unit.c
xt-xcc -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle -o .output/eagle/debug/obj/user_main.o -c user_main.c
xt-ar ru .output/eagle/debug/lib/libuser.a .output/eagle/debug/obj/global_unit.o .output/eagle/debug/obj/user_main.o
make[2]: Leaving directory `/mnt/Share/esp_iot_sdk_v1.1.1/app/user'
make[2]: Entering directory `/mnt/Share/esp_iot_sdk_v1.1.1/app/driver'
make[2]: Leaving directory `/mnt/Share/esp_iot_sdk_v1.1.1/app/driver'
xt-xcc -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lupgrade -lssl -lpwm -lsmartconfig user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
/opt/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
collect2: error: ld returned 1 exit status
Re: 编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby vowstar » Tue Sep 27, 2016 11:09 am
在所有非中断函数之前加 ICACHE_FLASH_ATTR ,然后重新编译。
如果还不行,就要用更激进的做法,改ld脚本把所有的常数常量放到flash,读出时4字节对齐读出。然后关掉switch的jumptable,把一些中断中永远用不到的函数放在flash里。
-
- Posts: 16
- Joined: Sat May 14, 2016 10:31 am
Re: 编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby pillarpeng » Wed Jan 04, 2017 11:00 am
vowstar wrote:上面的回答答非所问,不知道误导了多少人
在所有非中断函数之前加 ICACHE_FLASH_ATTR ,然后重新编译。
如果还不行,就要用更激进的做法,改ld脚本把所有的常数常量放到flash,读出时4字节对齐读出。然后关掉switch的jumptable,把一些中断中永远用不到的函数放在flash里。
感谢,解决问题。。。
Re: 编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby YimingLi » Thu Oct 05, 2017 10:40 pm
lijay910 wrote:您好,怎么解决的?
我在大部分函数前加了ICACHE_FLASH_ATTR,还是报section `.text' will not fit in region `iram1_0_seg'
因为iram1_0_seg空间有限,只有0x8000=32KBytes,如果采用上述做法之后,依然提示这个错误,那么可以进一步,将所有或部分的const常数,通过在声明处加上“ICACHE_RODATA_ATTR STORE_ATTR” ,也放置到flash里不要驻留iram1_0,例如:const char abc[] ICACHE_RODATA_ATTR STORE_ATTR = "Welcom to Espressif";
ps: 常量也包括诸如 os_sprintf(my_str, "welcome to %s", company_name);里面的引号中间部分。所以,尽量少用这类函数,以免太多之后,增加对iram1_0_seg空间的显著占用;或者更换其他方式使用(例如机智云的参考代码中,定义了一个Gizwits_print函数,就很好的的解决了这个问题)。
希望可以帮到你。
Re: 编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby lijay910 » Sat Oct 14, 2017 11:36 am
YimingLi wrote:lijay910 wrote:您好,怎么解决的?
我在大部分函数前加了ICACHE_FLASH_ATTR,还是报section `.text' will not fit in region `iram1_0_seg'
因为iram1_0_seg空间有限,只有0x8000=32KBytes,如果采用上述做法之后,依然提示这个错误,那么可以进一步,将所有或部分的const常数,通过在声明处加上“ICACHE_RODATA_ATTR STORE_ATTR” ,也放置到flash里不要驻留iram0_1,例如:const char abc[] ICACHE_RODATA_ATTR STORE_ATTR = "Welcom to Espressif";
ps: 常量也包括诸如 os_sprintf(my_str, "welcome to %s", company_name);里面的引号中间部分。所以,尽量少用这类函数,以免太多之后,增加对iram1_0_seg空间的显著占用;或者更换其他方式使用(例如机智云的参考代码中,定义了一个Gizwits_print函数,就很好的的解决了这个问题)。
希望可以帮到你。
您好,例如机智云的参考代码中,定义了一个Gizwits_print函数,关于这个能否提供具体的代码呢?我们没有它的这个参考代码,谢谢
Re: 编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby lijay910 » Sat Oct 14, 2017 2:02 pm
app目录下各目录编译后生成的.a文件总大小加起来303KB
ld里面分配情况是
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x5C000
现在一直提示../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
我该怎么弄了呢?谢谢
Re: 编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby YimingLi » Mon Oct 16, 2017 11:14 am
lijay910 wrote:您好,我在能加的地方都加了ICACHE_FLASH_ATTR 常量加了ICACHE_RODATA_ATTR STORE_ATTR
app目录下各目录编译后生成的.a文件总大小加起来303KB
ld里面分配情况是
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x5C000
现在一直提示../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
我该怎么弄了呢?谢谢
如果你已经对所有的常量进一步加了ICACHE_RODATA_ATTR STORE_ATTR的标志,依然“iram1_0_seg“错误,那就没办法了,只能说你的代码量太大了,相对于乐鑫这个版本的SDK留给你的开发的可用iram1_0_seg'太多了。基本上没办法了,删除一些功能吧。
如果你非要强行做下去,我可以给你提供一个思路,也可以实现。但是这个思路属于”馊主意”类型,需要你自己承担风险和责任。即使做成了,也需要你自己去分析和完整测试。当然,如果严格分析和严格测试后,发现没有问题,那么这两个主意也可能成为“好主意”:
(1)试一试换低版本的SDK,因为低版本的SDK对iram1_0_seg的占用比高版本的少,所以,越低版本的SDK留给用户的iram1_0_seg也会越多。
(2)修改ld文件,编译时强行将乐鑫提供的SDK库文件全部或部分放置到flash里,给你开发的固件程序腾出iram1_0_seg的空间。
但是这样做,是否会带来的问题,估计乐鑫不会保证。我也概不负责。:)
ps: 如果这个回复因可能容易造成误导而不适合出现在乐鑫论坛,那么乐鑫管理员可以删除。
Re: 编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby YimingLi » Mon Oct 16, 2017 11:23 am
lijay910 wrote:您好,我在能加的地方都加了ICACHE_FLASH_ATTR 常量加了ICACHE_RODATA_ATTR STORE_ATTR
app目录下各目录编译后生成的.a文件总大小加起来303KB
ld里面分配情况是
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x5C000
现在一直提示../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section `.text' will not fit in region `iram1_0_seg'
我该怎么弄了呢?谢谢
或者,你可以使用下面的“假编译”的方法找出你还缺多少iram1_0_seg:将 len = 0x8000 逐步改大一点点,直到编译后不再出现这个错误为止,此时你改到的数值,和 0x8000比较的差值,就是你缺的部分。-- 但是这种修改,仅限于编译,即使编译成功后的代码也是不可以执行的,因为实际的iram1_0_seg最大就是0x8000。所以,这种方法我称之为“假编译”。
如果这个差值很少,那你就去尝试改你的固件代码,能精简的地方,就精简一下;能不要的,就给先删除;可重复性的代码,就做成一个函数,适当通过牺牲时间换空间;争取节约一些空间出来,说不定这样处理后,再改回0x8000就可以编译通过了。
但是,如果这个差值很大,那就参考我前一贴的回复,要么放弃或大删,要么自己去冒险。:p
Re: 编译时提示`.text' will not fit in region `iram1_0_seg' 可能是什么原因?
Postby YimingLi » Mon Oct 16, 2017 11:29 am
lijay910 wrote:YimingLi wrote:lijay910 wrote:您好,怎么解决的?
我在大部分函数前加了ICACHE_FLASH_ATTR,还是报section `.text' will not fit in region `iram1_0_seg'
因为iram1_0_seg空间有限,只有0x8000=32KBytes,如果采用上述做法之后,依然提示这个错误,那么可以进一步,将所有或部分的const常数,通过在声明处加上“ICACHE_RODATA_ATTR STORE_ATTR” ,也放置到flash里不要驻留iram0_1,例如:const char abc[] ICACHE_RODATA_ATTR STORE_ATTR = "Welcom to Espressif";
ps: 常量也包括诸如 os_sprintf(my_str, "welcome to %s", company_name);里面的引号中间部分。所以,尽量少用这类函数,以免太多之后,增加对iram1_0_seg空间的显著占用;或者更换其他方式使用(例如机智云的参考代码中,定义了一个Gizwits_print函数,就很好的的解决了这个问题)。
希望可以帮到你。
您好,例如机智云的参考代码中,定义了一个Gizwits_print函数,关于这个能否提供具体的代码呢?我们没有它的这个参考代码,谢谢
在乐鑫论坛搜一下,有的。
Who is online
Users browsing this forum: No registered users and 308 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.