S32K144: Bootloader not jumping to application

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

S32K144: Bootloader not jumping to application

216 Views
Estelle13
Contributor I

I want to download the bootloader onto the S32K144 board.The following error occurred after running the startup code, provided for reference.

No source available for "0xfffffffe"

BusFault: A bus fault has occurred on exception entry.
MemManage: The processor attempted an instruction fetch from a location that does not permit execution.
HardFault: A fault has been escalated to a hard fault.

 

#include "timeout.h"

#include "comm.h"

#include "clock.h"

#include <stdio.h>

#include "power_rcm_hw_access.h"

#include "uart.h"

 

#define APP_START_ADDRESS 0x00008000

uint8_t boot_from_comm = 0;

static void JumpToUserApplication( unsigned int userSP, unsigned int userStartup);

void Bootup_Application(uint32_t appEntry, uint32_t appStack);

 

int main(void) {

uint32_t time = 50000;

uint32_t appEntry, appStack;

uint8_t bootCount = 0;

uint8_t bootInfo = 0;

uint8_t DOWN_LINK = 0;

clock_initi();

init_comm();

init_timeout();

do{

if(comm_status_rx())

bootInfo = UART_GetChar(UART_PORT);

if(bootInfo == 0x2A)

bootCount++;

else

bootCount = 0;

if(bootCount>=4) {

DOWN_LINK = 1;

UART_PutChar(UART_PORT, LINKED); }

} while(!timeout() && (!DOWN_LINK));

if(DOWN_LINK) {

do{

uint8_t word_received = comm_status_rx();

if(word_received){

boot_from_comm = 1;

comm_download_app(); }

} while(!boot_from_comm);

}

disable_timeout();

disable_comm();

reset_clock();

while(time--);

appStack = *(uint32_t *)(APP_START_ADDRESS);

appEntry = *(uint32_t *)(APP_START_ADDRESS + 4);

Bootup_Application(appEntry, appStack);

for (;;) {};

return 0; }

void JumpToUserApplication( unsigned int userSP, unsigned int userStartup) {

if(userSP == 0xFFFFFFFF){ return; }

__asm("msr msp, r0");

__asm("msr psp, r0");

S32_SCB->VTOR = (uint32_t)APP_START_ADDRESS;

__asm("mov pc, r1"); }

void Bootup_Application(uint32_t appEntry, uint32_t appStack) {

static void (*jump_to_application)(void);

static uint32_t stack_pointer;

jump_to_application = (void (*)(void))appEntry;

stack_pointer = appStack;

S32_SCB->VTOR = (uint32_t)APP_START_ADDRESS;

__asm volatile ("MSR msp, %0\n" : : "r" (stack_pointer) : "sp");

__asm volatile ("MSR psp, %0\n" : : "r" (stack_pointer) : "sp");

jump_to_application(); }

 

 

0 Kudos
Reply
1 Reply

176 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Estelle13

Are you following AN12218 for the bootloader implementation? 

Please look into the following community posts, as there has been a similar discussion about this topic:

Best regards,
Julián

 

0 Kudos
Reply