xref: /OK3568_Linux_fs/u-boot/doc/README.ti-secure (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunREADME on how boot images are created for secure TI devices
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunCONFIG_TI_SECURE_DEVICE:
4*4882a593SmuzhiyunSecure TI devices require a boot image that is authenticated by ROM
5*4882a593Smuzhiyuncode to function. Without this, even JTAG remains locked and the
6*4882a593Smuzhiyundevice is essentially useless. In order to create a valid boot image for
7*4882a593Smuzhiyuna secure device from TI, the initial public software image must be signed
8*4882a593Smuzhiyunand combined with various headers, certificates, and other binary images.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunInformation on the details on the complete boot image format can be obtained
11*4882a593Smuzhiyunfrom Texas Instruments. The tools used to generate boot images for secure
12*4882a593Smuzhiyundevices are part of a secure development package (SECDEV) that can be
13*4882a593Smuzhiyundownloaded from:
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun	http://www.ti.com/mysecuresoftware (login required)
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunThe secure development package is access controlled due to NDA and export
18*4882a593Smuzhiyuncontrol restrictions. Access must be requested and granted by TI before the
19*4882a593Smuzhiyunpackage is viewable and downloadable. Contact TI, either online or by way
20*4882a593Smuzhiyunof a local TI representative, to request access.
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunBooting of U-Boot SPL
23*4882a593Smuzhiyun=====================
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun	When CONFIG_TI_SECURE_DEVICE is set, the U-Boot SPL build process
26*4882a593Smuzhiyun	requires the presence and use of these tools in order to create a
27*4882a593Smuzhiyun	viable boot image. The build process will look for the environment
28*4882a593Smuzhiyun	variable TI_SECURE_DEV_PKG, which should be the path of the installed
29*4882a593Smuzhiyun	SECDEV package. If the TI_SECURE_DEV_PKG variable is not defined or
30*4882a593Smuzhiyun	if it is defined but doesn't point to a valid SECDEV package, a
31*4882a593Smuzhiyun	warning is issued during the build to indicate that a final secure
32*4882a593Smuzhiyun	bootable image was not created.
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun	Within the SECDEV package exists an image creation script:
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun	${TI_SECURE_DEV_PKG}/scripts/create-boot-image.sh
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun	This is called as part of the SPL/u-boot build process. As the secure
39*4882a593Smuzhiyun	boot image formats and requirements differ between secure SOC from TI,
40*4882a593Smuzhiyun	the purpose of this script is to abstract these details as much as
41*4882a593Smuzhiyun	possible.
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun	The script is basically the only required interface to the TI SECDEV
44*4882a593Smuzhiyun	package for creating a bootable SPL image for secure TI devices.
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun	Invoking the script for AM33xx Secure Devices
47*4882a593Smuzhiyun	=============================================
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun	create-boot-image.sh \
50*4882a593Smuzhiyun		<IMAGE_FLAG> <INPUT_FILE> <OUTPUT_FILE> <SPL_LOAD_ADDR>
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun	<IMAGE_FLAG> is a value that specifies the type of the image to
53*4882a593Smuzhiyun	generate OR the action the image generation tool will take. Valid
54*4882a593Smuzhiyun	values are:
55*4882a593Smuzhiyun		SPI_X-LOADER - Generates an image for SPI flash (byte swapped)
56*4882a593Smuzhiyun		X-LOADER - Generates an image for non-XIP flash
57*4882a593Smuzhiyun		MLO - Generates an image for SD/MMC/eMMC media
58*4882a593Smuzhiyun		2ND - Generates an image for USB, UART and Ethernet
59*4882a593Smuzhiyun		XIP_X-LOADER - Generates a single stage u-boot for NOR/QSPI XiP
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun	<INPUT_FILE> is the full path and filename of the public world boot
62*4882a593Smuzhiyun	loaderbinary file (depending on the boot media, this is usually
63*4882a593Smuzhiyun	either u-boot-spl.bin or u-boot.bin).
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun	<OUTPUT_FILE> is the full path and filename of the final secure
66*4882a593Smuzhiyun	image. The output binary images should be used in place of the standard
67*4882a593Smuzhiyun	non-secure binary images (see the platform-specific user's guides and
68*4882a593Smuzhiyun	releases notes for how the non-secure images are typically used)
69*4882a593Smuzhiyun	u-boot-spl_HS_SPI_X-LOADER - byte swapped boot image for SPI flash
70*4882a593Smuzhiyun	u-boot-spl_HS_X-LOADER - boot image for NAND or SD/MMC/eMMC rawmode
71*4882a593Smuzhiyun	u-boot-spl_HS_MLO - boot image for SD/MMC/eMMC media
72*4882a593Smuzhiyun	u-boot-spl_HS_2ND - boot image for USB, UART and Ethernet
73*4882a593Smuzhiyun	u-boot_HS_XIP_X-LOADER - boot image for NOR or QSPI Xip flash
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun	<SPL_LOAD_ADDR> is the address at which SOC ROM should load the
76*4882a593Smuzhiyun	<INPUT_FILE>
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun	Invoking the script for AM43xx Secure Devices
79*4882a593Smuzhiyun	=============================================
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun	create-boot-image.sh \
82*4882a593Smuzhiyun		<IMAGE_FLAG> <INPUT_FILE> <OUTPUT_FILE> <SPL_LOAD_ADDR>
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun	<IMAGE_FLAG> is a value that specifies the type of the image to
85*4882a593Smuzhiyun	generate OR the action the image generation tool will take. Valid
86*4882a593Smuzhiyun	values are:
87*4882a593Smuzhiyun		SPI_X-LOADER - Generates an image for SPI flash (byte
88*4882a593Smuzhiyun			swapped)
89*4882a593Smuzhiyun		XIP_X-LOADER - Generates a single stage u-boot for
90*4882a593Smuzhiyun			NOR/QSPI XiP
91*4882a593Smuzhiyun		ISSW - Generates an image for all other boot modes
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun	<INPUT_FILE> is the full path and filename of the public world boot
94*4882a593Smuzhiyun	loaderbinary file (depending on the boot media, this is usually
95*4882a593Smuzhiyun	either u-boot-spl.bin or u-boot.bin).
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun	<OUTPUT_FILE> is the full path and filename of the final secure
98*4882a593Smuzhiyun	image. The output binary images should be used in place of the standard
99*4882a593Smuzhiyun	non-secure binary images (see the platform-specific user's guides and
100*4882a593Smuzhiyun	releases notes for how the non-secure images are typically used)
101*4882a593Smuzhiyun	u-boot-spl_HS_SPI_X-LOADER - byte swapped boot image for SPI flash
102*4882a593Smuzhiyun	u-boot_HS_XIP_X-LOADER - boot image for NOR or QSPI flash
103*4882a593Smuzhiyun	u-boot-spl_HS_ISSW - boot image for all other boot media
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun	<SPL_LOAD_ADDR> is the address at which SOC ROM should load the
106*4882a593Smuzhiyun	<INPUT_FILE>
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun	Invoking the script for DRA7xx/AM57xx Secure Devices
109*4882a593Smuzhiyun	====================================================
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun	create-boot-image.sh <IMAGE_TYPE> <INPUT_FILE> <OUTPUT_FILE>
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun	<IMAGE_TYPE> is a value that specifies the type of the image to
114*4882a593Smuzhiyun	generate OR the action the image generation tool will take. Valid
115*4882a593Smuzhiyun	values are:
116*4882a593Smuzhiyun		X-LOADER - Generates an image for NOR or QSPI boot modes
117*4882a593Smuzhiyun		MLO - Generates an image for SD/MMC/eMMC boot modes
118*4882a593Smuzhiyun		ULO - Generates an image for USB/UART peripheral boot modes
119*4882a593Smuzhiyun		Note: ULO is not yet used by the u-boot build process
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun	<INPUT_FILE> is the full path and filename of the public world boot
122*4882a593Smuzhiyun	loader binary file (for this platform, this is always u-boot-spl.bin).
123*4882a593Smuzhiyun
124*4882a593Smuzhiyun	<OUTPUT_FILE> is the full path and filename of the final secure image.
125*4882a593Smuzhiyun	The output binary images should be used in place of the standard
126*4882a593Smuzhiyun	non-secure binary images (see the platform-specific user's guides
127*4882a593Smuzhiyun	and releases notes for how the non-secure images are typically used)
128*4882a593Smuzhiyun	u-boot-spl_HS_MLO - boot image for SD/MMC/eMMC. This image is
129*4882a593Smuzhiyun		copied to a file named MLO, which is the name that
130*4882a593Smuzhiyun		the device ROM bootloader requires for loading from
131*4882a593Smuzhiyun		the FAT partition of an SD card (same as on
132*4882a593Smuzhiyun		non-secure devices)
133*4882a593Smuzhiyun	u-boot-spl_HS_X-LOADER - boot image for all other flash memories
134*4882a593Smuzhiyun		including QSPI and NOR flash
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun	Invoking the script for Keystone2 Secure Devices
137*4882a593Smuzhiyun	=============================================
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun	create-boot-image.sh \
140*4882a593Smuzhiyun		<UNUSED> <INPUT_FILE> <OUTPUT_FILE> <UNUSED>
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun	<UNUSED> is currently ignored and reserved for future use.
143*4882a593Smuzhiyun
144*4882a593Smuzhiyun	<INPUT_FILE> is the full path and filename of the public world boot
145*4882a593Smuzhiyun	loader binary file (only u-boot.bin is currently supported on
146*4882a593Smuzhiyun	Keystone2 devices, u-boot-spl.bin is not currently supported).
147*4882a593Smuzhiyun
148*4882a593Smuzhiyun	<OUTPUT_FILE> is the full path and filename of the final secure image.
149*4882a593Smuzhiyun	The output binary images should be used in place of the standard
150*4882a593Smuzhiyun	non-secure binary images (see the platform-specific user's guides
151*4882a593Smuzhiyun	and releases notes for how the non-secure images are typically used)
152*4882a593Smuzhiyun	u-boot_HS_MLO - signed and encrypted boot image that can be used to
153*4882a593Smuzhiyun		boot from all media. Secure boot from SPI NOR flash is not
154*4882a593Smuzhiyun		currently supported.
155*4882a593Smuzhiyun
156*4882a593SmuzhiyunBooting of Primary U-Boot (u-boot.img)
157*4882a593Smuzhiyun======================================
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun	The SPL image is responsible for loading the next stage boot loader,
160*4882a593Smuzhiyun	which is the main u-boot image. For secure TI devices, the SPL will
161*4882a593Smuzhiyun	be authenticated, as described above, as part of the particular
162*4882a593Smuzhiyun	device's ROM boot process. In order to continue the secure boot
163*4882a593Smuzhiyun	process, the authenticated SPL must authenticate the main u-boot
164*4882a593Smuzhiyun	image that it loads.
165*4882a593Smuzhiyun
166*4882a593Smuzhiyun	The configurations for secure TI platforms are written to make the boot
167*4882a593Smuzhiyun	process use the FIT image format for the u-boot.img (CONFIG_SPL_FRAMEWORK
168*4882a593Smuzhiyun	and CONFIG_SPL_LOAD_FIT). With these configurations the binary
169*4882a593Smuzhiyun	components that the SPL loads include a specific DTB image and u-boot
170*4882a593Smuzhiyun	image. These DTB image may be one of many available to the boot
171*4882a593Smuzhiyun	process. In order to secure these components so that they can be
172*4882a593Smuzhiyun	authenticated by the SPL as they are loaded from the FIT image,	the
173*4882a593Smuzhiyun	build procedure for secure TI devices will secure these images before
174*4882a593Smuzhiyun	they are integrated into the FIT image. When those images are extracted
175*4882a593Smuzhiyun	from the FIT image at boot time, they are post-processed to verify that
176*4882a593Smuzhiyun	they are still secure. The outlined security-related SPL post-processing
177*4882a593Smuzhiyun	is enabled through the CONFIG_SPL_FIT_IMAGE_POST_PROCESS option which
178*4882a593Smuzhiyun	must be enabled for the secure boot scheme to work. In order to allow
179*4882a593Smuzhiyun	verifying proper operation of the secure boot chain in case of successful
180*4882a593Smuzhiyun	authentication messages like "Authentication passed: CERT_U-BOOT-NOD" are
181*4882a593Smuzhiyun	output by the SPL to the console for each blob that got extracted from the
182*4882a593Smuzhiyun	FIT image. Note that the last part of this log message is the (truncated)
183*4882a593Smuzhiyun	name of the signing certificate embedded into the blob that got processed.
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun	The exact details of the how the images are secured is handled by the
186*4882a593Smuzhiyun	SECDEV package. Within the SECDEV package exists a script to process
187*4882a593Smuzhiyun	an input binary image:
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun	${TI_SECURE_DEV_PKG}/scripts/secure-binary-image.sh
190*4882a593Smuzhiyun
191*4882a593Smuzhiyun	This is called as part of the u-boot build process. As the secure
192*4882a593Smuzhiyun	image formats and requirements can differ between the various secure
193*4882a593Smuzhiyun	SOCs from TI, this script in the SECDEV package abstracts these
194*4882a593Smuzhiyun	details. This script is essentially the only required interface to the
195*4882a593Smuzhiyun	TI SECDEV package for creating a u-boot.img image for secure TI
196*4882a593Smuzhiyun	devices.
197*4882a593Smuzhiyun
198*4882a593Smuzhiyun	The SPL/u-boot code contains calls to dedicated secure ROM functions
199*4882a593Smuzhiyun	to perform the validation on the secured images. The details of the
200*4882a593Smuzhiyun	interface to those functions is shown in the code. The summary
201*4882a593Smuzhiyun	is that they are accessed by invoking an ARM secure monitor call to
202*4882a593Smuzhiyun	the device's secure ROM (fixed read-only-memory that is secure and
203*4882a593Smuzhiyun	only accessible when the ARM core is operating in the secure mode).
204*4882a593Smuzhiyun
205*4882a593Smuzhiyun	Invoking the secure-binary-image script for Secure Devices
206*4882a593Smuzhiyun	==========================================================
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun	secure-binary-image.sh <INPUT_FILE> <OUTPUT_FILE>
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun	<INPUT_FILE> is the full path and filename of the input binary image
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun	<OUTPUT_FILE> is the full path and filename of the output secure image.
213