Hi,
We are using S32k144 in our project. As per use case requirement we need to update the Firmware of S32k144 with the help of UART interface(a/b approach-Firmware will occupy the complete memory).
Is there any test code/procedure document by which we can update the firmware with the help of UART.
Hi Lukas,
Thanks for the reply I have ported the code of boot loader code to IAR.
Now I am able to write my application code to the flash memory
but the boot loader is not jumping to the application code it is showing Hardware fault.
/*linker of bootloader*/
/*linker of application code*/
Hi,
the linker files don't help...
Did you disable all interrupts before jump? It's necessary to disable globally and also disable all local enable bits. It's good practice to put everything to default state before jump.
If you step asm code, which instruction does cause the hard fault?
Regards,
Lukas
Hi Lukas,
Thanks for the reply.
We are disabling the interrupts before jump. Please find the below code.
After the execution of jumptoUserApplication()
the code is getting stuck in AC0_IRQHandler().
Please help me where am I going wrong
#include "timeout.h"
#include "comm.h"
#include "clock.h"
/* Bootloader definitions */
/* Start address for the application received by the bootloader
* application vector table should start at this address
* */
#define APP_START_ADDRESS 0x1000
/* Global variables */
uint8_t boot_from_comm = 0; /* Used to signal activity on the comm channel */
/* Prototype */
void JumpToUserApplication( unsigned int userSP, unsigned int userStartup);
void NVIC_SCBDeInit(void);
/* Main Application*/
int main(void)
{
/* Initialize clock */
clock_initi();
/* Initialize communication interfaces */
init_comm();
/* Initialize timeout */
init_timeout();
/* Check if boot start has been received or timeout occurred */
do{
uint8_t word_received = comm_status_rx();
if(word_received){
boot_from_comm = 1;
comm_download_app();
}
} while((!timeout()) & (!boot_from_comm));
/* Disable all systems and leave device as if coming out of reset */
/* Relocate vector table */
S32_SCB->VTOR = (uint32_t)APP_START_ADDRESS;
NVIC_SCBDeInit();
uint8_t v_Index_u8r;
for(v_Index_u8r = 0U; v_Index_u8r < 8U; v_Index_u8r ++)
{
S32_NVIC->ICER[v_Index_u8r] = 0xffffffff;
S32_NVIC->ISER[v_Index_u8r] = 0xffffffff;
S32_NVIC->ICPR[v_Index_u8r] = 0xffffffff;
}
disable_timeout();
disable_comm();
reset_clock();
/* Check if a valid application is loaded and jump to it */
JumpToUserApplication(*((uint32_t*)APP_START_ADDRESS), *((uint32_t*)(APP_START_ADDRESS + 4)));
/* Should never return from application code */
for (;;) {};
/* Never leave main */
return 0;
}
void NVIC_SCBDeInit(void)
{
S32_SCB->ICSR = 0x0A000000;
S32_SCB->VTOR = 0x00000000;
S32_SCB->AIRCR = 0x05FA0000;
S32_SCB->SCR = 0x00000000;
S32_SCB->CCR = 0x00000000;
S32_SCB->SHPR1 =0x00000000;
S32_SCB->SHPR2 =0x00000000;
S32_SCB->SHPR3 =0x00000000;
S32_SCB->SHCSR = 0x00000000;
S32_SCB->CFSR = 0xFFFFFFFF;
S32_SCB->HFSR = 0xFFFFFFFF;
S32_SCB->DFSR = 0xFFFFFFFF;
}
/**
* 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");
/* Jump to application PC (r1) */
__asm("mov pc, r1");
}
Hi,
there are these application notes:
https://www.nxp.com/docs/en/application-note/AN12218.pdf
https://www.nxp.com/docs/en/application-note-software/AN12218SW.zip
https://www.nxp.com/docs/en/application-note/AN12323.pdf
https://www.nxp.com/docs/en/application-note-software/AN12323SW.zip
Regards,
Lukas