0

I have put the two pieces of code together (originally described in This Question Here).

I have now just experienced this error from MpLab (Microchip MPLAB C30)

 Link Error: Could not allocate section .nbss, size = 20004 bytes, attributes = bss near 

Strangest thing, I looked for that message, even sub-strings of that message, in the Compiler manual (Microchip publication DS51284F) and found nothing.

I even looked for the single word allocate and found it only three or four times, never with an error message.

Prior to putting these two pieces of code together, I had a segment defined at 0x8000 which I was using for the "big chunk" of memory we are going to use to move data from Thing-X over to Thing-Y

I shrunk that data area which I had defined at 0x8000 down to 1 solitary byte, and I'm still getting this error.

I do not see this message documented in the compiler manual DS51284F from Microchip. Has anyone ever resolved this before ?

Is there a different manual for the linker ?

Is there a way that I can get a memory map to see where my memory areas are ?

Community
  • 1
  • 1
User.1
  • 2,562
  • 3
  • 33
  • 40
  • Sounds like you have the same problems as the forum post [here](http://www.microchip.com/forums/m343461.aspx), where the near data memory is only a small size and from your linker output you are trying to put 20k into it. But since I can't say definitively and can't check, this is only a comment. – tinman Mar 13 '13 at 17:23
  • Good eyes and +1 for that. Do you know how that guy produced the `Program Memory Usage` list he put in his post ? By the way, extra good eyes for finding that post. I searched Microchip's site and found zero – User.1 Mar 13 '13 at 17:27
  • Sorry, don't use mplab so can't say. But it'll likely be a linker setting for generating a map output. – tinman Mar 13 '13 at 17:28

1 Answers1

3

The error indicates that there is not enough memory left in the near data space for the un-initialized variables (near bss or in short nbss).

You can use these recommendations to reduce the data memory usage : 1) Use Compiler Optimizations, -O3 or -Os.

2) Select the Large Data Model under Compiler build options: - default -msmall-data - large (>8KB) -mlarge-data - small (<=8KB) -msmall-data The default data model is small.

3) Declare some of your variables in far space. This will free up the space in the near ram space.

4) Reduce the size or number of function parameters, for instance rather than passing a structure by value pass a pointer to the same instead.

5) Change the storage class of some of your local variables to static or make them global.

6) Where possible reuse local variables and parameters.

7) Use types which are no bigger than what they need to be, for instance the counter variable in for loop over 100 objects need only be as large as a char.

8) Place some of your initialized data / arrays into code space. -mconst-in-code

Cyclops
  • 108
  • 5