Bootloader Image Questions

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

Bootloader Image Questions

3,053 Views
chadgraham
Contributor V

Hello,

I am trying to write a custom bootloader based on the evkmimxrt1060_ota_bootloader example program, but I'm having issues understanding some of the assumptions used in the example.  I am using the 1060-EVK dev board and I would like to install the evkmimxrt1060_iled_blinky example at location 0x6020 0000 so that I can try calling it from my bootloader.

  1. Why does the evkmimxrt1060_ota_bootloader example program immediately crash when I run it?  (I get an immediate hard fault prior to it even getting to the first instruction.)
  2. Is there a concise list that explains what I need to do to convert the evkmimxrt1060_iled_blinky example such that it can be used?
    1. I have references the "i.MX RT1060 Manufacturing User's Guide", "i.MX RT Flashloader Use Case", "elftosb User's Guide", "MCU Flashloader Reference Manual" and several other app notes, but I'm still confused.
  3. How does one determine the applicationAddress, APP_VECTOR_TABLE, and the MSP/PSP?
0 Kudos
3 Replies

3,038 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @chadgraham ,

1. I tested on my RT1060 EVK, it works fine. I guess there my be some software or hardware issue on your board. Can your own application or other demos in SDK run on your board? Have you set RT1060 in internal boot or fuse boot mode?

2. Please refer to the attachment. The start address of customer image is 0x60040000. And it need a OTA header.

3. You can set and change memory details in Properties->MCU settings. The interrupt vector address is set in .ld file.

 

Regards,

Jing

 

Regards,

Jing

0 Kudos

3,033 Views
chadgraham
Contributor V

Hello Jing,

  1. Yes, I am able to run other examples and my applications on the dev board.  We have done some minor mods to it such as routing the SPI to the Arduino connectors, but that was some months back and we've not had any issues with it.
  2. Thank you for the attachment, I will start studying it.
  3. Regarding the addresses, the bootloader is looking for the application address, MSP, PSP and Vector table.  My understanding is that the application start address is the one specified by the flash address in MCU settings and the vector table is offset by 0x1000, but where are the MSP and PSP?  Are they the same as listed in the registers when you start running the application?
  4. And a new question, how do I change the application start address?  Specifically, I took a clean copy of blinky, changed the QSPI address to 0x6020 0000 and reduced the size to 0x60 0000.  When I program the board in Debug mode, the program does not halt at the beginning of the example and the LED does not blink; I can see that the application is at the correct location.  (See attached pictures)

Thank you for the help.

0 Kudos

3,005 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

MSP and PSP keep the stack address. In interrupt vector table, the first word is stack address. Bootloader will get this address and put into MSP and PSP. Below is extract from bl_main.c

static void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer)
{
#if BL_FEATURE_OTFAD_MODULE
    quadspi_cache_clear();
    oftfad_resume_as_needed();
#endif

    shutdown_cleanup(kShutdownType_Shutdown);

    // Create the function call to the user application.
    // Static variables are needed since changed the stack pointer out from under the compiler
    // we need to ensure the values we are using are not stored on the previous stack
    static uint32_t s_stackPointer = 0;
    s_stackPointer = stackPointer;
    static void (*farewellBootloader)(void) = 0;
    farewellBootloader = (void (*)(void))applicationAddress;

    // Set the VTOR to the application vector table address.
    SCB->VTOR = (uint32_t)APP_VECTOR_TABLE;

    // Set stack pointers to the application stack pointer.
    __set_MSP(s_stackPointer);
    __set_PSP(s_stackPointer);

    // Jump to the application.
    farewellBootloader();
    // Dummy fcuntion call, should never go to this fcuntion call
    shutdown_cleanup(kShutdownType_Shutdown);
}

MCUXpresso can generate link file. It will put vector table at the top of image.

You can put your application image at anywhere, but you must change the bootloader to tell it the address. It defined in bootloader_config.h

#define BL_APP_VECTOR_TABLE_ADDRESS (0x60040000u)

You can trace this definition to see how it deal with application image.

 

Regards,

Jing

0 Kudos