Flash layout when using a bootloader on the S32K144

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

Flash layout when using a bootloader on the S32K144

1,458 Views
damiendusha
Contributor II

I am currently designing a bootloader for the S32K144, and I have some questions about the flash layout when using the bootloader.

When compiling a normal application (i.e. single program, no bootloader), there is a section of flash for the interrupts, a section of flash for the Flash configuration and the remainder for the program itself.  That is:

/* 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 = 0x0007FBF0

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

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

However, the bootloader in the S32K144 CAN bootloader has an additional "hole" in the flash map between where the m_flash_config ends and the text section begins. Is there a reason for this hole?

/* Specify the memory areas */
MEMORY
{
  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000400
  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
  /** Note the hole here between 0x410 and 0x500 **/
  m_text                (RX)  : ORIGIN = 0x00000500, LENGTH = 512K - 0x500
  m_data                (RW)  : ORIGIN = 0x1FFF8000, LENGTH = 0x00007FFF
  m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00007000
}

Secondly, when looking at AN12218 ("Using the bootloader, S32K1xx Bootloader,Rev. 0,07/2018", p8 sec.3), there is an explicit location in the user application for storage of the flash_config space, even through (as I understand it), they are read and applied only on reset and thus it is the value at 0x0400 in flash that really matters.

pastedImage_1.png

The S32K144 CAN bootloader application keeps the flash_config in the expected location, and there is no "hole" for it in the memory map:

/* Specify the memory areas */
MEMORY
{
  m_interrupts          (RX)  : ORIGIN = 0x00004000, LENGTH = 0x00000400
  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
  m_text                (RX)  : ORIGIN = 0x00004400, LENGTH = 512K - 0x4400
  m_data                (RW)  : ORIGIN = 0x1FFF8000, LENGTH = 0x00007FFF
  m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00007000
}

Does there need to be a section in flash reserved for the flash_config, even when in the application?

My second question is with respect to the alignment of m_interrupts.   Does this need to be aligned with anything specific (e.g. 512-byte/1024-byte boundaries, a 4k sector of flash, etc)?

1 Reply

906 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Damien,

I’m not familiar with this bootloader, but in general, there is no reason for the "hole" between m_flash_config and m_text section, as you can see by default there is no any "hole".  

The MCU reads the configuration (security, backdoor key, protection, …) from the location 0x400-0x410 (flash configuration field) which is a part of the bootloader.

You are right, there is no need for the section in the application.

Please refer to 36.4.1 Flash configuration field description in the reference manual S32K1xx RM, rev.8. There you can find the details. 

The m_interrupts section should be at the 0x00000000 address in the bootloader project. Because the m_interrupts contains stack pointer and reset vector which is expected always at the address 0x0 and 0x4.(The first 8B)

The m_interrupts section in the application project starts at the beginning of the sector (0x00001000 - AN12218, 0x00004000 - S32K144 CAN bootloader,....). The reason is that the smallest unit which can be erased is 1 sector (4 KB). 

I hope it helps you.

Best regards,

Diana