Boot Flow Details

Understanding the system boot flow helps in grasping the working principle and key configuration points of RDP:

When RDP is enabled, the Flash encrypted area stores the encrypted TrustZone secure firmware, and the address field in the Image Header specifies the secure address to be loaded to. After the system boots from secure ROM, the subsequent boot process runs entirely within the TrustZone Secure world. The key peripherals (OTP, decryption engine, DMA, etc.) and memory used during the boot process are all security-isolated through MPC and PPC, ensuring the security of the firmware loading flow.

The boot flow for each chip is as follows:

RTL8721Dx:

Flash address security isolation is not supported. Encrypted firmware is decrypted using a symmetric hardware crypto engine. During system boot, the firmware is fully decrypted and loaded into secure RAM, then executed by the CPU. RDP Flow Details:

  1. Key Loading: The RDP key in OTP is automatically loaded into the symmetric hardware crypto engine by hardware.

  2. Firmware Read: The internal secure DMA reads the encrypted firmware from external Flash in chunks.

  3. Hardware Decryption: The symmetric hardware crypto engine performs the decryption operation and transfers the data to the protected secure RAM area via secure DMA.

  4. Execution: The CPU jumps to the secure RAM and begins executing the secure firmware.

../../_images/rdp_diagram.svg

OTP Configuration

OTP (One Time Programmable) is used to store the RDP key and enable control bits, serving as the hardware foundation for RDP functionality. During boot, the Bootloader checks the enable bits in OTP to determine whether RDP is enabled.

OTP can only be written once. Before configuring, carefully verify the addresses and data. Configuration order: burn the key first, then burn the enable bits.

RTL8721Dx:

Use the IPSEC-S hardware engine with OTP keys to decrypt secure firmware. The RDP-related OTP configurations are as follows:

Name

OTP Address

Size (bits)

Description

RDP_EN_PHY

Physical addr 0x368[5]

1

Permanent enable bit. Once programmed, RDP is enabled and cannot be revoked. Used in the mass production stage.

RDP_EN_LOG

Logical addr 0x3[4]

1

Revocable enable bit. Once programmed, RDP is enabled and can be disabled later. Used in the development and debugging stage.

S_IPSEC_Key1 (RDP)

Physical addr 0x200 ~ 0x21F

256

Stores the RDP key.

S_IPSEC_Key1_R_Protection_EN

Physical addr 0x365[3]

1

Read protection enable. Once programmed, the CPU cannot read the key, preventing key exposure.

S_IPSEC_Key1_W_Forbidden_EN

Physical addr 0x365[4]

1

Write protection enable. Once programmed, the key cannot be modified, preventing key tampering.

Note

The most significant byte of the RDP OTP key is stored at the highest address. For example, if the key string in Manifest.json5 is otp_key_0x200: c9a8b1f4e7d293b6a5d8f009be6c3d21e4a7b8f5d3b901a984087844c2f7b6e0, the value 0xc9 should be programmed into eFuse 0x200, 0xa8 into 0x201, and so on.

Enabling Method

RDP enabling is divided into three phases. Please execute them in order:

  • Development phase: SDK configuration and firmware compilation

  • Production phase: OTP burning and firmware programming

  • Production line verification phase: Verify that RDP is properly enabled

Development Phase

Step 1: Enable TrustZone

ameba.py menuconfig > CONFIG TrustZone > Enable TrustZone

The secure RAM region size is configured by default in the SDK. Users can adjust the region size by modifying the TZ_S_SIZE macro definition in the linker script ameba_layout.ld under the project directory, based on the firmware size.

Step 2: Configure Secure Firmware Encryption Parameters

Configure the secure firmware Manifest file to specify the encryption parameters. The configuration file is <SDK>\component\soc\amebadxxx\project\manifest.json5:

RTL8721Dx:

The post-processing script will generate an AES-CBC encrypted RDP firmware based on the keys in the configuration file.

Configuration Items

  • rdp_enable: Enable RDP encryption

  • rdp_iv: Initialization vector for AES-CBC encryption

  • otp_key_0x200: RDP key, must match the key programmed in OTP

Configuration Steps

  1. Set rdp_enable to 1 in image3 to enable RDP encryption.

  2. Fill in rdp_iv with a length of 8 bytes (AES-CBC requires a 16-byte IV; the remaining 8 bytes reuse rsip_iv from image2).

  3. Fill in otp_key_0x200 with a length of 32 bytes, which must match the OTP key programmed during production.

{
   ...
   image2: {
      rsip_iv: "213253647586a7b8",
   },

   image3: {
      rdp_enable: 1,
      rdp_iv: "0123456789abcdef",
      rdp_key: "otp_key_0x200",
   },

   /* =================================== OTP key value =================================== */
   ...
   otp_key_0x200: "c9a8b1f4e7d293b6a5d8f009be6c3d21e4a7b8f5d3b901a984087844c2f7b6e0",
   ...
}

Step 3: Compile Firmware

Recompile the project. The post-processing script will automatically generate the encrypted secure firmware based on the key in the configuration file. The encrypted secure firmware will be automatically integrated at the end of app.bin.

After completing the development phase configuration, the firmware is ready. Proceed to the production phase for OTP burning and firmware programming.

Production Phase

Note

CONFIG_ATCMD_SECURE must be enabled in menuconfig before using AT+SEC commands. Path: CONFIG SHELL Enable ATCMD SECURE (disabled by default).

RDP mass production requires using the mass production tool firmware to perform OTP burning. This is because the encrypted application firmware depends on the correctly configured key in OTP to boot. Before OTP configuration is complete, the encrypted application firmware cannot run properly. The RDP mass production flow is similar to RSIP. For detailed procedures, please refer to the Flash XIP Decryption (RSIP) Mass Production Guide section in the Application Note.

Step 4: Burn RDP Key

The RDP key is used to encrypt the secure firmware. The hardware uses this key to decrypt the firmware during boot.

RTL8721Dx:

The RDP key must be programmed when the device enters the mass production stage.

Note

CONFIG_ATCMD_SECURE must be enabled in menuconfig before using AT+SEC commands. Path: CONFIG SHELL Enable ATCMD SECURE (disabled by default).

Use the following command to program the RDP key:

AT+SEC=RDP_KEY,c9a8b1f4e7d293b6a5d8f009be6c3d21e4a7b8f5d3b901a984087844c2f7b6e0

The RDP key must be 32 bytes in length. The value above is an example; please generate a random key. The command automatically reads back and verifies the OTP after writing. If verification fails, an error message is returned.

Once the key is confirmed to be correctly programmed, set the key read-protection and write-protection bits:

AT+SEC=RDP_PROT,rw

This operation sets both S_IPSEC_Key1_R_Protection_EN (prevents the key from being read) and S_IPSEC_Key1_W_Forbidden_EN (prevents the key from being tampered with).

Step 5: Burn RDP Enable Bits

The RDP enable bits are used to activate the RDP function. Choose the appropriate enabling method based on the device stage:

Development Stage:

When the device is in the development stage, it is recommended to use temporary enable (this can be disabled later):

AT+SEC=RDP_EN,temp

To disable RDP temporarily enabled above (this has no effect if permanently enabled via perm):

AT+SEC=RDP_EN,temp_off

Step 6: Program Firmware

Program the boot.bin and app.bin generated during the development phase into Flash.

Production Line Verification

After completing all the above configurations, reset the development board for verification. If RDP is properly enabled, the startup log will display the RDP EN message.

Caution

The RDP function does not verify the legitimacy of the firmware. To prevent firmware tampering, it must be used in conjunction with Secure Boot. For details, please refer to Secure Boot chapter .