S32K146 bootloader problem

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

S32K146 bootloader problem

1,660 Views
13530606925
Contributor I

Hi,SDK

I am developing a bootloader program for S32K146.

Now I am able to write my application code to the flash memory

but the boot loader is not jumping to the application code.

/*linker of bootloader*/

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

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

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

/*linker of application code*/

/* Specify the memory areas */
MEMORY
{
   /* Flash */
   m_interrupts (RX) : ORIGIN = 0x00025000, LENGTH = 0x00000400
   m_flash_config (RX) : ORIGIN = 0x00025400, LENGTH = 0x00000010
   m_text (RX) : ORIGIN = 0x00025410, LENGTH = 0x000DABF0

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

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

#define APP_ENRTY_POINT_FLASH_ADDR  (0x025000UL) 

  • My app jump function.

static void EnterAppPro(void)
{

   /*延时*/
   TimeDelay(2000);

   WDOG_disable();
   BSP_DISABLE_IRQ();

   /* 初始化中断向量表地址 */

   /* Check if a valid application is loaded and jump to it */
    JumpToUserApplication(*((uint32_t*)APP_ENRTY_POINT_FLASH_ADDR), *  ((uint32_t*)  (APP_ENRTY_POINT_FLASH_ADDR + 4)));

}

/**
* Used to jump to the entry point of the user application
* The Vector table of the user application must be located at 0x1000
*
* */
void JumpToUserApplication( unsigned int userSP, unsigned int userStartup)
{
   /* Check if Entry address is erased and return if erased */
   if(userSP == 0xFFFFFFFF){
   return;
   }

   /* Set up stack pointer */
   __asm("msr msp, r0");
   __asm("msr psp, r0");

   /* Relocate vector table */
   S32_SCB->VTOR = (uint32_t)APP_ENRTY_POINT_FLASH_ADDR;

   /* Jump to application PC (r1) */
   __asm("mov pc, r1");
}

I don't know where my code went wrong, could you give me some hints?

Thanks~~

Tags (1)
0 Kudos
Reply
5 Replies

1,440 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Jack,

The bootloader and application address space are overlapped. I recommend changing the length of the bootloader or/and start address and length of the application.

Also, before the jump, I recommend you to check if the application is correctly loaded into memory. For example, by memory window located in the S32DS. 

pastedImage_1.png

I hope it helps.

Best regards,

Diana

0 Kudos
Reply

1,440 Views
347996379
Contributor III

Hi,Diana

First, my program and successfully downloaded into.

"The bootloader and application address space are overlapped."

Can you tell me why the addresses I configured overlap and how they are distinguished?

How should I configure my boot file and app file separately?

0 Kudos
Reply

1,440 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi, 

Your bootloader length is 0xDABF0. So, you have reserved for the bootloader 874KB 

 m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x000DABF0

But the application starts at address 0x25000 which is address located in the bootloader address space.

It is up to your application requirements how you split the address space. 

What size of memory do you need to reserve for bootloader and application?

 

How do you load the application into the flash memory of the MCU, do you use Srecord, hex, ... (if yes, can you share it)?

The documents below can be helpful:

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

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

Best regards,

Diana

0 Kudos
Reply

1,440 Views
13530606925
Contributor I

Hi,Diana

        My code has been able to implement the bootloader function, but there is a problem in the middle.My app code is more than 300K. In my test, boot jump to app is successful only if the app code is below 196K. Plus the size of the boot space (60K) I divided, it is exactly 256K (0x40000).I don't know where the problem is, whether it is related to ld file.My boot space is: 0x0000-0x0F000;My app space is: 0x0F000-0xD0BF0. Can you give me some hints?Looking forward to your reply, thank you very much

0 Kudos
Reply

1,440 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Jack,

Have you seen any error during loading application into memory when the app code is more than 300KB, for example, in the FSTAT register?

Have you tried to debug the code, when is writing to the address 0x40000?

Best regards,

Diana

0 Kudos
Reply