How does the bootloader decide if xip or not xip?

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

How does the bootloader decide if xip or not xip?

3,105 Views
mastupristi
Senior Contributor I

I can find this figure in the reference manual:

qspi-flowchart1.png

and I wonder how the ROM bootloader manages to decide in which of the two branches of the highlighted if block should go.

Which IVT and boot data structure fields does it check? What values do they have to take to go to one or the other branch?

best regards

Max

0 Kudos
Reply
8 Replies

2,775 Views
igorpadykov
NXP Employee
NXP Employee

Hi Max

you are right, it checks boot data structure fields as described in Figure1 Bootable image layout

AN12107 How to Enable Boot from Octal SPI Flash and SD Card 

and if destination memory is the same as boot memory, it considers it as xip.

https://www.nxp.com/docs/en/application-note/AN12107.pdf 

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

0 Kudos
Reply

2,775 Views
mastupristi
Senior Contributor I

so, the ROM bootloader needs to know the addresses and size of the boot memory and the destination memory.

I guess the ROM bootloader can deduce the boot memory address based on the boot device selected by the fuses, right? (I don't know about its size).

I wonder which fields of IVT and/or boot data structure are used by the ROM bootloader to infer address and size of the destination memory. Entry field of IVT? Start field of boot data structure?

What happens if Entry does not reside within the memory defined by boot data? What if the boot memory is also different?

best regards

Max

0 Kudos
Reply

2,775 Views
igorpadykov
NXP Employee
NXP Employee

>which fields of IVT and/or boot data structure are used by the ROM bootloader to

>infer address and size of the destination memory. Entry field of IVT? Start field of boot data structure?

size does not matter, address fields are described in Figure1 Bootable image layout

AN12107 How to Enable Boot from Octal SPI Flash and SD Card 

https://www.nxp.com/docs/en/application-note/AN12107.pdf

Best regards
igor

0 Kudos
Reply

2,775 Views
mastupristi
Senior Contributor I

so, to determine if XIP or not XIP, the ROM bootloader uses the start field of the boot data structure and compares it with the boot memory address space, right?

The flash is at the address 0x60000000, in my case it's big 2MB, so it ends at the address 0x601fffff

In the case of XIP the start field has to contain the value 0x60000000 (base address of the flash)?

If start contained a value different from 0x60000000 but still inside the flash, such as 0x60003000, would it be XIP or not XIP?

Does the IVT Entry field not affect the ROM bootloader in the choice between XIP and non-XIP?

best regards

Max

0 Kudos
Reply

2,775 Views
igorpadykov
NXP Employee
NXP Employee

ROM bootloader knows that it boots from FlexSPI and then see that destination

memory addresses also in that range (Table 2-1. System memory map i.MXRT Reference Manual),

so it considers it as xip. If it see that destination memory addresses are in SEMC external

memories (SDRAM) then it is not xip.

Best regards
igor

0 Kudos
Reply

2,775 Views
mastupristi
Senior Contributor I

igorpadykov wrote:

ROM bootloader knows that it boots from FlexSPI and then see that destination

memory addresses also in that range (Table 2-1. System memory map i.MXRT Reference Manual),

so it considers it as xip. If it see that destination memory addresses are in SEMC external

memories (SDRAM) then it is not xip.

then the question becomes another: how does the ROM bootloader deduce the destination memory addresses? Which fields are involved? For example, in the source code of the ROM bootloader I guess there is something like the following pseudo-code:

uint32_t dest_mem;
struct IVT ivt;
struct BOOT_DATA boot_data;

dest_mem = Get_Dest_Mem(&ivt, &boot_data);‍‍‍‍‍

Could you detail the Get_Dest_Mem() function in pseudo-code or words?

You said "size does not matter", but I think that in a non-XIP scenario ROM bootloader have to know how many bytes to copy to destination memory, right?

if I want XIP

how should I populate boot data fields? The start field which value should it contain? Should it contain the exact base address of the boot memory or should it just contain an address inside the flash? In this case the ROM bootloader should also know the size of the flash, right? And what about IVT's Entry field? Is it used by the ROM bootloader to calculate the destination memory or is it only used to set the PC register?

If I want non-XIP

how should I populate boot data fields? In this case, the size field is taken into account, right? In this non-XIP case the ROM bootloader makes a copy from the boot memory to the destination memory, right? Could you express this copy to me in terms of memcpy()? What parameters should I pass to this hypothetical memcpy? In this example, could you avoid using the terms "boot memory" and "destination memory"? Could you express the parameters only using the fields of the data structures? For example, boot_data.start or IVT->entry.

best regards

Max

0 Kudos
Reply

2,775 Views
igorpadykov
NXP Employee
NXP Employee

>how many bytes to copy to destination memory

pastedImage_1.jpg

Unfortunately I am not aware of official nxp documentation explaining this using "boot_data.start or IVT->entry".

Regarding MCUExpresso or other software api questions suggest to create new thread.


Best regards
igor

0 Kudos
Reply

1,245 Views
Itomarayo
Contributor I

In that case, size matters, right?

0 Kudos
Reply