1*91f16700Schasinglulu 2*91f16700Schasinglulu-------------- 3*91f16700SchasingluluNXP Platforms: 4*91f16700Schasinglulu-------------- 5*91f16700SchasingluluTRUSTED_BOARD_BOOT option can be enabled by specifying TRUSTED_BOARD_BOOT=1 on command line during make. 6*91f16700Schasinglulu 7*91f16700Schasinglulu 8*91f16700Schasinglulu 9*91f16700SchasingluluBare-Minimum Preparation to run TBBR on NXP Platforms: 10*91f16700Schasinglulu======================================================= 11*91f16700Schasinglulu- OTPMK(One Time Programable Key) needs to be burnt in fuses. 12*91f16700Schasinglulu -- It is the 256 bit key that stores a secret value used by the NXP SEC 4.0 IP in Trusted or Secure mode. 13*91f16700Schasinglulu 14*91f16700Schasinglulu Note: It is primarily for the purpose of decrypting additional secrets stored in system non-volatile memory. 15*91f16700Schasinglulu 16*91f16700Schasinglulu -- NXP CST tool gives an option to generate it. 17*91f16700Schasinglulu 18*91f16700Schasinglulu Use the below command from directory 'cst', with correct options. 19*91f16700Schasinglulu 20*91f16700Schasinglulu .. code:: shell 21*91f16700Schasinglulu 22*91f16700Schasinglulu ./gen_otpmk_drbg 23*91f16700Schasinglulu 24*91f16700Schasinglulu- SRKH (Super Root Key Hash) needs to be burnt in fuses. 25*91f16700Schasinglulu -- It is the 256 bit hash of the list of the public keys of the SRK key pair. 26*91f16700Schasinglulu -- NXP CST tool gives an option to generate the RSA key pair and its hash. 27*91f16700Schasinglulu 28*91f16700Schasinglulu Use the below command from directory 'cst', with correct options. 29*91f16700Schasinglulu 30*91f16700Schasinglulu .. code:: shell 31*91f16700Schasinglulu 32*91f16700Schasinglulu ./gen_keys 33*91f16700Schasinglulu 34*91f16700SchasingluluRefer fuse frovisioning readme 'nxp-ls-fuse-prov.rst' for steps to blow these keys. 35*91f16700Schasinglulu 36*91f16700Schasinglulu 37*91f16700Schasinglulu 38*91f16700SchasingluluTwo options are provided for TRUSTED_BOARD_BOOT: 39*91f16700Schasinglulu================================================ 40*91f16700Schasinglulu 41*91f16700Schasinglulu------------------------------------------------------------------------- 42*91f16700SchasingluluOption 1: CoT using X 509 certificates 43*91f16700Schasinglulu------------------------------------------------------------------------- 44*91f16700Schasinglulu 45*91f16700Schasinglulu- This CoT is as provided by ARM. 46*91f16700Schasinglulu 47*91f16700Schasinglulu- To use this option user needs to specify mbedtld dir path in MBEDTLS_DIR. 48*91f16700Schasinglulu 49*91f16700Schasinglulu- To generate CSF header, path of CST repository needs to be specified as CST_DIR 50*91f16700Schasinglulu 51*91f16700Schasinglulu- CSF header is embedded to each of the BL2 image. 52*91f16700Schasinglulu 53*91f16700Schasinglulu- GENERATE_COT=1 adds the tool 'cert_create' to the build environment to generate: 54*91f16700Schasinglulu -- X509 Certificates as (.crt) files. 55*91f16700Schasinglulu -- X509 Pem key file as (.pem) files. 56*91f16700Schasinglulu 57*91f16700Schasinglulu- SAVE_KEYS=1 saves the keys and certificates, if GENERATE_COT=1. 58*91f16700Schasinglulu -- For this to work, file name for cert and keys are provided as part of compilation or build command. 59*91f16700Schasinglulu 60*91f16700Schasinglulu --- default file names will be used, incase not provided as part compilation or build command. 61*91f16700Schasinglulu --- default folder 'BUILD_PLAT' will be used to store them. 62*91f16700Schasinglulu 63*91f16700Schasinglulu- ROTPK for x.509 certificates is generated and embedded in bl2.bin and 64*91f16700Schasinglulu verified as part of CoT by Boot ROM during secure boot. 65*91f16700Schasinglulu 66*91f16700Schasinglulu- Compilation steps: 67*91f16700Schasinglulu 68*91f16700SchasingluluAll Images 69*91f16700Schasinglulu .. code:: shell 70*91f16700Schasinglulu 71*91f16700Schasinglulu make PLAT=$PLAT TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$MBEDTLS_PATH CST_DIR=$CST_DIR_PATH \ 72*91f16700Schasinglulu BOOT_MODE=<platform_supported_boot_mode> \ 73*91f16700Schasinglulu RCW=$RCW_BIN \ 74*91f16700Schasinglulu BL32=$TEE_BIN SPD=opteed\ 75*91f16700Schasinglulu BL33=$UBOOT_SECURE_BIN \ 76*91f16700Schasinglulu pbl \ 77*91f16700Schasinglulu fip 78*91f16700Schasinglulu 79*91f16700SchasingluluAdditional FIP_DDR Image (For NXP platforms like lx2160a) 80*91f16700Schasinglulu .. code:: shell 81*91f16700Schasinglulu 82*91f16700Schasinglulu make PLAT=$PLAT TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$MBEDTLS_PATH fip_ddr 83*91f16700Schasinglulu 84*91f16700Schasinglulu Note: make target 'fip_ddr' should never be combine with other make target 'fip', 'pbl' & 'bl2'. 85*91f16700Schasinglulu 86*91f16700Schasinglulu------------------------------------------------------------------------- 87*91f16700SchasingluluOption 2: CoT using NXP CSF headers. 88*91f16700Schasinglulu------------------------------------------------------------------------- 89*91f16700Schasinglulu 90*91f16700Schasinglulu- This option is automatically selected when TRUSTED_BOARD_BOOT is set but MBEDTLS_DIR path is not specified. 91*91f16700Schasinglulu 92*91f16700Schasinglulu- CSF header is embedded to each of the BL31, BL32 and BL33 image. 93*91f16700Schasinglulu 94*91f16700Schasinglulu- To generate CSF header, path of CST repository needs to be specified as CST_DIR 95*91f16700Schasinglulu 96*91f16700Schasinglulu- Default input files for CSF header generation is added in this repo. 97*91f16700Schasinglulu 98*91f16700Schasinglulu- Default input file requires user to generate RSA key pair named 99*91f16700Schasinglulu -- srk.pri, and 100*91f16700Schasinglulu -- srk.pub, and add them in ATF repo. 101*91f16700Schasinglulu -- These keys can be generated using gen_keys tool of CST. 102*91f16700Schasinglulu 103*91f16700Schasinglulu- To change the input file , user can use the options BL33_INPUT_FILE, BL32_INPUT_FILE, BL31_INPUT_FILE 104*91f16700Schasinglulu 105*91f16700Schasinglulu- There are 2 paths in secure boot flow : 106*91f16700Schasinglulu -- Development Mode (sb_en in RCW = 1, SFP->OSPR, ITS = 0) 107*91f16700Schasinglulu 108*91f16700Schasinglulu --- In this flow , even on ROTPK comparison failure, flow would continue. 109*91f16700Schasinglulu --- However SNVS is transitioned to non-secure state 110*91f16700Schasinglulu 111*91f16700Schasinglulu -- Production mode (SFP->OSPR, ITS = 1) 112*91f16700Schasinglulu 113*91f16700Schasinglulu --- Any failure is fatal failure 114*91f16700Schasinglulu 115*91f16700Schasinglulu- Compilation steps: 116*91f16700Schasinglulu 117*91f16700SchasingluluAll Images 118*91f16700Schasinglulu .. code:: shell 119*91f16700Schasinglulu 120*91f16700Schasinglulu make PLAT=$PLAT TRUSTED_BOARD_BOOT=1 CST_DIR=$CST_DIR_PATH \ 121*91f16700Schasinglulu BOOT_MODE=<platform_supported_boot_mode> \ 122*91f16700Schasinglulu RCW=$RCW_BIN \ 123*91f16700Schasinglulu BL32=$TEE_BIN SPD=opteed\ 124*91f16700Schasinglulu BL33=$UBOOT_SECURE_BIN \ 125*91f16700Schasinglulu pbl \ 126*91f16700Schasinglulu fip 127*91f16700Schasinglulu 128*91f16700SchasingluluAdditional FIP_DDR Image (For NXP platforms like lx2160a) 129*91f16700Schasinglulu .. code:: shell 130*91f16700Schasinglulu 131*91f16700Schasinglulu make PLAT=$PLAT TRUSTED_BOARD_BOOT=1 CST_DIR=$CST_DIR_PATH fip_ddr 132*91f16700Schasinglulu 133*91f16700Schasinglulu- Compilation Steps with build option for generic image processing filters to prepend CSF header: 134*91f16700Schasinglulu -- Generic image processing filters to prepend CSF header 135*91f16700Schasinglulu 136*91f16700Schasinglulu BL32_INPUT_FILE = < file name> 137*91f16700Schasinglulu BL33_INPUT_FILE = <file name> 138*91f16700Schasinglulu 139*91f16700Schasinglulu .. code:: shell 140*91f16700Schasinglulu 141*91f16700Schasinglulu make PLAT=$PLAT TRUSTED_BOARD_BOOT=1 CST_DIR=$CST_DIR_PATH \ 142*91f16700Schasinglulu BOOT_MODE=<platform_supported_boot_mode> \ 143*91f16700Schasinglulu RCW=$RCW_BIN \ 144*91f16700Schasinglulu BL32=$TEE_BIN SPD=opteed\ 145*91f16700Schasinglulu BL33=$UBOOT_SECURE_BIN \ 146*91f16700Schasinglulu BL33_INPUT_FILE = <ip file> \ 147*91f16700Schasinglulu BL32_INPUT_FILE = <ip_file> \ 148*91f16700Schasinglulu BL31_INPUT_FILE = <ip file> \ 149*91f16700Schasinglulu pbl \ 150*91f16700Schasinglulu fip 151*91f16700Schasinglulu 152*91f16700Schasinglulu 153*91f16700SchasingluluDeploy ATF Images 154*91f16700Schasinglulu================= 155*91f16700SchasingluluSame steps as mentioned in the readme "nxp-layerscape.rst". 156*91f16700Schasinglulu 157*91f16700Schasinglulu 158*91f16700Schasinglulu 159*91f16700SchasingluluVerification to check if Secure state is achieved: 160*91f16700Schasinglulu================================================== 161*91f16700Schasinglulu 162*91f16700Schasinglulu+---+----------------+-----------------+------------------------+----------------------------------+-------------------------------+ 163*91f16700Schasinglulu| | Platform | SNVS_HPSR_REG | SYS_SECURE_BIT(=value) | SYSTEM_SECURE_CONFIG_BIT(=value) | SSM_STATE | 164*91f16700Schasinglulu+===+================+=================+========================+==================================+===============================+ 165*91f16700Schasinglulu| 1.| lx2160ardb or | 0x01E90014 | 15 | 14-12 | 11-8 | 166*91f16700Schasinglulu| | lx2160aqds or | | ( = 1, BootROM Booted) | ( = 010 means Intent to Secure, | (=1111 means secure boot) | 167*91f16700Schasinglulu| | lx2162aqds | | | ( = 000 Unsecure) | (=1011 means Non-secure Boot) | 168*91f16700Schasinglulu+---+----------------+-----------------+------------------------+----------------------------------+-------------------------------+ 169*91f16700Schasinglulu 170*91f16700Schasinglulu- Production mode (SFP->OSPR, ITS = 1) 171*91f16700Schasinglulu -- Linux prompt will successfully come. if the TBBR is successful. 172*91f16700Schasinglulu 173*91f16700Schasinglulu --- Else, Linux boot will be successful. 174*91f16700Schasinglulu 175*91f16700Schasinglulu -- For secure-boot status, read SNVS Register $SNVS_HPSR_REG from u-boot prompt: 176*91f16700Schasinglulu 177*91f16700Schasinglulu .. code:: shell 178*91f16700Schasinglulu 179*91f16700Schasinglulu md $SNVS_HPSR_REG 180*91f16700Schasinglulu 181*91f16700Schasinglulu Command Output: 182*91f16700Schasinglulu 1e90014: 8000AF00 183*91f16700Schasinglulu 184*91f16700Schasinglulu In case it is read as 00000000, then read this register using jtag (in development mode only through CW tap). 185*91f16700Schasinglulu +0 +4 +8 +C 186*91f16700Schasinglulu [0x01E90014] 8000AF00 187*91f16700Schasinglulu 188*91f16700Schasinglulu 189*91f16700Schasinglulu- Development Mode (sb_en in RCW = 1, SFP->OSPR, ITS = 0) 190*91f16700Schasinglulu -- Refer the SoC specific table to read the register to interpret whether the secure boot is achieved or not. 191*91f16700Schasinglulu -- Using JTAG (in development environment only, using CW tap): 192*91f16700Schasinglulu 193*91f16700Schasinglulu --- For secure-boot status, read SNVS Register $SNVS_HPSR_REG 194*91f16700Schasinglulu 195*91f16700Schasinglulu .. code:: shell 196*91f16700Schasinglulu 197*91f16700Schasinglulu ccs::display_regs 86 0x01E90014 4 0 1 198*91f16700Schasinglulu 199*91f16700Schasinglulu Command Output: 200*91f16700Schasinglulu Using the SAP chain position number 86, following is the output. 201*91f16700Schasinglulu 202*91f16700Schasinglulu +0 +4 +8 +C 203*91f16700Schasinglulu [0x01E90014] 8000AF00 204*91f16700Schasinglulu 205*91f16700Schasinglulu Note: Chain position number will vary from one SoC to other SoC. 206*91f16700Schasinglulu 207*91f16700Schasinglulu- Interpretation of the value: 208*91f16700Schasinglulu 209*91f16700Schasinglulu -- 0xA indicates BootROM booted, with intent to secure. 210*91f16700Schasinglulu -- 0xF = secure boot, as SSM_STATE. 211