Erase an Entire Code Flash Memory Block

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

Erase an Entire Code Flash Memory Block

640 Views
ASN7
Contributor II

I am using the S32K314 MCU and the C40_Ip Driver (RTD Version: 5.0.0) to manage flash operations. The MCU has four Code Flash Memory Blocks, and I want to erase one entire block.

I understand from the Reference Manual that using the block erase operation (via the ESS bit in the MCR register) is restricted for factory use only, due to its reduced endurance (25 Program/Erase cycles). As such, I am using the C40_Ip_MainInterfaceSectorErase() function provided by the driver to erase individual sectors.

ASN7_0-1733143835739.png

Here are my specific questions:

  1. Is it correct to erase an entire block by looping through its sectors and erasing them one by one using C40_Ip_MainInterfaceSectorErase()?
  2. Are there any best practices that exist to perform this operation ?
  3. Is there a specific example or reference implementation available for this scenario using the C40_Ip driver?
Tags (3)
0 Kudos
Reply
3 Replies

588 Views
ASN7
Contributor II

@VaneB Thank you for you suggestion. I have checked that document and the example projects and since my query was not cleared from it, I posted the question on the forum.

My questions still remains the same, in order to erase a complete block of memory, do I have to erase sector by sector ? Are there no functions defined in order to do as currently C40 drivers do not have that option (to erase from one address till another) ? 

0 Kudos
Reply

570 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @ASN7 

The C40_Ip/Fls or Mem_43_INFLS drivers only provides the sector-based erase function, but it can be used to erase multiple sectors in a single call as shown below:

#define EXAMPLE_NUMBER_OF_SECTORS      (1U)
#define EXAMPLE_SECTOR_SIZE            (0x2000U)     /* 8K */
#define EXAMPLE_ERASE_SIZE             (EXAMPLE_NUMBER_OF_SECTORS * EXAMPLE_SECTOR_SIZE)

#define EXAMPLE_SECTOR_START_ADDR      (0x00600000U) /* C40_CODE_ARRAY_0_BLOCK_2_S256 */
#define EXAMPLE_BUFFER_SIZE            (512U)        /* byte */

uint32 t_SectorStartAddr = EXAMPLE_SECTOR_START_ADDR;
uint32 t_EraseSize       = EXAMPLE_ERASE_SIZE;
uint32 t_BufferSize      = EXAMPLE_BUFFER_SIZE;

/* Erase */
t_ReturnValue = Mem_43_INFLS_Erase(Example_MemInstanceId, t_SectorStartAddr, t_EraseSize);
0 Kudos
Reply

606 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @ASN7 

We provide Memori Guide application note and demo projects which explains all the steps in detail.

Application note can be can be downloaded from: S32K3 Microcontrollers for Automotive General Purpose > Documentation > S32K3 Memories Guide (AN13388)

The demo projects are provided with RTDs with the names "C40_Ip_Example_S32K344" and "Mem_InFls_Example_S32K344"

 

BR, VaneB

0 Kudos
Reply