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