AmebaPro2 (RTL8735B) – Secure Boot Level 3 with per-device SEC key: technical questions

Dear Realtek Team,

We are preparing mass production (~10,000 units) of a video doorbell based on the RTL8735B (AmebaPro2). Our setup:

  • SDK release 9.6_r
  • NOR flash, non-TrustZone (NTZ) build
  • Secure boot manual UM0702

We plan to enable Secure Boot Level 3 (otp_secure_boot_enable(), sign_enc images) with:

  • One shared ROTKEY, image signing keys (PARTAB/BOOT/FW) and HUK for all devices
  • A unique SEC key per device

For production and OTA, we build the firmware once. Then, for each device, we run elf2bin secure sign+enc+hash with that device’s key file. Before finalizing, we’d appreciate your confirmation on the following points.

  1. Per-device SEC key workflow
    Is it a supported approach to keep key_private.json / key_public.json identical across devices and change only SEC.key1 per device, then run elf2bin secure sign+enc+hash+dbg=boot and …=fw for each device? Should certificate_signed.bin and partition_signed.bin be identical for all devices in this setup?

  2. AES-CTR IV and key derivation
    encrypt_fw.json and encrypt_bl.json use a fixed IV (123456789ABCDEF0).

  • (a) Can we use a different IV for each firmware release? Does the boot ROM/bootloader read the IV from the image manifest (ENCIV / encryption records)?
  • (b) Is the AES-256-CTR key the SEC key itself, or is it derived from the SEC key together with ENCKN/ENCKS?
  1. Image hash input
    For sign_enc images, is the manifest HASH (step 5, “Image Payload Hash Check”) calculated over the encrypted payload as stored in flash, or over the plaintext?

  2. MP firmware boot flow
    The manual’s MP phase describes a combined image: Key Certificate ‖ Partition Table ‖ Bootloader (plain) ‖ Application (encrypted) ‖ MP Firmware ‖ User Data (encrypted bootloader).

  • (a) How does the boot flow select and boot the MP firmware first? (mp_trap, MP partition record, or another method?) In our partition table the mp record is only 4 KB and currently invalid.
  • (b) Is it acceptable to place the MP firmware in the FW2 partition and stage the encrypted bootloader in the boot_s partition, with the MP firmware copying it to boot_p before enabling secure boot?
  • (c) Is there a recommended order between “copy encrypted bootloader”, “write keys / SSZ lock”, and “enable secure boot”?
  1. UART download after enabling secure boot
    After otp_secure_boot_enable(), can we still flash the device with uartfwburn.exe (-U flash loader / UART download mode), for example for factory rework?

  2. JTAG/SWD protection
    How do we permanently disable JTAG/SWD (secure and non-secure), or enable password mode, in OTP? We found hal_otp_s_jtag_key_write() / hal_otp_ns_jtag_key_write() and the AON S_JTAG_SWD_MODE / NS_JTAG_SWD_MODE fields, but no API or OTP address to set the mode permanently.

  3. Anti-rollback
    What is the format of the firmware anti-rollback version in OTP (OTP_FW_VANTI_ADDR 0x570, enable bits around 0x5B4)? How does it relate to the manifest VERSION field, and is there an API to update it safely?

  4. Firmware slot fallback
    If a newly updated FW1/FW2 slot fails signature, hash or decryption checks at boot, does the device automatically boot the other (previous) valid slot? Is this behaviour the same on chips where hal_sys_get_rom_ver() > 2, where slot selection is handled by the ROM?

  5. User crypto key after SSZ lock
    Is the user crypto key in OTP (efuse_crypto_key_get() slot 0) still readable by application firmware after hal_otp_ssz_lock()? We’d like to use it (or HUK through the crypto engine) to protect per-device secrets stored in flash.

  6. Key generation
    Is the random number generator used by elf2bin keygen suitable for production keys? Or do you recommend generating the keys externally (e.g. in an HSM) and writing key_private.json / key_public.json ourselves?

  7. Factory key provisioning
    Do you or your distributors offer a factory key-provisioning service or tool for RTL8735B?

Thank you for your support.

Thank you for your questions. Please give us some time to look into them.

Any Update on this

Hi @deepakkumarbinwal ,

We have already sent you a private reply. For the interest and benefits of other forum users, kindly refer the answers below:

1. Per-device SEC key workflow
Is it a supported approach to keep key_private.json / key_public.json identical across devices and change only SEC.key1 per device, then run elf2bin secure sign+enc+hash+dbg=boot and …=fw for each device? Should certificate_signed.bin and partition_signed.bin be identical for all devices in this setup?

A: Yes. After replacing the SEC.key1 used by an individual device in key_private.json, you can use elf2bin to generate the encrypted boot and fw images for that specific device. As long as no other settings are changed, it will generate identical partition_signed.bin and certificate_signed.bin files across devices.

2. AES-CTR IV and key derivation
encrypt_fw.json and encrypt_bl.json use a fixed IV (123456789ABCDEF0).

  • (a) Can we use a different IV for each firmware release? Does the boot ROM/bootloader read the IV from the image manifest (ENCIV / encryption records)?
    A: Yes, you can use a different IV for each firmware release, and the boot stage does indeed read the IV from the image manifest (it is not hard-coded in the hardware).

    • encrypt_fw.json / encrypt_bl.json embed the IV for each image block (e.g., “iv”:“123456789ABCDEF0”) and pass it to elf2bin.
    • The tool writes the IV into the manifest TLV ENCIV (ID 0x08) and into the manif_sec_enc_record_t.iv_ptn_low/iv_ptn_high records.
    • The Boot ROM / Bootloader reads this record at startup to obtain the IV, rather than reading it from OTP. Therefore, changing the IV in the JSON will correctly apply the new setting.
  • (b) Is the AES-256-CTR key the SEC key itself, or is it derived from the SEC key together with ENCKN/ENCKS?
    A: The AES key is the SEC key itself. It is not a derived key from KDF(SEC, ENCKN/ENCKS).

3. Image hash input
For sign_enc images, is the manifest HASH (step 5, “Image Payload Hash Check”) calculated over the encrypted payload as stored in flash, or over the plaintext?

A: For sign_enc images, the HASH in the manifest (Step 5 “Image Payload Hash Check”) is calculated over the ciphertext (the encrypted payload) as stored in the Flash.

4. MP firmware boot flow
The manual’s MP phase describes a combined image: Key Certificate ‖ Partition Table ‖ Bootloader (plain) ‖ Application (encrypted) ‖ MP Firmware ‖ User Data (encrypted bootloader).

  • (a) How does the boot flow select and boot the MP firmware first? (mp_trap, MP partition record, or another method?) In our partition table the mp record is only 4 KB and currently invalid.
    A: We do not use the MP partition. The Application (encrypted) uses FW1, and the MP Firmware uses FW2. If the firmware version of the MP Firmware is higher than that of the Application Firmware, the system will automatically boot the MP Firmware with the higher version at startup.

  • (b) Is it acceptable to place the MP firmware in the FW2 partition and stage the encrypted bootloader in the boot_s partition, with the MP firmware copying it to boot_p before enabling secure boot?
    A: No, this is not allowed. If you place the encrypted bootloader in boot_s, it might mistakenly be selected during the boot process.

  • (c) Is there a recommended order between “copy encrypted bootloader”, “write keys / SSZ lock”, and “enable secure boot”?
    A: Please refer to the sequence outlined in the Secure Boot NDA document:

    1. Replace Bootloader by copying from User Data section.
    2. Write HUK, ROTPK Hash, and SEC Key to OTP secure region by using OTP API.
    3. Enable super secure zone lock by using OTP API.
    4. Enable secure boot for authentication, hash verification, and decryption by using OTP API.

5. UART download after enabling secure boot
After otp_secure_boot_enable(), can we still flash the device with uartfwburn.exe (-U flash loader / UART download mode), for example for factory rework?

A: Yes, you can.

6. JTAG/SWD protection
How do we permanently disable JTAG/SWD (secure and non-secure), or enable password mode, in OTP? We found hal_otp_s_jtag_key_write() / hal_otp_ns_jtag_key_write() and the AON S_JTAG_SWD_MODE / NS_JTAG_SWD_MODE fields, but no API or OTP address to set the mode permanently.

Please refer to AmebaPro2 Secure SWD.pdf. (Note: For secure boot related documents, please contact AmebaAIoT@realtek.com)

7. Anti-rollback
What is the format of the firmware anti-rollback version in OTP (OTP_FW_VANTI_ADDR 0x570, enable bits around 0x5B4)? How does it relate to the manifest VERSION field, and is there an API to update it safely?

A: For the format of the firmware version, please refer to the application note. The version field is 256 bits long, where each bit represents a version, allowing for a total of 256 versions. The highest-order bit with a value of 0 indicates the current version. If version anti-rollback is enabled, the system will compare the image version in the FW Manifest against the FW anti-rollback version stored in the OTP. If the anti-rollback version in the OTP is greater than the image version, the boot will fail.

8. Firmware slot fallback
If a newly updated FW1/FW2 slot fails signature, hash or decryption checks at boot, does the device automatically boot the other (previous) valid slot? Is this behaviour the same on chips where hal_sys_get_rom_ver() > 2, where slot selection is handled by the ROM?

A: FW image rollback is only supported by the ROM codes from the C-cut revision onwards. This FW image rollback feature is enabled by default. If a boot failure occurs, the device will automatically reset, and during the next boot, the bootloader will automatically select the other valid FW slot.

9. User crypto key after SSZ lock
Is the user crypto key in OTP (efuse_crypto_key_get() slot 0) still readable by application firmware after hal_otp_ssz_lock()? We’d like to use it (or HUK through the crypto engine) to protect per-device secrets stored in flash.

A: Yes, the User Crypto Key remains readable; however, the HUK and SEC Key cannot be read.

  • Executing hal_otp_ssz_lock() only locks the Super-Secure Zone (which includes HUK1/2, SEC Key1/2, etc.).

  • The User Crypto Key is located in the Secure Zone (SZ). Locking the SSZ does not affect SZ permissions, so the application code can still read it via hal_otp_crypto_key_get().

  • Although the HUK cannot be read by the CPU after locking, it can still be used internally by the hardware crypto engine. To protect device-specific secrets stored in Flash, use the HUK directly via the hardware engine to derive AES/HMAC keys. This completely avoids exposing any plaintext keys to the software layer.

10. Key generation
Is the random number generator used by elf2bin keygen suitable for production keys? Or do you recommend generating the keys externally (e.g. in an HSM) and writing key_private.json / key_public.json ourselves?

A: The elf2bin keygen tool uses the mbedTLS DRBG (collecting OS environmental random seeds). As a software-generated random number (CSPRNG), it is quite reasonable; however, it runs on a developer’s PC, and the private key is stored in plaintext in key_private.json. For mass production, we highly recommend external HSM generation.

11. Factory key provisioning
Do you or your distributors offer a factory key-provisioning service or tool for RTL8735B?

A: Please refer to the secure_boot example provided in the SDK, and implement the specific OTP APIs manually in your code to program the OTP.