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