Hi,
I'm using CW 10.1 with Coldfire MCF51MM128 and I'm having problem when the code reach more than 0x0000FFE8 getting the following linker error:
>Overflow in segment: code from section: .text
>Segment reserved size is: 0x0000ffe8 -- Overflow of: 0x00000620
By default CW creates two memory segments for flash flash, as below:
code (RX) : ORIGIN = 0x00000414, LENGTH = 0x0000FFE8
code_00010410 (RX) : ORIGIN = 0x00010410, LENGTH = 0x0000FBF0
and the .text segment is declared by default as:
.text :
{
*(.text)
. = ALIGN (0x4);
*(.rodata)
. = ALIGN (0x4);
___ROM_AT = .;
___DATA_ROM = .;
} >> code
On my understanding it does this because this mcu has 2 flash controllers and @0x0000040D @0x0001040D some non volatile registers (like the flash protection registers) are located.making the memory for code non continuous.
Now, how can I tell the linker to use both memory segments ("code" and "code_00010410") for ".text" section?
I believe this is the root cause of the linker error message.
Thanks in advance,
Andrés
Hello Andres Villalobos:
The ColdFire linker is not able to split the .text section into both flash spaces automatically. It is possible however to modify the linker file and manually place code from source files to the different memory segments. There should be a document in your installation about ColdFire build tools, but just in case I attach it here. Refer to Chapter 14 about Linker usage and in particular to sections 14.5.3 and 14.6.4.
You can also find the next application note useful, which explains how to locate code to specific memory segments:
http://cache.freescale.com/files/soft_dev_tools/doc/app_note/AN4329.pdf
This workaround may not be optimal, but I guess this is the only option.
Also, CW v10.1 is a very, very old version. I recommend you to install the latest version, CW for MCU v10.6.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jorge/Xin Kuang,
thanks for the clarification. I´ve already tried to change the linker file to allocate the ".text" section from some files into the new section following the appnote like below:
.text2 :
{
usb_main.c (.text)
. = ALIGN (0x4);
usb_main.c (.rodata)
. = ALIGN (0x4);
___ROM_AT2 = .;
___DATA_ROM2 = .;
} >> code_00010410
but I've got the following linker error:
### C:/Program Files/Freescale/CW MCU v10.1/MCU/ColdFire_Tools/Command_Line_Tools/mwldmcf Linker Error:
# Linker command file error at line 47
# File not found: usb_main.c
Any clue?
Thanks in advance,
Andrés
Hello Andres:
- Try with these changes:
usb_main.c(.text) -> usb_main_c.obj(.text)
usb_main.c(.rodata) -> usb_main_c.obj(.rodata)
- Make sure that your .text2 section is defined before the .text section in the linker file, like below. This is because there is a wildcard in the .text section that will scan all of the object files, thus ignoring your references to specific files if declared later.
.text2 :
{
...
} >> code_00010410
.text :
{
...
*(.text) // <- Wildcard
...
} >> code
- You may need to change the code addressing scheme. Go to Project -> Properties -> C/C++ Build -> Settings -> ColdFire Compiler -> Processor, and set Code Model as Smart and Data Model as Far:
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
CodeWarrior linker cannot allocate the code into two memory segments automatically. If you want to place some code into “code”, the others into “code_00010410”, you may create a new section for the source code using “#pragma define_section” in some C files, and in link command file, place this new section in “code_00010410”, and place .text in “code” by default.
For how to create a new section and allocate it in link command file, please refer to < 4 Relocating Code in ROM > in:
http://cache.freescale.com/files/soft_dev_tools/doc/app_note/AN4329.pdf
Fiona Kuang
Technical Information & Commercial Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------