lwIP Demo port to GCC: undefined references

nobody wrote on Thursday, October 13, 2005:

I tried to ‘port’ the FreeRTOS AT91SAM7X lwIP_Demo_Rowley_ARM7 Demo to
plain GCC/Make compileable with the gnuarm toolchain.
everything seems to compile fine, but the final linking shows errors (undefined references):
    *  in function `bss_error_loop’ (in crt0.s):
       `__stack_und_end__’ , `__stack_abt_end__’ , `__stack_irq_end__’ , `__stack_fiq_end__’ ,
       `__stack_svc_end__’ , `__stack_end__’ , `__data_load_start__’ , `__data_start__’ ,
       `__data_end__’ , `__text_load_start__’ , `__text_start__’ , `__text_end__’ , `__fast_load_start__’ ,
       `__fast_start__’ , `__fast_end__’ , `__heap_start__’ , `__heap_end__’ , `__ctors_start__’ ,
       `__ctors_end__’ , `__dtors_start__’ , `__dtors_end__’
    * in function `slipif_output’:
    * in function `slipif_input’:
    * in function `slipif_init’:

what do i need to do so as to resolve those references?

for more detail information, the compiler logs and the Makefile needed to reproduce the error, go to:

thanks and regards,

rtel wrote on Friday, October 14, 2005:

As before - thanks for the info.

nobody wrote on Friday, October 14, 2005:

The undefined references look like a missmatch between the linker script and the startup code.  Try using the linker script and startup code from the download.

nobody wrote on Friday, October 14, 2005:

thanks for the pointer to the ld script. (it’s the first time i use gcc for an embedded project, so i never used these ld scripts)

i didn’t find any ld script for the AT91SAM7 (or even SAM7X) in the download though. where can i find it?
(i did find ld scripts for other devices though, such as Demo/ARM7_AT91FR40008_GCC/atmel-ram.ld and Demo/ARM7_LPC2106_GCC/lpc2106-rom.ld, but i guess they don’t work with the AT91SAM7X, do they?)

nobody wrote on Friday, October 14, 2005:

If you use the load scripts you mention in your post, then just modify the RAM/ROM start addresses and sizes within the scripts I think you should find it works.

Make sure you are using the startup code from the FreeRTOS download, it is important to ensure you call main() from Supervisor mode.

Here is a post from Scott Miller that might help:

"Here’s my own SAM7S GCC project. It’s FreeRTOS with its demo application,
set up as a Kdevelop project. This includes the gnuarm toolchain and
FreeRTOS, so it’s a big download. It’s missing serial and USB support
because I haven’t rewritten the ISRs yet.


nobody wrote on Friday, October 14, 2005:

thank you for reminding me about the startup code, i had indeed forgotten to add a target for AT91SAM7_Startup.s.

I tried to assemble (compile) that one now and had the following error:
Error: constant expression expected – `ldr r0,=(50<<MC_FMR_FMCN_BIT_OFFSET)|MC_FMR_FWS_1FWS’
and the same kind of error for the lines 112, 121 and 130, i.e. in every line of the type
ldr r0,=(some_expression_calculating_together_constants)
whereas all lines of this type make no problem:
ldr r0,=constant
obviously my gnu-arm-as (or gnu-arm-cc) don’t want to accept expressions calculated from constants as constants.
the command was:
arm-elf-as AT91SAM7_Startup.s -o AT91SAM7_Startup.o

what do i have to do to make as eat that one without errors?

thanks and best regards,

nobody wrote on Friday, October 14, 2005:

about the linker ld scripts, i now tried to do as you suggest. indeed, it does take away some undefined references (exactly those that are defined in the ld script: __bss_start__ and __bss_end__ ) but not the others.
i also tried with the ld script from Scott Miller’s example project and with ld scipts i adapted from atmel ld scripts for the SAM7S64 i found in another example on the net.
the result is the same (cause they define pretty much the same minimum set of references)
there’s a couple references required by crt0.s, for example initial stack pointers for every mode.
a grep (string search) reveals that they are obviously obtained from the file flash_placement.xml by the rowley system (one foo_start and foo_end reference for each “ProgramSection” in that file. that xml file looks quite readable, still i’m not sure how that would translate into ld script language.
any idea on that one?
are all those different stack pointers even necessary?

thanks and regards,

rtel wrote on Sunday, October 16, 2005:

I have just tired putting together a linker script, startup file and very simple makefile.  They can be found here:


Placing these files in the demo/lwIP_Demo_Rowley_ARM7, then simply ‘making’ I am able to get a successful build.


1) I am a long way away from my hardware at present so cannot test these files.  All I know is that they build.

2) Check the linker script for you particular configuration.

3) These files do not perform any peripheral configuration such as PLL setup, turn of watchdog, etc.  See the AT91SAM7_Startup.s for an example of what is needed (this is the file used by the Rowley demo, so is in the same directory already).  Alternatively see the file startup code provided by Atmel.

4) For a clean build, just ‘touch’ the makefile.

These files are adapted from the Demo/ARM7_AT91FR40008_GCC demo project.


nobody wrote on Sunday, October 16, 2005:

thanks a lot,

this does build here (under linux) as well.

(there’s just a minor letter case thing in the Makefile:
i had to change lines 46, 50,51 so as to have “…/Common” instead of “…/common” and “…/Source” instead of “…/source”, so as to match the actual directory names)

the linker script looks fine. actually it’s not really so different from what i used here. what DOES make THE difference is the boot.s you added that (unlike the crt0.s from the rowley-based lwIP-demo) doesn’t need all those references that aren’t in the linker script file.

unfortunately, i can’t test it on actual hardware either right now  since i still haven’t received my SAM7X256-EK Dev Kit. I hope to get it next week (but they don’t know for sure). As soon as i have it, i’ll continue in that direction and give you a feed-back. on the test. Unfortunately, network stuff is (i guess) nothing i could soft-simulate until then. For now i feel quite relieved (i was so afraid that there could be some major problem speaking against the MCU/RTOS/Tools choice and am happy to see that it builds).

about the startup code: i was not able to compile that (i posted the errors in an earlier message in this thread) but that’s just constant fumbling stuff, at worst i’ll redefine a couple constants so as to avoid any constant calculation in the second arg to ldr and it should go through.

thanks again