compiler error with lwIP gcc sam7x demo

bejkarna wrote on Thursday, February 25, 2010:

when I try to compile the demo using yagarto gcc 4.4.2 under eclipse (same results under command line)

I get this:

…-I./lwip-1.1.0/contrib/port/FreeRTOS/AT91SAM7X -I./lwip-1.1.0/src/include/ipv4 -D SAM7_GCC -D THUMB_INTERWORK -mcpu=arm7tdmi -D PACK_STRUCT_END=__attribute\(\(packed\)\) -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) -fomit-frame-pointer -mthumb-interwork -fno-strict-aliasing -fno-dwarf2-cfi-asm EMAC/SAM7_EMAC_ISR.c -o EMAC/SAM7_EMAC_ISR.o
EMAC/SAM7_EMAC_ISR.c: In function ‘vEMACISR_Wrapper’:
EMAC/SAM7_EMAC_ISR.c:92: internal compiler error: in expand_expr_addr_expr_1, at expr.c:6835
Please submit a full bug report,
with preprocessed source if appropriate.
See <> for instructions.
make: ***  Error 1

this is with optimisation level O3, with lower level eg O2 I get:

c:/program files/yagarto/bin/…/lib/gcc/arm-elf/4.4.2/…/…/…/…/arm-elf/bin/ld.exe: RTOSDemo.elf section `.bss’ will not fit in region `ram’
c:/program files/yagarto/bin/…/lib/gcc/arm-elf/4.4.2/…/…/…/…/arm-elf/bin/ld.exe: region `ram’ overflowed by 27568 bytes
collect2: ld returned 1 exit status
make: ***  Error 1

I also tried older version of gcc with the same result. Version of FreeRTOS V6.0.1
Any ideas what can be wrong, I am really stuck here with no idea, where to search for problem.
thanks for anything.

rtel wrote on Thursday, February 25, 2010:

I just tried the same, and found it compiled with no problem but generated the following error while linking:

“no memory region specified for loadable section `.eh_frame”

I have read stuff about this error before and from memory (so might be wrong) there are two things that can cause this.  The first is an error in the linker script - but the linker script worked fine with previous versions of Yagarto.  The second is simply that the section “.eh_frame” should be stripped out using some command line option or other that I can’t remember.  I think this will require a bit of Googling.


bejkarna wrote on Thursday, February 25, 2010:

Thanks a lot for your answer, it now works, I dont know how :frowning: i will try to explain

I found on that if the message you mentioned about “.eh_frame” appears one should add the following to the linker script:

. = ALIGN(4);
.eh_frame :
KEEP (*(.eh_frame))
} > ram

Now I was actually working with two demos: SAM7X WEB Server & USB Mouse Demo
Using Eclipse where I removed the uIP stack and added lwIP from the lwIP demo
and I also tried lwIP demo as I said earlier.

with the uIP demo the linker script contained the above part but the lwIP did not, so I added it there, this removed the .eh_frame error but new one appeard:

c:/program files/yagarto/bin/…/lib/gcc/arm-elf/4.4.2/…/…/…/…/arm-elf/lib/interwork\libg.a(lib_a-sbrkr.o): In function `_sbrk_r’:
C:\msys\1.0\home\yagarto\newlib-build\arm-elf\interwork\newlib\libc\reent/…/…/…/…/…/…/newlib-1.18.0/newlib/libc/reent/sbrkr.c:60: undefined reference to `_sbrk’
collect2: ld returned 1 exit status

but I found that the linker script works with memory I increased it as I have at91sam7x512 which has larger memory. this caused that the uip demo (with lwIP implemented) started working. Sadly the lwIP demo does not work as it throws the error mentioned above.

I am not really sure what I exactly did as I am just begginer, but now it works. Amazing.

bejkarna wrote on Thursday, February 25, 2010:

I changed the following in atmel-rom.ld

flash : ORIGIN = 0x00100000, LENGTH = 256K
ram : ORIGIN = 0x00200000, LENGTH = 64K

__stack_end__ = 0x00200000 + 64K - 4;


flash : ORIGIN = 0x00100000, LENGTH = 512K
ram : ORIGIN = 0x00200000, LENGTH = 128K

__stack_end__ = 0x00200000 + 128K - 4;

I found also that lowering configTOTAL_HEAP_SIZE in FreeRTOSConfig.h to 20 * 1024 also works. It is about the same as set up in the lwIP demo.