RTOS MSP and PSP

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

RTOS MSP and PSP

1,238 Views
347996379
Contributor III

Hi,team

 I think there is no problem with my jump address, and the program may run away after the jump. My app program is with RTOS, while the boot program is without RTOS.The RTOS is dual stack, do the MSP and PSP need to be modified before the boot jumps to the application?

The ld file of boot:

/* Specify the memory areas */
MEMORY
{
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_boot_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0000EF00


m_app_text (RX) : ORIGIN = 0x0000F410, LENGTH = 0x000D0BF0

/* SRAM_L */
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00008000

/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x0000F000
}

the ld file of app:

/* Specify the memory areas */
MEMORY
{
/* Flash */
m_boot_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0000EF00

m_interrupts (RX) : ORIGIN = 0x0000F000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x0000F400, LENGTH = 0x00000010
m_app_text (RX) : ORIGIN = 0x0000F410, LENGTH = 0x000D0BF0

/* SRAM_L */
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000

/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x0000F000
}

跳转1.png

跳转2.png

跳转3.png

0 Kudos
3 Replies

1,106 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello,

As you mention the PSP and the MSP should be modified before jumping to the application, the following routine corresponds to a bootloader example found in the Kinetis devices but the idea is the same for the S32K devices:

    shutdown_cleanup(kShutdownType_Shutdown); //disable the modules used in the bootloader

    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();‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I hope this helps you.

Best Regards,

Alexis Andalon

0 Kudos

1,106 Views
347996379
Contributor III

Hi,Alexis.

Thank you for your reply!Now my boot can jump to the app.However, when I jumped to boot from the app, the boot did not run successfully. Before judging this sentence, I used j-link to read the contents of memory. Both my boot and app were in the flash space I specified.When the app jumps to boot, I disallow watchdog and disallow global interrupt.The original software reset is able to achieve a direct jump to the boot, but the fact is not like this.I would like to ask whether it is related to RTOS, and whether there are any requirements on the stack between boot and app interchange. What work do I need to do before I can successfully realize the transition from app to app? Can you give me some information?

My boot does not have a home rtos, but my app has an rtos.

0 Kudos

1,106 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello,

If the memory spaces are correctly preserved, the RTOS shouldn't interrupt the execution of your program and shouldn't matter if your app or your bootloader is using an RTOS. I will suggest to double-check where are placed the bootloader and the application and be sure the peripherals are you using in the bootloader are correctly de-initialized before entering your application.

Best Regards,

Alexis Andalon

0 Kudos