CW50 Linker Error:

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CW50 Linker Error:

2,295 Views
datamstr
Contributor II
Hi All,
 
I am working with the MC908QB8 Demo Board and CW50. I am getting the linker error "L1102: Out of allocation space in segment RAM at address 0x117" when the following line of code is added:
 
     inbuff[index] = RChar; //save received char

 
This code takes the SCI received byte and saves it to an input buffer. (the variable "index" is set to 0)
Both "RChar" and "inbuff" variables are declard as type "byte". The line of code is not adding any new variables, so I am stick on this error.
 
Any thoughts?
 
TIA,
David Evennou
 
Labels (1)
Tags (1)
0 Kudos
4 Replies

459 Views
bigmac
Specialist III
Hello David,
 
The default PRM file for the QB8 specifies DEFAULT_RAM INTO RAM.  The RAM segment occupies 0x0100 TO 0x013F, a total of 64 bytes only, for both stack and global variables.  The default STACKSIZE is 0x30 (48 bytes), leaving only 16 bytes total for global variables.  I think this may be your present problem, especially if the buffer size exceeds 16 bytes.  The global buffer inbuff[] would need to be allocated to the Z_RAM segment to avoid this, possibly by the modified placement of DEFAULT_RAM INTO Z_RAM.
 
It is also problematic if the stack size should need to exceed 64 bytes.
 
This means that, for the majority of projects, the default PRM settings provided by CW new project wizard are quite inappropriate when using the QB8 device.
 
Regards,
Mac
 
0 Kudos

459 Views
datamstr
Contributor II
Hi Mac,
 
You are correct:smileyhappy: That is exactly what is happening. I suspect that the line of code I posted will "make use of the stack" for the array variable assignment and therfore caused the linker error even though no new variables were allocated. I changed the stack size to 32 bytes and the linker error has been removed.
 
Thanks for your help!
 
David
0 Kudos

459 Views
bigmac
Specialist III
Hello David,
 
I think I need to make a couple of additional comments -
 
The inbuf[] array variable will likely need to be allocated as a global variable, rather than a local variable on the stack.  This is required so that writing to the buffer, and the reading of the buffer contents can be handled by two separate functions, with both having access to the buffer.  Ultimately, the buffer write process could be handled by an ISR.
 
If you are programming in C, reducing the allocated stack size ia probably not a good idea.  While your program may compile and link without error, during normal operation of  the program, the stack may attempt to over-write the global variables anyway.  This type of bug may be very difficult to diagnose.
 
So it is a very good idea to keep the global variables, including the buffer, well separated from the stack.  With the default PRM settings, Z_RAM segment does not get used for anything, but this would seem the obvious place to locate the globals.
 
Regards.
Mac
 
0 Kudos

459 Views
NLFSJ
Contributor III
Hi,
 
I am not sure why you are receiving this error.  Maybe someone with more expertise will answer that for you.
 
Usually I suggest the following to fix the "L1102" error:
Increase the segment in your prm file or try to add compiler options to reduce the size of your datas/ram.
For more details and examples, check the smartlinker manual.
 
Regards,
Nina
0 Kudos