Second state bootloader

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

Second state bootloader

1,081 Views
BiHDeveloper
Contributor I

I'm using the i.MX RT1052 CPU and I'm trying to create a second-stage bootloader at address 0x60002000 based on the NXP flashloader example. The application is supposed to be located at address 0x60080000. The bootloader is copied into RAM and executed, and then I'm using the jump_to_application function to jump to address 0x60080000. However, the device is going into a hard fault.

I'm not sure where I'm making a mistake in setting up: *appEntry = 0x60080000; *appStack = 0x2001FFFF; (as the DTC RAM memory size is 0x20000) SCB->VTOR = (uint32_t)APP_VECTOR_TABLE;

Can someone please help me debug this issue?

0 Kudos
Reply
7 Replies

827 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @BiHDeveloper ,

    Your bootloader is running in the external flash, and the led_blinky is also in the external flash.

   I checked your code, the main issues should caused by your led code contains the interrupt.

   To this situation, normally, customer need to copy the interrupt table to the internal RAM, or at least the interrupt ISR to RAM, then it will workaround the hardfault issues.

 

Wish it helps you!
If you still have questions about it, as this is case is really opened so long time, please help to create the new case if you have continuous issues, thanks so much!
Best Regards,

Kerry

0 Kudos
Reply

1,060 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @BiHDeveloper ,

   1. If you directly test your app which located in 0x60080000, whether it works OK or not?

   2. The hardware fault happens after the jumpto app, right? Or after enter the app, the app meet the hardfault?

   3. to the jump code, you can refer to the flashloader:

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);
}

also need to set stack point.

https://www.cnblogs.com/henjay724/p/9322963.html

If you still have issues, you also can refer to the SBL:

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

This also the secondary bootloader.

 

Wish it helps you!

Best Regards,

Kerry

 

 

0 Kudos
Reply

1,022 Views
BiHDeveloper
Contributor I
Hi @kerryzhou,
the debug output looks like this:

Thread #1 1 (Suspended : Signal : SIGSTOP:Stopped (signal))
             0x6008691c
             <signal handler called>() at 0xfffffff9
             0x60080000
             jump_to_application() at bl_main.c:212 0x20007d16
arm-none-eabi-gdb (10.2.90.20210621)

I jumped to the application address when the signal handler was called and stacked in a hard fault.
As an application I use the nxp example led_blinky (only a binary file created through mcuexpresso IDE). For the second state Flashloader, I use the nxp example as well, downloaded via the MCUExpresso Provisioning Tool to the flash memory.

Thank you for your assistance.

0 Kudos
Reply

1,003 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @BiHDeveloper ,

   Thanks for your effort.

    Can you also reproduce the issues on the NXP MIMXRT1050-EVKB board?

   If yes, please share me your tested project, I will find time to help you to check it on my board.

   In your app, do you do the flash operation like program and erase? If yes, you may also need to copy the vector table to internal RAM when you have interrupt function.

   Anyway, reproduce the issues on the NXP MIMXRT1050-EVKB, then I will help you to check it, thanks.

 

Best Regards,

Kerry

0 Kudos
Reply

965 Views
BiHDeveloper
Contributor I

Hi @kerryzhou ,

I wanted to let you know how incredibly grateful I am for your unwavering support and kindness.

On the other hand, I am forwarding two projects to you (bootloader and blinky application). I am using the IMXRT1050-evkb, and you can reproduce the error there. In the bootloader application, I have initialized an LED diode to indicate my current position in the code.

To transfer the blinky application to flash, I generate the binary file ( Binary Utilities -> Create binary) and then use the blhost commands to flash it.

Best regards


0 Kudos
Reply

846 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @BiHDeveloper ,

   Which SDK version you are using, I import your project, report the SDK unmatch, please tell me your used SDK version, thanks:

kerryzhou_0-1688466652793.png

 

0 Kudos
Reply

961 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @BiHDeveloper ,

You are always welcome!

I got your code, will find time to test it, please give me more time, thanks.

Any updated information, will let you know.

 

Best Regards,

Kerry

0 Kudos
Reply