Hai all,
I am facing some problems while placing a function in a particular location in flash memory.
I have explained the issues below.
To do this I modified the LCF as follows.
/**********************************************************************/
resetvector: org = 0x00030000, len = 0x00000010
init: org = 0x00030010, len = 0x00000FF0 /* ~4K */
exception_handlers_p0: org = 0x00080000, len = 0x00010000
exception_handlers_p1: org = 0x00090000, len = 0x00010000
internal_flash: org = 0x000A0000, len = 0x00090000 /* 1792 KB*/
myrom_1: org = 0x00130000, len = 0x00004000
key_segment: org = 0x0013FFF8, len = 0x00000008 /* 8 byte for key*/
/***************************************************************************/
/***************************************************************************/
GROUP : {
.rom_symbols1 (VLECODE):
{
__ROM_SYMBOLS = 0x00130000; /* start address of the new symbol area */
. = ALIGN (0x4);
*(.romsymbols1) /* actual data matching pragma directives. */
. = ALIGN (0x4);
}
} > myrom_1
.__key_segment LOAD (0x0013FFF8): {} > key_segment
/***************************************************************************/
In source code I declared the function as follows.
#pragma section RX ".romsymbols1" code_mode=far_abs
__declspec(section ".romsymbols1") void funcInROM_Test_1(int flag,int *); //Function Prototype
#pragma push
#pragma section all_types ".__key_segment" ".__key_segment"
unsigned long long key = BOOT_KEY;
#pragma pop
void funcInROM_Test_1(int flag,int *iData)
{
const int i = 55;
if (flag > 0)
{
flag ++;
}
*iData = 111;
}
Program compiled successfully and I verified the MAP file. I n MAP file I can see both the functions are placed in locations as I expected. But
.rom_symbols1 section layout
Starting Virtual File
address Size address offset
---------------------------------
00000000 00000c 00130000 0000e1d0 1 .romsymbols1 OBC_Main_c.obj
00000000 00000c 00130000 0000e1d0 2 funcInROM_Test_1 OBC_Main_c.obj
In memory map section I found the following line.
Memory map:
.rom_symbols1 00130000 0000000c 0000e1d0 000ad270 000ad270 34572 0000d270 DP_SPL_6202_FWO_QT(RSM)_PXS3020_1V00.000A0000.bin
Starting Address – 0x00130000;
Size – 0x0000000c;
File Offset – 0x0000e1d0;
ROM Address – 0x000ad270;
RAM Buffer Address – 0x000ad270;
S Record Line number – 34572;
Bin file offset – 0x0000d270;
Bin file Name - DP_SPL_6202_FWO_QT(RSM)_PXS3020_1V00.000A0000.bin
Here S Record Line number and the corresponding address made me confused. The memory address available at line number 34572 is not matching with 0x00130000. Please check the attachment. Instead of 0x00130000, it is 0x000ad270.
A screenshot of the location 0x00130000 is also attached. Please check it.
This made me really confused. Somebody please help me to solve this problem.
I will appreciate any help.
Thank you all.
Original Attachment has been moved to: DP_SPL_6202_FWO_QT(RSM)_PXS3020_1V00.MAP.zip
Original Attachment has been moved to: MPC5675K_FLASH.lcf.zip
Original Attachment has been moved to: DP_SPL_6202_FWO_QT(RSM)_PXS3020_1V00.mot.zip
Hai all,
I found some solution. I have gone through the MCU_Power_Architecture_Compiler document and I found an example for absolute placement of code in flash.
I have given the piece of code below.
#pragma push
#pragma section code_type ".abs.00010000" code_mode=pc_rel
asm void _ISRVectorTable(void)
{
b InterruptHandler
nop
b InterruptHandler
}
#pragma pop
MEMORY
{
//internal Flash
APPL_INT_VECT : org= 0x00010000, len= 0x000000FF;
// If org is changed, make sure to adjust start
// address in .abs.00010000 LOAD (0x00010000): {} >
// APPL_INT_VECT accordingly
// ...
}
SECTIONS {
.abs.00010000 LOAD (0x00010000): {} > APPL_INT_VECT
<...>
}
I verified both MAP file and .MOT file and found OK.
But I want to know the difference between placing a piece of code using "#pragma push" and "__declspec".
I think "#pragma push" place the function at the physical memory as specified in LCF and I don't know what exactly is happening in the case of "__declspec".
Somebody please help me and clarify my doubts.
Also I want to modify a function which is already available in a fixed location(say 0x00040000) during run time. That is, I will receive the S Record file for that particular function through UART and keep it in RAM. After validating the checksum of the received data, I would like erase the particular sector(0x00040000) and write the received data. If I call the function after modifying it, will it work?
Thank you.