How can I allocate more than 32K of const data in program memory?
The total size of a PSV (Program Space Visibility) type section cannot exceed 32K because PSV pages cannot cross a PSV page boundary. With the default const-in-code memory model the compiler will place all const qualified variables into a PSV type section named '.const'. Other PSV type sections can be created using the space(psv) attribute.
This error most often occurs with the const qualified objects, as the compiler will normally allocate space(psv) attributed variables into their own section which will allow the linker to not overfill the PSV page.
The large objects placed in FLASH using space(psv) might also trigger this error. Please remember that there are size limitations on objects that the compiler can handle, for instance the maximum array size is 32K.
To resolve this link error, consider placing some larger const qualified objects into a compiler managed psv section instead. For example:
could be placed into a compiler managed psv section using the following declaration:
A related error message indicates that the compiler cannot allocate memory, even though there appears to be enough memory available. This can occur when there is not enough memory left within a page boundary. The 'prog' memory space does not have the restriction that memory must fit within a PSV page boundary. Placing objects in a prog space gives the tool chain more flexibility but is less efficient that space(psv). The same declaration above could be allocated: