SAM7X Demo error in linkerscript (Yagarto)

rbekkers wrote on Tuesday, February 21, 2012:

I discovered something, that is in my humble opinion an error, in the atmel-rom.ld linker script that comes with the FreeRTOS 7.1.0 demo. The original initilises the symbol __data_beg_src__ in the .data segment:
.data :

{
data_beg = .;
data_beg_src = end_of_text;
*(.data)
data_end = .;
} >ram AT>flash

This causes however that the value of the symbol will be in the 300xxx range of the address space instead of the 100xxx range. Apparantly the Yagarto linker adds the base value of the segment to the symbol. Therefore the initialisation of the  C-variables fails. For the demo it does not seem to be a problem but when using other functions for your own apllications the controller will surely crash. For example my printf hang-up the system. By moving the __data_beg_src__ initialisation to the .text segment the problem is solved:

	prog : 
	{
		*(.text)
		*(.rodata)
		*(.rodata*)
		*(.glue_7)
		*(.glue_7t)
	} >flash
	__end_of_text__ = .;
	__data_beg_src__ = __end_of_text__;
	.data : 
	{
		__data_beg__ = .;
		*(.data)
		__data_end__ = .;
	} >ram AT>flash

I tested this with Yagarto 4.6.2 and after modification everything (also printf) works.

Does anybody have similar experiences?

Rob

rtel wrote on Tuesday, February 21, 2012:

Thanks for your feedback.  I will look into this.

This particular demo is very, very, old and probably not used that much any more and the SAM3 chips are being pushed more by Atmel.  I don’t think the linker script has ever been modified.  From your post it would appear as if it was originally created from a linker script used to run the code from RAM.

Regards.