imxrt1170 custom bootloader linker file problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imxrt1170 custom bootloader linker file problem

Jump to solution
2,549 Views
burhanhagi
Contributor IV

Hello, 

I have one custom bootloader located at 0x30000000 till 0x30080000. I compiled it with these addresses.

After that, my main app starts from 0x30800000 till 0x31000000. I compiled my main app with these addresses.

When I compiled my main app:

Automatically generated project_name.debug.ld file in Debug folder does not add below header info to linker file. However if I start my main app with 0x30000000 address, that debug.ld file adds below lines as it should be.

Since I have to use my bootloader, I need to compile my main app with offset  address I stated above. Otherwise, if it does not have below lines, my main app does not work.

So, how can I keep below lines in debug.ld file when I compile my app with offset relative to 0x30000000 address? I do not want below lines to be deleted automatically.

burhanhagi_0-1728425733913.png

 

 

0 Kudos
Reply
1 Solution
2,342 Views
mayliu1
NXP Employee
NXP Employee

Hi @burhanhagi ,

Thank you for your updated information.

 I use MCUXPresso IDE generate bootloader and app image separately, then I use JFlash tool to merge bootloader and app image into a hex file.

         Please refer Jlink使用技巧之合并烧写文件 - whik - 博客园 (cnblogs.com).

mayliu1_0-1728710373869.png

 

I try to up load my bootloader and app project, but it was limited by exceeding the maximum file size, so I upload the whole project hex file.

mayliu1_1-1728710565837.png

hardware: MIMXRT1170-EVKB board

When the sw7 button is pressed the first four times, the LED will light up. When the sw7 button is pressed for the fifth time, the boot loader program will jump to the APP, and the LED light does not need to press the button to flash periodically.

I will show you bootloader critical code. It is just a demo, Please modify and strictly verify according to your needs.

mayliu1_3-1728711149558.png

Wish it helps you.
If you still have question about it, please kindly let me know.

 

Best Regards

mayliu

 

View solution in original post

18 Replies
2,521 Views
mayliu1
NXP Employee
NXP Employee

Hi @burhanhagi ,

Thank you for your interest in the NXP MIMXRT product, I would  like to provide service for you.

Please tell me about the IDE you use, if you use MCUXPresso IDE.

Please check the following points:

1: The follows resources will be refreshed after the project is built

mayliu1_0-1728458955504.png

2: Window->Preferences->Run/Debug->Launching-> Uncheck it Build(if required) before launching

 

mayliu1_2-1728459180479.png

 

 

Wish it helps you.
If you still have question about it, please kindly let me know.

 

Best Regards

mayliu

 

 

 

0 Kudos
Reply
2,518 Views
burhanhagi
Contributor IV

Hello @mayliu1,

 

I did your directives. But it does not help me. Problem still exists.

Here is the SS.

burhanhagi_0-1728460257442.png

 

My memory address is below

burhanhagi_1-1728460316890.png

As I mentioned, when ı give offset address to the origin 0x30000000, IDE deletes the required parts in debug.ld file in Debug Folder as below automatically.

burhanhagi_2-1728460478860.png

 

I need the above one in automatic linker file.

 

My IDE is MCUXpresso v11.8.1

0 Kudos
Reply
2,491 Views
mayliu1
NXP Employee
NXP Employee

Hi @burhanhagi ,

 

Thank you for your updated information, I would  like to provide service for you.

mayliu1_0-1728525837489.png

Please try to set as I show.

Wish it helps you.
If you still have question about it, please kindly let me know.

 

Best Regards

 

 

0 Kudos
Reply
2,488 Views
burhanhagi
Contributor IV

Hi @mayliu1 , 

I have used it in a way you suggested up to now. That is why I am aware of that for a long time.

However. I have to make everything as automatized with some script files. I need a permanent solution, not manual intervention. Because I will use it in a mass production.
That is why it does not solve my problem. 

0 Kudos
Reply
2,451 Views
mayliu1
NXP Employee
NXP Employee

Hi @burhanhagi ,

 

I'm sorry for the incorrect understanding of your question before.

section "BOARD_FLASH" is used for boot ROM, It is related to the address 0x30000000 the address,  For example ,IVT address is Absolute address.

mayliu1_2-1728542614635.png

 

mayliu1_1-1728541997587.png

I think you can refer to MIMXRT1170RM 10.1 Chip-specific Boot Information.

https://www.nxp.com/webapp/Download?colCode=IMXRT1170RM

 

 

Your bootloader located at 0x30000000 till 0x30080000. It must need section "BOARD_FLASH".

Your App starts from 0x30800000 till 0x31000000, I think this APP project do not need  section "BOARD_FLASH", because if your bootloader start successfully,  do some of your logical processing , then will jump to the app 0x30800000.

Wish it helps you.
If you still have question about it, please kindly let me know.

 

Best Regards

mayliu

 

 

 

 

 

 

 

 

 

 

2,438 Views
burhanhagi
Contributor IV

@mayliu1 , I faced this kind of problem a while ago. However, as you see in the link, The method suggested there helped me. Now the same debug.ld file causes me to prevent from automating of process. I think there must be an easy method in the below link.
https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/imxrt1176-freertos-linkerscript-file-problem/m-p...

0 Kudos
Reply
2,443 Views
burhanhagi
Contributor IV

Hi @mayliu1, As I stated before, my app works well. However, without those lines in debug.ld file, my app does not work and enters exception. So I need those lines. 
I tried without those lines, even today again, but it not work. So please help me a way how to keep those lines there when I compile my app. 
I think there should be a simple method or simple setting in IDE to keep it there. Thanks

0 Kudos
Reply
2,379 Views
mayliu1
NXP Employee
NXP Employee

Hi @burhanhagi .

 

Thank you for your updated information,  I would  like to provide service for you.

I don't think your problem is to set up the MCUXPresso IDE , but to solve the problem of why your APP  don't work.

Answer 1:

If you still want setting MCUXPresso IDE to not change xx__Debug.ld, I have shown to  you. 

mayliu1_0-1728699171325.png.

 

Answer 2: I use MIMXRT1170-EVKB board,  and program bootloader and  app project.

The Bootloader address and APP address setting is exactly the same as those you set. 

And APP Debug.ld  do not have section "BOARD_FLASH".

mayliu1_5-1728700056179.png

 

I can jump to the APP successfully. Please check your Bootloader and app code.

Bootloader:mayliu1_4-1728699754209.png

APP:              mayliu1_3-1728699735510.png

mayliu1_2-1728699703386.png

 

Wish it helps you.
If you still have question about it, please kindly let me know.

0 Kudos
Reply
2,350 Views
burhanhagi
Contributor IV

Hi @mayliu1 ,

 

How did you load your bootloader code and your main app code to flash? Are you loading them with debugger seperately? 

Also when only bootloader is running, are you able to write your main app code to the same flash with yout bootloader? If yes, what is your bootloader code xip_boot_header_enable, xip_external_flash and xip_dcd_header_enable preprocessor flags value? Also what is those flag values in your main app? Which address are you jumping when switch bootloader to main app? After compiled your bootloader code, which address do you start to load your code to Flash? Also after compiled your main app code, which address do you start to load your code to this same Flash? 

Can you please upload your bootloader and app source codes as project? Maybe I can see the difference much better if I see the each code and details.

Thanks a lot.

0 Kudos
Reply
2,343 Views
mayliu1
NXP Employee
NXP Employee

Hi @burhanhagi ,

Thank you for your updated information.

 I use MCUXPresso IDE generate bootloader and app image separately, then I use JFlash tool to merge bootloader and app image into a hex file.

         Please refer Jlink使用技巧之合并烧写文件 - whik - 博客园 (cnblogs.com).

mayliu1_0-1728710373869.png

 

I try to up load my bootloader and app project, but it was limited by exceeding the maximum file size, so I upload the whole project hex file.

mayliu1_1-1728710565837.png

hardware: MIMXRT1170-EVKB board

When the sw7 button is pressed the first four times, the LED will light up. When the sw7 button is pressed for the fifth time, the boot loader program will jump to the APP, and the LED light does not need to press the button to flash periodically.

I will show you bootloader critical code. It is just a demo, Please modify and strictly verify according to your needs.

mayliu1_3-1728711149558.png

Wish it helps you.
If you still have question about it, please kindly let me know.

 

Best Regards

mayliu

 

2,312 Views
burhanhagi
Contributor IV

Hi @mayliu1

No need full project codes anymore. The part you shared shows the useful part. 
Actually, I had ported already existing codes from ST platform to NXP platform. In ST platforms, I did the same as you shared above when I want to jump APP. However in NXP, the situation has a little bit changed. I reviewed several examples as well as mcuboot_opensource specially example in SDK. It shows there when trying to jump your APP:

0x2000 address offset relative to the first loaded flash base address. So, in our case, 0x30080000 + 0x2000 address is my jump address. At first I surprised because I thought I must have added +4 for ISR Reset Handler. Also I had questioned why 0x2000 offset required? Because this part is only being questioned by on-chip Boot Rom firmware at initial power-up. Anyway, when my codes are running perfect, I do not make any additional steps or consideration. Just admit it was true and OK.

My jump address and yours is different. That is why you do not need the first required boot header info. But I wonder why mcuboot_opensource SDK example explains different than you? Is it possible to review that example? I really wonder where I am missing there.

Thank you very much for your valuable assistance. I will try it on Monday and share the results with you. 

 

0 Kudos
Reply
2,229 Views
mayliu1
NXP Employee
NXP Employee

Hi @burhanhagi ,

 

Thank you for your updated information.

I look forward to your good news and thank you for sharing your results with me.

My previous routine settings are based on your settings to verify, if it is different from NXP SDK demo, please use SDK demo as the standard.

 

Waiting for your good news

 

Best Regards 

mayliu

2,225 Views
burhanhagi
Contributor IV

Hi @mayliu1 ,

Thank you very much for your valuable helps and guide.

It worked. No need boot header section in linker debug.ld file of APP anymore.

Have a nice day. Best Regards

Burhan

0 Kudos
Reply
557 Views
KAVIN_M
Contributor II

Hi @mayliu1, @burhanhagi

If possible, please share the Project that linker is modified.
I can't understand the above solution

0 Kudos
Reply
544 Views
burhanhagi
Contributor IV

Hi @KAVIN_M ,

It is not possible to share the project. However, I can share the settings as below;

I have 2 firmware running. First when power enters into the PCB, below settings bootloader is running first;

burhanhagi_2-1743580634351.png

 

burhanhagi_1-1743580602730.png

 

As you see above, first bootloader is copying itself to the external SDRAM.

When bootloader finishes its job, it runs the main firmware as below;

 

burhanhagi_3-1743580850597.png

 

Lastly, the main firmware begins to execute. Here is its settings;

burhanhagi_4-1743580933808.pngburhanhagi_5-1743580995440.png

 

As you know; linker is automatically created by IDE according to the above settings. So sharing it is the same with linker files. 

By the way; in boot firmware the preprocessor flags is as below;

burhanhagi_6-1743581145130.png

 

However, in main firmware those flags is as below;

burhanhagi_7-1743581227455.png

Hope it helps.

 

 

0 Kudos
Reply
539 Views
KAVIN_M
Contributor II
Hi @burhanhagi

Clear me this in your case
Bootloader and Application both where separate projects right?

What is did so far for BL start adder 0x30000000, only size is modified using the MCU setting in IDE.

In Application project, using MCU Setting offset the board flash start address w.r.t BL size(len).
But the code is either getting into Active fault sometimes or not reaching the desired location.

Once the linker is modified (address offset) the project is not working properly. Is it related to the QSPI flash driver or anything else.

If possible, please provide a document with step-by-step instructions for modifying the linker.

Thanks & Regards
KAVIN

0 Kudos
Reply
535 Views
burhanhagi
Contributor IV

@KAVIN_M ,

 

I added linker files for both projects in attachment. Hope it clears.

 

0 Kudos
Reply
537 Views
burhanhagi
Contributor IV

You do not need to modify linker files manually. You should leave it as it is created for both. When I first encounter the problem, I took some problems as well because of changing linker files. But not required to change it.  

Yes, they are two different projects. I only once write BL to the flash with NXP secure Provisioning Tool. Later than, in IDE I start/stop my main IDE with debugger. 

You should not take any fault in any step. If there is, then possible to have some problem with your code elsewhere.

0 Kudos
Reply