how to store const structure in particular memory location in kds

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

how to store const structure in particular memory location in kds

跳至解决方案
3,825 次查看
sudhakarp
Contributor V

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

标签 (1)
0 项奖励
回复
1 解答
3,207 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

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!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

6 回复数
3,207 次查看
sudhakarp
Contributor V

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

0 项奖励
回复
3,207 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

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!
-----------------------------------------------------------------------------------------------------------------------

3,207 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

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!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
3,207 次查看
sudhakarp
Contributor V

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

0 项奖励
回复
3,207 次查看
ondrejlutera
NXP Employee
NXP Employee

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

3,208 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

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!
-----------------------------------------------------------------------------------------------------------------------