Introduction

During the production of an electronic product, it is desirable to protect the memory against reading after the firmware (binary) has been flashed to the microcontroller. This ensures that the firmware is not accessible to competitors and/or malicious hackers.

To protect the memory of the RA family from Renesas of microcontrollers, specifically those with an Arm Cortex-M33 core, it is necessary to use the Device Lifecycle Management (DLM). Both the debug capability and the serial programming interface depend on its configurations [1]. You can verify the Device Lifecycle states below [2]:

Device Lifecycle States

The transitions from one state to another are described below:

Device Lifecycle State Transitions

Note that it is possible to make reverse transitions, such as going from the DPL (Deployed) state of memory protected against reading, back to the SSD (Secure Software Development) state with memory reading access, via a key authentication process [3] [4]. If you have not performed the key authentication process, it is still possible to recover write and read access (reversing the transition), but all MCU memory will be erased, thus protecting the program content.

Example

See below a step-by-step guide on how to write an example firmware and protect the memory without key injection. To do this, we will use Renesas Flash Programmer to:

  • Flash the example firmware
  • Verify that it is possible to read the flashed firmware
  • Make the transition from SSD to NSECSD and then to DPL
  • Verify memory protection
  • Revert to the SSD state and verify that the memory has been erased

Flash the example firmware

Follow the steps in the article Getting Started with Renesas Flash Programmer to write the example firmware that flashes the LEDs on the EK-RA4M2 evaluation kit for RA4M2 MCUs.

Verify that it is possible to read the flashed firmware

Follow the steps in the article How to Read Microcontroller Memory with Renesas Flash Programmer to read the flashed firmware.

Make the transition from SSD to NSECSD and then to DPL

Go to Target Device » Read Device Information, and verify that the microcontroller is in the initial state SSD (or CM).

RFP Read Device Information SSD

RFP Device SSD

Go to Target Device » DLM Transition..., and choose NSECSD.

RFP DLM Transition

RFP DLM Transition to NSECSD

See now with Read Device Information that the device is in NSECSD state:

RFP Device NSECSD

Following the same process, go to Target Device » DLM Transition..., and now choose DPL. And also verify with Read Device Information:

RFP Device DPL

Verify Memory Protection

Although it is possible to read general device information with Read Device Information, it is no longer possible to read the flashed firmware. Like before, go to Target Device » Read Memory... and try to read the first 8KB (0x2000) of the Code Flash. And as expected, it is not possible to read the flashed firmware:

RFP Read Memory Fail Error(E100000E): A protection error occurred in the device. (Command: 15, Response: D5) Operation failed

Revert to the SSD state and verify that the memory was erased

Since we did not set up the key authentication process, to return to the initial SSD state, it is necessary to go to Target Device » Initialize Device:

RFP Initialize Device

After this process, the LEDs stop flashing, indicating that the device memory has been erased. And, by doing a final Read Device Information, we verify that the device has returned to the SSD state and can be programmed again.

RFP Device SSD

References