Firmware update of s32k144 via UART

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

Firmware update of s32k144 via UART

2,827 Views
shubhendu_shukl
Contributor II

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.

Labels (1)
0 Kudos
Reply
4 Replies

2,464 Views
shubhendu_shukl
Contributor II

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*/

define symbol __ram_vector_table_size__ =  isdefinedsymbol(__flash_vector_table__) ? 0 : 0x00000400;
define symbol __ram_vector_table_offset__ =  isdefinedsymbol(__flash_vector_table__) ? 0 : 0x000003FF;
/* Flash */
define symbol m_interrupts_start       = 0x00000000;
define symbol m_interrupts_end         = 0x000003FF;
define symbol m_flash_config_start     = 0x00000400;
define symbol m_flash_config_end       = 0x0000040F;
define symbol m_text_start             = 0x10000000;
define symbol m_text_end               = 0x10003FFF;
/* SRAM_L */
define symbol m_interrupts_ram_start   = 0x1FFF8000;
define symbol m_interrupts_ram_end     = 0x1FFF8000 + __ram_vector_table_offset__;
define symbol m_data_start             = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_data_end               = 0x1FFFFFFF;
/* SRAM_U */
define symbol m_data_2_start           = 0x20000000;
define symbol m_data_2_end             = 0x20006FFF;

/*linker of application code*/

define symbol __ram_vector_table_size__ =  isdefinedsymbol(__flash_vector_table__) ? 0 : 0x00000400;
define symbol __ram_vector_table_offset__ =  isdefinedsymbol(__flash_vector_table__) ? 0 : 0x000003FF;
/* Flash */
define symbol m_interrupts_start       = 0x00001000;
define symbol m_interrupts_end         = 0x000013FF;
define symbol m_flash_config_start     = 0x00001400;
define symbol m_flash_config_end       = 0x0000140F;
define symbol m_text_start             = 0x00001410;
define symbol m_text_end               = 0x0007FFFF;
/* SRAM_L */
define symbol m_interrupts_ram_start   = 0x1FFF8000;
define symbol m_interrupts_ram_end     = 0x1FFF8000 + __ram_vector_table_offset__;
define symbol m_data_start             = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_data_end               = 0x1FFFFFFF;
/* SRAM_U */
define symbol m_data_2_start           = 0x20000000;
define symbol m_data_2_end             = 0x20006FFF;
Can you suggest me where am I going wrong.
0 Kudos
Reply

2,464 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply

2,464 Views
shubhendu_shukl
Contributor II

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

issue_boot.png

#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");

}

0 Kudos
Reply