Hi,
i am using MK64FN1M0VLL12 controller. i am using KDS2.0 IDE. i want to store const structure in particular memory location.
how to do that one. assume i want to store const structure at 0x64000. give some example it will helpful to all.
my structure like this
const struct config_params default_params =
{
0xC0A800FE, //local IP address
7727, //local port No. 7727
7728, //local port No. 7728
7729, //local port No. 7729
7730, //local port No. 7730
0xFFFFFF00, //local Netmask
0xC0A800D2, //Gateway
}
thanks and regards,
sudhakar p
Solved! Go to Solution.
Hi,
I just modify the demo code .
see attached,
in ld file, i define a section called my_const:
my_const | (RX) : ORIGIN = 0x00000410, LENGTH = 0x00000100 |
.my_const :
{
KEEP(*(.myconst))
} > my_const
in C code, define structure as
const config_params __attribute__((section(".myconst"))) params_to_myconst=
{
0x12345678, //local IP address
0xabcd, //local port No. 7727
};
in memory window you will see the params_to_myconst allocated from 0x410.
can this help?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
hi,
can you give detail about "RelocateFunction" API function in internal flash writing.
flashSSDConfig.CallBack = (PCALLBACK)RelocateFunction((uint32_t)__ram_for_callback , CALLBACK_SIZE , (uint32_t)callback);
g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)__ram_func , LAUNCH_CMD_SIZE ,(uint32_t)FlashCommandSequence);
what is the use of this function and how to use this function
regards,
sudhakar p
hi
because one flash can not be written and read parallel. for writing flash, we need copy flash routine from flash to RAM then execute flash command and programming sequence from RAM.
I don't know where you got the code, but i think these code should on this regard.
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi sudhakar p,
I just made a demo code of allocating const struct in flash. see attached.
to avoid optimization, I add KEEP (*(.rodata)) in .text section in *.ld file.
can this help you?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
hi ,
thanks for your reply. but i want to store CONST structure in perticular memory address only i want that structure in 0x64000 location only for that what can i do..?
thanks and regards,
sudhakar p
Hi sudhakar p,
I hope this helps Defining Variables at Absolute Addresses with gcc | MCU on Eclipse
simple example :
const uint8_t __attribute__((section (".my_rodata"))) myData[256];
add this to the linker file :
.my_rodata_block 0x64000 :
{
KEEP (*(.my_rodata))
} > m_text
Best Regards,
Ondrej
Hi,
I just modify the demo code .
see attached,
in ld file, i define a section called my_const:
my_const | (RX) : ORIGIN = 0x00000410, LENGTH = 0x00000100 |
.my_const :
{
KEEP(*(.myconst))
} > my_const
in C code, define structure as
const config_params __attribute__((section(".myconst"))) params_to_myconst=
{
0x12345678, //local IP address
0xabcd, //local port No. 7727
};
in memory window you will see the params_to_myconst allocated from 0x410.
can this help?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------