How to place heap in different sram banks with the linker script manager

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

How to place heap in different sram banks with the linker script manager

1,133 Views
Catosh
Contributor IV

I am developing on a LPC54xxx on MCUXpresso and I need a big heap. 

The linker script allows me to define the heap region only as a single sram bank; 

How is it possible (if possible) to define a heap spanning in multiple sram banks?

I suppose sing the textual editor it is going to be straight forward, but still don't get how to do it in the linker manager. 

Any hint would be very appreciated. 

B.R.

Luca.

3 Replies

924 Views
lpcxpresso_supp
NXP Employee
NXP Employee

I would suggest sticking with 1), but then potentially modifying your post-build step so that it modifies your output file (.axf) to split it into two - one part containing the main image, the second part containing just the "custom data flash". See section 14.11, "Post-build (and Pre-build) steps", of the MCUXpresso IDE v10.0.0 User Guide for more details

This post-build step would consist of something similar to :

arm-none-eabi-objcopy --only-section .text_Flash2 --rename-section .text_Flash2=.text -O elf32-littlearm "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}_EXTFLASH.axf"
arm-none-eabi-objcopy --remove-section .text_Flash2 -O elf32-littlearm "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.axf"

[Note section names will need matching agains those in your actual image. You can look in the map file and the disassembled image to work these out. - right click on the .axf in the Project Explorer and use Binary Utilities -> Disassemble]

Then when you debug, you will only get the main application programmed into flash. But if you want to reload the "custom data flash" with its default values again, you could, for instance, use the LinkServer GUI flash programmer to do so using the "_EXTFLASH" image. See section 10.5, "Using the LinkServer flash programmer", of the MCUXpresso IDE v10.0.0 User Guide for more details.

Regards,

MCUXpresso IDE Support

924 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Our heap allocator implementation cannot split the heap between multiple RAM banks.

Possible things you could do - depending on the details of the actual part being used:

1) If RAM banks are contiguous, then you could use the Memory Configuration Editor to merge them together - providing a larger overall RAM bank. There can be some issues with this, depending on what else you are doing in your system. But in many cases it will just work. But take care, for example, if your code is using IAP to update flash.

2) If you have two RAM banks in your memory configuration, then the first listed in the Memory Configuration Editor will be used by default for the global data, heap and stack (as show in the MCUXpresso IDE v10.0.0 User Guide - section 12.4 - Default image layout). But if your second RAM bank is smaller than the first, then you could use the Memory Configuration Editor to swap their order, so the small bank is used for globals and stack, and then use the Stack & Heap placement  Editor to move the heap into the larger RAM bank (see MCUXpresso IDE v10.0.0 User Guide- section 12.9.1 - MCUXpresso style heap and stack).

Regards,

MCUXpresso IDE Support

924 Views
Catosh
Contributor IV

Hello LPCX Support, thanks for the suggestion. I think I'll try option 1, then eventually move to a custom liker file. 

I have one more question related to memory management with the atuomated tool.

Let's say I want to have a different section for program and storage of custom data; which one is the correct approach?
1) split the flash into two areas with different location and aliases (flash 0-0x19000 and flash2 0x19000 - 0x40000) with the same driver?
2) reduce the size of the main flash and then do not insert into the tool another spare sector?

3) others (any hint very appreciated..) 

Bonus question: What does a cfx driver do in the tool? Is the implementation of the IAP/ISP API?

Thanks and best regards, 

L.T.

0 Kudos