Compile problem

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Compile problem

Postby alexchang » Mon Apr 27, 2015 12:15 am

I meet some problem and I can't figure it out, needs some help (1MB memory):

c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: build/app.out section `.text' will not fit in region `iram1_0_seg'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-mallocr.o):(.literal+0x24): undefined reference to `_sbrk_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-mallocr.o): In function `malloc_extend_top':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:2165: undefined reference to `_sbrk_r'
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:2202: undefined reference to `_sbrk_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-abort.o):(.literal+0x0): undefined reference to `_exit'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-abort.o): In function `abort':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-freer.o): In function `_malloc_trim_r':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:3325: undefined reference to `_sbrk_r'
C:/Espressif/examples/eco_plug/Makefile:227: recipe for target 'build/app.out' failed
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:3332: undefined reference to `_sbrk_r'
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdlib/../../../../../newlib/libc/stdlib/mallocr.c:3340: undefined reference to `_sbrk_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-makebuf.o):(.literal+0x8): undefined reference to `_fstat_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-makebuf.o): In function `__smakebuf_r':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdio/../../../../../newlib/libc/stdio/makebuf.c:59: undefined reference to `_fstat_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-signal.o):(.literal+0x0): undefined reference to `_getpid_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-signal.o):(.literal+0x4): undefined reference to `_kill_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-signal.o): In function `_raise_r':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\signal/../../../../../newlib/libc/signal/signal.c:163: undefined reference to `_getpid_r'
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\signal/../../../../../newlib/libc/signal/signal.c:163: undefined reference to `_kill_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-stdio.o):(.literal+0x0): undefined reference to `_read_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-stdio.o):(.literal+0x4): undefined reference to `_lseek_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-stdio.o):(.literal+0x8): undefined reference to `_write_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-stdio.o):(.literal+0xc): undefined reference to `_close_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-stdio.o): In function `__sread':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdio/../../../../../newlib/libc/stdio/stdio.c:48: undefined reference to `_read_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-stdio.o): In function `__swrite':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdio/../../../../../newlib/libc/stdio/stdio.c:89: undefined reference to `_lseek_r'
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdio/../../../../../newlib/libc/stdio/stdio.c:97: undefined reference to `_write_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-stdio.o): In function `__sseek':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdio/../../../../../newlib/libc/stdio/stdio.c:117: undefined reference to `_lseek_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(lib_a-stdio.o): In function `__sclose':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\stdio/../../../../../newlib/libc/stdio/stdio.c:135: undefined reference to `_close_r'
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libc.a(isatty.o): In function `_isatty_r':
d:\Neo\Project\ESP8266\DevKit\build\compiler\dl\esp-newlib\build\xtensa-lx106-elf\newlib\libc\sys\xtensa/../../../../../../newlib/libc/sys/xtensa/isatty.c:13: undefined reference to `_fstat_r'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe: *** [build/app.out] Error 1

00:08:25 Build Finished (took 10s.196ms)

mculibrk
Posts: 22
Joined: Mon Feb 09, 2015 3:35 am

Re: Compile problem

Postby mculibrk » Mon Apr 27, 2015 1:09 am

Well... at first sight could be a "data size" problem.
Maybe your code is too big so some variables/functions cannot be linked in and so "missing" and generating a lot of errors.

Code: Select all

c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: build/app.out section `.text' will not fit in region `iram1_0_seg

grantgao
Posts: 36
Joined: Tue Apr 14, 2015 5:20 pm

Re: Compile problem

Postby grantgao » Mon Apr 27, 2015 10:17 am

this problem can be resolved by two ways,
firstly,you need a bigger size flash ,
secondly,extensa compile can not support some std c function yet,such as file read/write/seek operation,so you need remove this function call from your code,or you can reconstruct them yourself.
hope these infomation can help you.
ps:find out all keywords like "seek" "open" "close" from your code
PS:hope espressif can resolve this complie issue asap,and explain why...

grantgao
Posts: 36
Joined: Tue Apr 14, 2015 5:20 pm

Re: Compile problem

Postby grantgao » Mon Apr 27, 2015 10:20 am

grantgao wrote:this problem can be resolved by two ways,
firstly,you need a bigger size flash ,
secondly,extensa compile can not support some std c function yet,such as file read/write/seek operation,so you need remove this function call from your code,or you can reconstruct them yourself.
hope these infomation can help you.
ps:find out all keywords like "seek" "open" "close" from your code
PS:hope espressif can resolve this complie issue asap,and explain why...



forgot one most important infomation,remove std c header include file from your code,such as "#include <stdio.h>"

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: Compile problem

Postby alexchang » Mon Apr 27, 2015 10:45 am

by comment this function, compile works:

enum wsFrameType { // errors starting from 0xF0
WS_EMPTY_FRAME = 0xF0,
WS_ERROR_FRAME = 0xF1,
WS_INCOMPLETE_FRAME = 0xF2,
WS_TEXT_FRAME = 0x01,
WS_BINARY_FRAME = 0x02,
WS_PING_FRAME = 0x09,
WS_PONG_FRAME = 0x0A,
WS_OPENING_FRAME = 0xF3,
WS_CLOSING_FRAME = 0x08
};

void ICACHE_FLASH_ATTR wsMakeFrame(const uint8_t *data, size_t dataLength, uint8_t *outFrame, size_t *outLength, enum wsFrameType frameType)
{
assert(outFrame && *outLength);
assert(frameType < 0x10);
if (dataLength > 0)
assert(data);

outFrame[0] = 0x80 | frameType;

if (dataLength <= 125) {
outFrame[1] = dataLength;
*outLength = 2;
//} else if (dataLength <= 0xFFFF) {
// outFrame[1] = 126;
// uint16_t payloadLength16b = (uint16_t) dataLength; //htons(dataLength);
// memcpy(&outFrame[2], &payloadLength16b, 2);
// *outLength = 4;
} else {
//assert(dataLength <= 0xFFFF);
assert(dataLength <= 125);

// implementation for 64bit systems
//outFrame[1] = 127;
//dataLength = htonll(dataLength);
//memcpy(&outFrame[2], &dataLength, 8);
//*outLength = 10;
}
memcpy(&outFrame[*outLength], data, dataLength);
*outLength+= dataLength;
}

but after comment this function, not much left:
Section info:

build/app.out: file format elf32-xtensa-le

Sections:
Idx Name Size VMA LMA File off Algn
0 .data 00000db4 3ffe8000 3ffe8000 000000e0 2**4
CONTENTS, ALLOC, LOAD, DATA
1 .rodata 0000174c 3ffe8dc0 3ffe8dc0 00000ea0 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .bss 000095b0 3ffea510 3ffea510 000025f0 2**4
ALLOC
3 .text 000077be 40100000 40100000 000025ec 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
4 .irom0.text 0002b254 40201010 40201010 00009db0 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
------------------------------------------------------------------------------
Section info:
Section| Description| Start (hex)| End (hex)|Used space
------------------------------------------------------------------------------
data| Initialized Data (RAM)| 3FFE8000| 3FFE8DB4| 3508
rodata| ReadOnly Data (RAM)| 3FFE8DC0| 3FFEA50C| 5964
bss| Uninitialized Data (RAM)| 3FFEA510| 3FFF3AC0| 38320
text| Cached Code (IRAM)| 40100000| 401077BE| 30654
irom0_text| Uncached Code (SPI)| 40201010| 4022C264| 176724
Total Used RAM : 47792
Free RAM : 34128
Free IRam : 2132
------------------------------------------------------------------------------

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: Compile problem

Postby alexchang » Mon Apr 27, 2015 10:51 am

don't know how to reduce irom0_text I wrote ... and also don't know how to enlarge irom0_text ... so sad > <

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: Compile problem

Postby alexchang » Mon Apr 27, 2015 10:56 am

don't know how to reduce irom0_text I wrote ... and also don't know how to enlarge irom0_text ... so sad > <

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: Compile problem

Postby alexchang » Mon Apr 27, 2015 3:30 pm

Fix it, I use IoT sample as a start project, after removing user_esp_platform, I have enough irom space right now. I should really be very careful ... when I add functions, thanks!

Who is online

Users browsing this forum: Google [Bot] and 4 guests