MpLab Link Error: Could Not Allocate Section (C30 Compiler)

↘锁芯ラ 提交于 2019-12-11 15:11:44

问题


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:


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



来源:https://stackoverflow.com/questions/15391996/mplab-link-error-could-not-allocate-section-c30-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!