How to use flash memory Lock-bit

How to use flash memory Lock-bit

How to use flash memory Lock-bit

This article offers supplementary information for users intending to control Lock-bit using the Flash FIT driver (r_flash_rx), including a description of Lock-bit behavior and the corresponding Flash FIT driver operations.

 

Lock-bit

The Lock-bit on RX MCUs is a feature used to protect specific code flash blocks from being accidentally erased or overwritten. It plays a key role in maintaining code and data integrity during in-field updates or normal operation. Lock-bit can be set for each user code flash block, and its manipulation can be divided into two types: Enable/Disable (enforcement/relaxation) or Set/Reset (protect/unprotect).

 

Enable : Do not disable the Lock-bit setting enforcement during P/E (Program/Erase)

Disable : Temporarily disable the enforcement of the entire Lock-bit setting during P/E

Set : Set (Insert) a Lock-bit setting for a specific block (Protect from P/E)

Reset : Reset (Remove) a Lock-bit setting for a specific block (Unprotect from P/E)

 

Lock-bit

Hardware user manual

Flash FIT driver

Enable

Register FPROTR.FPROTCN=0

R_FLASH_Control() with FLASH_CMD_LOCKBIT_ENABLE

Disable

Register FPROTR.FPROTCN=1

R_FLASH_Control() with FLASH_CMD_LOCKBIT_DISABLE (Note 1)

Set

FACI Lock-bit program command

R_FLASH_Control() with FLASH_CMD_LOCKBIT_WRITE

Reset

FACI Block erase command while FPROTR.FPROTCN=1

R_FLASH_Control() with FLASH_CMD_LOCKBIT_DISABLE followed by R_FLASH_Erase()

Note 1. Disabling the Lock-bit enforcement during P/E is temporary. It will be restored to the default of enforcement enable when the MCU is reset or the [Clearing Conditions] mentioned in the Hardware user manual are met.

 

Example project

The example project provided on this page is intended to demonstrate how to set and reset the Lock-bit for a specific code flash block on the RX66T CPU Card board. Block8 has been selected solely for testing purposes and can be changed as needed.

 

Step 1: Import and build the attached example project with one of the following define enabled, and run it on the RX66T CPU Card board.

    #define LOCK_BIT_RESET_TEST                    0

    #define LOCK_BIT_SET_TEST                        1

 

Step 2: Launch Renesas Flash Programmer, then go to the Target Device tab and select [Read Block Information]. After the dialog box appears, as shown below, check whether the Lock-bit of Block8 is set or reset as defined in Step 1.

Renesas Flash Programmer : https://www.renesas.com/en/software-tool/renesas-flash-programmer-programming-gui