Massimiliano Cialdi

A way to create a binary that is copied to RAM from the ROM bootloader in RT1050

Discussion created by Massimiliano Cialdi on Nov 26, 2018
Latest reply on Mar 13, 2020 by Victor Jimenez

Hello, everyone,
in the last few days I have been looking for a way for the ROM bootloader to copy to DTC RAM the binary I was building. In this regard you have probably seen some posts of mine and a colleague of mine. ( and
We have succeeded in the task, and here I want to explain how we did it. I know that probably there will be better and more direct ways, but this one is definitely a working one.

First of all, I'll start by describing our scenario, which involves having a project independent of MCUXpresso. The binary must be able to be built by makefile with the least possible use of external tools (hopefully none). Our Micro is i.MX RT1051


The reference manual

There are clues in the reference manual, but they are not conclusive.

For example:

Given what is written it might seem that the copy can only be made to OCRAM, but I believe that it can really happen in any destination. In fact here there is an example to copy in SDRAM.


BOOT Header

One of the things that is unclear is the position of the BOOT Header.

If you examine this image you will see that it seems that the entire Boot Header should be copied to the target memory. I haven't done much testing. I just saw that if it is not mapped to the target memory (and therefore not copied) it doesn't work, otherwise it does. Actually I still have several ideas for ways to try. I will do it in the future.



To simplify, we will start from an example provided by the SDK: led_blinky.

I imported the example keeping all the default settings:



Actually, for what we're going to do, it doesn't matter neither the library used, nor, for example, if the SDRAM is present or not (in my board there's no SDRAM), nor if the size of the flash is different.


Once you have imported the project, you need to change a linker setting.


This setting allows MCUXpresso to automatically create a linker script as similar as possible to the one we need.

So just build (Ctrl+B)

Once the building's over, you will find the created linker script in Debug directory:

you will need to edit this script to edit the line as shown in the following figure:

This causes the boot header to be mapped to RAM.

And another line to edit is:

You have to replace LOADADDR(.text) with LOADADDR(.boot_hdr). This is used to calculate the correct size of the image.


Then go back to the linker settings to uncheck Manage linker script


This makes MCUXpresso use the linker script just edited instead of overwriting it with a new one.


The last steps are more tricky: there is the need to edit a file provided by the SDK, which, in my opinion, is wrong.

The file is xip/fsl_flexspi_nor_boot.c


It's contents is:


And here is the IVT format:

if you try to follow the IMAGE_ENTRY_ADDRESS symbol you will see that it is defined as the address of the interrupt vectors. In my opinion this is wrong. According to the description of IVT format it should be the address of the ResetISR function.


Here is the Boot Data format:


In the fsl_flexspi_nor_boot.c Boot Data is populated with the address of the flash and the size of the flash. In my opinion this is wrong. Start field sould be in DTCM and length should be the actual size of the image.


Since I wanted to copy also boot header I modified the file as follows:

That's it.
I repeat that there are probably cleaner ways, where maybe you don't waste 8KB of the target memory for the boot header. However, this is a starting point.


Please let me know your feedback, comments, corrections and improvements.


best regards