xref: /openbmc/u-boot/doc/README.ti-secure (revision 8662bea38e2779a45275a6ac13a378f9f989930a)
198350f7fSDaniel AllredREADME on how boot images are created for secure TI devices
298350f7fSDaniel Allred
398350f7fSDaniel AllredCONFIG_TI_SECURE_DEVICE:
498350f7fSDaniel AllredSecure TI devices require a boot image that is authenticated by ROM
598350f7fSDaniel Allredcode to function. Without this, even JTAG remains locked and the
698350f7fSDaniel Allreddevice is essentially useless. In order to create a valid boot image for
798350f7fSDaniel Allreda secure device from TI, the initial public software image must be signed
898350f7fSDaniel Allredand combined with various headers, certificates, and other binary images.
998350f7fSDaniel Allred
1098350f7fSDaniel AllredInformation on the details on the complete boot image format can be obtained
1198350f7fSDaniel Allredfrom Texas Instruments. The tools used to generate boot images for secure
1298350f7fSDaniel Allreddevices are part of a secure development package (SECDEV) that can be
1398350f7fSDaniel Allreddownloaded from:
1498350f7fSDaniel Allred
1598350f7fSDaniel Allred	http://www.ti.com/mysecuresoftware (login required)
1698350f7fSDaniel Allred
1798350f7fSDaniel AllredThe secure development package is access controlled due to NDA and export
1898350f7fSDaniel Allredcontrol restrictions. Access must be requested and granted by TI before the
1998350f7fSDaniel Allredpackage is viewable and downloadable. Contact TI, either online or by way
2098350f7fSDaniel Allredof a local TI representative, to request access.
2198350f7fSDaniel Allred
22*8662bea3SAndreas DannenbergBooting of U-Boot SPL
23*8662bea3SAndreas Dannenberg=====================
24*8662bea3SAndreas Dannenberg
25*8662bea3SAndreas Dannenberg	When CONFIG_TI_SECURE_DEVICE is set, the U-Boot SPL build process
26*8662bea3SAndreas Dannenberg	requires the presence and use of these tools in order to create a
27*8662bea3SAndreas Dannenberg	viable boot image. The build process will look for the environment
28*8662bea3SAndreas Dannenberg	variable TI_SECURE_DEV_PKG, which should be the path of the installed
29*8662bea3SAndreas Dannenberg	SECDEV package. If the TI_SECURE_DEV_PKG variable is not defined or
30*8662bea3SAndreas Dannenberg	if it is defined but doesn't point to a valid SECDEV package, a
31*8662bea3SAndreas Dannenberg	warning is issued during the build to indicate that a final secure
32*8662bea3SAndreas Dannenberg	bootable image was not created.
3398350f7fSDaniel Allred
3498350f7fSDaniel Allred	Within the SECDEV package exists an image creation script:
3598350f7fSDaniel Allred
3698350f7fSDaniel Allred	${TI_SECURE_DEV_PKG}/scripts/create-boot-image.sh
3798350f7fSDaniel Allred
38*8662bea3SAndreas Dannenberg	This is called as part of the SPL/u-boot build process. As the secure
39*8662bea3SAndreas Dannenberg	boot image formats and requirements differ between secure SOC from TI,
40*8662bea3SAndreas Dannenberg	the purpose of this script is to abstract these details as much as
41*8662bea3SAndreas Dannenberg	possible.
4298350f7fSDaniel Allred
43*8662bea3SAndreas Dannenberg	The script is basically the only required interface to the TI SECDEV
44*8662bea3SAndreas Dannenberg	package for creating a bootable SPL image for secure TI devices.
4598350f7fSDaniel Allred
4698350f7fSDaniel Allred	Invoking the script for AM43xx Secure Devices
4798350f7fSDaniel Allred	=============================================
4898350f7fSDaniel Allred
49*8662bea3SAndreas Dannenberg	create-boot-image.sh \
50*8662bea3SAndreas Dannenberg		<IMAGE_FLAG> <INPUT_FILE> <OUTPUT_FILE> <SPL_LOAD_ADDR>
5198350f7fSDaniel Allred
52*8662bea3SAndreas Dannenberg	<IMAGE_FLAG> is a value that specifies the type of the image to
53*8662bea3SAndreas Dannenberg	generate OR the action the image generation tool will take. Valid
54*8662bea3SAndreas Dannenberg	values are:
55*8662bea3SAndreas Dannenberg		SPI_X-LOADER - Generates an image for SPI flash (byte
56*8662bea3SAndreas Dannenberg			swapped)
57*8662bea3SAndreas Dannenberg		XIP_X-LOADER - Generates a single stage u-boot for
58*8662bea3SAndreas Dannenberg			NOR/QSPI XiP
5998350f7fSDaniel Allred		ISSW - Generates an image for all other boot modes
6098350f7fSDaniel Allred
61*8662bea3SAndreas Dannenberg	<INPUT_FILE> is the full path and filename of the public world boot
62*8662bea3SAndreas Dannenberg	loaderbinary file (depending on the boot media, this is usually
63*8662bea3SAndreas Dannenberg	either u-boot-spl.bin or u-boot.bin).
6498350f7fSDaniel Allred
65*8662bea3SAndreas Dannenberg	<OUTPUT_FILE> is the full path and filename of the final secure
66*8662bea3SAndreas Dannenberg	image. The output binary images should be used in place of the standard
67*8662bea3SAndreas Dannenberg	non-secure binary images (see the platform-specific user's guides and
68*8662bea3SAndreas Dannenberg	releases notes for how the non-secure images are typically used)
6998350f7fSDaniel Allred	u-boot-spl_HS_SPI_X-LOADER - byte swapped boot image for SPI flash
7098350f7fSDaniel Allred	u-boot_HS_XIP_X-LOADER - boot image for NOR or QSPI flash
7198350f7fSDaniel Allred	u-boot-spl_HS_ISSW - boot image for all other boot media
7298350f7fSDaniel Allred
73*8662bea3SAndreas Dannenberg	<SPL_LOAD_ADDR> is the address at which SOC ROM should load the
74*8662bea3SAndreas Dannenberg	<INPUT_FILE>
7598350f7fSDaniel Allred
7698350f7fSDaniel Allred	Invoking the script for DRA7xx/AM57xx Secure Devices
7798350f7fSDaniel Allred	====================================================
7898350f7fSDaniel Allred
7998350f7fSDaniel Allred	create-boot-image.sh <IMAGE_TYPE> <INPUT_FILE> <OUTPUT_FILE>
8098350f7fSDaniel Allred
81*8662bea3SAndreas Dannenberg	<IMAGE_TYPE> is a value that specifies the type of the image to
82*8662bea3SAndreas Dannenberg	generate OR the action the image generation tool will take. Valid
83*8662bea3SAndreas Dannenberg	values are:
8498350f7fSDaniel Allred		X-LOADER - Generates an image for NOR or QSPI boot modes
8598350f7fSDaniel Allred		MLO - Generates an image for SD/MMC/eMMC boot modes
8698350f7fSDaniel Allred		ULO - Generates an image for USB/UART peripheral boot modes
8798350f7fSDaniel Allred		Note: ULO is not yet used by the u-boot build process
8898350f7fSDaniel Allred
89*8662bea3SAndreas Dannenberg	<INPUT_FILE> is the full path and filename of the public world boot
90*8662bea3SAndreas Dannenberg	loader binary file (for this platform, this is always u-boot-spl.bin).
9198350f7fSDaniel Allred
92*8662bea3SAndreas Dannenberg	<OUTPUT_FILE> is the full path and filename of the final secure image.
93*8662bea3SAndreas Dannenberg	The output binary images should be used in place of the standard
94*8662bea3SAndreas Dannenberg	non-secure binary images (see the platform-specific user's guides
95*8662bea3SAndreas Dannenberg	and releases notes for how the non-secure images are typically used)
9698350f7fSDaniel Allred	u-boot-spl_HS_MLO - boot image for SD/MMC/eMMC. This image is
9798350f7fSDaniel Allred		copied to a file named MLO, which is the name that
9898350f7fSDaniel Allred		the device ROM bootloader requires for loading from
9998350f7fSDaniel Allred		the FAT partition of an SD card (same as on
10098350f7fSDaniel Allred		non-secure devices)
10198350f7fSDaniel Allred	u-boot-spl_HS_X-LOADER - boot image for all other flash memories
10298350f7fSDaniel Allred		including QSPI and NOR flash
103*8662bea3SAndreas Dannenberg
104*8662bea3SAndreas DannenbergBooting of Primary U-Boot (u-boot.img)
105*8662bea3SAndreas Dannenberg======================================
106*8662bea3SAndreas Dannenberg
107*8662bea3SAndreas Dannenberg	The SPL image is responsible for loading the next stage boot loader,
108*8662bea3SAndreas Dannenberg	which is the main u-boot image. For secure TI devices, the SPL will
109*8662bea3SAndreas Dannenberg	be authenticated, as described above, as part of the particular
110*8662bea3SAndreas Dannenberg	device's ROM boot process. In order to continue the secure boot
111*8662bea3SAndreas Dannenberg	process, the authenticated SPL must authenticate the main u-boot
112*8662bea3SAndreas Dannenberg	image that it loads.
113*8662bea3SAndreas Dannenberg
114*8662bea3SAndreas Dannenberg	The configurations for secure TI platforms are written to make the boot
115*8662bea3SAndreas Dannenberg	process use the FIT image format for the u-boot.img (CONFIG_SPL_FRAMEWORK
116*8662bea3SAndreas Dannenberg	and CONFIG_SPL_LOAD_FIT). With these configurations the binary
117*8662bea3SAndreas Dannenberg	components that the SPL loads include a specific DTB image and u-boot
118*8662bea3SAndreas Dannenberg	image. These DTB image may be one of many available to the boot
119*8662bea3SAndreas Dannenberg	process. In order to secure these components so that they can be
120*8662bea3SAndreas Dannenberg	authenticated by the SPL as they are loaded from the FIT image,	the
121*8662bea3SAndreas Dannenberg	build procedure for secure TI devices will secure these images before
122*8662bea3SAndreas Dannenberg	they are integrated into the FIT image. When those images are extracted
123*8662bea3SAndreas Dannenberg	from the FIT image at boot time, they are post-processed to verify that
124*8662bea3SAndreas Dannenberg	they are still secure. The outlined security-related SPL post-processing
125*8662bea3SAndreas Dannenberg	is enabled through the CONFIG_SPL_FIT_IMAGE_POST_PROCESS option which
126*8662bea3SAndreas Dannenberg	must be enabled for the secure boot scheme to work. In order to allow
127*8662bea3SAndreas Dannenberg	verifying proper operation of the secure boot chain in case of successful
128*8662bea3SAndreas Dannenberg	authentication messages like "Authentication passed: CERT_U-BOOT-NOD" are
129*8662bea3SAndreas Dannenberg	output by the SPL to the console for each blob that got extracted from the
130*8662bea3SAndreas Dannenberg	FIT image. Note that the last part of this log message is the (truncated)
131*8662bea3SAndreas Dannenberg	name of the signing certificate embedded into the blob that got processed.
132*8662bea3SAndreas Dannenberg
133*8662bea3SAndreas Dannenberg	The exact details of the how the images are secured is handled by the
134*8662bea3SAndreas Dannenberg	SECDEV package. Within the SECDEV package exists a script to process
135*8662bea3SAndreas Dannenberg	an input binary image:
136*8662bea3SAndreas Dannenberg
137*8662bea3SAndreas Dannenberg	${TI_SECURE_DEV_PKG}/scripts/secure-binary-image.sh
138*8662bea3SAndreas Dannenberg
139*8662bea3SAndreas Dannenberg	This is called as part of the u-boot build process. As the secure
140*8662bea3SAndreas Dannenberg	image formats and requirements can differ between the various secure
141*8662bea3SAndreas Dannenberg	SOCs from TI, this script in the SECDEV package abstracts these
142*8662bea3SAndreas Dannenberg	details. This script is essentially the only required interface to the
143*8662bea3SAndreas Dannenberg	TI SECDEV package for creating a u-boot.img image for secure TI
144*8662bea3SAndreas Dannenberg	devices.
145*8662bea3SAndreas Dannenberg
146*8662bea3SAndreas Dannenberg	The SPL/u-boot code contains calls to dedicated secure ROM functions
147*8662bea3SAndreas Dannenberg	to perform the validation on the secured images. The details of the
148*8662bea3SAndreas Dannenberg	interface to those functions is shown in the code. The summary
149*8662bea3SAndreas Dannenberg	is that they are accessed by invoking an ARM secure monitor call to
150*8662bea3SAndreas Dannenberg	the device's secure ROM (fixed read-only-memory that is secure and
151*8662bea3SAndreas Dannenberg	only accessible when the ARM core is operating in the secure mode).
152*8662bea3SAndreas Dannenberg
153*8662bea3SAndreas Dannenberg	Invoking the secure-binary-image script for Secure Devices
154*8662bea3SAndreas Dannenberg	==========================================================
155*8662bea3SAndreas Dannenberg
156*8662bea3SAndreas Dannenberg	secure-binary-image.sh <INPUT_FILE> <OUTPUT_FILE>
157*8662bea3SAndreas Dannenberg
158*8662bea3SAndreas Dannenberg	<INPUT_FILE> is the full path and filename of the input binary image
159*8662bea3SAndreas Dannenberg
160*8662bea3SAndreas Dannenberg	<OUTPUT_FILE> is the full path and filename of the output secure image.
161