NXP S32K bootloader

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

NXP S32K bootloader

586 Views
scoles
Contributor I

Good Day, 

I have seen the below bootloader code on the web and is posting to see if someone familiar could explain in detail on how the microcontroller is erased and how the new firmware is pushed?

{
while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0); // Wait if operation in progress
FTFC->FSTAT = FTFC_FSTAT_ACCERR_MASK | FTFC_FSTAT_FPVIOL_MASK;

FTFC->FCCOB[3] = 0x09; // Erase flash sector command
FTFC->FCCOB[2] = (0x8000 >> 16) & 0xff; // Flash address [23:16]
FTFC->FCCOB[1] = (0x8000 >> & 0xff; // Flash address [15:08]
FTFC->FCCOB[0] = 0x8000 & 0xff; // Flash address [7:0]

FTFC->FSTAT = FTFC_FSTAT_CCIF_MASK; // Launch command
while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0); // Wait for done

if(!(FTFC->FSTAT & FTFC_FSTAT_MGSTAT0_MASK))
continue; // Error occurred

if((*((uint32_t*)APP_START_ADDRESS)) == 0xFFFFFFFF) // Check if the sector was actually cleared
{
S32_SCB->AIRCR = S32_SCB_AIRCR_VECTKEY(0x5FA) | S32_SCB_AIRCR_SYSRESETREQ(1);
}

0 Kudos
1 Reply

565 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

The routine you are presenting only erases and checks a sectior in the flash memory. This part has nothong with new data writing.

The best way to understand bootloader is to read application notes. These two are recomended.

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

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

 

There are also SW files available on our web.

Best regards,

Ladislav

0 Kudos