How to avoid putting code into a particular place in FLASH?

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

How to avoid putting code into a particular place in FLASH?

1,287 次查看
stephenlangstaf
Contributor III

I have a linker command file that puts code into FLASH at address 0x0 .. 0xFFFF.

 

I want my code to "flow" around addresses 0x8000..0x8003 to ensure that the CPU does not see a BOOT_ID signature there.

 

Any hints?

标签 (1)
0 项奖励
回复
3 回复数

1,119 次查看
TICS_Fiona
NXP Employee
NXP Employee

Hello Stephen

You can define two memory sections in your link command file for program code. Like:

MEMORY {

# List of all sections specified in the "Build options" tab

.p_Code1  (RWX) : ORIGIN = 0x00000000, LENGTH = 0x00008000

.p_Code2  (RWX) : ORIGIN = 0x00008004, LENGTH = 0x00007FFC

...}

Or only define one section for code,  but pay attention to avoid the memory overlap inside SECTION{}, like below:

MEMORY {

# List of all sections specified in the "Build options" tab

.p_Code1  (RWX) : ORIGIN = 0x00000000, LENGTH = 0x0000FFFF

...}

SECTIONS {

{

}

.ApplicationCode :

{

              # .text sections

             * (rtlib.text)

              * (startup.text)

              * (fp_engine.text)

              * (ll_engine.text)

              * (user.text)

              . = 0X8000;

              F_BOOT_ID_start = . ;

              . = F_BOOT_ID_start + 0x004;

              F_BOOT_ID_end = .;

             

              * (.text)

        } > .p_Code

Hope this helps! If not, could you please supply the part number of your MCU?

Best Regards

Fiona Kuang

TIC - Technical Information Center

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Mark Correct button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,119 次查看
stephenlangstaf
Contributor III

The part I am using is an MPC5604B.

I realise that I can manually split the memory into two parts (via either of the methods you show) to avoid putting "random" data into a particular address but that means that I may have to juggle with which object files are assigned to which areas whenever the object files change.

At the moment I've got 30+ object files in my project and I can assign all of their ROMable sections to my FLASH area using a couple of lines that group all the .text and .text_vle content together without the rigmarole of a) listing all the files individually and b) allocating them into different sections in FLASH to make efficient use of the space available - that's something I expect a linker to do!

0 项奖励
回复

1,119 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Stephen,

Which chip do you used ?

You'd better put the BOOT_ID into the end of flash ,then you can use

the Program Flash Protection register (FTFA_FPROTn)

to protect the region from program and erase .

Hope it helps
Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复