MCUXN947 Security Configuration (Secure Boot + Lifecycle)

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

MCUXN947 Security Configuration (Secure Boot + Lifecycle)

MCUXN947 Security Configuration (Secure Boot + Lifecycle)

MCUXN947 Security Configuration (Secure Boot + Lifecycle)

 

1. Introduction

This application note aims to guide developers on configuring Secure Boot and Lifecycle on the MCXN947 microcontroller. The goal is to ensure security during mass production, prevent code theft and tampering, and allow for secure firmware updates. By following this document, developers can better understand and implement best practices for secure boot and firmware updates.

2. Implementation Overview

2.1 Secure Boot (SB) Introduction

The Secure Binary (SB) container brings secure and easy way to upload or update firmware in embedded device during either the manufacturing process or end-customer's device lifecycle. An SB file is a command-based firmware update image. The SB file can be considered a script (commands and data), with the ROM acting as the interpreter. The ROM supports version 3.1 of the SB image format.

The SB container in version 3.1 (SB3.1) uses the latest cryptographic algorithms to ensure the authenticity and confidentiality of the carried firmware. The boot time and security level, which fit the best for the required use case, control the various available security configurations. The digital signature based on Elliptic Curve Cryptography (ECC) ensures the authenticity of the SB3.1 container. The use of the Advanced Encryption Standard (AES) in Cipher Block Chaining (CBC) mode ensures the confidentiality of the SB3.1 container.

2.2 Lifecycle Introduction

The lifecycle state of a chip reflects its actual state and is used to guide how the chip protects its hosted assets at specific times. For example, when a project is completed, during mass production, or when the device is in use by the end customer, the chip's access permissions are much more restricted compared to the development stage.

The MCXN947 microcontroller supports multiple secure lifecycle states. For detailed information, refer to the "Lifecycle States" chapter in the MCX Nx4x Security Reference Manual. Note that the lifecycle state is monotonic, meaning it can only increase, and access permissions become more restrictive.

This document focuses on field configuration (In-field) to ensure security after deployment.

2.3 MCUXpresso Tool Introduction

The MCUXpresso Security Configuration Tool is a GUI-based application that simplifies the generation and configuration of bootable executable files on NXP MCUs. This tool can be used to generate SB3.1 files and deploy MCU security configurations.

3. Implementation Steps

3.1 Preparation

Software

  • Two image files:

frdmmcxn947_led_blinky_red.s19 and frdmmcxn947_led_blinky_green.s19

Hardware

3.2 Steps

3.2.1 Restore MCU to Default Configuration

  1. Power on MCU with ISP Mode
    • Hold the ISP key and power on the MCU (POR). This document uses the ISP-USB interface, so connect the USB cable to J11 (HS-USB) port.
  2. Configure CMPA and CFPA to Default State
    • Open the SPT Tool, create a new workspace, and select the corresponding chip. Configure as follows:
Alice_Yang_12-1730643271271.png

Alice_Yang_13-1730643271307.png

Alice_Yang_14-1730643271338.png

Alice_Yang_15-1730643271376.png

 

  1. Program CMPA and CFPA
    • OK -> Build image, Write image, to burn the configured default CMPA and CFPA into the MCU.
  2. Erase Entire Flash
    • Connect the board's debugging interface MCU-link via USB. Select the debug probe in the SPT Tool. After a successful connection, use Erase to erase the entire flash.
Alice_Yang_16-1730643271416.png
  • The chip is restored to its default state with no enabled security configurations.

3.2.2 Configure Secure Boot and Lifecycle for Field Mode (In-field) 

  1. Generate Secure Boot Keys
  • Select the PKI management interface -> Generate Keys... -> Generate
Alice_Yang_17-1730643271457.png

 

  1. Configure Image File
  • Open the "Build image" interface and configure as follows:
    • Boot: Select Encrypted (PRINCE/IPED) and signed
    • Source executable image: Select the application image file frdmmcxn947_led_blinky_green.s19
    • Start address: 0x00000000
    • Firmware version: 1
    • Authentication key: Choose any one of the 4 options
    • CUST_MK_SK: Click Random to generate a random number
    • OEM seed: Click Random to generate a random number
Alice_Yang_18-1730643271609.png

 

  1. Configure CMPA and CFPA
    • Open CMPA and CFPA, and configure to enable security:
Alice_Yang_19-1730643271639.png
Alice_Yang_20-1730643271659.png
  1. Generate Configuration Files and Image File
  • After configuration, build the image to generate CMPA, CFPA configuration files, and the SB3-formatted image file.
  •  

3.2.3 Program Application

  1. Program Configuration Files and Image File
    • Open the "Write image" window, click "Write image" to program the configuration files and the SB image file.
Alice_Yang_21-1730643271828.png

 

  1. Verify Application
    • Power on the board again, and you should see the green LED flashing, indicating that the application is running normally.
    • Then, hold the ISP key and perform a software reset of the board (note that this must be a software reset for the CFPA lifecycle configuration to take effect; a power-on reset will not activate the CFPA configuration). If the development is complete and in the production stage, and OTP is used to manage the lifecycle, any reset will detect the OTP configuration.
    • At this point, secure boot is enabled, and the lifecycle is configured for field mode. Therefore, the chip no longer supports SWD interface debugging or reading flash content via ISP. To update the flash program, only a valid SB3 file can be burned.

3.2.4 Update Application

  1. Create a New SB3 File
  • Compile the SDK example frdmmcxn947_led_blinky to generate a .bin file or s19 file. For all supported formats by the SPT tool, refer to the SPT manual. Here, use the s19 file format frdmmcxn947_led_blinky_red.s19.
  • Open the SPT tool and use the workspace created for the first application image file. This will import the necessary keys directly. Then, import frdmmcxn947_led_blinky_red.s19.
  • The Image firmware version should be greater than 0. Since we have not configured Set minimal firmware version, the minimum version is 0. This involves the anti-rollback feature, which will be explained in detail later.
  • After configuration, hold the ISP key and power on the board to restart. Then, build the image to generate frdmmcxn947_led_blinky_red.sb.
  1. Program the New SB3 File
  • Use the blhost receive-sb-file command to burn the file:

blhost.exe -u 0x1fc9 0x014f receive-sb-file frdmmcxn947_led_blinky_red.sb

  • After burning, restart the MCU. The red LED flashing indicates that the firmware update was successful.

3.2.5 Verify Security Features

After enabling secure boot and configuring the lifecycle for field mode, the MCU cannot read the flash via SWD or ISP, ensuring the security of the customer's code against theft and tampering. To test if the configuration is successful, you can use the SWD and ISP interfaces. You should find that the SWD interface cannot connect, and while the ISP interface can connect, it cannot read or write. Note that before testing, you need to hold the ISP key and perform a software reset (not a power-on reset).

Alice_Yang_22-1730643271844.png

 

Alice_Yang_23-1730643271880.png
 
4. Notes

By following this document, developers can learn how to configure and manage the security lifecycle on the MCXN947 microcontroller, ensuring the security and reliability of the device at different stages. Following the steps in this document can effectively achieve secure boot and operation, as well as firmware updates.

 

Attachments
No ratings
Version history
Last update:
‎11-18-2024 08:55 PM
Updated by: