MpLab Link Error: Could Not Allocate Section (C30

2019-08-20 06:01发布

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 ?

1条回答
孤傲高冷的网名
2楼-- · 2019-08-20 06:44

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

查看更多
登录 后发表回答