Does anyone know what this linker error means and/or how to resolve it?
'Building target: USB_CDC_Test_App.elf'
'Executing target #4 USB_CDC_Test_App.elf'
'Invoking: ColdFire Linker'
"C:/Program Files/Freescale/CW MCU v10.2/MCU/ColdFire_Tools/Command_Line_Tools/mwldmcf" @@"USB_CDC_Test_App.args" -o "USB_CDC_Test_App.elf" -l"C:/Users/jim.fell/Source/Embedded/Libs/Target/Debug/Queue_MCF51JM.lib" -l"C:/Users/jim.fell/Source/Embedded/Libs/Target/Debug/USB_MCF51JM.lib" -l"C:/Users/jim.fell/Source/Embedded/Libs/Target/Debug/Debug_MCF51JM.lib" -l"C:/Users/jim.fell/Source/Embedded/Libs/Target/Debug/SArray_MCF51JM.lib" -l"C:/Users/jim.fell/Source/Embedded/Libs/Target/Debug/Serial_MCF51JM.lib" -l"C:/Users/jim.fell/Source/Embedded/Libs/Target/Debug/Text_MCF51JM.lib" -l"C:/Users/jim.fell/Source/Embedded/Libs/Target/Debug/Timer_MCF51JM.lib" -l"C:/Users/jim.fell/Source/Embedded/Libs/Target/Debug/valloc_MCF51JM.lib"
C:/Program Files/Freescale/CW MCU v10.2/MCU/ColdFire_Tools/Command_Line_Tools/mwldmcf|Linker|Error
>Illegal 16-bit small data area relative reference to symbol '_g_Mem'
>from address 0x000030BA in section '.text' of file 'USB_MCF51JM.lib
>usb_dci_c.o '.
>This type of reference has a range from 4294934528 to 32767 bytes.
>from address 0x00003202 in section '.text' of file 'USB_MCF51JM.lib
>usb_dci_c.o '.
I am using CodeWarrior for MCU v10 with the ColdFire V1 architecture. My application project is a simple bareboard project, which references multiple compiled libraries. All of the libraries build without issue. One of the libraries references a CDC library built using the Freescale USB stack v4.0.2. Changes I made to the stack were very minimal:
Functionality found in virtual_com.c was moved to one of the new libraries for abstraction purposes. I know where g_Mem is declared, but I'm confused as to why it's giving me this link error when I try to build my application with the USB driver in referenced libraries. Any help or insight into the linker error would be appreciated. Thanks.
Solved! Go to Solution.
Have you seen any linker/compiler warnings? That might be good indicators what is going wrong.
I have g_Mem[] non-static as I'm using it from another source file.
That location pragma in the source is used so I can use it in the linker file:
. = ALIGN(512); | |
__BDT_BASE = .; | |
*(.usb_bdt) | |
__BDT_END = .; |
Erich
Hello,
this means that the distance to the symbol/variable does fit any more into a 16bit offset. You need to change the 'memory' model of the compiler. Go into the project settings > ColdFire Compiler > Processor and select e.g. 'Far (32bit)' data model:
I hope this helps,
Erich
Hi Erich. Thanks for the tip, but my project settings were already configured for the Far (32 bit) Data Model. I tried changing the Code Model from Near Relative (pc16) to Far (32 bit), but it yielded the same results. All of my projects (library and application) are using the same ColdFire Compiler Processor settings:
Any other ideas? :smileyhappy:
Hmm, it looks like it is still using 16bit reference from usb_dci_c.o:
>Illegal 16-bit small data area relative reference to symbol '_g_Mem'
>from address 0x000030BA in section '.text' of file 'USB_MCF51JM.lib
>usb_dci_c.o '.
>This type of reference has a range from 4294934528 to 32767 bytes.
>from address 0x00003202 in section '.text' of file 'USB_MCF51JM.lib
>usb_dci_c.o '.
That might depend as well how g_Mem is referenced, Maybe your header file declaring g_Mem is using somehow a short segment?
As for my project (see USB CDC goes medical | MCU on Eclipse) I have it like this:
#pragma define_section usb_bdt ".usb_bdt" RW
__declspec (usb_bdt) uint_8 g_Mem[BYTES_1024];
Erich
The stack I'm using has g_Mem declared as static:
#pragma define_section usb_bdt ".usb_bdt" RW
__declspec (usb_bdt) static uint_8 g_Mem[BYTES_1024];
When I comment out the program line and declspec, as such...
//#pragma define_section usb_bdt ".usb_bdt" RW
/* __declspec (usb_bdt) */ static uint_8 g_Mem[BYTES_1024];
...everything seems to build okay. Would you happen to know if this is a valid workaround? Was g_Mem defined as within that special section for a reason? Thanks.
Have you seen any linker/compiler warnings? That might be good indicators what is going wrong.
I have g_Mem[] non-static as I'm using it from another source file.
That location pragma in the source is used so I can use it in the linker file:
. = ALIGN(512); | |
__BDT_BASE = .; | |
*(.usb_bdt) | |
__BDT_END = .; |
Erich
Hi Erich,
The solution is killing the Processor Expert generated FLASH.lcf file only.
For MCF52223 only a warning comes as doing it differently:
_g_Mem(.usb_bdt) in file usb_dci_cfv2_c.obj is referenced but has not been written. Check your linker command file.
However, in MCF51JM there is an error.
Can I see step by step solution?
Regards,
Marceli
Problem solved in component Help file and by disable PE build linker.
https://mcuoneclipse.com/2012/03/10/usb-or-not-cdc-with-processor-expert/
Thanks. I copied the .usb_bdt section from the linker file in the USB stack to the linker file in my application project, and it seems to be correctly building now.
Hi Erich. Can you please elaborate? I don't understand how that is helpful. Thanks. :smileyhappy:
Sorry for not being clear: I just wanted to show how I'm using it in the linker file.
Erich