Placing code/rodata into different FLASH blocks

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

Placing code/rodata into different FLASH blocks

7,130 Views
lpcware-support
Senior Contributor I

Most of the LPC18 and LPC43xx parts containing internal flash (such as LPC1857 and LPC4357) actually provide dual banks of flash. By default the managed linker script mechanism will place all of the application code and rodata (consts) into the first bank of FLASH.

However it is also possible to place specific functions or rodata items into the second bank of FLASH as displayed in:

Project Properties ->  C/C++ Build -> MCU settings

This placement is controlled via macros provided in an LPCXpresso header file which can be pulled into your project using:

#include <cr_section_macros.h> 

For simplicity, the *additional* FLASH region can be referenced as Flash2 (as well as using its "formal" region name - for example MFlashB512 - which will vary depending upon part).

For example, to place a rodata item into this section, you can use the __RODATA macro, thus:

__RODATA(Flash2) const int roarray[] = {10,20,30,40,50};

Or to place a function into it you can use __TEXT macro:

__TEXT(Flash2) void systick_delay(uint32_t delayTicks) { 
 :
 : 
} 

In addition the __RODATA_EXT and __TEXT_EXT macros can be used to place functions/rodata into a more specifically named section, for example:

__TEXT_EXT(Flash2,systick_delay) void systick_delay(uint32_t delayTicks) { 
 :
 : 
} 

will be placed into the section ".text.$Flash2.systick_delay" rather than ".text.$Flash2".

Related FAQs

Labels (1)
Tags (2)
0 Kudos
Reply
0 Replies