Relocating Code and Data in External MRAM. NXP CodeWarrior Development Studio
જાહેરાત
જાહેરાત
Chapter 14 Linker
___myRAMStart = .;
*(.myCodeInRAM)
___myRAMEnd = .;
. = ALIGN (0x4);
} > myram
14.9 Relocating Code and Data in External MRAM
Many times the internal RAM in the Microcontroller you are using is not enough for the application. For this reason it is needed to use external memories as part of the solution.
The process to relocate code and data in external memories is exactly the same as you did for internal RAM. The only difference is that the external device needs to be communicated by an interface controller.
14.10 Unique LCF Examples
This topic describes the following LCF examples.
•
Configuring Linker File to Several ROM Blocks
•
Place the Library File in the LCF
•
Place Symbols in Specific Memory Location
•
14.10.1 Configuring Linker File to Several ROM Blocks
The following listing is an example to configure linker file to several ROM blocks.
Listing 14-19. ROM IMAGE address = 0x3000
MEMORY{
internal_flash: org = 0x00003000, len = 0x0010000
MyFlash: org = 0x00041000, len = 0x00000008
//org should match the LOAD address
}
SECTIONS{
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
Freescale Semiconductor, Inc.
275
Unique LCF Examples
.text {} > internal_flash
.my_flash ALIGN(0x08) LOAD(0x00041000) : {} > MyFlash
}
14.10.2 Place the Library File in the LCF
The following listing is an example to place the library file in the LCF.
Listing 14-20. Placing library file in LCF
GROUP : {
.libcode (VLECODE) LOAD (0x00004000) : {
Runtime.PPCEABI.VS.UC.a (.text)
}
.libconst:
{
Runtime.PPCEABI.VS.UC.a (.rodata)
}
} > lib_flash
NOTE
For small data sections, ctors, dtors section it's not allowed to have different output section name.
14.10.3 Place Symbols in Specific Memory Location
For placing the symbols in specific memory location, user has to define the memory region (say Memory_to_store ) in the lcf file and also define a new section
(say .user_defined_section) then use the same section in the source file to place the symbol.
Listing 14-21. Example for initialized variable
In the source file:
#pragma section <section_qualifier(R,RW)> ".user_defined_section"
__declspec(section ".user_defined_section") int temp = 5;
In the LCF file:
GROUP : {
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
276 Freescale Semiconductor, Inc.
Chapter 14 Linker
.user_defined_section :{}
} > Memory_to_store // Memory_to_store is the memory area where user want to store
Listing 14-22. Example for uninitialized variable
In the source file:
#pragma section ".user_defined_section"".data"
__declspec(section ".user_defined_section") /* We cannot have an uninitialized section name in The //uninitialized section must be paired with initialized section. */
__declspec(section ".user_defined_section") int temp;
In the LCF file:
GROUP : {
.user_defined_section :{}
} > Memory_to_store
14.10.4 How to Relocate Code in RAM
The following listings provide sample code examples to relocate the code in RAM.
Listing 14-23. Sample code in the source file
#pragma section ".myCodeInRAM" code_mode=far_abs
__declspec(section ".myCodeInRAM") int _add(int a , int b); int main(void) {
volatile int i = 0;
volatile int total = 0;
/* Loop forever */
for (;;) {
total = _add(i , i);
i++;
}
}
__declspec(section ".myCodeInRAM") int _add(int a , int b)
{
return a + b;
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
Freescale Semiconductor, Inc.
277
ડાઉનલોડ કરો
જાહેરાત