<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dh-electronics.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jneuhauser</id>
	<title>Wiki-DB - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dh-electronics.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jneuhauser"/>
	<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=Special:Contributions/Jneuhauser"/>
	<updated>2026-04-27T16:34:38Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=Main_Page&amp;diff=3864</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=Main_Page&amp;diff=3864"/>
		<updated>2024-06-12T09:49:02Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: This wiki is no more &amp;quot;new&amp;quot; for a long time&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| style=&amp;quot;width: 100%; color: #000000; border-spacing: 2px; border: 1px solid darkgray;&amp;quot; valign=&amp;quot;top&amp;quot; |&lt;br /&gt;
| style=&amp;quot;width: 25%; text-align: center;&amp;quot; |&lt;br /&gt;
| style=&amp;quot;width: 50%; text-align: center;&amp;quot; |&lt;br /&gt;
| style=&amp;quot;width: 25%; text-align: center;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; | [[Image:Welcome.jpg|200px|Welcome to DH electronics MediaWiki]]&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; | [[Image:LOGO_DH_electronics-SMALL.jpg|200px|Welcome to DH electronics MediaWiki]]&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; | [[Image:Mediawiki.jpg|183px|Welcome to DH electronics MediaWiki]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Welcome to DH electronics MediaWiki. This Wiki has the aim to provide our customers technical support for DH electronics products.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width: 100%; color: #000000; border-collapse:collapse; border: darkgray; border-style: solid; border-width: 1px 0 1px 0&amp;quot;&lt;br /&gt;
| &lt;br /&gt;
|style=&amp;quot;padding:10px;&amp;quot;|&lt;br /&gt;
=== [[DHSOM|DHSOM]] ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;System On Module&#039;&#039;&#039; (SOM) is a powerful embedded computer on a compact circuit board.&lt;br /&gt;
&lt;br /&gt;
Our DHCOM modules offer high performance coupled with extensive features and interfaces, low power consumption&lt;br /&gt;
as well as compact size.Possible applications for our modules are in visualization, multimedia, automation and communication devices&lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;[[DHSOM|here]]&#039;&#039;&#039; to get support information for our &#039;&#039;&#039;[[DHSOM|DHSOM]]&#039;&#039;&#039; products.&lt;br /&gt;
| style=&amp;quot;text-align: right;&amp;quot; |[[Image:IM6Modul.png|center|300px|COM iMX6-D2|link=DHSOM]]&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot;|&lt;br /&gt;
|style=&amp;quot;padding:10px; border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== [[Image:XLON Logo in Schwarz von SD Kopie.jpg|120px|DH electronics XLON|link=XLON]] ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;XLON&#039;&#039;&#039; products are network interfaces and infrastructure components for LonWorks technology.&lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;[[XLON|here]]&#039;&#039;&#039; to get support information for our &#039;&#039;&#039;[[XLON]]&#039;&#039;&#039; products.&lt;br /&gt;
| style=&amp;quot;text-align: right; border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot; |[[Image:XLON U10.png|center|275px|XLON U10|link=XLON]]&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot;|&lt;br /&gt;
|style=&amp;quot;padding:10px; border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== [[Avenger96]] ===&lt;br /&gt;
&lt;br /&gt;
The AVENGER Board is a 96Boards compliant consumer edition board based on the STM32MP15 series of SoCs.&lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;[[Avenger96|here]]&#039;&#039;&#039; to get support information for our &#039;&#039;&#039;[[Avenger96]]&#039;&#039;&#039; products.&lt;br /&gt;
| style=&amp;quot;text-align: right; border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot; |[[Image:Avenger96_Pers.png|center|350px|Avenger96|link=Avenger96]]&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot;|&lt;br /&gt;
|style=&amp;quot;padding:10px; border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot;|&lt;br /&gt;
=== [[DHMI]] ===&lt;br /&gt;
&lt;br /&gt;
DHMI is our HMI systems (Human-Machine Interface) product range. The standard series are equipped with resistive or capacitive touch displays and our SOM.&lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;[[DHMI|here]]&#039;&#039;&#039; to get support information for our &#039;&#039;&#039;[[DHMI]]&#039;&#039;&#039; products.&lt;br /&gt;
| style=&amp;quot;text-align: right; border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot; |[[Image:HMI_7_mit_Rahmen_Display_medres_wiki.png|center|350px|DHMI|link=DHMI]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot;|&lt;br /&gt;
|style=&amp;quot;padding:10px; border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot;|&lt;br /&gt;
=== [[DHCON]] ===&lt;br /&gt;
&lt;br /&gt;
Our DHCON products are optimized for smart home &amp;amp; building as well as Industry 4.0 and IoT applications.&lt;br /&gt;
&lt;br /&gt;
Click &#039;&#039;&#039;[[DHCON|here]]&#039;&#039;&#039; to get support information for our &#039;&#039;&#039;[[DHCON]]&#039;&#039;&#039; products.&lt;br /&gt;
| style=&amp;quot;text-align: right; border: darkgray; border-style: solid; border-width: 1px 0 0 0;&amp;quot; |[[Image:IN-RAIL.png|center|350px|DHCON|link=DHCON]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=COM_iMX8_Hardware&amp;diff=3863</id>
		<title>COM iMX8 Hardware</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=COM_iMX8_Hardware&amp;diff=3863"/>
		<updated>2024-06-11T06:58:42Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Link to product page instead of the &amp;quot;broken&amp;quot;, direct links to the files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== User Manual / Datasheet ==&lt;br /&gt;
[https://www.dh-electronics.com/embedded-produkte/dhsom/detail/dhcom-imx8m-plus DH electronics Product page]&lt;br /&gt;
&lt;br /&gt;
== Downloads ==&lt;br /&gt;
:* [[media:DHCOM_schematic_symbol_R03.zip|Download schematic symbols for DHCOM SODIMM-200 connector]]&lt;br /&gt;
:* [[media:CAD_DHCOM-iMX8MPlus-3D-Model-2022-03-23.zip|DHCOM i.MX8M Plus 3D model]]&lt;br /&gt;
&lt;br /&gt;
== Available Documents and Links from ST ==&lt;br /&gt;
&lt;br /&gt;
[https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors/i-mx-8m-plus-arm-cortex-a53-machine-learning-vision-multimedia-and-industrial-iot:IMX8MPLUS NXP product page and documentation]&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP1_Hardware&amp;diff=3862</id>
		<title>DHCOM STM32MP1 Hardware</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP1_Hardware&amp;diff=3862"/>
		<updated>2024-06-11T06:57:50Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Update linkt to product page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== User Manual / Datasheet ==&lt;br /&gt;
[https://www.dh-electronics.com/embedded-produkte/dhsom/detail/dhcom-stm32mp15 DH electronics Product page]&lt;br /&gt;
&lt;br /&gt;
== Downloads ==&lt;br /&gt;
:* [[media:DHCOM_schematic_symbol_R03.zip|Download schematic symbols for DHCOM SODIMM-200 and display adaptor connector]]&lt;br /&gt;
&lt;br /&gt;
== Available Documents and Links from ST ==&lt;br /&gt;
&lt;br /&gt;
[https://wiki.st.com/stm32mpu/index.php/STM32MP15_resources STM32MP15 resources]&lt;br /&gt;
&lt;br /&gt;
[https://wiki.st.com/stm32mpu STM32MP1 wiki]&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3853</id>
		<title>U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3853"/>
		<updated>2023-10-11T13:56:49Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide details the process of flashing U-Boot onto our i.MX6 based DHCOM using OpenOCD.&lt;br /&gt;
The hardware configuration, software installation, and step-by-step programming procedures are provided.&lt;br /&gt;
&lt;br /&gt;
== Required Hardware ==&lt;br /&gt;
* Baseboard as power source for DHCOM&lt;br /&gt;
* JTAG Debugger: [https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/ Olimex Arm-USB-OCD-Tiny-H]&lt;br /&gt;
:All tests and documents were made with this one, but technically all JTAG adapters listed by OpenOCD should work.&lt;br /&gt;
* DHCOM JTAG adapter for FFC connection: Article number FD00037&lt;br /&gt;
:[[File:JTAG-Adapter.jpeg|300px]]&lt;br /&gt;
* Wuerth FFC cable: [https://www.we-online.com/de/components/products/FFC_0_50_TYPE_1_6876XXXXX002 687610050002]&lt;br /&gt;
:Note: One cable is included with the DHCOM JTAG adapter.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;To support all our i.MX6 based DHCOM, it is necessary to have OpenOCD v0.11.0 or higher.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from master branch (before Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install needed libraries and tools &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install git build-essential pkg-config autoconf automake libtool libusb-dev libusb-1.0-0-dev libhidapi-dev libftdi-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
# Clone git repository to local directory and checkout v0.12.0 tag &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;git clone -b v0.12.0 https://repo.or.cz/openocd.git&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
# Prepare source directory and submodules (when building from the git repository) &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./bootstrap&amp;lt;/code&amp;gt;&lt;br /&gt;
# Generate the Makefiles to build OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt;&lt;br /&gt;
# Build OpenOCD from source &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;make -j4&amp;lt;/code&amp;gt;&lt;br /&gt;
# Install OpenOCD to /usr/local &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
# (optional) Remove openocd source directory &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd .. &amp;amp;&amp;amp; rm -rf openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from Debian repositories (since Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install OpenOCD from Debian repositories &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Non root access to tty devices ===&lt;br /&gt;
# Add your user to the dialout group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G dialout ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add your user to the plugdev group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G plugdev ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Logout and login to apply new group rights&lt;br /&gt;
&lt;br /&gt;
== U-Boot Programming ==&lt;br /&gt;
There are two ways for doing this.&lt;br /&gt;
The easy way is an automatic shell script, which handles all the commands needed for the programming process.&lt;br /&gt;
The other one is to type in the required commands.&lt;br /&gt;
In a few cases the shell script fails then you need to go the other way and program the U-Boot manually.&lt;br /&gt;
The steps [[#Preparation|Preparation]] and [[#Start up OpenOCD|Start up OpenOCD]] are required for both automatic and manual flash programming.&lt;br /&gt;
&lt;br /&gt;
=== Preparation ===&lt;br /&gt;
==== Get the needed recovery files ====&lt;br /&gt;
# Download and extract the needed files [[media:2023-08-28_imx6_U-Boot_recovery.tar.xz|| tar xJ&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd 2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
==== Connect JTAG adapter ====&lt;br /&gt;
# Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB&lt;br /&gt;
# Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don&#039;t have a JTAG adapter, please ask DH electronics)&lt;br /&gt;
#:[[File:JTAG-connection.jpeg|1000px]]]&lt;br /&gt;
# Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord&lt;br /&gt;
# Connect to the serial console (serial port) of the board like here [[COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console|Enter_Bootloader_Console]]&lt;br /&gt;
&lt;br /&gt;
=== Start up OpenOCD ===&lt;br /&gt;
# Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]]&lt;br /&gt;
# Power up the i.MX6 board and have a look at the serial output (serial port).&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;It is okay if a U-Boot is starting up, because the device will be reset later.&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;There must be no output of U-Boot, otherwise go to [[#Troubleshooting|Troubleshooting]].&lt;br /&gt;
# Open a new terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Start OpenOCD depending on your hardware&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f imx6ull.cfg -f target/imx6ul.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The output should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Open On-Chip Debugger 0.12.0&lt;br /&gt;
Licensed under GNU GPL v2&lt;br /&gt;
For bug reports, read&lt;br /&gt;
        http://openocd.org/doc/doxygen/bugs.html&lt;br /&gt;
Info : auto-selecting first available session transport &amp;quot;jtag&amp;quot;. To override use &#039;transport select &amp;lt;transport&amp;gt;&#039;.&lt;br /&gt;
Warn : imx6.sdma: nonstandard IR value&lt;br /&gt;
boot_from_sd&lt;br /&gt;
Info : Listening on port 6666 for tcl connections&lt;br /&gt;
Info : Listening on port 4444 for telnet connections&lt;br /&gt;
Info : clock speed 1000 kHz&lt;br /&gt;
Info : JTAG tap: imx6.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x4)&lt;br /&gt;
Info : TAP imx6.sdma does not have valid IDCODE (idcode=0x4323803a)&lt;br /&gt;
Info : JTAG tap: imx6.sjc tap/device found: 0x2191c01d (mfg: 0x00e (Freescale (Motorola)), part: 0x191c, ver: 0x2)&lt;br /&gt;
Info : imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
Info : starting gdb server for imx6.cpu.0 on 3333&lt;br /&gt;
Info : Listening on port 3333 for gdb connections&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Automated Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Execute the automated bash script with arguments depending on your hardware and desired U-Boot&lt;br /&gt;
#:* Default DH U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* Custom U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of the script should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Programming: u-boot-with-spl-imx6qdl.imx to imx6qdl&lt;br /&gt;
Trying ::1...&lt;br /&gt;
Connection failed: Connection refused&lt;br /&gt;
Trying 127.0.0.1...&lt;br /&gt;
Connected to localhost.&lt;br /&gt;
Escape character is &#039;^]&#039;.&lt;br /&gt;
Open On-Chip Debugger&lt;br /&gt;
&amp;gt; boot_from_sd&lt;br /&gt;
imx6.cpu.0: MPIDR level2 0, cluster 0, core 0, multi core, no SMT&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0xa00001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: enabled, D-Cache: enabled, I-Cache: enabled&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for cortex_a_exec_opcode&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for dpm prepare&lt;br /&gt;
&lt;br /&gt;
Invalid ACK (7) in DAP response&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
Debug regions are unpowered, an unexpected reset might have happened&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not initialize the APB-AP&lt;br /&gt;
Examination failed, GDB will be halted. Polling again in 100ms&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
&amp;gt; prepare_code_load&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: disabled&lt;br /&gt;
&amp;gt; load_image u-boot-spl-prog-imx6qdl.bin 0x908000&lt;br /&gt;
32768 bytes written at address 0x00908000&lt;br /&gt;
downloaded 32768 bytes in 1.152152s (27.774 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; halt&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x0090ba5e&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-with-spl-imx6qdl.imx 0x12000000&lt;br /&gt;
567752 bytes written at address 0x12000000&lt;br /&gt;
downloaded 567752 bytes in 18.675529s (29.688 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; Connection closed by foreign host.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of serial console (serial port) should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
U-Boot SPL 2018.05-23076-g8686cf2574 (Mar 10 2020 - 10:26:00 +0100)&lt;br /&gt;
SPL: Unsupported Boot Device!&lt;br /&gt;
SPL: failed to boot from all boot devices&lt;br /&gt;
### ERROR ### Please RESET the board ###&lt;br /&gt;
Searching for IVT header at DDR address 0x12000000&lt;br /&gt;
....&lt;br /&gt;
Found IVT header&lt;br /&gt;
Determinded image length: 0x8a9c8&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Trying to program SPI flash ###&lt;br /&gt;
Probing SPI flash... ok&lt;br /&gt;
Erasing SPI flash... ok&lt;br /&gt;
Programming SPI flash... ok&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Finished ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If some error occures you can try the [[#Manual Programming|Manual Programming]] method below&lt;br /&gt;
&lt;br /&gt;
=== Manual Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
## Ensure device boot fails by booting from invalid media&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;boot_from_sd&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;Follow [[#Troubleshooting|Troubleshooting]] to ensure no U-Boot starts.&lt;br /&gt;
## Prepare for running manual loaded code&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;prepare_code_load&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load modified U-Boot SPL as flash programmer in SRAM (device dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6qdl.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6ull.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution at entry point of loaded U-Boot SPL &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume 0x00908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Halt code execution if you see &#039;&#039;&#039;Searching for IVT header at DDR address 0xX2000000&#039;&#039;&#039; in serial console &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;halt&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load desired U-Boot image into RAM (device and customer dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6qdl.imx 0x12000000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6ull.imx 0x82000000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution after U-Boot image is in RAM&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume&amp;lt;/code&amp;gt;&lt;br /&gt;
## Wait until the serial output (serial port) looks like in [[#Automated Programming|Automated Programming]]&lt;br /&gt;
## Exit telnet with &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; and close OpenOCD with STRG+C&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the OpenOCD procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 ULL) ===&lt;br /&gt;
# Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for sdp boot mode on the SODIMM-200 module (DHCOM) next to the BGA module (DHCOR)&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for sdp boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;br /&gt;
&lt;br /&gt;
=== SD Boot (only i.MX6 Q/D/DL/S) ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
# Use the following command to trigger a boot from an invalid source by setting the boot source to an invalid media for the next boot and then reset the device. &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;boot_from_sd&amp;lt;/code&amp;gt;&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3852</id>
		<title>U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3852"/>
		<updated>2023-10-11T13:56:29Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide details the process of flashing U-Boot onto our i.MX6 based DHCOM using OpenOCD.&lt;br /&gt;
The hardware configuration, software installation, and step-by-step programming procedures are provided.&lt;br /&gt;
&lt;br /&gt;
== Required Hardware ==&lt;br /&gt;
* Baseboard as power source for DHCOM&lt;br /&gt;
* JTAG Debugger: [https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/ Olimex Arm-USB-OCD-Tiny-H]&lt;br /&gt;
:All tests and documents were made with this one, but technically all JTAG adapters listed by OpenOCD should work.&lt;br /&gt;
* DHCOM JTAG adapter for FFC connection: Article number FD00037&lt;br /&gt;
:[[File:JTAG-Adapter.jpeg|300px]]&lt;br /&gt;
* Wuerth FFC cable: [https://www.we-online.com/de/components/products/FFC_0_50_TYPE_1_6876XXXXX002 687610050002]&lt;br /&gt;
:Note: One cable is included with the DHCOM JTAG adapter.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;To support all our i.MX6 based DHCOM, it is necessary to have OpenOCD v0.11.0 or higher.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from master branch (before Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install needed libraries and tools &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install git build-essential pkg-config autoconf automake libtool libusb-dev libusb-1.0-0-dev libhidapi-dev libftdi-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
# Clone git repository to local directory and checkout v0.12.0 tag &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;git clone -b v0.12.0 https://repo.or.cz/openocd.git&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
# Prepare source directory and submodules (when building from the git repository) &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./bootstrap&amp;lt;/code&amp;gt;&lt;br /&gt;
# Generate the Makefiles to build OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt;&lt;br /&gt;
# Build OpenOCD from source &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;make -j4&amp;lt;/code&amp;gt;&lt;br /&gt;
# Install OpenOCD to /usr/local &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
# (optional) Remove openocd source directory &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd .. &amp;amp;&amp;amp; rm -rf openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from Debian repositories (since Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install OpenOCD from Debian repositories &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Non root access to tty devices ===&lt;br /&gt;
# Add your user to the dialout group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G dialout ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add your user to the plugdev group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G plugdev ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Logout and login to apply new group rights&lt;br /&gt;
&lt;br /&gt;
== U-Boot Programming ==&lt;br /&gt;
There are two ways for doing this.&lt;br /&gt;
The easy way is an automatic shell script, which handles all the commands needed for the programming process.&lt;br /&gt;
The other one is to type in the required commands.&lt;br /&gt;
In a few cases the shell script fails then you need to go the other way and program the U-Boot manually.&lt;br /&gt;
The steps [[#Preparation|Preparation]] and [[#Start up OpenOCD|Start up OpenOCD]] are required for both automatic and manual flash programming.&lt;br /&gt;
&lt;br /&gt;
=== Preparation ===&lt;br /&gt;
==== Get the needed recovery files ====&lt;br /&gt;
# Download and extract the needed files [[media:2023-08-28_imx6_U-Boot_recovery.tar.xz|| tar xJ&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd 2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
==== Connect JTAG adapter ====&lt;br /&gt;
# Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB&lt;br /&gt;
# Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don&#039;t have a JTAG adapter, please ask DH electronics)&lt;br /&gt;
#:[[File:JTAG-connection.jpeg|1000px]]]&lt;br /&gt;
# Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord&lt;br /&gt;
# Connect to the serial console (serial port) of the board like here [[COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console|Enter_Bootloader_Console]]&lt;br /&gt;
&lt;br /&gt;
=== Start up OpenOCD ===&lt;br /&gt;
# Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]]&lt;br /&gt;
# Power up the i.MX6 board and have a look at the serial output (serial port).&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;It is okay if a U-Boot is starting up, because the device will be reset later.&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;There must be no output of U-Boot, otherwise go to [[#Troubleshooting|Troubleshooting]].&lt;br /&gt;
# Open a new terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Start OpenOCD depending on your hardware&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f imx6ull.cfg -f target/imx6ul.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The output should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Open On-Chip Debugger 0.12.0&lt;br /&gt;
Licensed under GNU GPL v2&lt;br /&gt;
For bug reports, read&lt;br /&gt;
        http://openocd.org/doc/doxygen/bugs.html&lt;br /&gt;
Info : auto-selecting first available session transport &amp;quot;jtag&amp;quot;. To override use &#039;transport select &amp;lt;transport&amp;gt;&#039;.&lt;br /&gt;
Warn : imx6.sdma: nonstandard IR value&lt;br /&gt;
boot_from_sd&lt;br /&gt;
Info : Listening on port 6666 for tcl connections&lt;br /&gt;
Info : Listening on port 4444 for telnet connections&lt;br /&gt;
Info : clock speed 1000 kHz&lt;br /&gt;
Info : JTAG tap: imx6.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x4)&lt;br /&gt;
Info : TAP imx6.sdma does not have valid IDCODE (idcode=0x4323803a)&lt;br /&gt;
Info : JTAG tap: imx6.sjc tap/device found: 0x2191c01d (mfg: 0x00e (Freescale (Motorola)), part: 0x191c, ver: 0x2)&lt;br /&gt;
Info : imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
Info : starting gdb server for imx6.cpu.0 on 3333&lt;br /&gt;
Info : Listening on port 3333 for gdb connections&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Automated Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Execute the automated bash script with arguments depending on your hardware and desired U-Boot&lt;br /&gt;
#:* Default DH U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* Custom U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of the script should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Programming: u-boot-with-spl-imx6qdl.imx to imx6qdl&lt;br /&gt;
Trying ::1...&lt;br /&gt;
Connection failed: Connection refused&lt;br /&gt;
Trying 127.0.0.1...&lt;br /&gt;
Connected to localhost.&lt;br /&gt;
Escape character is &#039;^]&#039;.&lt;br /&gt;
Open On-Chip Debugger&lt;br /&gt;
&amp;gt; boot_from_sd&lt;br /&gt;
imx6.cpu.0: MPIDR level2 0, cluster 0, core 0, multi core, no SMT&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0xa00001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: enabled, D-Cache: enabled, I-Cache: enabled&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for cortex_a_exec_opcode&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for dpm prepare&lt;br /&gt;
&lt;br /&gt;
Invalid ACK (7) in DAP response&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
Debug regions are unpowered, an unexpected reset might have happened&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not initialize the APB-AP&lt;br /&gt;
Examination failed, GDB will be halted. Polling again in 100ms&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
&amp;gt; prepare_code_load&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: disabled&lt;br /&gt;
&amp;gt; load_image u-boot-spl-prog-imx6qdl.bin 0x908000&lt;br /&gt;
32768 bytes written at address 0x00908000&lt;br /&gt;
downloaded 32768 bytes in 1.152152s (27.774 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; halt&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x0090ba5e&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-with-spl-imx6qdl.imx 0x12000000&lt;br /&gt;
567752 bytes written at address 0x12000000&lt;br /&gt;
downloaded 567752 bytes in 18.675529s (29.688 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; Connection closed by foreign host.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of serial console (serial port) should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
U-Boot SPL 2018.05-23076-g8686cf2574 (Mar 10 2020 - 10:26:00 +0100)&lt;br /&gt;
SPL: Unsupported Boot Device!&lt;br /&gt;
SPL: failed to boot from all boot devices&lt;br /&gt;
### ERROR ### Please RESET the board ###&lt;br /&gt;
Searching for IVT header at DDR address 0x12000000&lt;br /&gt;
....&lt;br /&gt;
Found IVT header&lt;br /&gt;
Determinded image length: 0x8a9c8&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Trying to program SPI flash ###&lt;br /&gt;
Probing SPI flash... ok&lt;br /&gt;
Erasing SPI flash... ok&lt;br /&gt;
Programming SPI flash... ok&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Finished ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If some error occures you can try the [[#Manual Programming|Manual Programming]] method below&lt;br /&gt;
&lt;br /&gt;
=== Manual Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
## Ensure device boot fails by booting from invalid media&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;boot_from_sd&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;Follow [[#Troubleshooting|Troubleshooting]] to ensure no U-Boot starts.&lt;br /&gt;
## Prepare for running manual loaded code&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;prepare_code_load&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load modified U-Boot SPL as flash programmer in SRAM (device dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6qdl.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6ull.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution at entry point of loaded U-Boot SPL &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume 0x00908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Halt code execution if you see &#039;&#039;&#039;Searching for IVT header at DDR address 0xX2000000&#039;&#039;&#039; in serial console &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;halt&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load desired U-Boot image into RAM (device and customer dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6qdl.imx 0x12000000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6ull.imx 0x82000000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution after U-Boot image is in RAM&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume&amp;lt;/code&amp;gt;&lt;br /&gt;
## Wait until the serial output (serial port) looks like in [[#Automated Programming|Automated Programming]]&lt;br /&gt;
## Exit telnet with &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; and close OpenOCD with STRG+C&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the OpenOCD procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 ULL) ===&lt;br /&gt;
# Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for sdp boot mode on the SODIMM-200 module (DHCOM) next to the BGA module (DHCOR)&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for sdp boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 Q/D/DL/S) ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
# Use the following command to trigger a boot from an invalid source by setting the boot source to an invalid media for the next boot and then reset the device. &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;boot_from_sd&amp;lt;/code&amp;gt;&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3851</id>
		<title>U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3851"/>
		<updated>2023-10-11T13:54:27Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide details the process of flashing U-Boot onto our i.MX6 based DHCOM using OpenOCD.&lt;br /&gt;
The hardware configuration, software installation, and step-by-step programming procedures are provided.&lt;br /&gt;
&lt;br /&gt;
== Required Hardware ==&lt;br /&gt;
* Baseboard as power source for DHCOM&lt;br /&gt;
* JTAG Debugger: [https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/ Olimex Arm-USB-OCD-Tiny-H]&lt;br /&gt;
:All tests and documents were made with this one, but technically all JTAG adapters listed by OpenOCD should work.&lt;br /&gt;
* DHCOM JTAG adapter for FFC connection: Article number FD00037&lt;br /&gt;
:[[File:JTAG-Adapter.jpeg|300px]]&lt;br /&gt;
* Wuerth FFC cable: [https://www.we-online.com/de/components/products/FFC_0_50_TYPE_1_6876XXXXX002 687610050002]&lt;br /&gt;
:Note: One cable is included with the DHCOM JTAG adapter.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;To support all our i.MX6 based DHCOM, it is necessary to have OpenOCD v0.11.0 or higher.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from master branch (before Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install needed libraries and tools &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install git build-essential pkg-config autoconf automake libtool libusb-dev libusb-1.0-0-dev libhidapi-dev libftdi-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
# Clone git repository to local directory and checkout v0.12.0 tag &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;git clone -b v0.12.0 https://repo.or.cz/openocd.git&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
# Prepare source directory and submodules (when building from the git repository) &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./bootstrap&amp;lt;/code&amp;gt;&lt;br /&gt;
# Generate the Makefiles to build OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt;&lt;br /&gt;
# Build OpenOCD from source &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;make -j4&amp;lt;/code&amp;gt;&lt;br /&gt;
# Install OpenOCD to /usr/local &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
# (optional) Remove openocd source directory &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd .. &amp;amp;&amp;amp; rm -rf openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from Debian repositories (since Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install OpenOCD from Debian repositories &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Non root access to tty devices ===&lt;br /&gt;
# Add your user to the dialout group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G dialout ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add your user to the plugdev group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G plugdev ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Logout and login to apply new group rights&lt;br /&gt;
&lt;br /&gt;
== U-Boot Programming ==&lt;br /&gt;
There are two ways for doing this.&lt;br /&gt;
The easy way is an automatic shell script, which handles all the commands needed for the programming process.&lt;br /&gt;
The other one is to type in the required commands.&lt;br /&gt;
In a few cases the shell script fails then you need to go the other way and program the U-Boot manually.&lt;br /&gt;
The steps [[#Preparation|Preparation]] and [[#Start up OpenOCD|Start up OpenOCD]] are required for both automatic and manual flash programming.&lt;br /&gt;
&lt;br /&gt;
=== Preparation ===&lt;br /&gt;
==== Get the needed recovery files ====&lt;br /&gt;
# Download and extract the needed files [[media:2023-08-28_imx6_U-Boot_recovery.tar.xz|| tar xJ&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd 2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
==== Connect JTAG adapter ====&lt;br /&gt;
# Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB&lt;br /&gt;
# Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don&#039;t have a JTAG adapter, please ask DH electronics)&lt;br /&gt;
#:[[File:JTAG-connection.jpeg|1000px]]]&lt;br /&gt;
# Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord&lt;br /&gt;
# Connect to the serial console (serial port) of the board like here [[COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console|Enter_Bootloader_Console]]&lt;br /&gt;
&lt;br /&gt;
=== Start up OpenOCD ===&lt;br /&gt;
# Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]]&lt;br /&gt;
# Power up the i.MX6 board and have a look at the serial output (serial port).&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;It is okay if a U-Boot is starting up, because the device will be reset later.&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;There must be no output of U-Boot, otherwise go to [[#Troubleshooting|Troubleshooting]].&lt;br /&gt;
# Open a new terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Start OpenOCD depending on your hardware&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f imx6ull.cfg -f target/imx6ul.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The output should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Open On-Chip Debugger 0.12.0&lt;br /&gt;
Licensed under GNU GPL v2&lt;br /&gt;
For bug reports, read&lt;br /&gt;
        http://openocd.org/doc/doxygen/bugs.html&lt;br /&gt;
Info : auto-selecting first available session transport &amp;quot;jtag&amp;quot;. To override use &#039;transport select &amp;lt;transport&amp;gt;&#039;.&lt;br /&gt;
Warn : imx6.sdma: nonstandard IR value&lt;br /&gt;
boot_from_sd&lt;br /&gt;
Info : Listening on port 6666 for tcl connections&lt;br /&gt;
Info : Listening on port 4444 for telnet connections&lt;br /&gt;
Info : clock speed 1000 kHz&lt;br /&gt;
Info : JTAG tap: imx6.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x4)&lt;br /&gt;
Info : TAP imx6.sdma does not have valid IDCODE (idcode=0x4323803a)&lt;br /&gt;
Info : JTAG tap: imx6.sjc tap/device found: 0x2191c01d (mfg: 0x00e (Freescale (Motorola)), part: 0x191c, ver: 0x2)&lt;br /&gt;
Info : imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
Info : starting gdb server for imx6.cpu.0 on 3333&lt;br /&gt;
Info : Listening on port 3333 for gdb connections&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Automated Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Execute the automated bash script with arguments depending on your hardware and desired U-Boot&lt;br /&gt;
#:* Default DH U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* Custom U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of the script should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Programming: u-boot-with-spl-imx6qdl.imx to imx6qdl&lt;br /&gt;
Trying ::1...&lt;br /&gt;
Connection failed: Connection refused&lt;br /&gt;
Trying 127.0.0.1...&lt;br /&gt;
Connected to localhost.&lt;br /&gt;
Escape character is &#039;^]&#039;.&lt;br /&gt;
Open On-Chip Debugger&lt;br /&gt;
&amp;gt; boot_from_sd&lt;br /&gt;
imx6.cpu.0: MPIDR level2 0, cluster 0, core 0, multi core, no SMT&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0xa00001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: enabled, D-Cache: enabled, I-Cache: enabled&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for cortex_a_exec_opcode&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for dpm prepare&lt;br /&gt;
&lt;br /&gt;
Invalid ACK (7) in DAP response&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
Debug regions are unpowered, an unexpected reset might have happened&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not initialize the APB-AP&lt;br /&gt;
Examination failed, GDB will be halted. Polling again in 100ms&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
&amp;gt; prepare_code_load&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: disabled&lt;br /&gt;
&amp;gt; load_image u-boot-spl-prog-imx6qdl.bin 0x908000&lt;br /&gt;
32768 bytes written at address 0x00908000&lt;br /&gt;
downloaded 32768 bytes in 1.152152s (27.774 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; halt&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x0090ba5e&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-with-spl-imx6qdl.imx 0x12000000&lt;br /&gt;
567752 bytes written at address 0x12000000&lt;br /&gt;
downloaded 567752 bytes in 18.675529s (29.688 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; Connection closed by foreign host.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of serial console (serial port) should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
U-Boot SPL 2018.05-23076-g8686cf2574 (Mar 10 2020 - 10:26:00 +0100)&lt;br /&gt;
SPL: Unsupported Boot Device!&lt;br /&gt;
SPL: failed to boot from all boot devices&lt;br /&gt;
### ERROR ### Please RESET the board ###&lt;br /&gt;
Searching for IVT header at DDR address 0x12000000&lt;br /&gt;
....&lt;br /&gt;
Found IVT header&lt;br /&gt;
Determinded image length: 0x8a9c8&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Trying to program SPI flash ###&lt;br /&gt;
Probing SPI flash... ok&lt;br /&gt;
Erasing SPI flash... ok&lt;br /&gt;
Programming SPI flash... ok&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Finished ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If some error occures you can try the [[#Manual Programming|Manual Programming]] method below&lt;br /&gt;
&lt;br /&gt;
=== Manual Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
## Ensure device boot fails by booting from invalid media&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;boot_from_sd&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;Follow [[#Troubleshooting|Troubleshooting]] to ensure no U-Boot starts.&lt;br /&gt;
## Prepare for running manual loaded code&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;prepare_code_load&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load modified U-Boot SPL as flash programmer in SRAM (device dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6qdl.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6ull.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution at entry point of loaded U-Boot SPL &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume 0x00908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Halt code execution if you see &#039;&#039;&#039;Searching for IVT header at DDR address 0xX2000000&#039;&#039;&#039; in serial console &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;halt&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load desired U-Boot image into RAM (device and customer dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6qdl.imx 0x12000000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6ull.imx 0x82000000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution after U-Boot image is in RAM&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume&amp;lt;/code&amp;gt;&lt;br /&gt;
## Wait until the serial output (serial port) looks like in [[#Automated Programming|Automated Programming]]&lt;br /&gt;
## Exit telnet with &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; and close OpenOCD with STRG+C&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the OpenOCD procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 ULL) ===&lt;br /&gt;
# Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for sdp boot mode on the SODIMM-200 module (DHCOM) next to the BGA module (DHCOR)&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for sdp boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 Q/D/DL/S) ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
# Use the following command to trigger a boot from an invalid source by overwriting the boot source to an invalid media for the next boot and then reset the device. &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;boot_from_sd&amp;lt;/code&amp;gt;&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3850</id>
		<title>U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3850"/>
		<updated>2023-10-11T13:42:15Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide details the process of flashing U-Boot onto our i.MX6 based DHCOM using OpenOCD.&lt;br /&gt;
The hardware configuration, software installation, and step-by-step programming procedures are provided.&lt;br /&gt;
&lt;br /&gt;
== Required Hardware ==&lt;br /&gt;
* Baseboard as power source for DHCOM&lt;br /&gt;
* JTAG Debugger: [https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/ Olimex Arm-USB-OCD-Tiny-H]&lt;br /&gt;
:All tests and documents were made with this one, but technically all JTAG adapters listed by OpenOCD should work.&lt;br /&gt;
* DHCOM JTAG adapter for FFC connection: Article number FD00037&lt;br /&gt;
:[[File:JTAG-Adapter.jpeg|300px]]&lt;br /&gt;
* Wuerth FFC cable: [https://www.we-online.com/de/components/products/FFC_0_50_TYPE_1_6876XXXXX002 687610050002]&lt;br /&gt;
:Note: One cable is included with the DHCOM JTAG adapter.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;To support all our i.MX6 based DHCOM, it is necessary to have OpenOCD v0.11.0 or higher.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from master branch (before Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install needed libraries and tools &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install git build-essential pkg-config autoconf automake libtool libusb-dev libusb-1.0-0-dev libhidapi-dev libftdi-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
# Clone git repository to local directory and checkout v0.12.0 tag &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;git clone -b v0.12.0 https://repo.or.cz/openocd.git&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
# Prepare source directory and submodules (when building from the git repository) &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./bootstrap&amp;lt;/code&amp;gt;&lt;br /&gt;
# Generate the Makefiles to build OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt;&lt;br /&gt;
# Build OpenOCD from source &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;make -j4&amp;lt;/code&amp;gt;&lt;br /&gt;
# Install OpenOCD to /usr/local &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
# (optional) Remove openocd source directory &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd .. &amp;amp;&amp;amp; rm -rf openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from Debian repositories (since Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install OpenOCD from Debian repositories &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Non root access to tty devices ===&lt;br /&gt;
# Add your user to the dialout group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G dialout ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add your user to the plugdev group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G plugdev ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Logout and login to apply new group rights&lt;br /&gt;
&lt;br /&gt;
== U-Boot Programming ==&lt;br /&gt;
There are two ways for doing this.&lt;br /&gt;
The easy way is an automatic shell script, which handles all the commands needed for the programming process.&lt;br /&gt;
The other one is to type in the required commands.&lt;br /&gt;
In a few cases the shell script fails then you need to go the other way and program the U-Boot manually.&lt;br /&gt;
The steps [[#Preparation|Preparation]] and [[#Start up OpenOCD|Start up OpenOCD]] are required for both automatic and manual flash programming.&lt;br /&gt;
&lt;br /&gt;
=== Preparation ===&lt;br /&gt;
==== Get the needed recovery files ====&lt;br /&gt;
# Download and extract the needed files [[media:2023-08-28_imx6_U-Boot_recovery.tar.xz|| tar xJ&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd 2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
==== Connect JTAG adapter ====&lt;br /&gt;
# Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB&lt;br /&gt;
# Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don&#039;t have a JTAG adapter, please ask DH electronics)&lt;br /&gt;
#:[[File:JTAG-connection.jpeg|1000px]]]&lt;br /&gt;
# Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord&lt;br /&gt;
# Connect to the serial console (serial port) of the board like here [[COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console|Enter_Bootloader_Console]]&lt;br /&gt;
&lt;br /&gt;
=== Start up OpenOCD ===&lt;br /&gt;
# Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]]&lt;br /&gt;
# Power up the i.MX6 board and have a look at the serial output (serial port).&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;It is okay if a U-Boot is starting up, because the device will be reset later.&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;There must be no output of U-Boot, otherwise go to [[#Troubleshooting|Troubleshooting]].&lt;br /&gt;
# Open a new terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Start OpenOCD depending on your hardware&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f imx6ull.cfg -f target/imx6ul.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The output should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Open On-Chip Debugger 0.12.0&lt;br /&gt;
Licensed under GNU GPL v2&lt;br /&gt;
For bug reports, read&lt;br /&gt;
        http://openocd.org/doc/doxygen/bugs.html&lt;br /&gt;
Info : auto-selecting first available session transport &amp;quot;jtag&amp;quot;. To override use &#039;transport select &amp;lt;transport&amp;gt;&#039;.&lt;br /&gt;
Warn : imx6.sdma: nonstandard IR value&lt;br /&gt;
boot_from_sd&lt;br /&gt;
Info : Listening on port 6666 for tcl connections&lt;br /&gt;
Info : Listening on port 4444 for telnet connections&lt;br /&gt;
Info : clock speed 1000 kHz&lt;br /&gt;
Info : JTAG tap: imx6.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x4)&lt;br /&gt;
Info : TAP imx6.sdma does not have valid IDCODE (idcode=0x4323803a)&lt;br /&gt;
Info : JTAG tap: imx6.sjc tap/device found: 0x2191c01d (mfg: 0x00e (Freescale (Motorola)), part: 0x191c, ver: 0x2)&lt;br /&gt;
Info : imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
Info : starting gdb server for imx6.cpu.0 on 3333&lt;br /&gt;
Info : Listening on port 3333 for gdb connections&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Automated Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Execute the automated bash script with arguments depending on your hardware and desired U-Boot&lt;br /&gt;
#:* Default DH U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* Custom U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of the script should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Programming: u-boot-with-spl-imx6qdl.imx to imx6qdl&lt;br /&gt;
Trying ::1...&lt;br /&gt;
Connection failed: Connection refused&lt;br /&gt;
Trying 127.0.0.1...&lt;br /&gt;
Connected to localhost.&lt;br /&gt;
Escape character is &#039;^]&#039;.&lt;br /&gt;
Open On-Chip Debugger&lt;br /&gt;
&amp;gt; boot_from_sd&lt;br /&gt;
imx6.cpu.0: MPIDR level2 0, cluster 0, core 0, multi core, no SMT&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0xa00001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: enabled, D-Cache: enabled, I-Cache: enabled&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for cortex_a_exec_opcode&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for dpm prepare&lt;br /&gt;
&lt;br /&gt;
Invalid ACK (7) in DAP response&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
Debug regions are unpowered, an unexpected reset might have happened&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not initialize the APB-AP&lt;br /&gt;
Examination failed, GDB will be halted. Polling again in 100ms&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
&amp;gt; prepare_code_load&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: disabled&lt;br /&gt;
&amp;gt; load_image u-boot-spl-prog-imx6qdl.bin 0x908000&lt;br /&gt;
32768 bytes written at address 0x00908000&lt;br /&gt;
downloaded 32768 bytes in 1.152152s (27.774 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; halt&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x0090ba5e&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-with-spl-imx6qdl.imx 0x12000000&lt;br /&gt;
567752 bytes written at address 0x12000000&lt;br /&gt;
downloaded 567752 bytes in 18.675529s (29.688 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; Connection closed by foreign host.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of serial console (serial port) should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
U-Boot SPL 2018.05-23076-g8686cf2574 (Mar 10 2020 - 10:26:00 +0100)&lt;br /&gt;
SPL: Unsupported Boot Device!&lt;br /&gt;
SPL: failed to boot from all boot devices&lt;br /&gt;
### ERROR ### Please RESET the board ###&lt;br /&gt;
Searching for IVT header at DDR address 0x12000000&lt;br /&gt;
....&lt;br /&gt;
Found IVT header&lt;br /&gt;
Determinded image length: 0x8a9c8&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Trying to program SPI flash ###&lt;br /&gt;
Probing SPI flash... ok&lt;br /&gt;
Erasing SPI flash... ok&lt;br /&gt;
Programming SPI flash... ok&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Finished ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If some error occures you can try the [[#Manual Programming|Manual Programming]] method below&lt;br /&gt;
&lt;br /&gt;
=== Manual Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
## Ensure device boot fails by booting from invalid media&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;boot_from_sd&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;Follow [[#Troubleshooting|Troubleshooting]] to ensure no U-Boot starts.&lt;br /&gt;
## Prepare for running manual loaded code&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;prepare_code_load&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load modified U-Boot SPL as flash programmer in SRAM (device dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6qdl.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6ull.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution at entry point of loaded U-Boot SPL &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume 0x00908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Halt code execution if you see &#039;&#039;&#039;Searching for IVT header at DDR address 0xX2000000&#039;&#039;&#039; in serial console &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;halt&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load desired U-Boot image into RAM (device and customer dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6qdl.imx 0x12000000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6ull.imx 0x82000000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution after U-Boot image is in RAM&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume&amp;lt;/code&amp;gt;&lt;br /&gt;
## Wait until the serial output (serial port) looks like in [[#Automated Programming|Automated Programming]]&lt;br /&gt;
## Exit telnet with &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; and close OpenOCD with STRG+C&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the OpenOCD procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 ULL) ===&lt;br /&gt;
# Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for sdp boot mode on the SODIMM-200 module (DHCOM) next to the BGA module (DHCOR)&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for sdp boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3833</id>
		<title>U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG_v2&amp;diff=3833"/>
		<updated>2023-08-28T12:56:06Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Initial v2 with untested i.MX6ULL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide details the process of flashing U-Boot onto our i.MX6 based DHCOM using OpenOCD.&lt;br /&gt;
The hardware configuration, software installation, and step-by-step programming procedures are provided.&lt;br /&gt;
&lt;br /&gt;
== Required Hardware ==&lt;br /&gt;
* Baseboard as power source for DHCOM&lt;br /&gt;
* JTAG Debugger: [https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/ Olimex Arm-USB-OCD-Tiny-H]&lt;br /&gt;
:All tests and documents were made with this one, but technically all JTAG adapters listed by OpenOCD should work.&lt;br /&gt;
* DHCOM JTAG adapter for FFC connection: Article number FD00037&lt;br /&gt;
:[[File:JTAG-Adapter.jpeg|300px]]&lt;br /&gt;
* Wuerth FFC cable: [https://www.we-online.com/de/components/products/FFC_0_50_TYPE_1_6876XXXXX002 687610050002]&lt;br /&gt;
:Note: One cable is included with the DHCOM JTAG adapter.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;To support all our i.MX6 based DHCOM, it is necessary to have OpenOCD v0.11.0 or higher.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from master branch (before Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install needed libraries and tools &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install git build-essential pkg-config autoconf automake libtool libusb-dev libusb-1.0-0-dev libhidapi-dev libftdi-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
# Clone git repository to local directory and checkout v0.12.0 tag &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;git clone -b v0.12.0 https://repo.or.cz/openocd.git&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
# Prepare source directory and submodules (when building from the git repository) &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./bootstrap&amp;lt;/code&amp;gt;&lt;br /&gt;
# Generate the Makefiles to build OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt;&lt;br /&gt;
# Build OpenOCD from source &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;make -j4&amp;lt;/code&amp;gt;&lt;br /&gt;
# Install OpenOCD to /usr/local &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
# (optional) Remove openocd source directory &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd .. &amp;amp;&amp;amp; rm -rf openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from Debian repositories (since Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install OpenOCD from Debian repositories &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Non root access to tty devices ===&lt;br /&gt;
# Add your user to the dialout group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G dialout ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add your user to the plugdev group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G plugdev ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Logout and login to apply new group rights&lt;br /&gt;
&lt;br /&gt;
== U-Boot Programming ==&lt;br /&gt;
There are two ways for doing this.&lt;br /&gt;
The easy way is an automatic shell script, which handles all the commands needed for the programming process.&lt;br /&gt;
The other one is to type in the required commands.&lt;br /&gt;
In a few cases the shell script fails then you need to go the other way and program the U-Boot manually.&lt;br /&gt;
The steps [[#Preparation|Preparation]] and [[#Start up OpenOCD|Start up OpenOCD]] are required for both automatic and manual flash programming.&lt;br /&gt;
&lt;br /&gt;
=== Preparation ===&lt;br /&gt;
==== Get the needed recovery files ====&lt;br /&gt;
# Download and extract the needed files [[media:2023-08-28_imx6_U-Boot_recovery.tar.xz|| tar xJ&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd 2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
==== Connect JTAG adapter ====&lt;br /&gt;
# Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB&lt;br /&gt;
# Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don&#039;t have a JTAG adapter, please ask DH electronics)&lt;br /&gt;
#:[[File:JTAG-connection.jpeg|1000px]]]&lt;br /&gt;
# Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord&lt;br /&gt;
# Connect to the serial console (serial port) of the board like here [[COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console|Enter_Bootloader_Console]]&lt;br /&gt;
&lt;br /&gt;
=== Start up OpenOCD ===&lt;br /&gt;
# Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]]&lt;br /&gt;
# Power up the i.MX6 board and have a look at the serial output (serial port). There must be no output (no U-Boot starting) else go to [[#Troubleshooting|Troubleshooting]]&lt;br /&gt;
# Open a new terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2020-03-10_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Start OpenOCD depending on your hardware&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f imx6ull.cfg -f target/imx6ul.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The output should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Open On-Chip Debugger 0.12.0&lt;br /&gt;
Licensed under GNU GPL v2&lt;br /&gt;
For bug reports, read&lt;br /&gt;
        http://openocd.org/doc/doxygen/bugs.html&lt;br /&gt;
Info : auto-selecting first available session transport &amp;quot;jtag&amp;quot;. To override use &#039;transport select &amp;lt;transport&amp;gt;&#039;.&lt;br /&gt;
Warn : imx6.sdma: nonstandard IR value&lt;br /&gt;
boot_from_sd&lt;br /&gt;
Info : Listening on port 6666 for tcl connections&lt;br /&gt;
Info : Listening on port 4444 for telnet connections&lt;br /&gt;
Info : clock speed 1000 kHz&lt;br /&gt;
Info : JTAG tap: imx6.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x4)&lt;br /&gt;
Info : TAP imx6.sdma does not have valid IDCODE (idcode=0x4323803a)&lt;br /&gt;
Info : JTAG tap: imx6.sjc tap/device found: 0x2191c01d (mfg: 0x00e (Freescale (Motorola)), part: 0x191c, ver: 0x2)&lt;br /&gt;
Info : imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
Info : starting gdb server for imx6.cpu.0 on 3333&lt;br /&gt;
Info : Listening on port 3333 for gdb connections&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Automated Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Execute the automated bash script with arguments depending on your hardware and desired U-Boot&lt;br /&gt;
#:* Default DH U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* Custom U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sh prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of the script should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Programming: u-boot-with-spl-imx6qdl.imx to imx6qdl&lt;br /&gt;
Trying ::1...&lt;br /&gt;
Connection failed: Connection refused&lt;br /&gt;
Trying 127.0.0.1...&lt;br /&gt;
Connected to localhost.&lt;br /&gt;
Escape character is &#039;^]&#039;.&lt;br /&gt;
Open On-Chip Debugger&lt;br /&gt;
&amp;gt; boot_from_sd&lt;br /&gt;
imx6.cpu.0: MPIDR level2 0, cluster 0, core 0, multi core, no SMT&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0xa00001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: enabled, D-Cache: enabled, I-Cache: enabled&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for cortex_a_exec_opcode&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Invalid ACK (0) in DAP response&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not read DSCR register&lt;br /&gt;
Error waiting for dpm prepare&lt;br /&gt;
&lt;br /&gt;
Invalid ACK (7) in DAP response&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
Debug regions are unpowered, an unexpected reset might have happened&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Could not initialize the APB-AP&lt;br /&gt;
Examination failed, GDB will be halted. Polling again in 100ms&lt;br /&gt;
JTAG-DP STICKY ERROR&lt;br /&gt;
Polling target imx6.cpu.0 failed, trying to reexamine&lt;br /&gt;
imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
&amp;gt; prepare_code_load&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x8ff7a982&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: disabled&lt;br /&gt;
&amp;gt; load_image u-boot-spl-prog-imx6qdl.bin 0x908000&lt;br /&gt;
32768 bytes written at address 0x00908000&lt;br /&gt;
downloaded 32768 bytes in 1.152152s (27.774 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; halt&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x0090ba5e&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-with-spl-imx6qdl.imx 0x12000000&lt;br /&gt;
567752 bytes written at address 0x12000000&lt;br /&gt;
downloaded 567752 bytes in 18.675529s (29.688 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; Connection closed by foreign host.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of serial console (serial port) should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
U-Boot SPL 2018.05-23076-g8686cf2574 (Mar 10 2020 - 10:26:00 +0100)&lt;br /&gt;
SPL: Unsupported Boot Device!&lt;br /&gt;
SPL: failed to boot from all boot devices&lt;br /&gt;
### ERROR ### Please RESET the board ###&lt;br /&gt;
Searching for IVT header at DDR address 0x12000000&lt;br /&gt;
....&lt;br /&gt;
Found IVT header&lt;br /&gt;
Determinded image length: 0x8a9c8&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Trying to program SPI flash ###&lt;br /&gt;
Probing SPI flash... ok&lt;br /&gt;
Erasing SPI flash... ok&lt;br /&gt;
Programming SPI flash... ok&lt;br /&gt;
&lt;br /&gt;
### Recovery ### Finished ###&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If some error occures you can try the [[#Manual Programming|Manual Programming]] method below&lt;br /&gt;
&lt;br /&gt;
=== Manual Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2023-08-28_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
## Ensure device boot fails by booting from invalid media&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;boot_from_sd&amp;lt;/code&amp;gt;&lt;br /&gt;
## Prepare for running manual loaded code&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;prepare_code_load&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load modified U-Boot SPL as flash programmer in SRAM (device dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6qdl.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6ull.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution at entry point of loaded U-Boot SPL &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume 0x00908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Halt code execution if you see &#039;&#039;&#039;Searching for IVT header at DDR address 0xX2000000&#039;&#039;&#039; in serial console &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;halt&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load desired U-Boot image into RAM (device and customer dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6qdl.imx 0x12000000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6ull.imx 0x82000000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution after U-Boot image is in RAM&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume&amp;lt;/code&amp;gt;&lt;br /&gt;
## Wait until the serial output (serial port) looks like in [[#Automated Programming|Automated Programming]]&lt;br /&gt;
## Exit telnet with &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; and close OpenOCD with STRG+C&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the OpenOCD procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 ULL) ===&lt;br /&gt;
# Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for sdp boot mode on the SODIMM-200 module (DHCOM) next to the BGA module (DHCOR)&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for sdp boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG&amp;diff=3832</id>
		<title>U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG&amp;diff=3832"/>
		<updated>2023-08-22T13:59:41Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Fix recovery file path&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide details the process of flashing U-Boot onto our i.MX6 based DHCOM using OpenOCD.&lt;br /&gt;
The hardware configuration, software installation, and step-by-step programming procedures are provided.&lt;br /&gt;
&lt;br /&gt;
== Required Hardware ==&lt;br /&gt;
* Baseboard as power source for DHCOM&lt;br /&gt;
* JTAG Debugger: [https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/ Olimex Arm-USB-OCD-Tiny-H]&lt;br /&gt;
:All tests and documents were made with this one, but technically all JTAG adapters listed by OpenOCD should work.&lt;br /&gt;
* DHCOM JTAG adapter for FFC connection: Article number FD00037&lt;br /&gt;
:[[File:JTAG-Adapter.jpeg|300px]]&lt;br /&gt;
* Wuerth FFC cable: [https://www.we-online.com/de/components/products/FFC_0_50_TYPE_1_6876XXXXX002 687610050002]&lt;br /&gt;
:Note: One cable is included with the DHCOM JTAG adapter.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;To support all our i.MX6 based DHCOM, it is necessary to have OpenOCD v0.11.0 or higher.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from master branch (before Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install needed libraries and tools &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install git build-essential pkg-config autoconf automake libtool libusb-dev libusb-1.0-0-dev libhidapi-dev libftdi-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
# Clone git repository to local directory and checkout v0.12.0 tag &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;git clone -b v0.12.0 https://repo.or.cz/openocd.git&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
# Prepare source directory and submodules (when building from the git repository) &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./bootstrap&amp;lt;/code&amp;gt;&lt;br /&gt;
# Generate the Makefiles to build OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt;&lt;br /&gt;
# Build OpenOCD from source &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;make -j4&amp;lt;/code&amp;gt;&lt;br /&gt;
# Install OpenOCD to /usr/local &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
# (optional) Remove openocd source directory &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd .. &amp;amp;&amp;amp; rm -rf openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from Debian repositories (since Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install OpenOCD from Debian repositories &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Non root access to tty devices ===&lt;br /&gt;
# Add your user to the dialout group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G dialout ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add your user to the plugdev group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G plugdev ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Logout and login to apply new group rights&lt;br /&gt;
&lt;br /&gt;
== U-Boot Programming ==&lt;br /&gt;
There are two ways for doing this.&lt;br /&gt;
The easy way is an automatic bash script, which handles all the commands needed for the programming process.&lt;br /&gt;
The other one is to type in the required commands.&lt;br /&gt;
In a few cases the bash script fails then you need to go the other way and program the U-Boot manually.&lt;br /&gt;
The steps [[#Preparation|Preparation]] and [[#Start up OpenOCD|Start up OpenOCD]] are required for both automatic and manual flash programming.&lt;br /&gt;
&lt;br /&gt;
=== Preparation ===&lt;br /&gt;
==== Get the needed recovery files ====&lt;br /&gt;
# Download and extract the needed files [[media:2020-03-10_imx6_U-Boot_recovery.tar.gz|| tar xz&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd 2020-03-10_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
==== Connect JTAG adapter ====&lt;br /&gt;
# Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB&lt;br /&gt;
# Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don&#039;t have a JTAG adapter, please ask DH electronics)&lt;br /&gt;
#:[[File:JTAG-connection.jpeg|1000px]]]&lt;br /&gt;
# Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord&lt;br /&gt;
# Connect to the serial console (serial port) of the board like here [[COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console|Enter_Bootloader_Console]]&lt;br /&gt;
&lt;br /&gt;
=== Start up OpenOCD ===&lt;br /&gt;
# Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]]&lt;br /&gt;
# Power up the i.MX6 board and have a look at the serial output (serial port). There must be no output (no U-Boot starting) else go to [[#Troubleshooting|Troubleshooting]]&lt;br /&gt;
# Open a new terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2020-03-10_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Start OpenOCD depending on your hardware&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f imx6ull.cfg -f target/imx6ul.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The output should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Open On-Chip Debugger 0.10.0+dev-00935-g31100927 (2019-10-01-12:14)&lt;br /&gt;
Licensed under GNU GPL v2&lt;br /&gt;
For bug reports, read&lt;br /&gt;
	http://openocd.org/doc/doxygen/bugs.html&lt;br /&gt;
0x088c101d&lt;br /&gt;
Info : auto-selecting first available session transport &amp;quot;jtag&amp;quot;. To override use &#039;transport select &amp;lt;transport&amp;gt;&#039;.&lt;br /&gt;
Warn : imx6ull.sdma: nonstandard IR value&lt;br /&gt;
2182283264&lt;br /&gt;
imx6_dummy_init&lt;br /&gt;
Info : Listening on port 6666 for tcl connections&lt;br /&gt;
Info : Listening on port 4444 for telnet connections&lt;br /&gt;
Info : clock speed 1000 kHz&lt;br /&gt;
Info : JTAG tap: imx6ull.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x5)&lt;br /&gt;
Info : TAP imx6ull.sdma does not have IDCODE&lt;br /&gt;
Info : JTAG tap: imx6ull.sjc tap/device found: 0x088c101d (mfg: 0x00e (Freescale (Motorola)), part: 0x88c1, ver: 0x0)&lt;br /&gt;
Info : imx6ull.cpu: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
Info : Listening on port 3333 for gdb connections&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Automated Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2019-10-08_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Execute the automated bash script with arguments depending on your hardware and desired U-Boot&lt;br /&gt;
#:* Default DH U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./prog_bl.sh imx6qdl&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./prog_bl.sh imx6ull&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* Custom U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of the script should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Programming: u-boot-with-spl-imx6ull.imx to imx6ull&lt;br /&gt;
Trying ::1...&lt;br /&gt;
Trying 127.0.0.1...&lt;br /&gt;
Connected to localhost.&lt;br /&gt;
Escape character is &#039;^]&#039;.&lt;br /&gt;
Open On-Chip Debugger&lt;br /&gt;
&amp;gt; reset&lt;br /&gt;
JTAG tap: imx6ull.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x5)&lt;br /&gt;
TAP imx6ull.sdma does not have IDCODE&lt;br /&gt;
JTAG tap: imx6ull.sjc tap/device found: 0x088c101d (mfg: 0x00e (Freescale (Motorola)), part: 0x88c1, ver: 0x0)&lt;br /&gt;
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41&lt;br /&gt;
imx6ull.cpu: MPIDR level2 0, cluster 0, core 0, multi core, no SMT&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x400001f3 pc: 0x00002f76&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x400001f3 pc: 0x00002f74&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-spl-prog-imx6ull.bin 0x908000&lt;br /&gt;
45056 bytes written at address 0x00908000&lt;br /&gt;
downloaded 45056 bytes in 1.610037s (27.329 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume 0x00908000&lt;br /&gt;
&amp;gt; halt&lt;br /&gt;
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x00908934&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-with-spl-imx6ull.imx 0x82000000&lt;br /&gt;
451456 bytes written at address 0x82000000&lt;br /&gt;
downloaded 451456 bytes in 15.305990s (28.804 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; Connection closed by foreign host.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of serial console (serial port) should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
U-Boot SPL 2018.05-DH_v0.19_emmc-00102-gc8e3c3df13 (Oct 01 2019 - 16:12:44 +0200)&lt;br /&gt;
DRAM: Auto calibration...successful&lt;br /&gt;
SPL: Unsupported Boot Device!&lt;br /&gt;
SPL: failed to boot from all boot devices&lt;br /&gt;
### ERROR ### Please RESET the board ###&lt;br /&gt;
Searching for IVT header at DDR address 0x82000000&lt;br /&gt;
.....&lt;br /&gt;
Found IVT header&lt;br /&gt;
Probing SPI flash... ok&lt;br /&gt;
Erasing... ok&lt;br /&gt;
Programming... ok&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If some error occures you can try the [[#Manual Programming|Manual Programming]] method below&lt;br /&gt;
&lt;br /&gt;
=== Manual Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2019-10-08_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
## Reset and halt the device &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;reset&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load modified U-Boot SPL as flash programmer in SRAM (device dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6qdl.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6ull.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution at entry point of loaded U-Boot SPL &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume 0x00908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Halt code execution if you see &#039;&#039;&#039;Searching for IVT header at DDR address 0xX2000000&#039;&#039;&#039; in serial console &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;halt&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load desired U-Boot image into RAM (device and customer dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6qdl.imx 0x12000000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6ull.imx 0x82000000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution after U-Boot image is in RAM&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume&amp;lt;/code&amp;gt;&lt;br /&gt;
## Wait until the serial output (serial port) looks like in [[#Automated Programming|Automated Programming]]&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the OpenOCD procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 ULL) ===&lt;br /&gt;
# Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for sdp boot mode on the SODIMM-200 module (DHCOM) next to the BGA module (DHCOR)&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for sdp boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;br /&gt;
&lt;br /&gt;
=== Delete U-Boot ===&lt;br /&gt;
# &amp;lt;code&amp;gt;sf probe&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;sf erase 0x0 0xf0000&amp;lt;/code&amp;gt;&lt;br /&gt;
# Restart the board&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG&amp;diff=3831</id>
		<title>U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_i.MX6_Q/D/DL/S/ULL_via_JTAG&amp;diff=3831"/>
		<updated>2023-08-22T13:48:38Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Update descriptions and fix broken links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide details the process of flashing U-Boot onto our i.MX6 based DHCOM using OpenOCD.&lt;br /&gt;
The hardware configuration, software installation, and step-by-step programming procedures are provided.&lt;br /&gt;
&lt;br /&gt;
== Required Hardware ==&lt;br /&gt;
* Baseboard as power source for DHCOM&lt;br /&gt;
* JTAG Debugger: [https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/ Olimex Arm-USB-OCD-Tiny-H]&lt;br /&gt;
:All tests and documents were made with this one, but technically all JTAG adapters listed by OpenOCD should work.&lt;br /&gt;
* DHCOM JTAG adapter for FFC connection: Article number FD00037&lt;br /&gt;
:[[File:JTAG-Adapter.jpeg|300px]]&lt;br /&gt;
* Wuerth FFC cable: [https://www.we-online.com/de/components/products/FFC_0_50_TYPE_1_6876XXXXX002 687610050002]&lt;br /&gt;
:Note: One cable is included with the DHCOM JTAG adapter.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;To support all our i.MX6 based DHCOM, it is necessary to have OpenOCD v0.11.0 or higher.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from master branch (before Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install needed libraries and tools &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install git build-essential pkg-config autoconf automake libtool libusb-dev libusb-1.0-0-dev libhidapi-dev libftdi-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
# Clone git repository to local directory and checkout v0.12.0 tag &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;git clone -b v0.12.0 https://repo.or.cz/openocd.git&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
# Prepare source directory and submodules (when building from the git repository) &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./bootstrap&amp;lt;/code&amp;gt;&lt;br /&gt;
# Generate the Makefiles to build OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt;&lt;br /&gt;
# Build OpenOCD from source &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;make -j4&amp;lt;/code&amp;gt;&lt;br /&gt;
# Install OpenOCD to /usr/local &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo make install&amp;lt;/code&amp;gt;&lt;br /&gt;
# (optional) Remove openocd source directory &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd .. &amp;amp;&amp;amp; rm -rf openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== OpenOCD from Debian repositories (since Debian 11 alias Bullseye) ===&lt;br /&gt;
# Install OpenOCD from Debian repositories &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo apt-get install openocd&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Non root access to tty devices ===&lt;br /&gt;
# Add your user to the dialout group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G dialout ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add your user to the plugdev group: &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;sudo usermod -a -G plugdev ${USER}&amp;lt;/code&amp;gt;&lt;br /&gt;
# Logout and login to apply new group rights&lt;br /&gt;
&lt;br /&gt;
== U-Boot Programming ==&lt;br /&gt;
There are two ways for doing this.&lt;br /&gt;
The easy way is an automatic bash script, which handles all the commands needed for the programming process.&lt;br /&gt;
The other one is to type in the required commands.&lt;br /&gt;
In a few cases the bash script fails then you need to go the other way and program the U-Boot manually.&lt;br /&gt;
The steps [[#Preparation|Preparation]] and [[#Start up OpenOCD|Start up OpenOCD]] are required for both automatic and manual flash programming.&lt;br /&gt;
&lt;br /&gt;
=== Preparation ===&lt;br /&gt;
==== Get the needed recovery files ====&lt;br /&gt;
# Download and extract the needed files [[media:2020-03-10_imx6_U-Boot_recovery.tar.gz|| tar xz&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change working directory to the extracted one &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd 2020-03-10_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
==== Connect JTAG adapter ====&lt;br /&gt;
# Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB&lt;br /&gt;
# Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don&#039;t have a JTAG adapter, please ask DH electronics)&lt;br /&gt;
#:[[File:JTAG-connection.jpeg|1000px]]]&lt;br /&gt;
# Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord&lt;br /&gt;
# Connect to the serial console (serial port) of the board like here [[COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console|Enter_Bootloader_Console]]&lt;br /&gt;
&lt;br /&gt;
=== Start up OpenOCD ===&lt;br /&gt;
# Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]]&lt;br /&gt;
# Power up the i.MX6 board and have a look at the serial output (serial port). There must be no output (no U-Boot starting) else go to [[#Troubleshooting|Troubleshooting]]&lt;br /&gt;
# Open a new terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2019-10-08_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Start OpenOCD depending on your hardware&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f imx6ull.cfg -f target/imx6ul.cfg -f dhcom-manual-loaded-code.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The output should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Open On-Chip Debugger 0.10.0+dev-00935-g31100927 (2019-10-01-12:14)&lt;br /&gt;
Licensed under GNU GPL v2&lt;br /&gt;
For bug reports, read&lt;br /&gt;
	http://openocd.org/doc/doxygen/bugs.html&lt;br /&gt;
0x088c101d&lt;br /&gt;
Info : auto-selecting first available session transport &amp;quot;jtag&amp;quot;. To override use &#039;transport select &amp;lt;transport&amp;gt;&#039;.&lt;br /&gt;
Warn : imx6ull.sdma: nonstandard IR value&lt;br /&gt;
2182283264&lt;br /&gt;
imx6_dummy_init&lt;br /&gt;
Info : Listening on port 6666 for tcl connections&lt;br /&gt;
Info : Listening on port 4444 for telnet connections&lt;br /&gt;
Info : clock speed 1000 kHz&lt;br /&gt;
Info : JTAG tap: imx6ull.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x5)&lt;br /&gt;
Info : TAP imx6ull.sdma does not have IDCODE&lt;br /&gt;
Info : JTAG tap: imx6ull.sjc tap/device found: 0x088c101d (mfg: 0x00e (Freescale (Motorola)), part: 0x88c1, ver: 0x0)&lt;br /&gt;
Info : imx6ull.cpu: hardware has 6 breakpoints, 4 watchpoints&lt;br /&gt;
Info : Listening on port 3333 for gdb connections&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Automated Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2019-10-08_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Execute the automated bash script with arguments depending on your hardware and desired U-Boot&lt;br /&gt;
#:* Default DH U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./prog_bl.sh imx6qdl&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./prog_bl.sh imx6ull&amp;lt;/code&amp;gt;&lt;br /&gt;
#:* Custom U-Boot&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
#:** &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;./prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of the script should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Programming: u-boot-with-spl-imx6ull.imx to imx6ull&lt;br /&gt;
Trying ::1...&lt;br /&gt;
Trying 127.0.0.1...&lt;br /&gt;
Connected to localhost.&lt;br /&gt;
Escape character is &#039;^]&#039;.&lt;br /&gt;
Open On-Chip Debugger&lt;br /&gt;
&amp;gt; reset&lt;br /&gt;
JTAG tap: imx6ull.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x5)&lt;br /&gt;
TAP imx6ull.sdma does not have IDCODE&lt;br /&gt;
JTAG tap: imx6ull.sjc tap/device found: 0x088c101d (mfg: 0x00e (Freescale (Motorola)), part: 0x88c1, ver: 0x0)&lt;br /&gt;
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41&lt;br /&gt;
imx6ull.cpu: MPIDR level2 0, cluster 0, core 0, multi core, no SMT&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x400001f3 pc: 0x00002f76&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x400001f3 pc: 0x00002f74&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-spl-prog-imx6ull.bin 0x908000&lt;br /&gt;
45056 bytes written at address 0x00908000&lt;br /&gt;
downloaded 45056 bytes in 1.610037s (27.329 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume 0x00908000&lt;br /&gt;
&amp;gt; halt&lt;br /&gt;
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41&lt;br /&gt;
target halted in Thumb state due to debug-request, current mode: Supervisor&lt;br /&gt;
cpsr: 0x800001f3 pc: 0x00908934&lt;br /&gt;
MMU: disabled, D-Cache: disabled, I-Cache: enabled&lt;br /&gt;
&amp;gt; load_image u-boot-with-spl-imx6ull.imx 0x82000000&lt;br /&gt;
451456 bytes written at address 0x82000000&lt;br /&gt;
downloaded 451456 bytes in 15.305990s (28.804 KiB/s)&lt;br /&gt;
&lt;br /&gt;
&amp;gt; resume&lt;br /&gt;
&amp;gt; Connection closed by foreign host.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;On success the output of serial console (serial port) should look like:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
U-Boot SPL 2018.05-DH_v0.19_emmc-00102-gc8e3c3df13 (Oct 01 2019 - 16:12:44 +0200)&lt;br /&gt;
DRAM: Auto calibration...successful&lt;br /&gt;
SPL: Unsupported Boot Device!&lt;br /&gt;
SPL: failed to boot from all boot devices&lt;br /&gt;
### ERROR ### Please RESET the board ###&lt;br /&gt;
Searching for IVT header at DDR address 0x82000000&lt;br /&gt;
.....&lt;br /&gt;
Found IVT header&lt;br /&gt;
Probing SPI flash... ok&lt;br /&gt;
Erasing... ok&lt;br /&gt;
Programming... ok&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If some error occures you can try the [[#Manual Programming|Manual Programming]] method below&lt;br /&gt;
&lt;br /&gt;
=== Manual Programming ===&lt;br /&gt;
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]]&lt;br /&gt;
# Open a second terminal window (local shell console)&lt;br /&gt;
# Ensure you are in the directory with the recovery files &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;cd /path/to/2019-10-08_imx6_U-Boot_recovery&amp;lt;/code&amp;gt;&lt;br /&gt;
# Open a telnet session to OpenOCD &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;telnet localhost 4444&amp;lt;/code&amp;gt;&lt;br /&gt;
## Reset and halt the device &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;reset&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load modified U-Boot SPL as flash programmer in SRAM (device dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6qdl.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-spl-prog-imx6ull.bin 0x908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution at entry point of loaded U-Boot SPL &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume 0x00908000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Halt code execution if you see &#039;&#039;&#039;Searching for IVT header at DDR address 0xX2000000&#039;&#039;&#039; in serial console &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;halt&amp;lt;/code&amp;gt;&lt;br /&gt;
## Load desired U-Boot image into RAM (device and customer dependent)&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 Q/D/DL/S&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6qdl.imx 0x12000000&amp;lt;/code&amp;gt;&lt;br /&gt;
##:* &#039;&#039;&#039;i.MX6 ULL&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;load_image u-boot-with-spl-imx6ull.imx 0x82000000&amp;lt;/code&amp;gt;&lt;br /&gt;
## Resume code execution after U-Boot image is in RAM&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;resume&amp;lt;/code&amp;gt;&lt;br /&gt;
## Wait until the serial output (serial port) looks like in [[#Automated Programming|Automated Programming]]&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the OpenOCD procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SDP Boot (only i.MX6 ULL) ===&lt;br /&gt;
# Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for sdp boot mode on the SODIMM-200 module (DHCOM) next to the BGA module (DHCOR)&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for sdp boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;br /&gt;
&lt;br /&gt;
=== Delete U-Boot ===&lt;br /&gt;
# &amp;lt;code&amp;gt;sf probe&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;sf erase 0x0 0xf0000&amp;lt;/code&amp;gt;&lt;br /&gt;
# Restart the board&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the flashing procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;diff=3800</id>
		<title>Yocto build guide with docker</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;diff=3800"/>
		<updated>2022-11-24T14:54:46Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Update to /path/to/kas-dhsom #2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Page submit URL&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;amp;action=submit&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;!-- Info toclimit-3:&lt;br /&gt;
http://automaten-karl.de/blog/?p=74&lt;br /&gt;
https://www.mediawiki.org/wiki/Template:TOC&lt;br /&gt;
https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss&lt;br /&gt;
https://www.mediawiki.org/wiki/Manual:CSS&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
To build Yocto images you need a powerfull build machine and a lot of time.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
* CPU: four cores or more&lt;br /&gt;
* RAM: 16 GB or more&lt;br /&gt;
* HDD/SSD: from 25 GB to 100 GB free space (depends on included features)&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
* Linux OS&lt;br /&gt;
* Docker&lt;br /&gt;
&lt;br /&gt;
= Start your build environment =&lt;br /&gt;
&lt;br /&gt;
The following two examples show how to create yocto images using the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas&amp;lt;/syntaxhighlight&amp;gt; container or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas-container&amp;lt;/syntaxhighlight&amp;gt; script.&lt;br /&gt;
&lt;br /&gt;
In the following examples, we use the meta-dhsom-stm32-bsp layer as the top layer for creating images for the STM32MP15 DHSOM family with our baseboards.&lt;br /&gt;
If you have your own layer on top because you have a custom DHSOM baseboard, then you must replace meta-dhsom-stm32-bsp with your own layer in all commands.&lt;br /&gt;
&lt;br /&gt;
See the documentation for how to use the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas&amp;lt;/syntaxhighlight&amp;gt; tool:&lt;br /&gt;
* https://kas.readthedocs.io/en/latest/userguide.html&lt;br /&gt;
* https://kas.readthedocs.io/en/latest/command-line.html&lt;br /&gt;
&lt;br /&gt;
== Docker container based bash shell ==&lt;br /&gt;
&lt;br /&gt;
Preparation:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export KAS_WORK_DIR=/mnt/work/yocto&lt;br /&gt;
export KAS_BUILD_DIR=/mnt/build/yocto&lt;br /&gt;
&lt;br /&gt;
sudo mkdir -p &amp;quot;${KAS_WORK_DIR}&amp;quot; &amp;quot;${KAS_BUILD_DIR}&amp;quot;&lt;br /&gt;
sudo chown $(id –u):$(id –g) &amp;quot;${KAS_WORK_DIR}&amp;quot; &amp;quot;${KAS_BUILD_DIR}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cd /path/to/kas-dhsom&lt;br /&gt;
&lt;br /&gt;
docker run --rm --interactive --tty --init \&lt;br /&gt;
	--env TERM=&amp;quot;xterm-256color&amp;quot; \&lt;br /&gt;
	--env USER_ID=&amp;quot;$(id -u)&amp;quot; --env GROUP_ID=&amp;quot;$(id -g)&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${KAS_BUILD_DIR}&amp;quot;:&amp;quot;${KAS_BUILD_DIR}&amp;quot;:rw \&lt;br /&gt;
	--env KAS_BUILD_DIR=&amp;quot;${KAS_BUILD_DIR}&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${KAS_WORK_DIR}&amp;quot;:&amp;quot;${KAS_WORK_DIR}&amp;quot;:rw \&lt;br /&gt;
	--env KAS_WORK_DIR=&amp;quot;${KAS_WORK_DIR}&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${PWD}&amp;quot;:&amp;quot;${PWD}&amp;quot;:rw \&lt;br /&gt;
	--workdir=&amp;quot;${PWD}&amp;quot; \&lt;br /&gt;
	ghcr.io/siemens/kas/kas:latest-release \&lt;br /&gt;
	/bin/bash&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/kas-dhsom&lt;br /&gt;
kas menu&lt;br /&gt;
kas build&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Docker container based kas tool ==&lt;br /&gt;
&lt;br /&gt;
Preparation:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
wget -O kas-container https://github.com/siemens/kas/raw/master/kas-container&lt;br /&gt;
chmod +x kas-container&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/kas-dhsom&lt;br /&gt;
/path/to/kas-container menu&lt;br /&gt;
/path/to/kas-container build&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;diff=3799</id>
		<title>Yocto build guide with docker</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;diff=3799"/>
		<updated>2022-11-24T14:54:12Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Update to /path/to/kas-dhsom&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Page submit URL&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;amp;action=submit&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;!-- Info toclimit-3:&lt;br /&gt;
http://automaten-karl.de/blog/?p=74&lt;br /&gt;
https://www.mediawiki.org/wiki/Template:TOC&lt;br /&gt;
https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss&lt;br /&gt;
https://www.mediawiki.org/wiki/Manual:CSS&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
To build Yocto images you need a powerfull build machine and a lot of time.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
* CPU: four cores or more&lt;br /&gt;
* RAM: 16 GB or more&lt;br /&gt;
* HDD/SSD: from 25 GB to 100 GB free space (depends on included features)&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
* Linux OS&lt;br /&gt;
* Docker&lt;br /&gt;
&lt;br /&gt;
= Start your build environment =&lt;br /&gt;
&lt;br /&gt;
The following two examples show how to create yocto images using the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas&amp;lt;/syntaxhighlight&amp;gt; container or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas-container&amp;lt;/syntaxhighlight&amp;gt; script.&lt;br /&gt;
&lt;br /&gt;
In the following examples, we use the meta-dhsom-stm32-bsp layer as the top layer for creating images for the STM32MP15 DHSOM family with our baseboards.&lt;br /&gt;
If you have your own layer on top because you have a custom DHSOM baseboard, then you must replace meta-dhsom-stm32-bsp with your own layer in all commands.&lt;br /&gt;
&lt;br /&gt;
See the documentation for how to use the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas&amp;lt;/syntaxhighlight&amp;gt; tool:&lt;br /&gt;
* https://kas.readthedocs.io/en/latest/userguide.html&lt;br /&gt;
* https://kas.readthedocs.io/en/latest/command-line.html&lt;br /&gt;
&lt;br /&gt;
== Docker container based bash shell ==&lt;br /&gt;
&lt;br /&gt;
Preparation:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export KAS_WORK_DIR=/mnt/work/yocto&lt;br /&gt;
export KAS_BUILD_DIR=/mnt/build/yocto&lt;br /&gt;
&lt;br /&gt;
sudo mkdir -p &amp;quot;${KAS_WORK_DIR}&amp;quot; &amp;quot;${KAS_BUILD_DIR}&amp;quot;&lt;br /&gt;
sudo chown $(id –u):$(id –g) &amp;quot;${KAS_WORK_DIR}&amp;quot; &amp;quot;${KAS_BUILD_DIR}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cd /path/to/kas-dhsom&lt;br /&gt;
&lt;br /&gt;
docker run --rm --interactive --tty --init \&lt;br /&gt;
	--env TERM=&amp;quot;xterm-256color&amp;quot; \&lt;br /&gt;
	--env USER_ID=&amp;quot;$(id -u)&amp;quot; --env GROUP_ID=&amp;quot;$(id -g)&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${KAS_BUILD_DIR}&amp;quot;:&amp;quot;${KAS_BUILD_DIR}&amp;quot;:rw \&lt;br /&gt;
	--env KAS_BUILD_DIR=&amp;quot;${KAS_BUILD_DIR}&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${KAS_WORK_DIR}&amp;quot;:&amp;quot;${KAS_WORK_DIR}&amp;quot;:rw \&lt;br /&gt;
	--env KAS_WORK_DIR=&amp;quot;${KAS_WORK_DIR}&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${PWD}&amp;quot;:&amp;quot;${PWD}&amp;quot;:rw \&lt;br /&gt;
	--workdir=&amp;quot;${PWD}&amp;quot; \&lt;br /&gt;
	ghcr.io/siemens/kas/kas:latest-release \&lt;br /&gt;
	/bin/bash&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/meta-dhsom-stm32-bsp/kas&lt;br /&gt;
kas menu&lt;br /&gt;
kas build&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Docker container based kas tool ==&lt;br /&gt;
&lt;br /&gt;
Preparation:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
wget -O kas-container https://github.com/siemens/kas/raw/master/kas-container&lt;br /&gt;
chmod +x kas-container&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/kas-dhsom&lt;br /&gt;
/path/to/kas-container menu&lt;br /&gt;
/path/to/kas-container build&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;diff=3798</id>
		<title>Yocto build guide with docker</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;diff=3798"/>
		<updated>2022-11-24T14:42:07Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Docker container based bash shell */ Update dir creation for KAS_WORK_DIR and KAS_BUILD_DIR&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Page submit URL&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;amp;action=submit&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;!-- Info toclimit-3:&lt;br /&gt;
http://automaten-karl.de/blog/?p=74&lt;br /&gt;
https://www.mediawiki.org/wiki/Template:TOC&lt;br /&gt;
https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss&lt;br /&gt;
https://www.mediawiki.org/wiki/Manual:CSS&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
To build Yocto images you need a powerfull build machine and a lot of time.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
* CPU: four cores or more&lt;br /&gt;
* RAM: 16 GB or more&lt;br /&gt;
* HDD/SSD: from 25 GB to 100 GB free space (depends on included features)&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
* Linux OS&lt;br /&gt;
* Docker&lt;br /&gt;
&lt;br /&gt;
= Start your build environment =&lt;br /&gt;
&lt;br /&gt;
The following two examples show how to create yocto images using the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas&amp;lt;/syntaxhighlight&amp;gt; container or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas-container&amp;lt;/syntaxhighlight&amp;gt; script.&lt;br /&gt;
&lt;br /&gt;
In the following examples, we use the meta-dhsom-stm32-bsp layer as the top layer for creating images for the STM32MP15 DHSOM family with our baseboards.&lt;br /&gt;
If you have your own layer on top because you have a custom DHSOM baseboard, then you must replace meta-dhsom-stm32-bsp with your own layer in all commands.&lt;br /&gt;
&lt;br /&gt;
See the documentation for how to use the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas&amp;lt;/syntaxhighlight&amp;gt; tool:&lt;br /&gt;
* https://kas.readthedocs.io/en/latest/userguide.html&lt;br /&gt;
* https://kas.readthedocs.io/en/latest/command-line.html&lt;br /&gt;
&lt;br /&gt;
== Docker container based bash shell ==&lt;br /&gt;
&lt;br /&gt;
Preparation:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export KAS_WORK_DIR=/mnt/work/yocto&lt;br /&gt;
export KAS_BUILD_DIR=/mnt/build/yocto&lt;br /&gt;
&lt;br /&gt;
sudo mkdir -p &amp;quot;${KAS_WORK_DIR}&amp;quot; &amp;quot;${KAS_BUILD_DIR}&amp;quot;&lt;br /&gt;
sudo chown $(id –u):$(id –g) &amp;quot;${KAS_WORK_DIR}&amp;quot; &amp;quot;${KAS_BUILD_DIR}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cd /path/to/meta-dhsom-stm32-bsp&lt;br /&gt;
&lt;br /&gt;
docker run --rm --interactive --tty --init \&lt;br /&gt;
	--env TERM=&amp;quot;xterm-256color&amp;quot; \&lt;br /&gt;
	--env USER_ID=&amp;quot;$(id -u)&amp;quot; --env GROUP_ID=&amp;quot;$(id -g)&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${KAS_BUILD_DIR}&amp;quot;:&amp;quot;${KAS_BUILD_DIR}&amp;quot;:rw \&lt;br /&gt;
	--env KAS_BUILD_DIR=&amp;quot;${KAS_BUILD_DIR}&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${KAS_WORK_DIR}&amp;quot;:&amp;quot;${KAS_WORK_DIR}&amp;quot;:rw \&lt;br /&gt;
	--env KAS_WORK_DIR=&amp;quot;${KAS_WORK_DIR}&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${PWD}&amp;quot;:&amp;quot;${PWD}&amp;quot;:rw \&lt;br /&gt;
	--workdir=&amp;quot;${PWD}&amp;quot; \&lt;br /&gt;
	ghcr.io/siemens/kas/kas:latest-release \&lt;br /&gt;
	/bin/bash&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/meta-dhsom-stm32-bsp/kas&lt;br /&gt;
kas menu&lt;br /&gt;
kas build&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Docker container based kas tool ==&lt;br /&gt;
&lt;br /&gt;
Preparation:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
wget -O kas-container https://github.com/siemens/kas/raw/master/kas-container&lt;br /&gt;
chmod +x kas-container&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/meta-dhsom-stm32-bsp/kas&lt;br /&gt;
/path/to/kas-container menu&lt;br /&gt;
/path/to/kas-container build&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3787</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3787"/>
		<updated>2022-11-23T10:15:59Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE */  Update upstreaming status&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| ITS || Image Tree Source (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: A Yocto example project would be the best!&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup ==&lt;br /&gt;
&lt;br /&gt;
The following table shows the Support status of our STM32MP1-based DHSOMs in the TF-A, OP-TEE OS and OP-TEE Developer Setup projects.&lt;br /&gt;
This table is also a good starting point for what is required to support custom boards based on the STM32MP1 DHSOM in these projects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup&lt;br /&gt;
|-&lt;br /&gt;
! DHSOM&lt;br /&gt;
! TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt; &lt;br /&gt;
! OP-TEE OS&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup Linux&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup manifest&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157C DHCOM PDK2&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/build/commit/5914639cb690f57a3ce8ba0277ddc6eea2fc3985 commit 5914639c]&lt;br /&gt;
| upstreamed in [https://github.com/linaro-swg/linux/commit/2e9ae24784dd51d0a8325871b400795b88f04e2a commit 2e9ae247]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/manifest/commit/ef96a36f1821dad69a3fec14c9b75160cdcad351 commit ef96a36f] and [https://github.com/OP-TEE/manifest/commit/2ebdc19d56b2dec9e57dcd2b8024a8023a8665b9 commit 2ebdc19d]&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157A DHCOR Avenger96&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/build/commit/e43efa5b691a5f594db982134d4116ad1e625412 commit e43efa5b]&lt;br /&gt;
| upstreamed in [https://github.com/linaro-swg/linux/commit/29aee39cfa576029922eee42542571f730850877 commit 29aee39c]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/manifest/commit/ef96a36f1821dad69a3fec14c9b75160cdcad351 commit ef96a36f] and [https://github.com/OP-TEE/manifest/commit/2ebdc19d56b2dec9e57dcd2b8024a8023a8665b9 commit 2ebdc19d]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
This example shows how to define an ITS file with your own content and how to use it from the U-Boot shell.&lt;br /&gt;
&lt;br /&gt;
To build the FIT binary, there is the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_fit_image.sh&amp;lt;/syntaxhighlight&amp;gt; script included in the repository mentioned in [[#Checkout_source_code_for_Verified_Boot|Checkout Source Code for Verified Boot]].&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note that you have to change &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_ALGO&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_IMG&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_CFG&amp;lt;/syntaxhighlight&amp;gt; to valid values if you build your image manually with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt;.&amp;lt;/div&amp;gt;&lt;br /&gt;
See [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT] for more examples and explanations of the possible properties.&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with Linux, ramdisk and device trees ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with Linux, ramdisk and two device trees as images and a configuration for each valid image combination:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, ramdisk and FDT for DHCOM STM32MP1&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP15 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS ramdisk DHSOM ARMv7&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio.gz compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load the FIT file &#039;&#039;&#039;linux-signed.itb&#039;&#039;&#039; and boot the configuration &#039;&#039;&#039;stm32mp157c-dhcom-pdk2&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} /boot/linux-signed.itb&lt;br /&gt;
bootm ${loadaddr}#stm32mp157c-dhcom-pdk2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with U-Boot scripts ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with images &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;recovery&#039;&#039;&#039; of type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Various signed scripts&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		boot {&lt;br /&gt;
			description = &amp;quot;Signed boot script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/boot.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		recovery {&lt;br /&gt;
			description = &amp;quot;Signed recovery script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/recovery.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations { /* Mandatory node */ };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load FIT file &#039;&#039;&#039;scripts-signed.itb&#039;&#039;&#039; and run the image &#039;&#039;&#039;boot&#039;&#039;&#039; with type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${scriptaddr} /boot/scripts-signed.itb&lt;br /&gt;
source ${scriptaddr}:boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=Toolchain_Container_Images&amp;diff=3776</id>
		<title>Toolchain Container Images</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=Toolchain_Container_Images&amp;diff=3776"/>
		<updated>2022-10-27T10:03:23Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Images with native Debian GCC toolchain */  Drop duplicate&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DH electronics provides Docker images with preinstalled toolchains. &lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
For cross developing of applications we provide Docker container images with preinstalled toolchains.&lt;br /&gt;
You need to have Docker installed ([https://docs.docker.com/engine/install/ How to install Docker]), in our [[Virtual Machine for Application Development|VM for Application Development]] starting with Stretch Vxx Docker is preinstalled and preconfigured.&lt;br /&gt;
The container images are available [https://hub.docker.com/ Docker Hub].&lt;br /&gt;
&lt;br /&gt;
You can check which commands are executed for each layer in an image, and thus the installed packages, by clicking a specific tag in the Tag tab of an image on [https://hub.docker.com/ Docker Hub].&lt;br /&gt;
Here is an example for the image [https://hub.docker.com/layers/dhelectronics/debian-build-essential/stretch-amd64/images/sha256-12438156065c6cda9e5edcc8e25e553d78a9f14c2eaaadc7e7069e2515b93911?context=repo dhelectronics/debian-build-essential:stretch-amd64].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: For userspace application development, we recommend using the ELBE/Yocto-SDK which came with your root filesystem.&lt;br /&gt;
This is because the SDKs comes with all needed development headers and libraries for its respective root filesystem.&lt;br /&gt;
&lt;br /&gt;
== Available Toolchains ==&lt;br /&gt;
&lt;br /&gt;
=== Images with native Debian GCC toolchain ===&lt;br /&gt;
&lt;br /&gt;
At the Docker repository &amp;lt;tt&amp;gt;[https://hub.docker.com/r/dhelectronics/debian-build-essential dhelectronics/debian-build-essential]&amp;lt;/tt&amp;gt; images with the standard native GCC toolchain of Debian are located.&lt;br /&gt;
&lt;br /&gt;
The images are based on the Debian (slim-varaiant) image with &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ccache&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;curl&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;lzop&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;xz-utils&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;jq&amp;lt;/tt&amp;gt; and other tools additionally installed.&lt;br /&gt;
The Debian GCC toolchain is installed via the package &amp;lt;tt&amp;gt;debian-build-essential&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Tags consists of a combination of the used version of Debian and the architecture of the image (e.g. &amp;lt;tt&amp;gt;buster-amd64&amp;lt;/tt&amp;gt;).&lt;br /&gt;
Currently there is any combination of the Debian versions &amp;lt;tt&amp;gt;jessie&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;stretch&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;buster&amp;lt;/tt&amp;gt; with the architectures &amp;lt;tt&amp;gt;amd64&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;arm32v5&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;arm32v7&amp;lt;/tt&amp;gt; is possible.&lt;br /&gt;
Note that Docker uses another names for distinguishing the different architectures of ARM processors: &amp;lt;tt&amp;gt;arm32v5&amp;lt;/tt&amp;gt; corresponds to Debian&#039;s &amp;lt;tt&amp;gt;armel&amp;lt;/tt&amp;gt; while &amp;lt;tt&amp;gt;arm32v7&amp;lt;/tt&amp;gt; corresponds to Debian&#039;s &amp;lt;tt&amp;gt;armhf&amp;lt;/tt&amp;gt; architecture.&lt;br /&gt;
&lt;br /&gt;
You can use QEMU&#039;s user mode emulation for running the ARM-containers on an amd64-machine, the resulting software of a build still runs on the respective ARM architecture.&lt;br /&gt;
To use this you have to install the packages &amp;lt;tt&amp;gt;binfmt-support&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;qemu-user-static&amp;lt;/tt&amp;gt; on the host.&lt;br /&gt;
To activate this for the container:&lt;br /&gt;
* If your host is on Debian &#039;&#039;&#039;stretch or earlier&#039;&#039;&#039;, you have to include the usermode emulator into the container at the start of your container. This can be done with a bind mount. Add the option &amp;lt;tt&amp;gt;--mount type=bind,src=/usr/bin/qemu-arm-static,dst=/usr/bin/qemu-arm-static&amp;lt;/tt&amp;gt; to the run command of the container.&lt;br /&gt;
* If your host is on Debian &#039;&#039;&#039;buster or later&#039;&#039;&#039;, this works automaticly. You don&#039;t have to alter the run command of the container.&lt;br /&gt;
Note that running a conatiner on emulated hardware affects the performance of the compiler.&lt;br /&gt;
Tests have indicated that building the Linux kernel with one thread on the native armhf compiler running on an amd64 machine with emulation is about 9 times slower than building the same kernel with one thread on the same machine via a crossbuild compiler.&lt;br /&gt;
&lt;br /&gt;
For easing the use with the [[Toolchain_Container_Images#Use_the_symlink_wrapper|symlink-wrapper]] script, aliases for &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; are created: &amp;lt;tt&amp;gt;make-container&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake-container&amp;lt;/tt&amp;gt;. These can be used at the symlink-script as additional symlinks which won&#039;t collide with the host system&#039;s &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; so that the complete build can run inside one container.&lt;br /&gt;
&lt;br /&gt;
=== Images with Debian crossbuild GCC toolchain ===&lt;br /&gt;
&lt;br /&gt;
At the Docker repository &amp;lt;tt&amp;gt;[https://hub.docker.com/r/dhelectronics/debian-cross-build-essential dhelectronics/debian-cross-build-essential]&amp;lt;/tt&amp;gt; images with the Debian GCC toolchain for crosscompiling are located.&lt;br /&gt;
&lt;br /&gt;
All images are based on the debian images (slim varaiant) and run on an amd64 host. The standard Debian crossbuild toolchain is used. This toolchain is installed via the package &amp;lt;tt&amp;gt;crossbuild-essentail-armhf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The packages &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bison&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;build-essential&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ca-certificates&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ccache&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;curl&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;flex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;git&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;jq&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ketchup&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;libssl-dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;lzop&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;xz-utils&amp;lt;/tt&amp;gt; additionally installed, so that the images are suited to build the Linux kernel.&lt;br /&gt;
&lt;br /&gt;
The tags have the schema &#039;&#039;&#039;&amp;lt;tt&amp;gt;DIST&amp;lt;/tt&amp;gt;-&amp;lt;tt&amp;gt;ARCH&amp;lt;/tt&amp;gt;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;DIST&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which debian version the container image is based on.&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;ARCH&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which the architecture for which the cross toolchain builds. Note that the architecture names of Docker are used as an example Debian&#039;s &amp;lt;tt&amp;gt;armhf&amp;lt;/tt&amp;gt; corresponds to &amp;lt;tt&amp;gt;arm32v7&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For easing the use with the [[Toolchain_Container_Images#Use_the_symlink_wrapper|symlink-wrapper]] script, aliases for &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; are created: &amp;lt;tt&amp;gt;make-cross&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake-cross&amp;lt;/tt&amp;gt;. These can be used at the symlink-script as additional symlinks which won&#039;t collide with the host system&#039;s &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; so that the complete build can run inside one container.&lt;br /&gt;
&lt;br /&gt;
=== Images with Linaro/ARM toolchain ===&lt;br /&gt;
&lt;br /&gt;
At the Docker repository &amp;lt;tt&amp;gt;[https://hub.docker.com/r/dhelectronics/linaro-cross-build dhelectronics/linaro-cross-build]&amp;lt;/tt&amp;gt; images with the Linaro/ARM GCC toolchain for crosscompiling are located.&lt;br /&gt;
&lt;br /&gt;
These images use the toolchain of Linaro (up to GCC 7) or ARM (beginning with GCC 8) and uses the debian-slim image as a basis for this image.&lt;br /&gt;
The toolchain is installed inside &amp;lt;tt&amp;gt;/opt&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;-variable is extened to include the directory with the binaries of the toolchain.&lt;br /&gt;
The packages &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bison&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;build-essential&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ca-certificates&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ccache&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;curl&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;flex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;git&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;jq&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ketchup&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;libssl-dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;lzop&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;xz-utils&amp;lt;/tt&amp;gt; additionally installed, so that the images are suited to build the Linux kernel.&lt;br /&gt;
&lt;br /&gt;
The tags have the schema &#039;&#039;&#039;&amp;lt;tt&amp;gt;DIST&amp;lt;/tt&amp;gt;-&amp;lt;tt&amp;gt;ARCH&amp;lt;/tt&amp;gt;-&amp;lt;tt&amp;gt;VERSION&amp;lt;/tt&amp;gt;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;DIST&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which debian version the container image is based on.&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;ARCH&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which the architecture for which the cross toolchain builds. Note that the architecture names of Docker are used as an example Debian&#039;s `armhf` corresponds to &amp;lt;tt&amp;gt;arm32v7&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;VERSION&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which version of the toolchain is used. There are two kinds of versions: &#039;&#039;&#039;&amp;lt;tt&amp;gt;X.Y\[.Z\]-yyyy.mm&amp;lt;/tt&amp;gt;&#039;&#039;&#039; does explictly point to a specific version of the toolchain. &#039;&#039;&#039;&amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt;&#039;&#039;&#039; points to the latest version of the major version of the toolchain, of which a image is existing. It is possible that some versions of the toolchain are skipped.&lt;br /&gt;
&lt;br /&gt;
For easing the use with the [[Toolchain_Container_Images#Use_the_symlink_wrapper|symlink-wrapper]] script, aliases for &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; are created: &amp;lt;tt&amp;gt;make-cross&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake-cross&amp;lt;/tt&amp;gt;. These can be used at the symlink-script as additional symlinks which won&#039;t collide with the host system&#039;s &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; so that the complete build can run inside one container.&lt;br /&gt;
&lt;br /&gt;
== Using the containers ==&lt;br /&gt;
&lt;br /&gt;
=== Open console inside the container ===&lt;br /&gt;
&lt;br /&gt;
You can start the container with the current work directory mounted into the container:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;$ docker run -it --rm --mount type=bind,src=$(pwd)/,dst=$(pwd) --workdir $(pwd) --user $(id -u):$(id -g) dhelectronics/linaro-cross-build:buster-arm32v7-8.3-2019.03&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the container has started a console is open, now you can run any command to build the application (e.g. &amp;lt;tt&amp;gt;make all&amp;lt;/tt&amp;gt;).&lt;br /&gt;
When the build is finished, you can quit the console with &amp;lt;tt&amp;gt;CTRL+D&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Call the buildsystem at container start ===&lt;br /&gt;
&lt;br /&gt;
Alternativly you can call the build command directly at the run command of the container:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;$ docker run -it --rm --mount type=bind,src=$(pwd)/,dst=$(pwd) --workdir $(pwd) --user $(id -u):$(id -g) dhelectronics/linaro-cross-build:stretch-arm32v7-6.3.1-2017.05 make all&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Use the symlink wrapper ===&lt;br /&gt;
&lt;br /&gt;
We created a python script called &amp;lt;tt&amp;gt;[[Docker Symlink Wrapper|docker-symlink-wrapper.py]]&amp;lt;/tt&amp;gt; (Not yet downloadable).&lt;br /&gt;
This script can create symlinks which point to a container.&lt;br /&gt;
Technicly, these symlinks point to the script.&lt;br /&gt;
If the script called over a symlink, it looks up which container should be called.&lt;br /&gt;
This container is then started with the name of the symlink as command to execute.&lt;br /&gt;
All arguments are passed to the container, If something is piped into STDIN, it is passed into the container, too.&lt;br /&gt;
It is possible to set the tag of the container image which should be started.&lt;br /&gt;
&lt;br /&gt;
This example uses the &amp;lt;tt&amp;gt;linaro-cross-build&amp;lt;/tt&amp;gt;-toolchain, what the commands are doing exactly, [[Docker_Symlink_Wrapper#Available_Commands|look at the documentation of the symlink wrapper]].&lt;br /&gt;
&lt;br /&gt;
To create the symlinks, you need a JSON file which defines the needed things about the container images:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{&lt;br /&gt;
    &amp;quot;symlinks&amp;quot;:[&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-as&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-ld&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-gcc&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-g++&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-ar&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-nm&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-strip&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-objcopy&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-objdump&amp;quot;,&lt;br /&gt;
        &amp;quot;make-cross&amp;quot;,&lt;br /&gt;
        &amp;quot;cmake-cross&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;registry&amp;quot;:&amp;quot;&amp;quot;,&lt;br /&gt;
    &amp;quot;image&amp;quot;:&amp;quot;dhelectronics/linaro-cross-build&amp;quot;,&lt;br /&gt;
    &amp;quot;tag&amp;quot;:&amp;quot;buster-arm32v7-8&amp;quot;,&lt;br /&gt;
    &amp;quot;installpath&amp;quot;:&amp;quot;/usr/local/bin&amp;quot;&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you can call the symlink script with superuser privileges to create the symlinks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;sudo docker-symlink-wrapper.py install cross-build install.json&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the symlinks are installed and every call to &amp;lt;tt&amp;gt;arm-linux-gnueabihf-gcc&amp;lt;/tt&amp;gt; and the other symlinks will go into the container.&lt;br /&gt;
Note that when calling a symlink only the current working directory is mounted into the container!&lt;br /&gt;
If you want to compile a file, you have to be inside the directory of the file or one of its parent directories.&lt;br /&gt;
&lt;br /&gt;
To get the list of available versions of the toolchain you can use the following command:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;docker-symlink-wrapper.py list-versions cross-build&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To set the tag (= version of the toolchain) of the container, there is a command. As an example if you want to use version 6.3.1-2017.05 of the Linaro toolchain (based on Debian stretch):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;sudo docker-symlink-wrapper.py set-version cross-build stretch-arm32v7-6.3.1-2017.05&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remove images which aren&#039;t needed anymore ===&lt;br /&gt;
&lt;br /&gt;
If you want to delete a container image which you do not need anymore you can enter:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;docker image rm &amp;lt;imagename+tag&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you download a newer version of an image, the old version won&#039;t be automaticly removed, the old image won&#039;t be accessible by its name and tag. This kind of image is called &amp;quot;dangling image&amp;quot;. To remove all dangling images (so they won&#039;t take any space on disk) you can enter&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;docker image prune&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extend the container with libraries ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: If you only need libraries which came on your root filesystem, we recommend using the ELBE/Yocto-SDK which came with this root filesystem.&lt;br /&gt;
In the SDK the corresponding headers and libraries are already preinstalled.&lt;br /&gt;
&lt;br /&gt;
=== Create a modified container image ===&lt;br /&gt;
&lt;br /&gt;
You can a new container image which includes the needed library.&lt;br /&gt;
For this you need to create a new Dockerfile inside an empty container.&lt;br /&gt;
Here is an example &amp;lt;tt&amp;gt;Dockerfile&amp;lt;/tt&amp;gt; to include the C/C++ libraries of mosquitto (MQTT-broker/client) into the &amp;lt;tt&amp;gt;debian-build-essential&amp;lt;/tt&amp;gt; image:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;FROM dhelectronics/debian-build-essential:buster-arm32v7&lt;br /&gt;
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y --no-install-recommends libmosquitto-dev libmosquittopp-dev &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can create the new container image with:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;docker build -t your-custom-image:latest .&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that the container can be started like any other container.&lt;br /&gt;
If you want to use the symlink script, you have to create your own JSON file to create the symlinks.&lt;br /&gt;
The symlinks of the normal &amp;lt;tt&amp;gt;debian-build-essential&amp;lt;/tt&amp;gt; container images have to be removed because they would collide with each other (unless you install the symlinks into another directory but then the symlink which comes first inside the &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt; enviornmental variable will be prefered over the other which can cause unwanted behavior).&lt;br /&gt;
&lt;br /&gt;
=== Install libraries at runtime ===&lt;br /&gt;
&lt;br /&gt;
When you run a console inside the container, you can run apt to install addional libraries. Note that when the container is removed, any changes to the container are lost.&lt;br /&gt;
&lt;br /&gt;
=== Include libraries and headers into your project folder ===&lt;br /&gt;
&lt;br /&gt;
You can include needed libraries and headers into a sub directory of your project directory which is mounted into the container. So you do not need to modify the image or the container at runtime.&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=Toolchain_Container_Images&amp;diff=3775</id>
		<title>Toolchain Container Images</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=Toolchain_Container_Images&amp;diff=3775"/>
		<updated>2022-10-27T10:02:59Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Remove &amp;quot;This is made for our VM&amp;quot; as it works on any docker enabled linux&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DH electronics provides Docker images with preinstalled toolchains. &lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
For cross developing of applications we provide Docker container images with preinstalled toolchains.&lt;br /&gt;
You need to have Docker installed ([https://docs.docker.com/engine/install/ How to install Docker]), in our [[Virtual Machine for Application Development|VM for Application Development]] starting with Stretch Vxx Docker is preinstalled and preconfigured.&lt;br /&gt;
The container images are available [https://hub.docker.com/ Docker Hub].&lt;br /&gt;
&lt;br /&gt;
You can check which commands are executed for each layer in an image, and thus the installed packages, by clicking a specific tag in the Tag tab of an image on [https://hub.docker.com/ Docker Hub].&lt;br /&gt;
Here is an example for the image [https://hub.docker.com/layers/dhelectronics/debian-build-essential/stretch-amd64/images/sha256-12438156065c6cda9e5edcc8e25e553d78a9f14c2eaaadc7e7069e2515b93911?context=repo dhelectronics/debian-build-essential:stretch-amd64].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: For userspace application development, we recommend using the ELBE/Yocto-SDK which came with your root filesystem.&lt;br /&gt;
This is because the SDKs comes with all needed development headers and libraries for its respective root filesystem.&lt;br /&gt;
&lt;br /&gt;
== Available Toolchains ==&lt;br /&gt;
&lt;br /&gt;
=== Images with native Debian GCC toolchain ===&lt;br /&gt;
&lt;br /&gt;
At the Docker repository &amp;lt;tt&amp;gt;[https://hub.docker.com/r/dhelectronics/debian-build-essential dhelectronics/debian-build-essential]&amp;lt;/tt&amp;gt; images with the standard native GCC toolchain of Debian are located.&lt;br /&gt;
&lt;br /&gt;
The images are based on the Debian (slim-varaiant) image with &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ccache&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;curl&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;lzop&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;xz-utils&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;jq&amp;lt;/tt&amp;gt; and other tools additionally installed.&lt;br /&gt;
The Debian GCC toolchain is installed via the package &amp;lt;tt&amp;gt;debian-build-essential&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can checkout which commands are executed for each layer, and therefore also the installed packages, if you click on a specific tag in the tag tab.&lt;br /&gt;
For example for image [https://hub.docker.com/layers/dhelectronics/debian-build-essential/stretch-amd64/images/sha256-12438156065c6cda9e5edcc8e25e553d78a9f14c2eaaadc7e7069e2515b93911?context=repo dhelectronics/debian-build-essential:stretch-amd64].&lt;br /&gt;
&lt;br /&gt;
Tags consists of a combination of the used version of Debian and the architecture of the image (e.g. &amp;lt;tt&amp;gt;buster-amd64&amp;lt;/tt&amp;gt;).&lt;br /&gt;
Currently there is any combination of the Debian versions &amp;lt;tt&amp;gt;jessie&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;stretch&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;buster&amp;lt;/tt&amp;gt; with the architectures &amp;lt;tt&amp;gt;amd64&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;arm32v5&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;arm32v7&amp;lt;/tt&amp;gt; is possible.&lt;br /&gt;
Note that Docker uses another names for distinguishing the different architectures of ARM processors: &amp;lt;tt&amp;gt;arm32v5&amp;lt;/tt&amp;gt; corresponds to Debian&#039;s &amp;lt;tt&amp;gt;armel&amp;lt;/tt&amp;gt; while &amp;lt;tt&amp;gt;arm32v7&amp;lt;/tt&amp;gt; corresponds to Debian&#039;s &amp;lt;tt&amp;gt;armhf&amp;lt;/tt&amp;gt; architecture.&lt;br /&gt;
&lt;br /&gt;
You can use QEMU&#039;s user mode emulation for running the ARM-containers on an amd64-machine, the resulting software of a build still runs on the respective ARM architecture.&lt;br /&gt;
To use this you have to install the packages &amp;lt;tt&amp;gt;binfmt-support&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;qemu-user-static&amp;lt;/tt&amp;gt; on the host.&lt;br /&gt;
To activate this for the container:&lt;br /&gt;
* If your host is on Debian &#039;&#039;&#039;stretch or earlier&#039;&#039;&#039;, you have to include the usermode emulator into the container at the start of your container. This can be done with a bind mount. Add the option &amp;lt;tt&amp;gt;--mount type=bind,src=/usr/bin/qemu-arm-static,dst=/usr/bin/qemu-arm-static&amp;lt;/tt&amp;gt; to the run command of the container.&lt;br /&gt;
* If your host is on Debian &#039;&#039;&#039;buster or later&#039;&#039;&#039;, this works automaticly. You don&#039;t have to alter the run command of the container.&lt;br /&gt;
Note that running a conatiner on emulated hardware affects the performance of the compiler.&lt;br /&gt;
Tests have indicated that building the Linux kernel with one thread on the native armhf compiler running on an amd64 machine with emulation is about 9 times slower than building the same kernel with one thread on the same machine via a crossbuild compiler.&lt;br /&gt;
&lt;br /&gt;
For easing the use with the [[Toolchain_Container_Images#Use_the_symlink_wrapper|symlink-wrapper]] script, aliases for &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; are created: &amp;lt;tt&amp;gt;make-container&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake-container&amp;lt;/tt&amp;gt;. These can be used at the symlink-script as additional symlinks which won&#039;t collide with the host system&#039;s &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; so that the complete build can run inside one container.&lt;br /&gt;
&lt;br /&gt;
=== Images with Debian crossbuild GCC toolchain ===&lt;br /&gt;
&lt;br /&gt;
At the Docker repository &amp;lt;tt&amp;gt;[https://hub.docker.com/r/dhelectronics/debian-cross-build-essential dhelectronics/debian-cross-build-essential]&amp;lt;/tt&amp;gt; images with the Debian GCC toolchain for crosscompiling are located.&lt;br /&gt;
&lt;br /&gt;
All images are based on the debian images (slim varaiant) and run on an amd64 host. The standard Debian crossbuild toolchain is used. This toolchain is installed via the package &amp;lt;tt&amp;gt;crossbuild-essentail-armhf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The packages &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bison&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;build-essential&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ca-certificates&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ccache&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;curl&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;flex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;git&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;jq&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ketchup&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;libssl-dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;lzop&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;xz-utils&amp;lt;/tt&amp;gt; additionally installed, so that the images are suited to build the Linux kernel.&lt;br /&gt;
&lt;br /&gt;
The tags have the schema &#039;&#039;&#039;&amp;lt;tt&amp;gt;DIST&amp;lt;/tt&amp;gt;-&amp;lt;tt&amp;gt;ARCH&amp;lt;/tt&amp;gt;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;DIST&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which debian version the container image is based on.&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;ARCH&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which the architecture for which the cross toolchain builds. Note that the architecture names of Docker are used as an example Debian&#039;s &amp;lt;tt&amp;gt;armhf&amp;lt;/tt&amp;gt; corresponds to &amp;lt;tt&amp;gt;arm32v7&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For easing the use with the [[Toolchain_Container_Images#Use_the_symlink_wrapper|symlink-wrapper]] script, aliases for &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; are created: &amp;lt;tt&amp;gt;make-cross&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake-cross&amp;lt;/tt&amp;gt;. These can be used at the symlink-script as additional symlinks which won&#039;t collide with the host system&#039;s &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; so that the complete build can run inside one container.&lt;br /&gt;
&lt;br /&gt;
=== Images with Linaro/ARM toolchain ===&lt;br /&gt;
&lt;br /&gt;
At the Docker repository &amp;lt;tt&amp;gt;[https://hub.docker.com/r/dhelectronics/linaro-cross-build dhelectronics/linaro-cross-build]&amp;lt;/tt&amp;gt; images with the Linaro/ARM GCC toolchain for crosscompiling are located.&lt;br /&gt;
&lt;br /&gt;
These images use the toolchain of Linaro (up to GCC 7) or ARM (beginning with GCC 8) and uses the debian-slim image as a basis for this image.&lt;br /&gt;
The toolchain is installed inside &amp;lt;tt&amp;gt;/opt&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;-variable is extened to include the directory with the binaries of the toolchain.&lt;br /&gt;
The packages &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bison&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;build-essential&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ca-certificates&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ccache&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;curl&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;flex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;git&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;jq&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ketchup&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;libssl-dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;lzop&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;xz-utils&amp;lt;/tt&amp;gt; additionally installed, so that the images are suited to build the Linux kernel.&lt;br /&gt;
&lt;br /&gt;
The tags have the schema &#039;&#039;&#039;&amp;lt;tt&amp;gt;DIST&amp;lt;/tt&amp;gt;-&amp;lt;tt&amp;gt;ARCH&amp;lt;/tt&amp;gt;-&amp;lt;tt&amp;gt;VERSION&amp;lt;/tt&amp;gt;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;DIST&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which debian version the container image is based on.&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;ARCH&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which the architecture for which the cross toolchain builds. Note that the architecture names of Docker are used as an example Debian&#039;s `armhf` corresponds to &amp;lt;tt&amp;gt;arm32v7&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;tt&amp;gt;VERSION&amp;lt;/tt&amp;gt;&#039;&#039;&#039;: Determines which version of the toolchain is used. There are two kinds of versions: &#039;&#039;&#039;&amp;lt;tt&amp;gt;X.Y\[.Z\]-yyyy.mm&amp;lt;/tt&amp;gt;&#039;&#039;&#039; does explictly point to a specific version of the toolchain. &#039;&#039;&#039;&amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt;&#039;&#039;&#039; points to the latest version of the major version of the toolchain, of which a image is existing. It is possible that some versions of the toolchain are skipped.&lt;br /&gt;
&lt;br /&gt;
For easing the use with the [[Toolchain_Container_Images#Use_the_symlink_wrapper|symlink-wrapper]] script, aliases for &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; are created: &amp;lt;tt&amp;gt;make-cross&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake-cross&amp;lt;/tt&amp;gt;. These can be used at the symlink-script as additional symlinks which won&#039;t collide with the host system&#039;s &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cmake&amp;lt;/tt&amp;gt; so that the complete build can run inside one container.&lt;br /&gt;
&lt;br /&gt;
== Using the containers ==&lt;br /&gt;
&lt;br /&gt;
=== Open console inside the container ===&lt;br /&gt;
&lt;br /&gt;
You can start the container with the current work directory mounted into the container:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;$ docker run -it --rm --mount type=bind,src=$(pwd)/,dst=$(pwd) --workdir $(pwd) --user $(id -u):$(id -g) dhelectronics/linaro-cross-build:buster-arm32v7-8.3-2019.03&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the container has started a console is open, now you can run any command to build the application (e.g. &amp;lt;tt&amp;gt;make all&amp;lt;/tt&amp;gt;).&lt;br /&gt;
When the build is finished, you can quit the console with &amp;lt;tt&amp;gt;CTRL+D&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Call the buildsystem at container start ===&lt;br /&gt;
&lt;br /&gt;
Alternativly you can call the build command directly at the run command of the container:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;$ docker run -it --rm --mount type=bind,src=$(pwd)/,dst=$(pwd) --workdir $(pwd) --user $(id -u):$(id -g) dhelectronics/linaro-cross-build:stretch-arm32v7-6.3.1-2017.05 make all&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Use the symlink wrapper ===&lt;br /&gt;
&lt;br /&gt;
We created a python script called &amp;lt;tt&amp;gt;[[Docker Symlink Wrapper|docker-symlink-wrapper.py]]&amp;lt;/tt&amp;gt; (Not yet downloadable).&lt;br /&gt;
This script can create symlinks which point to a container.&lt;br /&gt;
Technicly, these symlinks point to the script.&lt;br /&gt;
If the script called over a symlink, it looks up which container should be called.&lt;br /&gt;
This container is then started with the name of the symlink as command to execute.&lt;br /&gt;
All arguments are passed to the container, If something is piped into STDIN, it is passed into the container, too.&lt;br /&gt;
It is possible to set the tag of the container image which should be started.&lt;br /&gt;
&lt;br /&gt;
This example uses the &amp;lt;tt&amp;gt;linaro-cross-build&amp;lt;/tt&amp;gt;-toolchain, what the commands are doing exactly, [[Docker_Symlink_Wrapper#Available_Commands|look at the documentation of the symlink wrapper]].&lt;br /&gt;
&lt;br /&gt;
To create the symlinks, you need a JSON file which defines the needed things about the container images:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{&lt;br /&gt;
    &amp;quot;symlinks&amp;quot;:[&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-as&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-ld&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-gcc&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-g++&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-ar&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-nm&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-strip&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-objcopy&amp;quot;,&lt;br /&gt;
        &amp;quot;arm-linux-gnueabihf-objdump&amp;quot;,&lt;br /&gt;
        &amp;quot;make-cross&amp;quot;,&lt;br /&gt;
        &amp;quot;cmake-cross&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;registry&amp;quot;:&amp;quot;&amp;quot;,&lt;br /&gt;
    &amp;quot;image&amp;quot;:&amp;quot;dhelectronics/linaro-cross-build&amp;quot;,&lt;br /&gt;
    &amp;quot;tag&amp;quot;:&amp;quot;buster-arm32v7-8&amp;quot;,&lt;br /&gt;
    &amp;quot;installpath&amp;quot;:&amp;quot;/usr/local/bin&amp;quot;&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you can call the symlink script with superuser privileges to create the symlinks:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;sudo docker-symlink-wrapper.py install cross-build install.json&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the symlinks are installed and every call to &amp;lt;tt&amp;gt;arm-linux-gnueabihf-gcc&amp;lt;/tt&amp;gt; and the other symlinks will go into the container.&lt;br /&gt;
Note that when calling a symlink only the current working directory is mounted into the container!&lt;br /&gt;
If you want to compile a file, you have to be inside the directory of the file or one of its parent directories.&lt;br /&gt;
&lt;br /&gt;
To get the list of available versions of the toolchain you can use the following command:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;docker-symlink-wrapper.py list-versions cross-build&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To set the tag (= version of the toolchain) of the container, there is a command. As an example if you want to use version 6.3.1-2017.05 of the Linaro toolchain (based on Debian stretch):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;sudo docker-symlink-wrapper.py set-version cross-build stretch-arm32v7-6.3.1-2017.05&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remove images which aren&#039;t needed anymore ===&lt;br /&gt;
&lt;br /&gt;
If you want to delete a container image which you do not need anymore you can enter:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;docker image rm &amp;lt;imagename+tag&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you download a newer version of an image, the old version won&#039;t be automaticly removed, the old image won&#039;t be accessible by its name and tag. This kind of image is called &amp;quot;dangling image&amp;quot;. To remove all dangling images (so they won&#039;t take any space on disk) you can enter&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;tt&amp;gt;docker image prune&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extend the container with libraries ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: If you only need libraries which came on your root filesystem, we recommend using the ELBE/Yocto-SDK which came with this root filesystem.&lt;br /&gt;
In the SDK the corresponding headers and libraries are already preinstalled.&lt;br /&gt;
&lt;br /&gt;
=== Create a modified container image ===&lt;br /&gt;
&lt;br /&gt;
You can a new container image which includes the needed library.&lt;br /&gt;
For this you need to create a new Dockerfile inside an empty container.&lt;br /&gt;
Here is an example &amp;lt;tt&amp;gt;Dockerfile&amp;lt;/tt&amp;gt; to include the C/C++ libraries of mosquitto (MQTT-broker/client) into the &amp;lt;tt&amp;gt;debian-build-essential&amp;lt;/tt&amp;gt; image:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;FROM dhelectronics/debian-build-essential:buster-arm32v7&lt;br /&gt;
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y --no-install-recommends libmosquitto-dev libmosquittopp-dev &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can create the new container image with:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;docker build -t your-custom-image:latest .&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that the container can be started like any other container.&lt;br /&gt;
If you want to use the symlink script, you have to create your own JSON file to create the symlinks.&lt;br /&gt;
The symlinks of the normal &amp;lt;tt&amp;gt;debian-build-essential&amp;lt;/tt&amp;gt; container images have to be removed because they would collide with each other (unless you install the symlinks into another directory but then the symlink which comes first inside the &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt; enviornmental variable will be prefered over the other which can cause unwanted behavior).&lt;br /&gt;
&lt;br /&gt;
=== Install libraries at runtime ===&lt;br /&gt;
&lt;br /&gt;
When you run a console inside the container, you can run apt to install addional libraries. Note that when the container is removed, any changes to the container are lost.&lt;br /&gt;
&lt;br /&gt;
=== Include libraries and headers into your project folder ===&lt;br /&gt;
&lt;br /&gt;
You can include needed libraries and headers into a sub directory of your project directory which is mounted into the container. So you do not need to modify the image or the container at runtime.&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3746</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3746"/>
		<updated>2022-09-16T08:18:23Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE */  Update upstreaming status&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| ITS || Image Tree Source (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: A Yocto example project would be the best!&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup ==&lt;br /&gt;
&lt;br /&gt;
The following table shows the Support status of our STM32MP1-based DHSOMs in the TF-A, OP-TEE OS and OP-TEE Developer Setup projects.&lt;br /&gt;
This table is also a good starting point for what is required to support custom boards based on the STM32MP1 DHSOM in these projects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup&lt;br /&gt;
|-&lt;br /&gt;
! DHSOM&lt;br /&gt;
! TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt; &lt;br /&gt;
! OP-TEE OS&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup Linux&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup manifest&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157C DHCOM PDK2&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/build/commit/5914639cb690f57a3ce8ba0277ddc6eea2fc3985 commit 5914639c]&lt;br /&gt;
| upstreamed in [https://github.com/linaro-swg/linux/commit/2e9ae24784dd51d0a8325871b400795b88f04e2a commit 2e9ae247]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157A DHCOR Avenger96&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/build/commit/e43efa5b691a5f594db982134d4116ad1e625412 commit e43efa5b]&lt;br /&gt;
| upstreamed in [https://github.com/linaro-swg/linux/commit/29aee39cfa576029922eee42542571f730850877 commit 29aee39c]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
This example shows how to define an ITS file with your own content and how to use it from the U-Boot shell.&lt;br /&gt;
&lt;br /&gt;
To build the FIT binary, there is the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_fit_image.sh&amp;lt;/syntaxhighlight&amp;gt; script included in the repository mentioned in [[#Checkout_source_code_for_Verified_Boot|Checkout Source Code for Verified Boot]].&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note that you have to change &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_ALGO&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_IMG&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_CFG&amp;lt;/syntaxhighlight&amp;gt; to valid values if you build your image manually with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt;.&amp;lt;/div&amp;gt;&lt;br /&gt;
See [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT] for more examples and explanations of the possible properties.&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with Linux, ramdisk and device trees ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with Linux, ramdisk and two device trees as images and a configuration for each valid image combination:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, ramdisk and FDT for DHCOM STM32MP1&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP15 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS ramdisk DHSOM ARMv7&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio.gz compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load the FIT file &#039;&#039;&#039;linux-signed.itb&#039;&#039;&#039; and boot the configuration &#039;&#039;&#039;stm32mp157c-dhcom-pdk2&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} /boot/linux-signed.itb&lt;br /&gt;
bootm ${loadaddr}#stm32mp157c-dhcom-pdk2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with U-Boot scripts ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with images &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;recovery&#039;&#039;&#039; of type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Various signed scripts&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		boot {&lt;br /&gt;
			description = &amp;quot;Signed boot script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/boot.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		recovery {&lt;br /&gt;
			description = &amp;quot;Signed recovery script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/recovery.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations { /* Mandatory node */ };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load FIT file &#039;&#039;&#039;scripts-signed.itb&#039;&#039;&#039; and run the image &#039;&#039;&#039;boot&#039;&#039;&#039; with type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${scriptaddr} /boot/scripts-signed.itb&lt;br /&gt;
source ${scriptaddr}:boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3745</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3745"/>
		<updated>2022-09-12T12:09:48Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Examples for Flatten Image Tree Source files */ Fix link to git repo source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| ITS || Image Tree Source (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: A Yocto example project would be the best!&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup ==&lt;br /&gt;
&lt;br /&gt;
The following table shows the Support status of our STM32MP1-based DHSOMs in the TF-A, OP-TEE OS and OP-TEE Developer Setup projects.&lt;br /&gt;
This table is also a good starting point for what is required to support custom boards based on the STM32MP1 DHSOM in these projects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup&lt;br /&gt;
|-&lt;br /&gt;
! DHSOM&lt;br /&gt;
! TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt; &lt;br /&gt;
! OP-TEE OS&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup Linux&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup manifest&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157C DHCOM PDK2&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/build/commit/5914639cb690f57a3ce8ba0277ddc6eea2fc3985 commit 5914639c]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157A DHCOR Avenger96&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/build/commit/e43efa5b691a5f594db982134d4116ad1e625412 commit e43efa5b]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
This example shows how to define an ITS file with your own content and how to use it from the U-Boot shell.&lt;br /&gt;
&lt;br /&gt;
To build the FIT binary, there is the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_fit_image.sh&amp;lt;/syntaxhighlight&amp;gt; script included in the repository mentioned in [[#Checkout_source_code_for_Verified_Boot|Checkout Source Code for Verified Boot]].&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note that you have to change &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_ALGO&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_IMG&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_CFG&amp;lt;/syntaxhighlight&amp;gt; to valid values if you build your image manually with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt;.&amp;lt;/div&amp;gt;&lt;br /&gt;
See [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT] for more examples and explanations of the possible properties.&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with Linux, ramdisk and device trees ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with Linux, ramdisk and two device trees as images and a configuration for each valid image combination:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, ramdisk and FDT for DHCOM STM32MP1&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP15 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS ramdisk DHSOM ARMv7&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio.gz compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load the FIT file &#039;&#039;&#039;linux-signed.itb&#039;&#039;&#039; and boot the configuration &#039;&#039;&#039;stm32mp157c-dhcom-pdk2&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} /boot/linux-signed.itb&lt;br /&gt;
bootm ${loadaddr}#stm32mp157c-dhcom-pdk2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with U-Boot scripts ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with images &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;recovery&#039;&#039;&#039; of type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Various signed scripts&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		boot {&lt;br /&gt;
			description = &amp;quot;Signed boot script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/boot.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		recovery {&lt;br /&gt;
			description = &amp;quot;Signed recovery script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/recovery.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations { /* Mandatory node */ };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load FIT file &#039;&#039;&#039;scripts-signed.itb&#039;&#039;&#039; and run the image &#039;&#039;&#039;boot&#039;&#039;&#039; with type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${scriptaddr} /boot/scripts-signed.itb&lt;br /&gt;
source ${scriptaddr}:boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3744</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3744"/>
		<updated>2022-09-12T07:12:57Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup */ Update upstreaming status&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| ITS || Image Tree Source (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: A Yocto example project would be the best!&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup ==&lt;br /&gt;
&lt;br /&gt;
The following table shows the Support status of our STM32MP1-based DHSOMs in the TF-A, OP-TEE OS and OP-TEE Developer Setup projects.&lt;br /&gt;
This table is also a good starting point for what is required to support custom boards based on the STM32MP1 DHSOM in these projects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup&lt;br /&gt;
|-&lt;br /&gt;
! DHSOM&lt;br /&gt;
! TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt; &lt;br /&gt;
! OP-TEE OS&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup Linux&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup manifest&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157C DHCOM PDK2&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/build/commit/5914639cb690f57a3ce8ba0277ddc6eea2fc3985 commit 5914639c]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157A DHCOR Avenger96&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/build/commit/e43efa5b691a5f594db982134d4116ad1e625412 commit e43efa5b]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
This example shows how to define an ITS file with your own content and how to use it from the U-Boot shell.&lt;br /&gt;
&lt;br /&gt;
To build the FIT binary, there is the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_fit_image.sh&amp;lt;/syntaxhighlight&amp;gt; script included in the repository mentioned in [[#Checkout Source Code for Verified Boot|Checkout Source Code for Verified Boot]].&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note that you have to change &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_ALGO&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_IMG&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_CFG&amp;lt;/syntaxhighlight&amp;gt; to valid values if you build your image manually with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt;.&amp;lt;/div&amp;gt;&lt;br /&gt;
See [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT] for more examples and explanations of the possible properties.&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with Linux, ramdisk and device trees ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with Linux, ramdisk and two device trees as images and a configuration for each valid image combination:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, ramdisk and FDT for DHCOM STM32MP1&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP15 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS ramdisk DHSOM ARMv7&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio.gz compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load the FIT file &#039;&#039;&#039;linux-signed.itb&#039;&#039;&#039; and boot the configuration &#039;&#039;&#039;stm32mp157c-dhcom-pdk2&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} /boot/linux-signed.itb&lt;br /&gt;
bootm ${loadaddr}#stm32mp157c-dhcom-pdk2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with U-Boot scripts ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with images &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;recovery&#039;&#039;&#039; of type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Various signed scripts&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		boot {&lt;br /&gt;
			description = &amp;quot;Signed boot script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/boot.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		recovery {&lt;br /&gt;
			description = &amp;quot;Signed recovery script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/recovery.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations { /* Mandatory node */ };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load FIT file &#039;&#039;&#039;scripts-signed.itb&#039;&#039;&#039; and run the image &#039;&#039;&#039;boot&#039;&#039;&#039; with type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${scriptaddr} /boot/scripts-signed.itb&lt;br /&gt;
source ${scriptaddr}:boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3743</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3743"/>
		<updated>2022-09-09T11:38:03Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Extend &amp;quot;Examples for Flatten Image Tree Source files&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| ITS || Image Tree Source (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: A Yocto example project would be the best!&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup ==&lt;br /&gt;
&lt;br /&gt;
The following table shows the Support status of our STM32MP1-based DHSOMs in the TF-A, OP-TEE OS and OP-TEE Developer Setup projects.&lt;br /&gt;
This table is also a good starting point for what is required to support custom boards based on the STM32MP1 DHSOM in these projects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup&lt;br /&gt;
|-&lt;br /&gt;
! DHSOM&lt;br /&gt;
! TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt; &lt;br /&gt;
! OP-TEE OS&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup Linux&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup manifest&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157C DHCOM PDK2&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
| under review in [https://github.com/OP-TEE/build/pull/586 pull request 586]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157A DHCOR Avenger96&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
| under review in [https://github.com/OP-TEE/build/pull/586 pull request 586]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
This example shows how to define an ITS file with your own content and how to use it from the U-Boot shell.&lt;br /&gt;
&lt;br /&gt;
To build the FIT binary, there is the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_fit_image.sh&amp;lt;/syntaxhighlight&amp;gt; script included in the repository mentioned in [[#Checkout Source Code for Verified Boot|Checkout Source Code for Verified Boot]].&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note that you have to change &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_ALGO&amp;lt;/syntaxhighlight&amp;gt;, &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_IMG&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_NAME_SSBL_CFG&amp;lt;/syntaxhighlight&amp;gt; to valid values if you build your image manually with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt;.&amp;lt;/div&amp;gt;&lt;br /&gt;
See [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT] for more examples and explanations of the possible properties.&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with Linux, ramdisk and device trees ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with Linux, ramdisk and two device trees as images and a configuration for each valid image combination:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, ramdisk and FDT for DHCOM STM32MP1&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP15 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS ramdisk DHSOM ARMv7&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio.gz compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/linux/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load the FIT file &#039;&#039;&#039;linux-signed.itb&#039;&#039;&#039; and boot the configuration &#039;&#039;&#039;stm32mp157c-dhcom-pdk2&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} /boot/linux-signed.itb&lt;br /&gt;
bootm ${loadaddr}#stm32mp157c-dhcom-pdk2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Signed FIT with U-Boot scripts ==&lt;br /&gt;
&lt;br /&gt;
Example of an ITS file with images &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;recovery&#039;&#039;&#039; of type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Various signed scripts&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		boot {&lt;br /&gt;
			description = &amp;quot;Signed boot script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/boot.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		recovery {&lt;br /&gt;
			description = &amp;quot;Signed recovery script&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/mnt/work/u-boot_scripts/recovery.scr&amp;quot;);&lt;br /&gt;
			type = &amp;quot;script&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations { /* Mandatory node */ };&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example U-Boot shell commands to load FIT file &#039;&#039;&#039;scripts-signed.itb&#039;&#039;&#039; and run the image &#039;&#039;&#039;boot&#039;&#039;&#039; with type script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${scriptaddr} /boot/scripts-signed.itb&lt;br /&gt;
source ${scriptaddr}:boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3742</id>
		<title>U-Boot recovery for STM32MP1 DHSOM via DFU</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3742"/>
		<updated>2022-09-09T07:42:36Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* U-Boot booting via DFU */ Add kernel log check also for USB download gadget&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB to temporarily boot U-Boot SPL and U-Boot.&lt;br /&gt;
From this U-Boot shell we can write both bootloader images from the SD card to the boot flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
=== Software ===&lt;br /&gt;
* Linux host computer ([[Virtual Machine for Application Development]] is used in this guide)&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 U-Boot 2022.04] for your board (download and build instructions below)&lt;br /&gt;
* [https://packages.debian.org/stable/dfu-util dfu-util] (for DFU boot mode)&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
* STM32MP1 based DHCOM&lt;br /&gt;
* DHCOM Premium Developer Kit Baseboard (or Baseboards with OTG ports)&lt;br /&gt;
* USB cable for OTG port (Mini USB for PDK2, USB-C for PDK3) (for DFU boot mode)&lt;br /&gt;
* SD card (for SD card boot mode)&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
=== Install dfu-util (debian) ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install dfu-util&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download/Build U-Boot SPL and U-Boot binaries ===&lt;br /&gt;
&lt;br /&gt;
There are two ways to get the required U-Boot binaries.&lt;br /&gt;
These can either be downloaded or built from the sources by yourself.&lt;br /&gt;
Follow one of the two steps below.&lt;br /&gt;
&lt;br /&gt;
==== Download prebuilt binaries ====&lt;br /&gt;
&lt;br /&gt;
[[media:AACQ30W-7l-Zi_Zutu0Zv-Zua|Dropbox: U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU]] ([https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 source])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
curl -LsS https://www.dropbox.com/sh/os9so01tivajkxs/AACQ30W-7l-Zi_Zutu0Zv-Zua &amp;gt; recovery_binaryies.zip&lt;br /&gt;
unzip recovery_binaryies.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Archive:  recovery_binaryies.zip&lt;br /&gt;
warning:  stripped absolute path spec from /&lt;br /&gt;
mapname:  conversion of  failed&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/av96/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/pdk2/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/drc02/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/picoitx/&lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot-spl.stm32  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Build binaries from source ====&lt;br /&gt;
&lt;br /&gt;
Clone U-Boot mainline source code for release v2022.04:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
UBOOT_SRC=/work/dev/u-boot_v2022.04&lt;br /&gt;
mkdir -p $UBOOT_SRC&lt;br /&gt;
git clone --branch v2022.04 --depth 1 https://source.denx.de/u-boot/u-boot.git $UBOOT_SRC&lt;br /&gt;
cd $UBOOT_SRC&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available U-Boot defconfigs for STM32MP1 based DHSOM devices with default device tree in bold:&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcom_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;pdk2&#039;&#039;&#039;, picoitx, drc02)&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcor_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;avenger96&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /work/dev/u-boot&lt;br /&gt;
git clone https://source.denx.de/u-boot/u-boot.git -b v2022.04 /work/dev/u-boot&lt;br /&gt;
cd /work/dev/u-boot&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make stm32mp15_dhcom_basic_defconfig&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change default device tree (Example for: stm32mp15xx-dhcom-picoitx):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sed -iE &#039;s/(stm32mp15xx-dhcom-pdk2|stm32mp157a-dhcor-avenger96)/stm32mp15xx-dhcom-picoitx/&#039; .config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build linux binaries with all available cores:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SHIPPED dts/dt.dtb&lt;br /&gt;
CAT     u-boot-dtb.bin&lt;br /&gt;
MKIMAGE u-boot.img&lt;br /&gt;
COPY    u-boot.dtb&lt;br /&gt;
MKIMAGE u-boot-dtb.img&lt;br /&gt;
MKIMAGE u-boot.itb&lt;br /&gt;
...&lt;br /&gt;
LD      spl/u-boot-spl&lt;br /&gt;
OBJCOPY spl/u-boot-spl-nodtb.bin&lt;br /&gt;
SYM     spl/u-boot-spl.sym&lt;br /&gt;
CAT     spl/u-boot-spl-dtb.bin&lt;br /&gt;
COPY    spl/u-boot-spl.bin&lt;br /&gt;
BINMAN  all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check that the required binaries have been created and are of the appropriate size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l u-boot.itb u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
-rw-r--r-- 1 devel devel 819720 Apr 11 17:03 u-boot.itb&lt;br /&gt;
-rw-r--r-- 1 devel devel 124288 Apr 11 17:03 u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via DFU ==&lt;br /&gt;
&lt;br /&gt;
To boot U-Boot SPL and U-Boot via DFU boot mode, you must first check if you have a DFU device connected, then load U-Boot SPL into the SRAM of your STM32MP1 and wait until the DRAM is initialized.&lt;br /&gt;
Then load U-Boot in the DRAM of your STM32MP1 and continue the boot process using the shown key combination.&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot SPL with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard and check the kernel log for a available &#039;&#039;&#039;DFU&#039;&#039;&#039; device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 2-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00&lt;br /&gt;
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&lt;br /&gt;
usb 2-2: Product: DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000&lt;br /&gt;
usb 2-2: Manufacturer: STMicroelectronics&lt;br /&gt;
usb 2-2: SerialNumber: 0040001D3130510439373430&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot SPL with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 1 -D u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #1 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 1024&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       160911 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from DFU&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard and check the kernel log for a available &#039;&#039;&#039;USB download gadget&#039;&#039;&#039; device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 3-2: new high-speed USB device number 8 using xhci_hcd&lt;br /&gt;
usb 3-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.27&lt;br /&gt;
usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0&lt;br /&gt;
usb 3-2: Product: USB download gadget&lt;br /&gt;
usb 3-2: Manufacturer: dh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 0 -D u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #0 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 4096&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       819232 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#DOWNLOAD ... OK&lt;br /&gt;
Ctrl+C to exit ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console after pressing &#039;&#039;&#039;Ctrl+C&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
&lt;br /&gt;
CPU: STM32MP157CAA Rev.Z&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Board: stm32mp1 in basic mode (dh,stm32mp15xx-dhcom-pdk2)&lt;br /&gt;
DRAM:  1 GiB&lt;br /&gt;
Clocks:&lt;br /&gt;
- MPU : 650 MHz&lt;br /&gt;
- MCU : 208.878 MHz&lt;br /&gt;
- AXI : 266.500 MHz&lt;br /&gt;
- PER : 24 MHz&lt;br /&gt;
- DDR : 533 MHz&lt;br /&gt;
Core:  255 devices, 31 uclasses, devicetree: separate&lt;br /&gt;
MMC:   STM32 SD/MMC: 2, STM32 SD/MMC: 0, STM32 SD/MMC: 1&lt;br /&gt;
Loading Environment from SPIFlash... SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
OK&lt;br /&gt;
In:    serial&lt;br /&gt;
Out:   serial&lt;br /&gt;
Err:   serial&lt;br /&gt;
Net:   eth0: ethernet@5800a000, eth1: ks8851mll@64000000&lt;br /&gt;
Hit any key to stop autoboot:  0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via SD card ==&lt;br /&gt;
&lt;br /&gt;
Set the disk:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32_DISK=/dev/sdc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Partition a SD card ===&lt;br /&gt;
&lt;br /&gt;
Create partition table and partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
parted --script -- ${STM32_DISK} \&lt;br /&gt;
  mktable gpt \&lt;br /&gt;
  mkpart fsbl1 1MiB 1.25MiB \&lt;br /&gt;
  mkpart fsbl2 2MiB 2.25MiB \&lt;br /&gt;
  mkpart ssbl 3MiB 5MiB \&lt;br /&gt;
  mkpart rootfs ext4 5MiB 100% \&lt;br /&gt;
  set 4 legacy_boot on \&lt;br /&gt;
  unit MiB \&lt;br /&gt;
  print&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Model: Generic STORAGE DEVICE (scsi)&lt;br /&gt;
Disk /dev/sdc: 954MiB&lt;br /&gt;
Sector size (logical/physical): 512B/512B&lt;br /&gt;
Partition Table: gpt&lt;br /&gt;
Disk Flags: &lt;br /&gt;
&lt;br /&gt;
Number  Start    End      Size     File system  Name    Flags&lt;br /&gt;
 1      1.00MiB  1.25MiB  0.25MiB               fsbl1&lt;br /&gt;
 2      2.00MiB  2.25MiB  0.25MiB               fsbl2&lt;br /&gt;
 3      3.00MiB  5.00MiB  2.00MiB               ssbl&lt;br /&gt;
 4      5.00MiB  953MiB   948MiB   ext4         rootfs  legacy_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Redetect partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
partprobe ${STM32_DISK}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create file system on partition 4 ===&lt;br /&gt;
&lt;br /&gt;
Create filesystem on partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkfs.ext4 -m 0 -L rootfs ${STM32_DISK}4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
mke2fs 1.46.2 (28-Feb-2021)&lt;br /&gt;
Creating filesystem with 242688 4k blocks and 60672 inodes&lt;br /&gt;
Filesystem UUID: bda8eff7-aa5a-4ed8-aa53-f22e3a1e3203&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
	32768, 98304, 163840, 229376&lt;br /&gt;
&lt;br /&gt;
Allocating group tables: done                            &lt;br /&gt;
Writing inode tables: done                            &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Write u-boot spl and u-boot to boot partitions 1, 2 and 3:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}1&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}2&lt;br /&gt;
dd if=u-boot.itb of=${STM32_DISK}3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.274919 s, 585 kB/s&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.280309 s, 574 kB/s&lt;br /&gt;
1600+1 records in&lt;br /&gt;
1600+1 records out&lt;br /&gt;
819232 bytes (819 kB, 800 KiB) copied, 0.862246 s, 950 kB/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy u-boot spl and u-boot to directory &amp;lt;code&amp;gt;boot&amp;lt;/code&amp;gt; on rootfs partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p rootfs&lt;br /&gt;
mount ${STM32_DISK}4 rootfs&lt;br /&gt;
mkdir -p rootfs/boot&lt;br /&gt;
cp u-boot-spl.stm32 u-boot.itb rootfs/boot/&lt;br /&gt;
umount rootfs &amp;amp;&amp;amp; rmdir rootfs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Boot from SD card ===&lt;br /&gt;
&lt;br /&gt;
# Hold the button for SD card boot mode on the SODIMM-200 module (DHCOM) below the eMMC chip.&lt;br /&gt;
#:[[File:STM32MP1-Button.jpg|400px]]&lt;br /&gt;
# Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
# Release the button for SD card boot mode&lt;br /&gt;
&lt;br /&gt;
== U-Boot flashing via SD card ==&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[#U-Boot booting via SD card|U-Boot booting via SD card]] to prepare an SD card with a file system on partition 4 that contains the required &amp;lt;code&amp;gt;u-boot-spl.stm32&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;u-boot.itb&amp;lt;/code&amp;gt; binaries.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to SPI-NOR-Flash ===&lt;br /&gt;
&lt;br /&gt;
# Start U-Boot by [[#U-Boot booting via DFU|U-Boot booting via DFU]] or by [[#Boot from SD card|Boot from SD card]]&lt;br /&gt;
# Attach prepared SD card to the on module SD card slot&lt;br /&gt;
# Program U-Boot SPL and U-Boot by the script &amp;lt;code&amp;gt;update_sf&amp;lt;/code&amp;gt; stored in the U-Boot environment.&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP&amp;gt; run update_sf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
160911 bytes read in 80 ms (1.9 MiB/s)&lt;br /&gt;
819232 bytes read in 115 ms (6.8 MiB/s)&lt;br /&gt;
SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
SF: 2097152 bytes @ 0x0 Erased: OK&lt;br /&gt;
device 0 offset 0x0, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.664s, speed 98903 B/s&lt;br /&gt;
device 0 offset 0x40000, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.626s, speed 101211 B/s&lt;br /&gt;
device 0 offset 0x80000, size 0xc8020&lt;br /&gt;
815136 bytes written, 4096 bytes skipped in 8.379s, speed 100094 B/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3741</id>
		<title>U-Boot recovery for STM32MP1 DHSOM via DFU</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3741"/>
		<updated>2022-09-09T06:16:30Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Fix translation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB to temporarily boot U-Boot SPL and U-Boot.&lt;br /&gt;
From this U-Boot shell we can write both bootloader images from the SD card to the boot flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
=== Software ===&lt;br /&gt;
* Linux host computer ([[Virtual Machine for Application Development]] is used in this guide)&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 U-Boot 2022.04] for your board (download and build instructions below)&lt;br /&gt;
* [https://packages.debian.org/stable/dfu-util dfu-util] (for DFU boot mode)&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
* STM32MP1 based DHCOM&lt;br /&gt;
* DHCOM Premium Developer Kit Baseboard (or Baseboards with OTG ports)&lt;br /&gt;
* USB cable for OTG port (Mini USB for PDK2, USB-C for PDK3) (for DFU boot mode)&lt;br /&gt;
* SD card (for SD card boot mode)&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
=== Install dfu-util (debian) ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install dfu-util&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download/Build U-Boot SPL and U-Boot binaries ===&lt;br /&gt;
&lt;br /&gt;
There are two ways to get the required U-Boot binaries.&lt;br /&gt;
These can either be downloaded or built from the sources by yourself.&lt;br /&gt;
Follow one of the two steps below.&lt;br /&gt;
&lt;br /&gt;
==== Download prebuilt binaries ====&lt;br /&gt;
&lt;br /&gt;
[[media:AACQ30W-7l-Zi_Zutu0Zv-Zua|Dropbox: U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU]] ([https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 source])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
curl -LsS https://www.dropbox.com/sh/os9so01tivajkxs/AACQ30W-7l-Zi_Zutu0Zv-Zua &amp;gt; recovery_binaryies.zip&lt;br /&gt;
unzip recovery_binaryies.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Archive:  recovery_binaryies.zip&lt;br /&gt;
warning:  stripped absolute path spec from /&lt;br /&gt;
mapname:  conversion of  failed&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/av96/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/pdk2/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/drc02/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/picoitx/&lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot-spl.stm32  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Build binaries from source ====&lt;br /&gt;
&lt;br /&gt;
Clone U-Boot mainline source code for release v2022.04:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
UBOOT_SRC=/work/dev/u-boot_v2022.04&lt;br /&gt;
mkdir -p $UBOOT_SRC&lt;br /&gt;
git clone --branch v2022.04 --depth 1 https://source.denx.de/u-boot/u-boot.git $UBOOT_SRC&lt;br /&gt;
cd $UBOOT_SRC&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available U-Boot defconfigs for STM32MP1 based DHSOM devices with default device tree in bold:&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcom_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;pdk2&#039;&#039;&#039;, picoitx, drc02)&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcor_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;avenger96&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /work/dev/u-boot&lt;br /&gt;
git clone https://source.denx.de/u-boot/u-boot.git -b v2022.04 /work/dev/u-boot&lt;br /&gt;
cd /work/dev/u-boot&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make stm32mp15_dhcom_basic_defconfig&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change default device tree (Example for: stm32mp15xx-dhcom-picoitx):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sed -iE &#039;s/(stm32mp15xx-dhcom-pdk2|stm32mp157a-dhcor-avenger96)/stm32mp15xx-dhcom-picoitx/&#039; .config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build linux binaries with all available cores:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SHIPPED dts/dt.dtb&lt;br /&gt;
CAT     u-boot-dtb.bin&lt;br /&gt;
MKIMAGE u-boot.img&lt;br /&gt;
COPY    u-boot.dtb&lt;br /&gt;
MKIMAGE u-boot-dtb.img&lt;br /&gt;
MKIMAGE u-boot.itb&lt;br /&gt;
...&lt;br /&gt;
LD      spl/u-boot-spl&lt;br /&gt;
OBJCOPY spl/u-boot-spl-nodtb.bin&lt;br /&gt;
SYM     spl/u-boot-spl.sym&lt;br /&gt;
CAT     spl/u-boot-spl-dtb.bin&lt;br /&gt;
COPY    spl/u-boot-spl.bin&lt;br /&gt;
BINMAN  all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check that the required binaries have been created and are of the appropriate size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l u-boot.itb u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
-rw-r--r-- 1 devel devel 819720 Apr 11 17:03 u-boot.itb&lt;br /&gt;
-rw-r--r-- 1 devel devel 124288 Apr 11 17:03 u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via DFU ==&lt;br /&gt;
&lt;br /&gt;
To boot U-Boot SPL and U-Boot via DFU boot mode, you must first check if you have a DFU device connected, then load U-Boot SPL into the SRAM of your STM32MP1 and wait until the DRAM is initialized.&lt;br /&gt;
Then load U-Boot in the DRAM of your STM32MP1 and continue the boot process using the shown key combination.&lt;br /&gt;
&lt;br /&gt;
=== Check for available DFU device ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard and check the kernel log for a available DFU device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 2-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00&lt;br /&gt;
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&lt;br /&gt;
usb 2-2: Product: DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000&lt;br /&gt;
usb 2-2: Manufacturer: STMicroelectronics&lt;br /&gt;
usb 2-2: SerialNumber: 0040001D3130510439373430&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot SPL with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot SPL with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 1 -D u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #1 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 1024&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       160911 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from DFU&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; === &lt;br /&gt;
&lt;br /&gt;
Download of U-Boot with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 0 -D u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #0 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 4096&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       819232 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#DOWNLOAD ... OK&lt;br /&gt;
Ctrl+C to exit ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console after pressing &#039;&#039;&#039;Ctrl+C&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
&lt;br /&gt;
CPU: STM32MP157CAA Rev.Z&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Board: stm32mp1 in basic mode (dh,stm32mp15xx-dhcom-pdk2)&lt;br /&gt;
DRAM:  1 GiB&lt;br /&gt;
Clocks:&lt;br /&gt;
- MPU : 650 MHz&lt;br /&gt;
- MCU : 208.878 MHz&lt;br /&gt;
- AXI : 266.500 MHz&lt;br /&gt;
- PER : 24 MHz&lt;br /&gt;
- DDR : 533 MHz&lt;br /&gt;
Core:  255 devices, 31 uclasses, devicetree: separate&lt;br /&gt;
MMC:   STM32 SD/MMC: 2, STM32 SD/MMC: 0, STM32 SD/MMC: 1&lt;br /&gt;
Loading Environment from SPIFlash... SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
OK&lt;br /&gt;
In:    serial&lt;br /&gt;
Out:   serial&lt;br /&gt;
Err:   serial&lt;br /&gt;
Net:   eth0: ethernet@5800a000, eth1: ks8851mll@64000000&lt;br /&gt;
Hit any key to stop autoboot:  0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via SD card ==&lt;br /&gt;
&lt;br /&gt;
Set the disk:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32_DISK=/dev/sdc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Partition a SD card ===&lt;br /&gt;
&lt;br /&gt;
Create partition table and partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
parted --script -- ${STM32_DISK} \&lt;br /&gt;
  mktable gpt \&lt;br /&gt;
  mkpart fsbl1 1MiB 1.25MiB \&lt;br /&gt;
  mkpart fsbl2 2MiB 2.25MiB \&lt;br /&gt;
  mkpart ssbl 3MiB 5MiB \&lt;br /&gt;
  mkpart rootfs ext4 5MiB 100% \&lt;br /&gt;
  set 4 legacy_boot on \&lt;br /&gt;
  unit MiB \&lt;br /&gt;
  print&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Model: Generic STORAGE DEVICE (scsi)&lt;br /&gt;
Disk /dev/sdc: 954MiB&lt;br /&gt;
Sector size (logical/physical): 512B/512B&lt;br /&gt;
Partition Table: gpt&lt;br /&gt;
Disk Flags: &lt;br /&gt;
&lt;br /&gt;
Number  Start    End      Size     File system  Name    Flags&lt;br /&gt;
 1      1.00MiB  1.25MiB  0.25MiB               fsbl1&lt;br /&gt;
 2      2.00MiB  2.25MiB  0.25MiB               fsbl2&lt;br /&gt;
 3      3.00MiB  5.00MiB  2.00MiB               ssbl&lt;br /&gt;
 4      5.00MiB  953MiB   948MiB   ext4         rootfs  legacy_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Redetect partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
partprobe ${STM32_DISK}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create file system on partition 4 ===&lt;br /&gt;
&lt;br /&gt;
Create filesystem on partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkfs.ext4 -m 0 -L rootfs ${STM32_DISK}4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
mke2fs 1.46.2 (28-Feb-2021)&lt;br /&gt;
Creating filesystem with 242688 4k blocks and 60672 inodes&lt;br /&gt;
Filesystem UUID: bda8eff7-aa5a-4ed8-aa53-f22e3a1e3203&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
	32768, 98304, 163840, 229376&lt;br /&gt;
&lt;br /&gt;
Allocating group tables: done                            &lt;br /&gt;
Writing inode tables: done                            &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Write u-boot spl and u-boot to boot partitions 1, 2 and 3:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}1&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}2&lt;br /&gt;
dd if=u-boot.itb of=${STM32_DISK}3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.274919 s, 585 kB/s&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.280309 s, 574 kB/s&lt;br /&gt;
1600+1 records in&lt;br /&gt;
1600+1 records out&lt;br /&gt;
819232 bytes (819 kB, 800 KiB) copied, 0.862246 s, 950 kB/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy u-boot spl and u-boot to directory &amp;lt;code&amp;gt;boot&amp;lt;/code&amp;gt; on rootfs partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p rootfs&lt;br /&gt;
mount ${STM32_DISK}4 rootfs&lt;br /&gt;
mkdir -p rootfs/boot&lt;br /&gt;
cp u-boot-spl.stm32 u-boot.itb rootfs/boot/&lt;br /&gt;
umount rootfs &amp;amp;&amp;amp; rmdir rootfs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Boot from SD card ===&lt;br /&gt;
&lt;br /&gt;
# Hold the button for SD card boot mode on the SODIMM-200 module (DHCOM) below the eMMC chip.&lt;br /&gt;
#:[[File:STM32MP1-Button.jpg|400px]]&lt;br /&gt;
# Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
# Release the button for SD card boot mode&lt;br /&gt;
&lt;br /&gt;
== U-Boot flashing via SD card ==&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[#U-Boot booting via SD card|U-Boot booting via SD card]] to prepare an SD card with a file system on partition 4 that contains the required &amp;lt;code&amp;gt;u-boot-spl.stm32&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;u-boot.itb&amp;lt;/code&amp;gt; binaries.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to SPI-NOR-Flash ===&lt;br /&gt;
&lt;br /&gt;
# Start U-Boot by [[#U-Boot booting via DFU|U-Boot booting via DFU]] or by [[#Boot from SD card|Boot from SD card]]&lt;br /&gt;
# Attach prepared SD card to the on module SD card slot&lt;br /&gt;
# Program U-Boot SPL and U-Boot by the script &amp;lt;code&amp;gt;update_sf&amp;lt;/code&amp;gt; stored in the U-Boot environment.&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP&amp;gt; run update_sf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
160911 bytes read in 80 ms (1.9 MiB/s)&lt;br /&gt;
819232 bytes read in 115 ms (6.8 MiB/s)&lt;br /&gt;
SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
SF: 2097152 bytes @ 0x0 Erased: OK&lt;br /&gt;
device 0 offset 0x0, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.664s, speed 98903 B/s&lt;br /&gt;
device 0 offset 0x40000, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.626s, speed 101211 B/s&lt;br /&gt;
device 0 offset 0x80000, size 0xc8020&lt;br /&gt;
815136 bytes written, 4096 bytes skipped in 8.379s, speed 100094 B/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3740</id>
		<title>U-Boot recovery for STM32MP1 DHSOM via DFU</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3740"/>
		<updated>2022-09-09T06:15:52Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Add text to section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB to temporarily boot U-Boot SPL and U-Boot.&lt;br /&gt;
From this U-Boot shell we can write both bootloader images from the SD card to the boot flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
=== Software ===&lt;br /&gt;
* Linux host computer ([[Virtual Machine for Application Development]] is used in this guide)&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 U-Boot 2022.04] for your board (download and build instructions below)&lt;br /&gt;
* [https://packages.debian.org/stable/dfu-util dfu-util] (for DFU boot mode)&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
* STM32MP1 based DHCOM&lt;br /&gt;
* DHCOM Premium Developer Kit Baseboard (or Baseboards with OTG ports)&lt;br /&gt;
* USB cable for OTG port (Mini USB for PDK2, USB-C for PDK3) (for DFU boot mode)&lt;br /&gt;
* SD card (for SD card boot mode)&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
=== Install dfu-util (debian) ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install dfu-util&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download/Build U-Boot SPL and U-Boot binaries ===&lt;br /&gt;
&lt;br /&gt;
There are two ways to get the required submarine binaries.&lt;br /&gt;
These can either be downloaded or built from the sources by yourself.&lt;br /&gt;
Follow one of the two steps below.&lt;br /&gt;
&lt;br /&gt;
==== Download prebuilt binaries ====&lt;br /&gt;
&lt;br /&gt;
[[media:AACQ30W-7l-Zi_Zutu0Zv-Zua|Dropbox: U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU]] ([https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 source])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
curl -LsS https://www.dropbox.com/sh/os9so01tivajkxs/AACQ30W-7l-Zi_Zutu0Zv-Zua &amp;gt; recovery_binaryies.zip&lt;br /&gt;
unzip recovery_binaryies.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Archive:  recovery_binaryies.zip&lt;br /&gt;
warning:  stripped absolute path spec from /&lt;br /&gt;
mapname:  conversion of  failed&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/av96/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/pdk2/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/drc02/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/picoitx/&lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot-spl.stm32  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Build binaries from source ====&lt;br /&gt;
&lt;br /&gt;
Clone U-Boot mainline source code for release v2022.04:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
UBOOT_SRC=/work/dev/u-boot_v2022.04&lt;br /&gt;
mkdir -p $UBOOT_SRC&lt;br /&gt;
git clone --branch v2022.04 --depth 1 https://source.denx.de/u-boot/u-boot.git $UBOOT_SRC&lt;br /&gt;
cd $UBOOT_SRC&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available U-Boot defconfigs for STM32MP1 based DHSOM devices with default device tree in bold:&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcom_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;pdk2&#039;&#039;&#039;, picoitx, drc02)&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcor_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;avenger96&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /work/dev/u-boot&lt;br /&gt;
git clone https://source.denx.de/u-boot/u-boot.git -b v2022.04 /work/dev/u-boot&lt;br /&gt;
cd /work/dev/u-boot&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make stm32mp15_dhcom_basic_defconfig&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change default device tree (Example for: stm32mp15xx-dhcom-picoitx):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sed -iE &#039;s/(stm32mp15xx-dhcom-pdk2|stm32mp157a-dhcor-avenger96)/stm32mp15xx-dhcom-picoitx/&#039; .config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build linux binaries with all available cores:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SHIPPED dts/dt.dtb&lt;br /&gt;
CAT     u-boot-dtb.bin&lt;br /&gt;
MKIMAGE u-boot.img&lt;br /&gt;
COPY    u-boot.dtb&lt;br /&gt;
MKIMAGE u-boot-dtb.img&lt;br /&gt;
MKIMAGE u-boot.itb&lt;br /&gt;
...&lt;br /&gt;
LD      spl/u-boot-spl&lt;br /&gt;
OBJCOPY spl/u-boot-spl-nodtb.bin&lt;br /&gt;
SYM     spl/u-boot-spl.sym&lt;br /&gt;
CAT     spl/u-boot-spl-dtb.bin&lt;br /&gt;
COPY    spl/u-boot-spl.bin&lt;br /&gt;
BINMAN  all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check that the required binaries have been created and are of the appropriate size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l u-boot.itb u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
-rw-r--r-- 1 devel devel 819720 Apr 11 17:03 u-boot.itb&lt;br /&gt;
-rw-r--r-- 1 devel devel 124288 Apr 11 17:03 u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via DFU ==&lt;br /&gt;
&lt;br /&gt;
To boot U-Boot SPL and U-Boot via DFU boot mode, you must first check if you have a DFU device connected, then load U-Boot SPL into the SRAM of your STM32MP1 and wait until the DRAM is initialized.&lt;br /&gt;
Then load U-Boot in the DRAM of your STM32MP1 and continue the boot process using the shown key combination.&lt;br /&gt;
&lt;br /&gt;
=== Check for available DFU device ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard and check the kernel log for a available DFU device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 2-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00&lt;br /&gt;
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&lt;br /&gt;
usb 2-2: Product: DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000&lt;br /&gt;
usb 2-2: Manufacturer: STMicroelectronics&lt;br /&gt;
usb 2-2: SerialNumber: 0040001D3130510439373430&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot SPL with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot SPL with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 1 -D u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #1 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 1024&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       160911 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from DFU&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; === &lt;br /&gt;
&lt;br /&gt;
Download of U-Boot with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 0 -D u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #0 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 4096&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       819232 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#DOWNLOAD ... OK&lt;br /&gt;
Ctrl+C to exit ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console after pressing &#039;&#039;&#039;Ctrl+C&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
&lt;br /&gt;
CPU: STM32MP157CAA Rev.Z&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Board: stm32mp1 in basic mode (dh,stm32mp15xx-dhcom-pdk2)&lt;br /&gt;
DRAM:  1 GiB&lt;br /&gt;
Clocks:&lt;br /&gt;
- MPU : 650 MHz&lt;br /&gt;
- MCU : 208.878 MHz&lt;br /&gt;
- AXI : 266.500 MHz&lt;br /&gt;
- PER : 24 MHz&lt;br /&gt;
- DDR : 533 MHz&lt;br /&gt;
Core:  255 devices, 31 uclasses, devicetree: separate&lt;br /&gt;
MMC:   STM32 SD/MMC: 2, STM32 SD/MMC: 0, STM32 SD/MMC: 1&lt;br /&gt;
Loading Environment from SPIFlash... SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
OK&lt;br /&gt;
In:    serial&lt;br /&gt;
Out:   serial&lt;br /&gt;
Err:   serial&lt;br /&gt;
Net:   eth0: ethernet@5800a000, eth1: ks8851mll@64000000&lt;br /&gt;
Hit any key to stop autoboot:  0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via SD card ==&lt;br /&gt;
&lt;br /&gt;
Set the disk:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32_DISK=/dev/sdc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Partition a SD card ===&lt;br /&gt;
&lt;br /&gt;
Create partition table and partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
parted --script -- ${STM32_DISK} \&lt;br /&gt;
  mktable gpt \&lt;br /&gt;
  mkpart fsbl1 1MiB 1.25MiB \&lt;br /&gt;
  mkpart fsbl2 2MiB 2.25MiB \&lt;br /&gt;
  mkpart ssbl 3MiB 5MiB \&lt;br /&gt;
  mkpart rootfs ext4 5MiB 100% \&lt;br /&gt;
  set 4 legacy_boot on \&lt;br /&gt;
  unit MiB \&lt;br /&gt;
  print&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Model: Generic STORAGE DEVICE (scsi)&lt;br /&gt;
Disk /dev/sdc: 954MiB&lt;br /&gt;
Sector size (logical/physical): 512B/512B&lt;br /&gt;
Partition Table: gpt&lt;br /&gt;
Disk Flags: &lt;br /&gt;
&lt;br /&gt;
Number  Start    End      Size     File system  Name    Flags&lt;br /&gt;
 1      1.00MiB  1.25MiB  0.25MiB               fsbl1&lt;br /&gt;
 2      2.00MiB  2.25MiB  0.25MiB               fsbl2&lt;br /&gt;
 3      3.00MiB  5.00MiB  2.00MiB               ssbl&lt;br /&gt;
 4      5.00MiB  953MiB   948MiB   ext4         rootfs  legacy_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Redetect partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
partprobe ${STM32_DISK}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create file system on partition 4 ===&lt;br /&gt;
&lt;br /&gt;
Create filesystem on partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkfs.ext4 -m 0 -L rootfs ${STM32_DISK}4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
mke2fs 1.46.2 (28-Feb-2021)&lt;br /&gt;
Creating filesystem with 242688 4k blocks and 60672 inodes&lt;br /&gt;
Filesystem UUID: bda8eff7-aa5a-4ed8-aa53-f22e3a1e3203&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
	32768, 98304, 163840, 229376&lt;br /&gt;
&lt;br /&gt;
Allocating group tables: done                            &lt;br /&gt;
Writing inode tables: done                            &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Write u-boot spl and u-boot to boot partitions 1, 2 and 3:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}1&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}2&lt;br /&gt;
dd if=u-boot.itb of=${STM32_DISK}3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.274919 s, 585 kB/s&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.280309 s, 574 kB/s&lt;br /&gt;
1600+1 records in&lt;br /&gt;
1600+1 records out&lt;br /&gt;
819232 bytes (819 kB, 800 KiB) copied, 0.862246 s, 950 kB/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy u-boot spl and u-boot to directory &amp;lt;code&amp;gt;boot&amp;lt;/code&amp;gt; on rootfs partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p rootfs&lt;br /&gt;
mount ${STM32_DISK}4 rootfs&lt;br /&gt;
mkdir -p rootfs/boot&lt;br /&gt;
cp u-boot-spl.stm32 u-boot.itb rootfs/boot/&lt;br /&gt;
umount rootfs &amp;amp;&amp;amp; rmdir rootfs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Boot from SD card ===&lt;br /&gt;
&lt;br /&gt;
# Hold the button for SD card boot mode on the SODIMM-200 module (DHCOM) below the eMMC chip.&lt;br /&gt;
#:[[File:STM32MP1-Button.jpg|400px]]&lt;br /&gt;
# Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
# Release the button for SD card boot mode&lt;br /&gt;
&lt;br /&gt;
== U-Boot flashing via SD card ==&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[#U-Boot booting via SD card|U-Boot booting via SD card]] to prepare an SD card with a file system on partition 4 that contains the required &amp;lt;code&amp;gt;u-boot-spl.stm32&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;u-boot.itb&amp;lt;/code&amp;gt; binaries.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to SPI-NOR-Flash ===&lt;br /&gt;
&lt;br /&gt;
# Start U-Boot by [[#U-Boot booting via DFU|U-Boot booting via DFU]] or by [[#Boot from SD card|Boot from SD card]]&lt;br /&gt;
# Attach prepared SD card to the on module SD card slot&lt;br /&gt;
# Program U-Boot SPL and U-Boot by the script &amp;lt;code&amp;gt;update_sf&amp;lt;/code&amp;gt; stored in the U-Boot environment.&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP&amp;gt; run update_sf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
160911 bytes read in 80 ms (1.9 MiB/s)&lt;br /&gt;
819232 bytes read in 115 ms (6.8 MiB/s)&lt;br /&gt;
SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
SF: 2097152 bytes @ 0x0 Erased: OK&lt;br /&gt;
device 0 offset 0x0, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.664s, speed 98903 B/s&lt;br /&gt;
device 0 offset 0x40000, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.626s, speed 101211 B/s&lt;br /&gt;
device 0 offset 0x80000, size 0xc8020&lt;br /&gt;
815136 bytes written, 4096 bytes skipped in 8.379s, speed 100094 B/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3739</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3739"/>
		<updated>2022-09-09T06:10:49Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: A Yocto example project would be the best!&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup ==&lt;br /&gt;
&lt;br /&gt;
The following table shows the Support status of our STM32MP1-based DHSOMs in the TF-A, OP-TEE OS and OP-TEE Developer Setup projects.&lt;br /&gt;
This table is also a good starting point for what is required to support custom boards based on the STM32MP1 DHSOM in these projects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup&lt;br /&gt;
|-&lt;br /&gt;
! DHSOM&lt;br /&gt;
! TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt; &lt;br /&gt;
! OP-TEE OS&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup Linux&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup manifest&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157C DHCOM PDK2&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
| under review in [https://github.com/OP-TEE/build/pull/586 pull request 586]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157A DHCOR Avenger96&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
| under review in [https://github.com/OP-TEE/build/pull/586 pull request 586]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3738</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3738"/>
		<updated>2022-09-08T15:45:39Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Fix layout/reference issues and add TODO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: A Yocto example project would be the best!&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup ==&lt;br /&gt;
&lt;br /&gt;
The following table shows the Suuport status of our STM32MP1-based DHSOMs in the TF-A, OP-TEE OS and OP-TEE Developer Setup projects.&lt;br /&gt;
This table is also a good starting point for what is required to support custom boards based on the STM32MP1 DHSOM in these projects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot;&lt;br /&gt;
|+ Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup&lt;br /&gt;
|-&lt;br /&gt;
! DHSOM&lt;br /&gt;
! TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt; &lt;br /&gt;
! OP-TEE OS&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup Linux&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
! OP-TEE developer setup manifest&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157C DHCOM PDK2&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
| under review in [https://github.com/OP-TEE/build/pull/586 pull request 586]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157A DHCOR Avenger96&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
| under review in [https://github.com/OP-TEE/build/pull/586 pull request 586]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3737</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3737"/>
		<updated>2022-09-08T15:39:32Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
== Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup ==&lt;br /&gt;
&lt;br /&gt;
The following table shows the Suuport status of our STM32MP1-based DHSOMs in the TF-A, OP-TEE OS and OP-TEE Developer Setup projects.&lt;br /&gt;
This table is also a good starting point for what is required to support custom boards based on the STM32MP1 DHSOM in these projects.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto&amp;quot; align=&amp;quot;left&amp;quot;&lt;br /&gt;
|+ Support of STM32MP1 DHSOM in TF-A, OP-TEE OS and OP-TEE Developer Setup&lt;br /&gt;
|-&lt;br /&gt;
! DHSOM&lt;br /&gt;
! TF-A&lt;br /&gt;
! OP-TEE OS&lt;br /&gt;
! OP-TEE developer setup&lt;br /&gt;
! OP-TEE developer setup Linux&lt;br /&gt;
! OP-TEE developer setup manifest&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157C DHCOM PDK2&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
| under review in [https://github.com/OP-TEE/build/pull/586 pull request 586]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|-&lt;br /&gt;
! STM32MP157A DHCOR Avenger96&lt;br /&gt;
| upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
| upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
| under review in [https://github.com/OP-TEE/build/pull/586 pull request 586]&lt;br /&gt;
| under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105]&lt;br /&gt;
| preview in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3736</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3736"/>
		<updated>2022-09-08T14:34:23Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/fdts/stm32mp157c-dhcom-pdk2.dts?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
# Add support for STM32MP15 DHCOM in OP-TEE OS &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
# Integrate STM32MP15 DHCOM into OP-TEE developer setup &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: under review in [https://github.com/OP-TEE/build/pull/586 pull request 586] (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://github.com/OP-TEE/build/pull/586 pull request 586] (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# Define Linux OP-TEE ressources for STM32MP15 DHSOM &amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105] (preview available in [https://github.com/jneuhauser/linux/tree/optee-stm32mp1-dhsom branch optee-stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105] (preview available in [https://github.com/jneuhauser/linux/tree/optee-stm32mp1-dhsom branch optee-stm32mp1-dhsom])&lt;br /&gt;
# Update required components in OP-TEE developer setup manifest &amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: waiting for next TF-A release (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: waiting for next TF-A release (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup manifest]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot;&amp;gt;[https://github.com/linaro-swg/linux Linux for OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3735</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3735"/>
		<updated>2022-09-08T14:32:46Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Update status of OP-TEE upstreaming&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/fdts/stm32mp157c-dhcom-pdk2.dts?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
# Add support for STM32MP15 DHCOM in OP-TEE OS &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://github.com/OP-TEE/optee_os/commit/6e9896c08ac4d8e81bb95ba1afa46cf6028fd4df commit 6e9896c0]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: upstreamed in [https://github.com/OP-TEE/optee_os/commit/5c932a03de3f1126c4710b3b6b296eb720746182 commit 5c932a03]&lt;br /&gt;
# Integrate STM32MP15 DHCOM into OP-TEE developer setup &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: under review in [https://github.com/OP-TEE/build/pull/586 pull request 586] (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://github.com/OP-TEE/build/pull/586 pull request 586] (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# Define Linux OP-TEE ressources for STM32MP15 DHSOM &amp;lt;ref name=&amp;quot;linaro-swg/linux&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105] (preview available in [https://github.com/jneuhauser/linux/tree/optee-stm32mp1-dhsom branch optee-stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://github.com/linaro-swg/linux/pull/105 pull request 105] (preview available in [https://github.com/jneuhauser/linux/tree/optee-stm32mp1-dhsom branch optee-stm32mp1-dhsom])&lt;br /&gt;
# Update required components in OP-TEE developer setup manifest &amp;lt;ref name=&amp;quot;OP-TEE/manifest&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: waiting for next TF-A release (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: waiting for next TF-A release (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3734</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3734"/>
		<updated>2022-09-06T06:04:44Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Update status of TF-A upstreaming&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/fdts/stm32mp157c-dhcom-pdk2.dts?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=51e223058fe70b311542178f1865514745fa7874 commit 51e22305]&lt;br /&gt;
# Add support for STM32MP15 DHCOM in OP-TEE OS &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: under review in [https://github.com/OP-TEE/optee_os/pull/5479 pull request 5479] (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://github.com/OP-TEE/optee_os/pull/5479 pull request 5479] (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# Integrate STM32MP15 DHCOM into OP-TEE developer setup &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# OP-TEE OP-TEE developer setup manifest &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3719</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3719"/>
		<updated>2022-08-09T12:29:15Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Update state of OP-TEE mainiling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/fdts/stm32mp157c-dhcom-pdk2.dts?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/15939 change 15939]&lt;br /&gt;
# Add support for STM32MP15 DHCOM in OP-TEE OS &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: under review in [https://github.com/OP-TEE/optee_os/pull/5479 pull request 5479] (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://github.com/OP-TEE/optee_os/pull/5479 pull request 5479] (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# Integrate STM32MP15 DHCOM into OP-TEE developer setup &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# OP-TEE OP-TEE developer setup manifest &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;diff=3717</id>
		<title>Yocto build guide with docker</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;diff=3717"/>
		<updated>2022-07-22T11:02:41Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Initial minimal version&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Page submit URL&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=Yocto_build_guide_with_docker&amp;amp;action=submit&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;!-- Info toclimit-3:&lt;br /&gt;
http://automaten-karl.de/blog/?p=74&lt;br /&gt;
https://www.mediawiki.org/wiki/Template:TOC&lt;br /&gt;
https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss&lt;br /&gt;
https://www.mediawiki.org/wiki/Manual:CSS&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
To build Yocto images you need a powerfull build machine and a lot of time.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
&lt;br /&gt;
* CPU: four cores or more&lt;br /&gt;
* RAM: 16 GB or more&lt;br /&gt;
* HDD/SSD: from 25 GB to 100 GB free space (depends on included features)&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
&lt;br /&gt;
* Linux OS&lt;br /&gt;
* Docker&lt;br /&gt;
&lt;br /&gt;
= Start your build environment =&lt;br /&gt;
&lt;br /&gt;
The following two examples show how to create yocto images using the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas&amp;lt;/syntaxhighlight&amp;gt; container or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas-container&amp;lt;/syntaxhighlight&amp;gt; script.&lt;br /&gt;
&lt;br /&gt;
In the following examples, we use the meta-dhsom-stm32-bsp layer as the top layer for creating images for the STM32MP15 DHSOM family with our baseboards.&lt;br /&gt;
If you have your own layer on top because you have a custom DHSOM baseboard, then you must replace meta-dhsom-stm32-bsp with your own layer in all commands.&lt;br /&gt;
&lt;br /&gt;
See the documentation for how to use the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;kas&amp;lt;/syntaxhighlight&amp;gt; tool:&lt;br /&gt;
* https://kas.readthedocs.io/en/latest/userguide.html&lt;br /&gt;
* https://kas.readthedocs.io/en/latest/command-line.html&lt;br /&gt;
&lt;br /&gt;
== Docker container based bash shell ==&lt;br /&gt;
&lt;br /&gt;
Preparation:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export KAS_WORK_DIR=/mnt/work/yocto&lt;br /&gt;
export KAS_BUILD_DIR=/mnt/build/yocto&lt;br /&gt;
&lt;br /&gt;
mkdir -p &amp;quot;${KAS_WORK_DIR}&amp;quot; &amp;quot;${KAS_BUILD_DIR}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cd /path/to/meta-dhsom-stm32-bsp&lt;br /&gt;
&lt;br /&gt;
docker run --rm --interactive --tty --init \&lt;br /&gt;
	--env TERM=&amp;quot;xterm-256color&amp;quot; \&lt;br /&gt;
	--env USER_ID=&amp;quot;$(id -u)&amp;quot; --env GROUP_ID=&amp;quot;$(id -g)&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${KAS_BUILD_DIR}&amp;quot;:&amp;quot;${KAS_BUILD_DIR}&amp;quot;:rw \&lt;br /&gt;
	--env KAS_BUILD_DIR=&amp;quot;${KAS_BUILD_DIR}&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${KAS_WORK_DIR}&amp;quot;:&amp;quot;${KAS_WORK_DIR}&amp;quot;:rw \&lt;br /&gt;
	--env KAS_WORK_DIR=&amp;quot;${KAS_WORK_DIR}&amp;quot; \&lt;br /&gt;
	--volume &amp;quot;${PWD}&amp;quot;:&amp;quot;${PWD}&amp;quot;:rw \&lt;br /&gt;
	--workdir=&amp;quot;${PWD}&amp;quot; \&lt;br /&gt;
	ghcr.io/siemens/kas/kas:latest-release \&lt;br /&gt;
	/bin/bash&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/meta-dhsom-stm32-bsp/kas&lt;br /&gt;
kas menu&lt;br /&gt;
kas build&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Docker container based kas tool ==&lt;br /&gt;
&lt;br /&gt;
Preparation:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
wget -O kas-container https://github.com/siemens/kas/raw/master/kas-container&lt;br /&gt;
chmod +x kas-container&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/meta-dhsom-stm32-bsp/kas&lt;br /&gt;
/path/to/kas-container menu&lt;br /&gt;
/path/to/kas-container build&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3716</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3716"/>
		<updated>2022-07-18T13:31:02Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Remove one useless subsection&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Abbreviations ==&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
== Basic and trusted boot in the context of Secure Boot ==&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Basic Boot with BootROM authentication and Verified Boot =&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
== Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
=== Technical details of Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== In-depth references for Verified Boot ===&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Flatten Image Tree ====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== Verified Boot ====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==== ECDSA signature verification ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
== Tutorial: Secure boot from BootROM to Linux with basic boot ==&lt;br /&gt;
&lt;br /&gt;
=== System requirements and needed tools ===&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add STM32CubeProrammer binaries to user environment ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Intended use of the four generated key pairs ===&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Created/Modified files in the U-Boot source for Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Build Verified Boot enabled U-Boot SPL and U-Boot ===&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
==== Checkout source code for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Generate key pair and sign U-Boot SPL for BootROM authentication ===&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; ====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to your boot media ===&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to an SD card ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to the eMMC ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enroll, test and enforce BootROM image authentication ===&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
==== Program public key hash to eFuses ====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
===== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Test BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/fdts/stm32mp157c-dhcom-pdk2.dts?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/15939 change 15939]&lt;br /&gt;
# Add support for STM32MP15 DHCOM in OP-TEE OS &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# Integrate STM32MP15 DHCOM into OP-TEE developer setup &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# OP-TEE OP-TEE developer setup manifest &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
&lt;br /&gt;
= Examples for Flatten Image Tree Source files =&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3715</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3715"/>
		<updated>2022-07-18T13:25:34Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* References */  Update OP-TEE developer setup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
=== Basic and trusted boot in the context of Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add STM32CubeProrammer binaries to user environment ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/fdts/stm32mp157c-dhcom-pdk2.dts?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/15939 change 15939]&lt;br /&gt;
# Add support for STM32MP15 DHCOM in OP-TEE OS &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# Integrate STM32MP15 DHCOM into OP-TEE developer setup &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# OP-TEE OP-TEE developer setup manifest &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
&lt;br /&gt;
== Examples for Flatten Image Tree Source files ==&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build OP-TEE developer setup]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3714</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3714"/>
		<updated>2022-07-18T13:21:17Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE */  Update TF-A and OP-TEE progress&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
=== Basic and trusted boot in the context of Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add STM32CubeProrammer binaries to user environment ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in TF-A&amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: upstreamed in [https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/fdts/stm32mp157c-dhcom-pdk2.dts?id=eef485abb13b6df9a94137edd82904aab0ecf02d commit eef485ab]&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: under review in [https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/15939 change 15939]&lt;br /&gt;
# Add support for STM32MP15 DHCOM in OP-TEE OS &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_os/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# Integrate STM32MP15 DHCOM into OP-TEE developer setup &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_build/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
# OP-TEE OP-TEE developer setup manifest &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
## STM32MP157C DHCOM on PDK2 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
## STM32MP157A DHCOR SoM on Avenger96 baseboard: work in progress (preview available in [https://github.com/jneuhauser/optee_manifest/tree/dev/stm32mp1-dhsom branch dev/stm32mp1-dhsom])&lt;br /&gt;
&lt;br /&gt;
== Examples for Flatten Image Tree Source files ==&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3701</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3701"/>
		<updated>2022-06-27T09:57:57Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Program public key hash to eFuses: Add note about command preference&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
=== Basic and trusted boot in the context of Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add STM32CubeProrammer binaries to user environment ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: If you have any problems with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command use the manual procedure with the generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command in the next section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:blue&amp;quot;&amp;gt;Note: Use this manual procedure only if you have problems with the simpler &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command from the previous section.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples for Flatten Image Tree Source files ==&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3700</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3700"/>
		<updated>2022-06-27T09:08:10Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Add FIT-Source examples section with a single example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
=== Basic and trusted boot in the context of Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add STM32CubeProrammer binaries to user environment ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples for Flatten Image Tree Source files ==&lt;br /&gt;
&lt;br /&gt;
Example for a FIT-Source file with signed Linux, ramdisk and two device trees / configurations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/dts-v1/;&lt;br /&gt;
&lt;br /&gt;
/ {&lt;br /&gt;
	description = &amp;quot;Linux, Ramdisk and FDT for STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
	#address-cells = &amp;lt;1&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
	images {&lt;br /&gt;
		linux {&lt;br /&gt;
			description = &amp;quot;Linux STM32MP1 DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/Image.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;kernel&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			/* Image compressed with gzip and decrompressed by U-Boot */&lt;br /&gt;
			compression = &amp;quot;gzip&amp;quot;;&lt;br /&gt;
			load = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			entry = &amp;lt;0xc0008000&amp;gt;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		ramdisk {&lt;br /&gt;
			description = &amp;quot;RootFS Ramdisk DHSOM&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/rootfs/ramdisk.cpio.gz&amp;quot;);&lt;br /&gt;
			type = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			os = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			/* ramdisk.cpio compressed with gzip and decrompressed by Linux instead of by U-Boot */&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		fdt-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;FDT STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			data = /incbin/(&amp;quot;/work/dev/linux/dev-5.10.y_dhsom/arch/arm/boot/dts/stm32mp157c-dhcom-picoitx.dtb&amp;quot;);&lt;br /&gt;
			type = &amp;quot;flat_dt&amp;quot;;&lt;br /&gt;
			arch = &amp;quot;arm&amp;quot;;&lt;br /&gt;
			compression = &amp;quot;none&amp;quot;;&lt;br /&gt;
			hash-1 {&lt;br /&gt;
				algo = &amp;quot;sha256&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_IMG&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	configurations {&lt;br /&gt;
		default = &amp;quot;config-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-pdk2 {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM Premium Developer Kit (2)&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-pdk2&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		config-stm32mp157c-dhcom-picoitx {&lt;br /&gt;
			description = &amp;quot;STM32MP157C DHCOM PicoITX&amp;quot;;&lt;br /&gt;
			kernel = &amp;quot;linux&amp;quot;;&lt;br /&gt;
			ramdisk = &amp;quot;ramdisk&amp;quot;;&lt;br /&gt;
			fdt = &amp;quot;fdt-stm32mp157c-dhcom-picoitx&amp;quot;;&lt;br /&gt;
			signature-1 {&lt;br /&gt;
				algo = &amp;quot;sha256,KEY_ALGO&amp;quot;;&lt;br /&gt;
				key-name-hint = &amp;quot;KEY_NAME_SSBL_CFG&amp;quot;;&lt;br /&gt;
				sign-images = &amp;quot;kernel&amp;quot;, &amp;quot;ramdisk&amp;quot;, &amp;quot;fdt&amp;quot;;&lt;br /&gt;
			};&lt;br /&gt;
		};&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM&amp;diff=3675</id>
		<title>U-Boot recovery for STM32MP1 DHSOM</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM&amp;diff=3675"/>
		<updated>2022-04-14T09:51:53Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Created page with &amp;quot;To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB or the SD card boot mode to temporarily boot U-...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB or the SD card boot mode to temporarily boot U-Boot SPL and U-Boot.&lt;br /&gt;
From this U-Boot shell we can write both bootloader images from the SD card to the boot flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
=== Software ===&lt;br /&gt;
* Linux host computer ([[Virtual Machine for Application Development]] is used in this guide)&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 U-Boot 2022.04] for your board (download and build instructions below)&lt;br /&gt;
* [https://packages.debian.org/stable/dfu-util dfu-util] (for DFU boot mode)&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
* STM32MP1 based DHCOM&lt;br /&gt;
* DHCOM Premium Developer Kit Baseboard (or Baseboards with OTG ports)&lt;br /&gt;
* USB cable for OTG port (Mini USB for PDK2, USB-C for PDK3) (for DFU boot mode)&lt;br /&gt;
* SD card (for SD card boot mode)&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
=== Install dfu-util (debian) ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install dfu-util&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download/Build U-Boot SPL and U-Boot binaries ===&lt;br /&gt;
&lt;br /&gt;
==== Download prebuilt binaries ====&lt;br /&gt;
&lt;br /&gt;
[[media:AACQ30W-7l-Zi_Zutu0Zv-Zua|Dropbox: U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU]] ([https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 source])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
curl -LsS https://www.dropbox.com/sh/os9so01tivajkxs/AACQ30W-7l-Zi_Zutu0Zv-Zua &amp;gt; recovery_binaryies.zip&lt;br /&gt;
unzip recovery_binaryies.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Archive:  recovery_binaryies.zip&lt;br /&gt;
warning:  stripped absolute path spec from /&lt;br /&gt;
mapname:  conversion of  failed&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/av96/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/pdk2/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/drc02/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/picoitx/&lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot-spl.stm32  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Build binaries from source ====&lt;br /&gt;
&lt;br /&gt;
Clone U-Boot mainline source code for release v2022.04:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
UBOOT_SRC=/work/dev/u-boot_v2022.04&lt;br /&gt;
mkdir -p $UBOOT_SRC&lt;br /&gt;
git clone --branch v2022.04 --depth 1 https://source.denx.de/u-boot/u-boot.git $UBOOT_SRC&lt;br /&gt;
cd $UBOOT_SRC&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available U-Boot defconfigs for STM32MP1 based DHSOM devices with default device tree in bold:&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcom_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;pdk2&#039;&#039;&#039;, picoitx, drc02)&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcor_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;avenger96&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /work/dev/u-boot&lt;br /&gt;
git clone https://source.denx.de/u-boot/u-boot.git -b v2022.04 /work/dev/u-boot&lt;br /&gt;
cd /work/dev/u-boot&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make stm32mp15_dhcom_basic_defconfig&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change default device tree (Example for: stm32mp15xx-dhcom-picoitx):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sed -iE &#039;s/(stm32mp15xx-dhcom-pdk2|stm32mp157a-dhcor-avenger96)/stm32mp15xx-dhcom-picoitx/&#039; .config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build linux binaries with all available cores:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SHIPPED dts/dt.dtb&lt;br /&gt;
CAT     u-boot-dtb.bin&lt;br /&gt;
MKIMAGE u-boot.img&lt;br /&gt;
COPY    u-boot.dtb&lt;br /&gt;
MKIMAGE u-boot-dtb.img&lt;br /&gt;
MKIMAGE u-boot.itb&lt;br /&gt;
...&lt;br /&gt;
LD      spl/u-boot-spl&lt;br /&gt;
OBJCOPY spl/u-boot-spl-nodtb.bin&lt;br /&gt;
SYM     spl/u-boot-spl.sym&lt;br /&gt;
CAT     spl/u-boot-spl-dtb.bin&lt;br /&gt;
COPY    spl/u-boot-spl.bin&lt;br /&gt;
BINMAN  all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check that the required binaries have been created and are of the appropriate size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l u-boot.itb u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
-rw-r--r-- 1 devel devel 819720 Apr 11 17:03 u-boot.itb&lt;br /&gt;
-rw-r--r-- 1 devel devel 124288 Apr 11 17:03 u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via DFU ==&lt;br /&gt;
&lt;br /&gt;
To boot U-Boot SPL and U-Boot via DFU boot mode, you must first check if you have a DFU device connected, then load U-Boot SPL into the SRAM of your STM32MP1 and wait until the DRAM is initialized.&lt;br /&gt;
Then load U-Boot in the DRAM of your STM32MP1 and continue the boot process using the shown key combination.&lt;br /&gt;
&lt;br /&gt;
=== Check for available DFU device ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard and check the kernel log for a available DFU device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 2-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00&lt;br /&gt;
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&lt;br /&gt;
usb 2-2: Product: DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000&lt;br /&gt;
usb 2-2: Manufacturer: STMicroelectronics&lt;br /&gt;
usb 2-2: SerialNumber: 0040001D3130510439373430&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot SPL with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot SPL with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 1 -D u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #1 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 1024&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       160911 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from DFU&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; === &lt;br /&gt;
&lt;br /&gt;
Download of U-Boot with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 0 -D u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #0 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 4096&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       819232 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#DOWNLOAD ... OK&lt;br /&gt;
Ctrl+C to exit ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console after pressing &#039;&#039;&#039;Ctrl+C&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
&lt;br /&gt;
CPU: STM32MP157CAA Rev.Z&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Board: stm32mp1 in basic mode (dh,stm32mp15xx-dhcom-pdk2)&lt;br /&gt;
DRAM:  1 GiB&lt;br /&gt;
Clocks:&lt;br /&gt;
- MPU : 650 MHz&lt;br /&gt;
- MCU : 208.878 MHz&lt;br /&gt;
- AXI : 266.500 MHz&lt;br /&gt;
- PER : 24 MHz&lt;br /&gt;
- DDR : 533 MHz&lt;br /&gt;
Core:  255 devices, 31 uclasses, devicetree: separate&lt;br /&gt;
MMC:   STM32 SD/MMC: 2, STM32 SD/MMC: 0, STM32 SD/MMC: 1&lt;br /&gt;
Loading Environment from SPIFlash... SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
OK&lt;br /&gt;
In:    serial&lt;br /&gt;
Out:   serial&lt;br /&gt;
Err:   serial&lt;br /&gt;
Net:   eth0: ethernet@5800a000, eth1: ks8851mll@64000000&lt;br /&gt;
Hit any key to stop autoboot:  0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via SD card ==&lt;br /&gt;
&lt;br /&gt;
Set the disk:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32_DISK=/dev/sdc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Partition a SD card ===&lt;br /&gt;
&lt;br /&gt;
Create partition table and partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
parted --script -- ${STM32_DISK} \&lt;br /&gt;
  mktable gpt \&lt;br /&gt;
  mkpart fsbl1 1MiB 1.25MiB \&lt;br /&gt;
  mkpart fsbl2 2MiB 2.25MiB \&lt;br /&gt;
  mkpart ssbl 3MiB 5MiB \&lt;br /&gt;
  mkpart rootfs ext4 5MiB 100% \&lt;br /&gt;
  set 4 legacy_boot on \&lt;br /&gt;
  unit MiB \&lt;br /&gt;
  print&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Model: Generic STORAGE DEVICE (scsi)&lt;br /&gt;
Disk /dev/sdc: 954MiB&lt;br /&gt;
Sector size (logical/physical): 512B/512B&lt;br /&gt;
Partition Table: gpt&lt;br /&gt;
Disk Flags: &lt;br /&gt;
&lt;br /&gt;
Number  Start    End      Size     File system  Name    Flags&lt;br /&gt;
 1      1.00MiB  1.25MiB  0.25MiB               fsbl1&lt;br /&gt;
 2      2.00MiB  2.25MiB  0.25MiB               fsbl2&lt;br /&gt;
 3      3.00MiB  5.00MiB  2.00MiB               ssbl&lt;br /&gt;
 4      5.00MiB  953MiB   948MiB   ext4         rootfs  legacy_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Redetect partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
partprobe ${STM32_DISK}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create file system on partition 4 ===&lt;br /&gt;
&lt;br /&gt;
Create filesystem on partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkfs.ext4 -m 0 -L rootfs ${STM32_DISK}4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
mke2fs 1.46.2 (28-Feb-2021)&lt;br /&gt;
Creating filesystem with 242688 4k blocks and 60672 inodes&lt;br /&gt;
Filesystem UUID: bda8eff7-aa5a-4ed8-aa53-f22e3a1e3203&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
	32768, 98304, 163840, 229376&lt;br /&gt;
&lt;br /&gt;
Allocating group tables: done                            &lt;br /&gt;
Writing inode tables: done                            &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Write u-boot spl and u-boot to boot partitions 1, 2 and 3:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}1&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}2&lt;br /&gt;
dd if=u-boot.itb of=${STM32_DISK}3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.274919 s, 585 kB/s&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.280309 s, 574 kB/s&lt;br /&gt;
1600+1 records in&lt;br /&gt;
1600+1 records out&lt;br /&gt;
819232 bytes (819 kB, 800 KiB) copied, 0.862246 s, 950 kB/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy u-boot spl and u-boot to directory &amp;lt;code&amp;gt;boot&amp;lt;/code&amp;gt; on rootfs partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p rootfs&lt;br /&gt;
mount ${STM32_DISK}4 rootfs&lt;br /&gt;
mkdir -p rootfs/boot&lt;br /&gt;
cp u-boot-spl.stm32 u-boot.itb rootfs/boot/&lt;br /&gt;
umount rootfs &amp;amp;&amp;amp; rmdir rootfs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Boot from SD card ===&lt;br /&gt;
&lt;br /&gt;
# Hold the button for SD card boot mode on the SODIMM-200 module (DHCOM) below the eMMC chip.&lt;br /&gt;
#:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
# Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
# Release the button for SD card boot mode&lt;br /&gt;
&lt;br /&gt;
== U-Boot flashing via SD card ==&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[#U-Boot booting via SD card|U-Boot booting via SD card]] to prepare an SD card with a file system on partition 4 that contains the required &amp;lt;code&amp;gt;u-boot-spl.stm32&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;u-boot.itb&amp;lt;/code&amp;gt; binaries.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to SPI-NOR-Flash ===&lt;br /&gt;
&lt;br /&gt;
# Start U-Boot by [[#U-Boot booting via DFU|U-Boot booting via DFU]] or by [[#Boot from SD card|Boot from SD card]]&lt;br /&gt;
# Attach prepared SD card to the on module SD card slot&lt;br /&gt;
# Program U-Boot SPL and U-Boot by the script &amp;lt;code&amp;gt;update_sf&amp;lt;/code&amp;gt; stored in the U-Boot environment.&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP&amp;gt; run update_sf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
160911 bytes read in 80 ms (1.9 MiB/s)&lt;br /&gt;
819232 bytes read in 115 ms (6.8 MiB/s)&lt;br /&gt;
SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
SF: 2097152 bytes @ 0x0 Erased: OK&lt;br /&gt;
device 0 offset 0x0, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.664s, speed 98903 B/s&lt;br /&gt;
device 0 offset 0x40000, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.626s, speed 101211 B/s&lt;br /&gt;
device 0 offset 0x80000, size 0xc8020&lt;br /&gt;
815136 bytes written, 4096 bytes skipped in 8.379s, speed 100094 B/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3674</id>
		<title>U-Boot recovery for STM32MP1 DHSOM via DFU</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3674"/>
		<updated>2022-04-14T09:50:37Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Write U-Boot SPL and U-Boot to the SD card */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB to temporarily boot U-Boot SPL and U-Boot.&lt;br /&gt;
From this U-Boot shell we can write both bootloader images from the SD card to the boot flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
=== Software ===&lt;br /&gt;
* Linux host computer ([[Virtual Machine for Application Development]] is used in this guide)&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 U-Boot 2022.04] for your board (download and build instructions below)&lt;br /&gt;
* [https://packages.debian.org/stable/dfu-util dfu-util] (for DFU boot mode)&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
* STM32MP1 based DHCOM&lt;br /&gt;
* DHCOM Premium Developer Kit Baseboard (or Baseboards with OTG ports)&lt;br /&gt;
* USB cable for OTG port (Mini USB for PDK2, USB-C for PDK3) (for DFU boot mode)&lt;br /&gt;
* SD card (for SD card boot mode)&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
=== Install dfu-util (debian) ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install dfu-util&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download/Build U-Boot SPL and U-Boot binaries ===&lt;br /&gt;
&lt;br /&gt;
==== Download prebuilt binaries ====&lt;br /&gt;
&lt;br /&gt;
[[media:AACQ30W-7l-Zi_Zutu0Zv-Zua|Dropbox: U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU]] ([https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 source])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
curl -LsS https://www.dropbox.com/sh/os9so01tivajkxs/AACQ30W-7l-Zi_Zutu0Zv-Zua &amp;gt; recovery_binaryies.zip&lt;br /&gt;
unzip recovery_binaryies.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Archive:  recovery_binaryies.zip&lt;br /&gt;
warning:  stripped absolute path spec from /&lt;br /&gt;
mapname:  conversion of  failed&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/av96/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/pdk2/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/drc02/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/picoitx/&lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot-spl.stm32  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Build binaries from source ====&lt;br /&gt;
&lt;br /&gt;
Clone U-Boot mainline source code for release v2022.04:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
UBOOT_SRC=/work/dev/u-boot_v2022.04&lt;br /&gt;
mkdir -p $UBOOT_SRC&lt;br /&gt;
git clone --branch v2022.04 --depth 1 https://source.denx.de/u-boot/u-boot.git $UBOOT_SRC&lt;br /&gt;
cd $UBOOT_SRC&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available U-Boot defconfigs for STM32MP1 based DHSOM devices with default device tree in bold:&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcom_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;pdk2&#039;&#039;&#039;, picoitx, drc02)&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcor_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;avenger96&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /work/dev/u-boot&lt;br /&gt;
git clone https://source.denx.de/u-boot/u-boot.git -b v2022.04 /work/dev/u-boot&lt;br /&gt;
cd /work/dev/u-boot&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make stm32mp15_dhcom_basic_defconfig&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change default device tree (Example for: stm32mp15xx-dhcom-picoitx):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sed -iE &#039;s/(stm32mp15xx-dhcom-pdk2|stm32mp157a-dhcor-avenger96)/stm32mp15xx-dhcom-picoitx/&#039; .config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build linux binaries with all available cores:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SHIPPED dts/dt.dtb&lt;br /&gt;
CAT     u-boot-dtb.bin&lt;br /&gt;
MKIMAGE u-boot.img&lt;br /&gt;
COPY    u-boot.dtb&lt;br /&gt;
MKIMAGE u-boot-dtb.img&lt;br /&gt;
MKIMAGE u-boot.itb&lt;br /&gt;
...&lt;br /&gt;
LD      spl/u-boot-spl&lt;br /&gt;
OBJCOPY spl/u-boot-spl-nodtb.bin&lt;br /&gt;
SYM     spl/u-boot-spl.sym&lt;br /&gt;
CAT     spl/u-boot-spl-dtb.bin&lt;br /&gt;
COPY    spl/u-boot-spl.bin&lt;br /&gt;
BINMAN  all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check that the required binaries have been created and are of the appropriate size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l u-boot.itb u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
-rw-r--r-- 1 devel devel 819720 Apr 11 17:03 u-boot.itb&lt;br /&gt;
-rw-r--r-- 1 devel devel 124288 Apr 11 17:03 u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via DFU ==&lt;br /&gt;
&lt;br /&gt;
To boot U-Boot SPL and U-Boot via DFU boot mode, you must first check if you have a DFU device connected, then load U-Boot SPL into the SRAM of your STM32MP1 and wait until the DRAM is initialized.&lt;br /&gt;
Then load U-Boot in the DRAM of your STM32MP1 and continue the boot process using the shown key combination.&lt;br /&gt;
&lt;br /&gt;
=== Check for available DFU device ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard and check the kernel log for a available DFU device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 2-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00&lt;br /&gt;
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&lt;br /&gt;
usb 2-2: Product: DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000&lt;br /&gt;
usb 2-2: Manufacturer: STMicroelectronics&lt;br /&gt;
usb 2-2: SerialNumber: 0040001D3130510439373430&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot SPL with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot SPL with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 1 -D u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #1 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 1024&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       160911 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from DFU&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; === &lt;br /&gt;
&lt;br /&gt;
Download of U-Boot with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 0 -D u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #0 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 4096&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       819232 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#DOWNLOAD ... OK&lt;br /&gt;
Ctrl+C to exit ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console after pressing &#039;&#039;&#039;Ctrl+C&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
&lt;br /&gt;
CPU: STM32MP157CAA Rev.Z&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Board: stm32mp1 in basic mode (dh,stm32mp15xx-dhcom-pdk2)&lt;br /&gt;
DRAM:  1 GiB&lt;br /&gt;
Clocks:&lt;br /&gt;
- MPU : 650 MHz&lt;br /&gt;
- MCU : 208.878 MHz&lt;br /&gt;
- AXI : 266.500 MHz&lt;br /&gt;
- PER : 24 MHz&lt;br /&gt;
- DDR : 533 MHz&lt;br /&gt;
Core:  255 devices, 31 uclasses, devicetree: separate&lt;br /&gt;
MMC:   STM32 SD/MMC: 2, STM32 SD/MMC: 0, STM32 SD/MMC: 1&lt;br /&gt;
Loading Environment from SPIFlash... SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
OK&lt;br /&gt;
In:    serial&lt;br /&gt;
Out:   serial&lt;br /&gt;
Err:   serial&lt;br /&gt;
Net:   eth0: ethernet@5800a000, eth1: ks8851mll@64000000&lt;br /&gt;
Hit any key to stop autoboot:  0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via SD card ==&lt;br /&gt;
&lt;br /&gt;
Set the disk:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32_DISK=/dev/sdc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Partition a SD card ===&lt;br /&gt;
&lt;br /&gt;
Create partition table and partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
parted --script -- ${STM32_DISK} \&lt;br /&gt;
  mktable gpt \&lt;br /&gt;
  mkpart fsbl1 1MiB 1.25MiB \&lt;br /&gt;
  mkpart fsbl2 2MiB 2.25MiB \&lt;br /&gt;
  mkpart ssbl 3MiB 5MiB \&lt;br /&gt;
  mkpart rootfs ext4 5MiB 100% \&lt;br /&gt;
  set 4 legacy_boot on \&lt;br /&gt;
  unit MiB \&lt;br /&gt;
  print&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Model: Generic STORAGE DEVICE (scsi)&lt;br /&gt;
Disk /dev/sdc: 954MiB&lt;br /&gt;
Sector size (logical/physical): 512B/512B&lt;br /&gt;
Partition Table: gpt&lt;br /&gt;
Disk Flags: &lt;br /&gt;
&lt;br /&gt;
Number  Start    End      Size     File system  Name    Flags&lt;br /&gt;
 1      1.00MiB  1.25MiB  0.25MiB               fsbl1&lt;br /&gt;
 2      2.00MiB  2.25MiB  0.25MiB               fsbl2&lt;br /&gt;
 3      3.00MiB  5.00MiB  2.00MiB               ssbl&lt;br /&gt;
 4      5.00MiB  953MiB   948MiB   ext4         rootfs  legacy_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Redetect partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
partprobe ${STM32_DISK}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create file system on partition 4 ===&lt;br /&gt;
&lt;br /&gt;
Create filesystem on partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkfs.ext4 -m 0 -L rootfs ${STM32_DISK}4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
mke2fs 1.46.2 (28-Feb-2021)&lt;br /&gt;
Creating filesystem with 242688 4k blocks and 60672 inodes&lt;br /&gt;
Filesystem UUID: bda8eff7-aa5a-4ed8-aa53-f22e3a1e3203&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
	32768, 98304, 163840, 229376&lt;br /&gt;
&lt;br /&gt;
Allocating group tables: done                            &lt;br /&gt;
Writing inode tables: done                            &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Write u-boot spl and u-boot to boot partitions 1, 2 and 3:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}1&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}2&lt;br /&gt;
dd if=u-boot.itb of=${STM32_DISK}3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.274919 s, 585 kB/s&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.280309 s, 574 kB/s&lt;br /&gt;
1600+1 records in&lt;br /&gt;
1600+1 records out&lt;br /&gt;
819232 bytes (819 kB, 800 KiB) copied, 0.862246 s, 950 kB/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy u-boot spl and u-boot to directory &amp;lt;code&amp;gt;boot&amp;lt;/code&amp;gt; on rootfs partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p rootfs&lt;br /&gt;
mount ${STM32_DISK}4 rootfs&lt;br /&gt;
mkdir -p rootfs/boot&lt;br /&gt;
cp u-boot-spl.stm32 u-boot.itb rootfs/boot/&lt;br /&gt;
umount rootfs &amp;amp;&amp;amp; rmdir rootfs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Boot from SD card ===&lt;br /&gt;
&lt;br /&gt;
# Hold the button for SD card boot mode on the SODIMM-200 module (DHCOM) below the eMMC chip.&lt;br /&gt;
#:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
# Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
# Release the button for SD card boot mode&lt;br /&gt;
&lt;br /&gt;
== U-Boot flashing via SD card ==&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[#U-Boot booting via SD card|U-Boot booting via SD card]] to prepare an SD card with a file system on partition 4 that contains the required &amp;lt;code&amp;gt;u-boot-spl.stm32&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;u-boot.itb&amp;lt;/code&amp;gt; binaries.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to SPI-NOR-Flash ===&lt;br /&gt;
&lt;br /&gt;
# Start U-Boot by [[#U-Boot booting via DFU|U-Boot booting via DFU]] or by [[#Boot from SD card|Boot from SD card]]&lt;br /&gt;
# Attach prepared SD card to the on module SD card slot&lt;br /&gt;
# Program U-Boot SPL and U-Boot by the script &amp;lt;code&amp;gt;update_sf&amp;lt;/code&amp;gt; stored in the U-Boot environment.&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP&amp;gt; run update_sf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
160911 bytes read in 80 ms (1.9 MiB/s)&lt;br /&gt;
819232 bytes read in 115 ms (6.8 MiB/s)&lt;br /&gt;
SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
SF: 2097152 bytes @ 0x0 Erased: OK&lt;br /&gt;
device 0 offset 0x0, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.664s, speed 98903 B/s&lt;br /&gt;
device 0 offset 0x40000, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.626s, speed 101211 B/s&lt;br /&gt;
device 0 offset 0x80000, size 0xc8020&lt;br /&gt;
815136 bytes written, 4096 bytes skipped in 8.379s, speed 100094 B/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3673</id>
		<title>U-Boot recovery for STM32MP1 DHSOM via DFU</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3673"/>
		<updated>2022-04-14T09:49:17Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB to temporarily boot U-Boot SPL and U-Boot.&lt;br /&gt;
From this U-Boot shell we can write both bootloader images from the SD card to the boot flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
=== Software ===&lt;br /&gt;
* Linux host computer ([[Virtual Machine for Application Development]] is used in this guide)&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 U-Boot 2022.04] for your board (download and build instructions below)&lt;br /&gt;
* [https://packages.debian.org/stable/dfu-util dfu-util] (for DFU boot mode)&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
* STM32MP1 based DHCOM&lt;br /&gt;
* DHCOM Premium Developer Kit Baseboard (or Baseboards with OTG ports)&lt;br /&gt;
* USB cable for OTG port (Mini USB for PDK2, USB-C for PDK3) (for DFU boot mode)&lt;br /&gt;
* SD card (for SD card boot mode)&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
=== Install dfu-util (debian) ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install dfu-util&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download/Build U-Boot SPL and U-Boot binaries ===&lt;br /&gt;
&lt;br /&gt;
==== Download prebuilt binaries ====&lt;br /&gt;
&lt;br /&gt;
[[media:AACQ30W-7l-Zi_Zutu0Zv-Zua|Dropbox: U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU]] ([https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 source])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
curl -LsS https://www.dropbox.com/sh/os9so01tivajkxs/AACQ30W-7l-Zi_Zutu0Zv-Zua &amp;gt; recovery_binaryies.zip&lt;br /&gt;
unzip recovery_binaryies.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Archive:  recovery_binaryies.zip&lt;br /&gt;
warning:  stripped absolute path spec from /&lt;br /&gt;
mapname:  conversion of  failed&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/av96/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/pdk2/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/drc02/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/picoitx/&lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot-spl.stm32  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Build binaries from source ====&lt;br /&gt;
&lt;br /&gt;
Clone U-Boot mainline source code for release v2022.04:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
UBOOT_SRC=/work/dev/u-boot_v2022.04&lt;br /&gt;
mkdir -p $UBOOT_SRC&lt;br /&gt;
git clone --branch v2022.04 --depth 1 https://source.denx.de/u-boot/u-boot.git $UBOOT_SRC&lt;br /&gt;
cd $UBOOT_SRC&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available U-Boot defconfigs for STM32MP1 based DHSOM devices with default device tree in bold:&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcom_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;pdk2&#039;&#039;&#039;, picoitx, drc02)&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcor_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;avenger96&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /work/dev/u-boot&lt;br /&gt;
git clone https://source.denx.de/u-boot/u-boot.git -b v2022.04 /work/dev/u-boot&lt;br /&gt;
cd /work/dev/u-boot&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make stm32mp15_dhcom_basic_defconfig&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change default device tree (Example for: stm32mp15xx-dhcom-picoitx):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sed -iE &#039;s/(stm32mp15xx-dhcom-pdk2|stm32mp157a-dhcor-avenger96)/stm32mp15xx-dhcom-picoitx/&#039; .config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build linux binaries with all available cores:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SHIPPED dts/dt.dtb&lt;br /&gt;
CAT     u-boot-dtb.bin&lt;br /&gt;
MKIMAGE u-boot.img&lt;br /&gt;
COPY    u-boot.dtb&lt;br /&gt;
MKIMAGE u-boot-dtb.img&lt;br /&gt;
MKIMAGE u-boot.itb&lt;br /&gt;
...&lt;br /&gt;
LD      spl/u-boot-spl&lt;br /&gt;
OBJCOPY spl/u-boot-spl-nodtb.bin&lt;br /&gt;
SYM     spl/u-boot-spl.sym&lt;br /&gt;
CAT     spl/u-boot-spl-dtb.bin&lt;br /&gt;
COPY    spl/u-boot-spl.bin&lt;br /&gt;
BINMAN  all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check that the required binaries have been created and are of the appropriate size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l u-boot.itb u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
-rw-r--r-- 1 devel devel 819720 Apr 11 17:03 u-boot.itb&lt;br /&gt;
-rw-r--r-- 1 devel devel 124288 Apr 11 17:03 u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via DFU ==&lt;br /&gt;
&lt;br /&gt;
To boot U-Boot SPL and U-Boot via DFU boot mode, you must first check if you have a DFU device connected, then load U-Boot SPL into the SRAM of your STM32MP1 and wait until the DRAM is initialized.&lt;br /&gt;
Then load U-Boot in the DRAM of your STM32MP1 and continue the boot process using the shown key combination.&lt;br /&gt;
&lt;br /&gt;
=== Check for available DFU device ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard and check the kernel log for a available DFU device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 2-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00&lt;br /&gt;
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&lt;br /&gt;
usb 2-2: Product: DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000&lt;br /&gt;
usb 2-2: Manufacturer: STMicroelectronics&lt;br /&gt;
usb 2-2: SerialNumber: 0040001D3130510439373430&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot SPL with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot SPL with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 1 -D u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #1 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 1024&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       160911 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from DFU&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; === &lt;br /&gt;
&lt;br /&gt;
Download of U-Boot with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 0 -D u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #0 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 4096&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       819232 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#DOWNLOAD ... OK&lt;br /&gt;
Ctrl+C to exit ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console after pressing &#039;&#039;&#039;Ctrl+C&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
&lt;br /&gt;
CPU: STM32MP157CAA Rev.Z&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Board: stm32mp1 in basic mode (dh,stm32mp15xx-dhcom-pdk2)&lt;br /&gt;
DRAM:  1 GiB&lt;br /&gt;
Clocks:&lt;br /&gt;
- MPU : 650 MHz&lt;br /&gt;
- MCU : 208.878 MHz&lt;br /&gt;
- AXI : 266.500 MHz&lt;br /&gt;
- PER : 24 MHz&lt;br /&gt;
- DDR : 533 MHz&lt;br /&gt;
Core:  255 devices, 31 uclasses, devicetree: separate&lt;br /&gt;
MMC:   STM32 SD/MMC: 2, STM32 SD/MMC: 0, STM32 SD/MMC: 1&lt;br /&gt;
Loading Environment from SPIFlash... SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
OK&lt;br /&gt;
In:    serial&lt;br /&gt;
Out:   serial&lt;br /&gt;
Err:   serial&lt;br /&gt;
Net:   eth0: ethernet@5800a000, eth1: ks8851mll@64000000&lt;br /&gt;
Hit any key to stop autoboot:  0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via SD card ==&lt;br /&gt;
&lt;br /&gt;
Set the disk:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32_DISK=/dev/sdc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Partition a SD card ===&lt;br /&gt;
&lt;br /&gt;
Create partition table and partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
parted --script -- ${STM32_DISK} \&lt;br /&gt;
  mktable gpt \&lt;br /&gt;
  mkpart fsbl1 1MiB 1.25MiB \&lt;br /&gt;
  mkpart fsbl2 2MiB 2.25MiB \&lt;br /&gt;
  mkpart ssbl 3MiB 5MiB \&lt;br /&gt;
  mkpart rootfs ext4 5MiB 100% \&lt;br /&gt;
  set 4 legacy_boot on \&lt;br /&gt;
  unit MiB \&lt;br /&gt;
  print&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Model: Generic STORAGE DEVICE (scsi)&lt;br /&gt;
Disk /dev/sdc: 954MiB&lt;br /&gt;
Sector size (logical/physical): 512B/512B&lt;br /&gt;
Partition Table: gpt&lt;br /&gt;
Disk Flags: &lt;br /&gt;
&lt;br /&gt;
Number  Start    End      Size     File system  Name    Flags&lt;br /&gt;
 1      1.00MiB  1.25MiB  0.25MiB               fsbl1&lt;br /&gt;
 2      2.00MiB  2.25MiB  0.25MiB               fsbl2&lt;br /&gt;
 3      3.00MiB  5.00MiB  2.00MiB               ssbl&lt;br /&gt;
 4      5.00MiB  953MiB   948MiB   ext4         rootfs  legacy_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Redetect partitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
partprobe ${STM32_DISK}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create file system on partition 4 ===&lt;br /&gt;
&lt;br /&gt;
Create filesystem on partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkfs.ext4 -m 0 -L rootfs ${STM32_DISK}4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
mke2fs 1.46.2 (28-Feb-2021)&lt;br /&gt;
Creating filesystem with 242688 4k blocks and 60672 inodes&lt;br /&gt;
Filesystem UUID: bda8eff7-aa5a-4ed8-aa53-f22e3a1e3203&lt;br /&gt;
Superblock backups stored on blocks: &lt;br /&gt;
	32768, 98304, 163840, 229376&lt;br /&gt;
&lt;br /&gt;
Allocating group tables: done                            &lt;br /&gt;
Writing inode tables: done                            &lt;br /&gt;
Creating journal (4096 blocks): done&lt;br /&gt;
Writing superblocks and filesystem accounting information: done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Write u-boot spl and u-boot to boot partitions 1, 2 and 3:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}1&lt;br /&gt;
dd if=u-boot-spl.stm32 of=${STM32_DISK}2&lt;br /&gt;
dd if=u-boot.itb of=${STM32_DISK}3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.274919 s, 585 kB/s&lt;br /&gt;
314+1 records in&lt;br /&gt;
314+1 records out&lt;br /&gt;
160911 bytes (161 kB, 157 KiB) copied, 0.280309 s, 574 kB/s&lt;br /&gt;
1600+1 records in&lt;br /&gt;
1600+1 records out&lt;br /&gt;
819232 bytes (819 kB, 800 KiB) copied, 0.862246 s, 950 kB/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy u-boot spl and u-boot to directory &amp;lt;code&amp;gt;boot&amp;lt;/code&amp;gt; on rootfs partition 4:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p rootfs&lt;br /&gt;
mount ${STM32_DISK}4 rootfs&lt;br /&gt;
mkdir -p rootfs/boot&lt;br /&gt;
cp u-boot-spl.stm32 u-boot.itb rootfs/boot/&lt;br /&gt;
umount rootfs &amp;amp;&amp;amp; rmdir rootfs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Boot from SD card ===&lt;br /&gt;
&lt;br /&gt;
# Hold the button for SD card boot mode on the SODIMM-200 module (DHCOM) below the eMMC chip.&lt;br /&gt;
#:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
# Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
# Release the button for SD card boot mode&lt;br /&gt;
&lt;br /&gt;
== U-Boot flashing via SD card ==&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to the SD card ===&lt;br /&gt;
&lt;br /&gt;
Follow the instruction in [[#U-Boot booting via SD card|U-Boot booting via SD card]] to prepare a SD card with a file system on partition 4, which contains the required binaries &amp;lt;code&amp;gt;u-boot-spl.stm32&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;u-boot.itb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Write U-Boot SPL and U-Boot to SPI-NOR-Flash ===&lt;br /&gt;
&lt;br /&gt;
# Start U-Boot by [[#U-Boot booting via DFU|U-Boot booting via DFU]] or by [[#Boot from SD card|Boot from SD card]]&lt;br /&gt;
# Attach prepared SD card to the on module SD card slot&lt;br /&gt;
# Program U-Boot SPL and U-Boot by the script &amp;lt;code&amp;gt;update_sf&amp;lt;/code&amp;gt; stored in the U-Boot environment.&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP&amp;gt; run update_sf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
#:&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
160911 bytes read in 80 ms (1.9 MiB/s)&lt;br /&gt;
819232 bytes read in 115 ms (6.8 MiB/s)&lt;br /&gt;
SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
SF: 2097152 bytes @ 0x0 Erased: OK&lt;br /&gt;
device 0 offset 0x0, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.664s, speed 98903 B/s&lt;br /&gt;
device 0 offset 0x40000, size 0x2748f&lt;br /&gt;
160911 bytes written, 0 bytes skipped in 1.626s, speed 101211 B/s&lt;br /&gt;
device 0 offset 0x80000, size 0xc8020&lt;br /&gt;
815136 bytes written, 4096 bytes skipped in 8.379s, speed 100094 B/s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3672</id>
		<title>U-Boot recovery for STM32MP1 DHSOM via DFU</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3672"/>
		<updated>2022-04-14T09:12:32Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: /* Check for available DFU device */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB to temporarily boot U-Boot SPL and U-Boot.&lt;br /&gt;
From this U-Boot shell we can write both bootloader images from the SD card to the boot flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
=== Software ===&lt;br /&gt;
* Linux host computer ([[Virtual Machine for Application Development]] is used in this guide)&lt;br /&gt;
* [https://packages.debian.org/stable/dfu-util dfu-util]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 U-Boot 2022.04] for your board (download and build instructions below)&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
* STM32MP1 based DHCOM&lt;br /&gt;
* DHCOM Premium Developer Kit Baseboard (or Baseboards with OTG ports)&lt;br /&gt;
* USB cable for OTG port (Mini USB for PDK2, USB-C for PDK3)&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
=== Install dfu-util (debian) ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install dfu-util&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download/Build U-Boot SPL and U-Boot binaries ===&lt;br /&gt;
&lt;br /&gt;
==== Download prebuilt binaries ====&lt;br /&gt;
&lt;br /&gt;
[[media:AACQ30W-7l-Zi_Zutu0Zv-Zua|Dropbox: U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU]] ([https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 source])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
curl -LsS https://www.dropbox.com/sh/os9so01tivajkxs/AACQ30W-7l-Zi_Zutu0Zv-Zua &amp;gt; recovery_binaryies.zip&lt;br /&gt;
unzip recovery_binaryies.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Archive:  recovery_binaryies.zip&lt;br /&gt;
warning:  stripped absolute path spec from /&lt;br /&gt;
mapname:  conversion of  failed&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/av96/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/pdk2/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/drc02/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/picoitx/&lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot-spl.stm32  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Build binaries from source ====&lt;br /&gt;
&lt;br /&gt;
Clone U-Boot mainline source code for release v2022.04:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
UBOOT_SRC=/work/dev/u-boot_v2022.04&lt;br /&gt;
mkdir -p $UBOOT_SRC&lt;br /&gt;
git clone --branch v2022.04 --depth 1 https://source.denx.de/u-boot/u-boot.git $UBOOT_SRC&lt;br /&gt;
cd $UBOOT_SRC&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available U-Boot defconfigs for STM32MP1 based DHSOM devices with default device tree in bold:&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcom_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;pdk2&#039;&#039;&#039;, picoitx, drc02)&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcor_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;avenger96&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /work/dev/u-boot&lt;br /&gt;
git clone https://source.denx.de/u-boot/u-boot.git -b v2022.04 /work/dev/u-boot&lt;br /&gt;
cd /work/dev/u-boot&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make stm32mp15_dhcom_basic_defconfig&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change default device tree (Example for: stm32mp15xx-dhcom-picoitx):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sed -iE &#039;s/(stm32mp15xx-dhcom-pdk2|stm32mp157a-dhcor-avenger96)/stm32mp15xx-dhcom-picoitx/&#039; .config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build linux binaries with all available cores:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SHIPPED dts/dt.dtb&lt;br /&gt;
CAT     u-boot-dtb.bin&lt;br /&gt;
MKIMAGE u-boot.img&lt;br /&gt;
COPY    u-boot.dtb&lt;br /&gt;
MKIMAGE u-boot-dtb.img&lt;br /&gt;
MKIMAGE u-boot.itb&lt;br /&gt;
...&lt;br /&gt;
LD      spl/u-boot-spl&lt;br /&gt;
OBJCOPY spl/u-boot-spl-nodtb.bin&lt;br /&gt;
SYM     spl/u-boot-spl.sym&lt;br /&gt;
CAT     spl/u-boot-spl-dtb.bin&lt;br /&gt;
COPY    spl/u-boot-spl.bin&lt;br /&gt;
BINMAN  all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check that the required binaries have been created and are of the appropriate size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l u-boot.itb u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
-rw-r--r-- 1 devel devel 819720 Apr 11 17:03 u-boot.itb&lt;br /&gt;
-rw-r--r-- 1 devel devel 124288 Apr 11 17:03 u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via DFU ==&lt;br /&gt;
&lt;br /&gt;
To boot U-Boot SPL and U-Boot via DFU boot mode, you must first check if you have a DFU device connected, then load U-Boot SPL into the SRAM of your STM32MP1 and wait until the DRAM is initialized.&lt;br /&gt;
Then load U-Boot in the DRAM of your STM32MP1 and continue the boot process using the shown key combination.&lt;br /&gt;
&lt;br /&gt;
=== Check for available DFU device ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard and check the kernel log for a available DFU device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 2-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00&lt;br /&gt;
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&lt;br /&gt;
usb 2-2: Product: DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000&lt;br /&gt;
usb 2-2: Manufacturer: STMicroelectronics&lt;br /&gt;
usb 2-2: SerialNumber: 0040001D3130510439373430&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot SPL with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot SPL with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 1 -D u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #1 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 1024&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       160911 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from DFU&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; === &lt;br /&gt;
&lt;br /&gt;
Download of U-Boot with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 0 -D u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #0 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 4096&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       819232 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#DOWNLOAD ... OK&lt;br /&gt;
Ctrl+C to exit ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console after pressing &#039;&#039;&#039;Ctrl+C&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
&lt;br /&gt;
CPU: STM32MP157CAA Rev.Z&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Board: stm32mp1 in basic mode (dh,stm32mp15xx-dhcom-pdk2)&lt;br /&gt;
DRAM:  1 GiB&lt;br /&gt;
Clocks:&lt;br /&gt;
- MPU : 650 MHz&lt;br /&gt;
- MCU : 208.878 MHz&lt;br /&gt;
- AXI : 266.500 MHz&lt;br /&gt;
- PER : 24 MHz&lt;br /&gt;
- DDR : 533 MHz&lt;br /&gt;
Core:  255 devices, 31 uclasses, devicetree: separate&lt;br /&gt;
MMC:   STM32 SD/MMC: 2, STM32 SD/MMC: 0, STM32 SD/MMC: 1&lt;br /&gt;
Loading Environment from SPIFlash... SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
OK&lt;br /&gt;
In:    serial&lt;br /&gt;
Out:   serial&lt;br /&gt;
Err:   serial&lt;br /&gt;
Net:   eth0: ethernet@5800a000, eth1: ks8851mll@64000000&lt;br /&gt;
Hit any key to stop autoboot:  0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the DFU procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SD card boot mode (only HS00014) ===&lt;br /&gt;
# Boot in SD card boot mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for SD card boot mode on the SODIMM-200 module (DHCOM) below the eMMC chip.&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for SD card boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the DFU booting procedure&lt;br /&gt;
&lt;br /&gt;
=== Delete U-Boot ===&lt;br /&gt;
# &amp;lt;code&amp;gt;sf probe&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;sf erase 0x0 0xf0000&amp;lt;/code&amp;gt;&lt;br /&gt;
# Restart the board&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the DFU booting procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3671</id>
		<title>U-Boot recovery for STM32MP1 DHSOM via DFU</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&amp;diff=3671"/>
		<updated>2022-04-14T08:50:06Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Created page with &amp;quot;&amp;lt;!-- https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU --&amp;gt;  To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the de...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To recover a corrupted U-Boot on a STM32MP1-based DHCOM, we can use the default fallback boot source DFU via serial link or USB to temporarily boot U-Boot SPL and U-Boot.&lt;br /&gt;
From this U-Boot shell we can write both bootloader images from the SD card to the boot flash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
=== Software ===&lt;br /&gt;
* Linux host computer ([[Virtual Machine for Application Development]] is used in this guide)&lt;br /&gt;
* [https://packages.debian.org/stable/dfu-util dfu-util]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 U-Boot 2022.04] for your board (download and build instructions below)&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
* STM32MP1 based DHCOM&lt;br /&gt;
* DHCOM Premium Developer Kit Baseboard (or Baseboards with OTG ports)&lt;br /&gt;
* USB cable for OTG port (Mini USB for PDK2, USB-C for PDK3)&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
This installation was made on the [[Virtual Machine for Application Development]].&lt;br /&gt;
All console expressions refer to this Debian system, but any other debian based system should also work.&lt;br /&gt;
&lt;br /&gt;
=== Install dfu-util (debian) ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install dfu-util&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download/Build U-Boot SPL and U-Boot binaries ===&lt;br /&gt;
&lt;br /&gt;
==== Download prebuilt binaries ====&lt;br /&gt;
&lt;br /&gt;
[[media:AACQ30W-7l-Zi_Zutu0Zv-Zua|Dropbox: U-Boot_recovery_for_STM32MP1_DHSOM_via_DFU]] ([https://source.denx.de/u-boot/u-boot/-/tree/v2022.04 source])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
curl -LsS https://www.dropbox.com/sh/os9so01tivajkxs/AACQ30W-7l-Zi_Zutu0Zv-Zua &amp;gt; recovery_binaryies.zip&lt;br /&gt;
unzip recovery_binaryies.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Archive:  recovery_binaryies.zip&lt;br /&gt;
warning:  stripped absolute path spec from /&lt;br /&gt;
mapname:  conversion of  failed&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/av96/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/pdk2/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/drc02/&lt;br /&gt;
   creating: U-Boot_v2022.04_mainline/picoitx/&lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot.itb  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/av96/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/pdk2/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/drc02/u-boot-spl.stm32  &lt;br /&gt;
 extracting: U-Boot_v2022.04_mainline/picoitx/u-boot-spl.stm32  &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Build binaries from source ====&lt;br /&gt;
&lt;br /&gt;
Clone U-Boot mainline source code for release v2022.04:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
UBOOT_SRC=/work/dev/u-boot_v2022.04&lt;br /&gt;
mkdir -p $UBOOT_SRC&lt;br /&gt;
git clone --branch v2022.04 --depth 1 https://source.denx.de/u-boot/u-boot.git $UBOOT_SRC&lt;br /&gt;
cd $UBOOT_SRC&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available U-Boot defconfigs for STM32MP1 based DHSOM devices with default device tree in bold:&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcom_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;pdk2&#039;&#039;&#039;, picoitx, drc02)&lt;br /&gt;
* &#039;&#039;&#039;stm32mp15_dhcor_basic_defconfig&#039;&#039;&#039; (&#039;&#039;&#039;avenger96&#039;&#039;&#039;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /work/dev/u-boot&lt;br /&gt;
git clone https://source.denx.de/u-boot/u-boot.git -b v2022.04 /work/dev/u-boot&lt;br /&gt;
cd /work/dev/u-boot&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make stm32mp15_dhcom_basic_defconfig&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change default device tree (Example for: stm32mp15xx-dhcom-picoitx):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sed -iE &#039;s/(stm32mp15xx-dhcom-pdk2|stm32mp157a-dhcor-avenger96)/stm32mp15xx-dhcom-picoitx/&#039; .config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build linux binaries with all available cores:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j$(nproc)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SHIPPED dts/dt.dtb&lt;br /&gt;
CAT     u-boot-dtb.bin&lt;br /&gt;
MKIMAGE u-boot.img&lt;br /&gt;
COPY    u-boot.dtb&lt;br /&gt;
MKIMAGE u-boot-dtb.img&lt;br /&gt;
MKIMAGE u-boot.itb&lt;br /&gt;
...&lt;br /&gt;
LD      spl/u-boot-spl&lt;br /&gt;
OBJCOPY spl/u-boot-spl-nodtb.bin&lt;br /&gt;
SYM     spl/u-boot-spl.sym&lt;br /&gt;
CAT     spl/u-boot-spl-dtb.bin&lt;br /&gt;
COPY    spl/u-boot-spl.bin&lt;br /&gt;
BINMAN  all&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check that the required binaries have been created and are of the appropriate size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
ls -l u-boot.itb u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
-rw-r--r-- 1 devel devel 819720 Apr 11 17:03 u-boot.itb&lt;br /&gt;
-rw-r--r-- 1 devel devel 124288 Apr 11 17:03 u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== U-Boot booting via DFU ==&lt;br /&gt;
&lt;br /&gt;
To boot U-Boot SPL and U-Boot via DFU boot mode, you must first check if you have a DFU device connected, then load U-Boot SPL into the SRAM of your STM32MP1 and wait until the DRAM is initialized.&lt;br /&gt;
Then load U-Boot in the DRAM of your STM32MP1 and continue the boot process using the shown key combination.&lt;br /&gt;
&lt;br /&gt;
=== Check for available DFU device ===&lt;br /&gt;
&lt;br /&gt;
(Re-)Connect the USB cable with your host computer and the OTG port of your baseboard.&lt;br /&gt;
In the kernel log you should see something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo dmesg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
usb 2-2: New USB device found, idVendor=0483, idProduct=df11, bcdDevice= 2.00&lt;br /&gt;
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&lt;br /&gt;
usb 2-2: Product: DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000&lt;br /&gt;
usb 2-2: Manufacturer: STMicroelectronics&lt;br /&gt;
usb 2-2: SerialNumber: 0040001D3130510439373430&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot SPL with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Download of U-Boot SPL with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 1 -D u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #1 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 1024&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       160911 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from DFU&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Download of U-Boot with &amp;lt;code&amp;gt;dfu-util&amp;lt;/code&amp;gt; === &lt;br /&gt;
&lt;br /&gt;
Download of U-Boot with dfu-util to connected device:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util -a 0 -D u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
dfu-util 0.9&lt;br /&gt;
&lt;br /&gt;
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.&lt;br /&gt;
Copyright 2010-2016 Tormod Volden and Stefan Schmidt&lt;br /&gt;
This program is Free Software and has ABSOLUTELY NO WARRANTY&lt;br /&gt;
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/&lt;br /&gt;
&lt;br /&gt;
dfu-util: Invalid DFU suffix signature&lt;br /&gt;
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!&lt;br /&gt;
Opening DFU capable USB device...&lt;br /&gt;
ID 0483:df11&lt;br /&gt;
Run-time device DFU version 0110&lt;br /&gt;
Claiming USB DFU Interface...&lt;br /&gt;
Setting Alternate Setting #0 ...&lt;br /&gt;
Determining device status: state = dfuIDLE, status = 0&lt;br /&gt;
dfuIDLE, continuing&lt;br /&gt;
DFU mode device DFU version 0110&lt;br /&gt;
Device returned transfer size 4096&lt;br /&gt;
Copying data from PC to DFU device&lt;br /&gt;
Download	[=========================] 100%       819232 bytes&lt;br /&gt;
Download done.&lt;br /&gt;
state(7) = dfuMANIFEST, status(0) = No error condition is present&lt;br /&gt;
state(2) = dfuIDLE, status(0) = No error condition is present&lt;br /&gt;
Done!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
#DOWNLOAD ... OK&lt;br /&gt;
Ctrl+C to exit ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output of the serial console after pressing &#039;&#039;&#039;Ctrl+C&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot 2022.04 (Apr 05 2022 - 08:27:30 +0200)&lt;br /&gt;
&lt;br /&gt;
CPU: STM32MP157CAA Rev.Z&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Board: stm32mp1 in basic mode (dh,stm32mp15xx-dhcom-pdk2)&lt;br /&gt;
DRAM:  1 GiB&lt;br /&gt;
Clocks:&lt;br /&gt;
- MPU : 650 MHz&lt;br /&gt;
- MCU : 208.878 MHz&lt;br /&gt;
- AXI : 266.500 MHz&lt;br /&gt;
- PER : 24 MHz&lt;br /&gt;
- DDR : 533 MHz&lt;br /&gt;
Core:  255 devices, 31 uclasses, devicetree: separate&lt;br /&gt;
MMC:   STM32 SD/MMC: 2, STM32 SD/MMC: 0, STM32 SD/MMC: 1&lt;br /&gt;
Loading Environment from SPIFlash... SF: Detected w25q16cl with page size 256 Bytes, erase size 4 KiB, total 2 MiB&lt;br /&gt;
OK&lt;br /&gt;
In:    serial&lt;br /&gt;
Out:   serial&lt;br /&gt;
Err:   serial&lt;br /&gt;
Net:   eth0: ethernet@5800a000, eth1: ks8851mll@64000000&lt;br /&gt;
Hit any key to stop autoboot:  0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If there is a U-Boot starting, the DFU procedure may not work properly.&lt;br /&gt;
There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.&lt;br /&gt;
&lt;br /&gt;
=== SD card boot mode (only HS00014) ===&lt;br /&gt;
# Boot in SD card boot mode to prevent booting the broken U-Boot from SPI-NOR-Flash&lt;br /&gt;
## Hold the button for SD card boot mode on the SODIMM-200 module (DHCOM) below the eMMC chip.&lt;br /&gt;
##:[[File:DHCOR_i.MX6ULL_SDP-Boot.jpg|400px]]&lt;br /&gt;
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.&lt;br /&gt;
## Release the button for SD card boot mode&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the DFU booting procedure&lt;br /&gt;
&lt;br /&gt;
=== Delete U-Boot ===&lt;br /&gt;
# &amp;lt;code&amp;gt;sf probe&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;sf erase 0x0 0xf0000&amp;lt;/code&amp;gt;&lt;br /&gt;
# Restart the board&lt;br /&gt;
# If no new output is printed on the serial console (serial port), continue with the DFU booting procedure&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3662</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3662"/>
		<updated>2022-03-23T08:18:18Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Update U-Boot repository URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
=== Basic and trusted boot in the context of Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add STM32CubeProrammer binaries to user environment ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; from DH electronics GitHub repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/dh-electronics/u-boot-stm32mp1.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add u-boot-stm32mp1 https://github.com/dh-electronics/u-boot-stm32mp1.git&lt;br /&gt;
git fetch u-boot-stm32mp1&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3661</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3661"/>
		<updated>2022-03-22T13:55:16Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Use image files with &amp;quot;-signed&amp;quot; postfix for all commands after signing of u-boot-spl.stm32&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
=== Basic and trusted boot in the context of Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add STM32CubeProrammer binaries to user environment ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Replace my personal GitLab by a public available repository&amp;lt;/div&amp;gt;&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; in my personal GitLab repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@dhplgl01:jneuhauser/u-boot.git -b v2022.01_stm32mp1_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add jneuhauser git@dhplgl01:jneuhauser/u-boot.git&lt;br /&gt;
git fetch jneuhauser&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl-signed.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl-signed.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot-signed.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl-signed.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-signed.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3660</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3660"/>
		<updated>2022-03-22T13:51:27Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Update commands and outputs in &amp;quot;Sign U-Boot SPL with STM32MP_SigningTool_CLI&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
=== Basic and trusted boot in the context of Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add STM32CubeProrammer binaries to user environment ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Replace my personal GitLab by a public available repository&amp;lt;/div&amp;gt;&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; in my personal GitLab repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@dhplgl01:jneuhauser/u-boot.git -b v2022.01_stm32mp1_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add jneuhauser git@dhplgl01:jneuhauser/u-boot.git&lt;br /&gt;
git fetch jneuhauser&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3659</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3659"/>
		<updated>2022-03-22T13:49:52Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Extend table of U-Boot binaries with signed variants and output signed STM32 image with signed postfix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| OP-TEE || Open Portable Trusted Execution Environment&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|-&lt;br /&gt;
| TF-A || Trusted Firmware A&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed during the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is a necessary cornerstone for enforcing security mechanisms in a trusted computing environment.&lt;br /&gt;
Enforcing the execution of signed software only during the boot process, as long as the chain of trust is secure, can guarantee that said software is free from tampering, as any manipulation will invalidate the software&#039;s signature and prevent the software from being executed.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. On success, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
Program code and certificate need to be trustworthy and therefore protected against tampering in each stage, otherwise the secure boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. As this is practically impossible for the first stage, manipulation protection has to be enforced by hardware measures to make said stage immutable, with the first stage&#039;s program code and the verification certificate for the second stage being stored in read-only memory (ROM).&lt;br /&gt;
&lt;br /&gt;
=== Basic and trusted boot in the context of Secure Boot ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#Verified Boot|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== Verified Boot ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes care the signature creation for the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
* swig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Add STM32CubeProrammer binaries to user environment ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
export PATH=${PATH}:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Replace my personal GitLab by a public available repository&amp;lt;/div&amp;gt;&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; in my personal GitLab repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@dhplgl01:jneuhauser/u-boot.git -b v2022.01_stm32mp1_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add jneuhauser git@dhplgl01:jneuhauser/u-boot.git&lt;br /&gt;
git fetch jneuhauser&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with [mailto:info@dh-electronics.com us] and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without errors, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl-signed.stm32 || FSBL || Same as above but as signed STM32 image. Is created in [[#Sign U-Boot SPL with STM32MP_SigningTool_CLI|Sign U-Boot SPL with STM32MP_SigningTool_CLI]].&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a FIT image.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-signed.itb || SSBL || Same as above but with signed configs and images.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoCs only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate a ECDSA key pair for the STM32MP Secure Boot use the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password &amp;lt;a secure password&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password &amp;lt;a secure password&amp;gt; --output /path/to/u-boot/u-boot-spl-signed.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoCs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; per TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3638</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3638"/>
		<updated>2022-03-21T14:58:54Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Add property lang=&amp;quot;shell&amp;quot; to empty syntaxhighlight blocks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Secure Boot? ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed in the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is the necessary cornerstone for enforcing security mechanisms in the overall system.&lt;br /&gt;
If only signed software is executed at system startup, it can also be assumed that the software is free from tampering, comes from a trusted source and the application of security policies always takes place during the boot process.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. If successful, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
The program code and the certificate must be trusted and protected against tampering in each stage, otherwise the boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. Since it is practically impossible to verify the first stage, but this must still be protected against manipulation, the program code for the first stage and the certificate for the verification of the second stage are stored in a ROM, for example.&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Secure Boot with basic/trusted boot? ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC&#039;s with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#What is meant by Verified Boot?|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#What is meant by Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Verified Boot? ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes over the creation of the signatures in the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with the included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Replace my personal GitLab by a public available repository&amp;lt;/div&amp;gt;&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; of my personal GitLab repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@dhplgl01:jneuhauser/u-boot.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add jneuhauser git@dhplgl01:jneuhauser/u-boot.git&lt;br /&gt;
git fetch jneuhauser&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with the script author [mailto:jneuhauser@dh-electronics.com Johann Neuhauser]  and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without error, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a signed FIT image.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoC&#039;s only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate ECDSA key pairs for the STM32MP Secure Boot we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt; to generate a single key pair.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password 12345678&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password 12345678 --output /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoC&#039;s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; by SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; by TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3637</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3637"/>
		<updated>2022-03-21T14:56:57Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Undo revision 3636 by Jneuhauser (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Secure Boot? ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed in the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is the necessary cornerstone for enforcing security mechanisms in the overall system.&lt;br /&gt;
If only signed software is executed at system startup, it can also be assumed that the software is free from tampering, comes from a trusted source and the application of security policies always takes place during the boot process.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. If successful, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
The program code and the certificate must be trusted and protected against tampering in each stage, otherwise the boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. Since it is practically impossible to verify the first stage, but this must still be protected against manipulation, the program code for the first stage and the certificate for the verification of the second stage are stored in a ROM, for example.&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Secure Boot with basic/trusted boot? ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC&#039;s with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#What is meant by Verified Boot?|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#What is meant by Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Verified Boot? ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes over the creation of the signatures in the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with the included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Replace my personal GitLab by a public available repository&amp;lt;/div&amp;gt;&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; of my personal GitLab repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@dhplgl01:jneuhauser/u-boot.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add jneuhauser git@dhplgl01:jneuhauser/u-boot.git&lt;br /&gt;
git fetch jneuhauser&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with the script author [mailto:jneuhauser@dh-electronics.com Johann Neuhauser]  and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without error, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a signed FIT image.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoC&#039;s only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate ECDSA key pairs for the STM32MP Secure Boot we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt; to generate a single key pair.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password 12345678&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password 12345678 --output /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoC&#039;s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; by SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; by TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3636</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3636"/>
		<updated>2022-03-21T14:54:33Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Add property lang=&amp;quot;bash&amp;quot; to empty syntaxhighlight blocks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Secure Boot? ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed in the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is the necessary cornerstone for enforcing security mechanisms in the overall system.&lt;br /&gt;
If only signed software is executed at system startup, it can also be assumed that the software is free from tampering, comes from a trusted source and the application of security policies always takes place during the boot process.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. If successful, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
The program code and the certificate must be trusted and protected against tampering in each stage, otherwise the boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. Since it is practically impossible to verify the first stage, but this must still be protected against manipulation, the program code for the first stage and the certificate for the verification of the second stage are stored in a ROM, for example.&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Secure Boot with basic/trusted boot? ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC&#039;s with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#What is meant by Verified Boot?|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#What is meant by Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Verified Boot? ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes over the creation of the signatures in the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with the included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| bash script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Replace my personal GitLab by a public available repository&amp;lt;/div&amp;gt;&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; of my personal GitLab repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@dhplgl01:jneuhauser/u-boot.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add jneuhauser git@dhplgl01:jneuhauser/u-boot.git&lt;br /&gt;
git fetch jneuhauser&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the bash script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with the script author [mailto:jneuhauser@dh-electronics.com Johann Neuhauser]  and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without error, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a signed FIT image.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoC&#039;s only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate ECDSA key pairs for the STM32MP Secure Boot we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt; to generate a single key pair.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password 12345678&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password 12345678 --output /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoC&#039;s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot bash&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot bash&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; by SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; by TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot bash can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3635</id>
		<title>DHCOM STM32MP15 Secure Boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&amp;diff=3635"/>
		<updated>2022-03-21T12:16:23Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Initial page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--&lt;br /&gt;
https://wiki.dh-electronics.com/index.php?title=DHCOM_STM32MP15_Secure_Boot&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--http://automaten-karl.de/blog/?p=74--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Template:TOC--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss--&amp;gt;&lt;br /&gt;
&amp;lt;!--https://www.mediawiki.org/wiki/Manual:CSS--&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toclimit-3&amp;quot;&amp;gt;__TOC__&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Abbreviations ===&lt;br /&gt;
&amp;lt;!--TODO: Check for non listed/used abbreviation--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Abbreviation !! Description&lt;br /&gt;
|-&lt;br /&gt;
| BSI || Bundesamt für Sicherheit in der Informationstechnik&lt;br /&gt;
|-&lt;br /&gt;
| CoM || Computer on module&lt;br /&gt;
|-&lt;br /&gt;
| FIT || Flattened Image Tree&lt;br /&gt;
|-&lt;br /&gt;
| FSBL || Fist Stage Bootloader (TF-A or U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| OTP || One Time Programmable (eFuses)&lt;br /&gt;
|-&lt;br /&gt;
| PKH || Public Key Hash&lt;br /&gt;
|-&lt;br /&gt;
| ROM || Read-Only Memory&lt;br /&gt;
|-&lt;br /&gt;
| RSA || Rivest, Shamir und Adleman (asynchronous encryption)&lt;br /&gt;
|-&lt;br /&gt;
| SHA || Secure Hash Algorithm&lt;br /&gt;
|-&lt;br /&gt;
| SoC || System on chip&lt;br /&gt;
|-&lt;br /&gt;
| SoM || System on module&lt;br /&gt;
|-&lt;br /&gt;
| SSBL || Second Stage Bootloader (U-Boot)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Secure Boot? ===&lt;br /&gt;
&lt;br /&gt;
The term Secure Boot originally comes from the UEFI specification&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot; /&amp;gt; and describes a secure boot process in which only signed software is loaded and executed in the boot process.&lt;br /&gt;
&lt;br /&gt;
Secure Boot is the necessary cornerstone for enforcing security mechanisms in the overall system.&lt;br /&gt;
If only signed software is executed at system startup, it can also be assumed that the software is free from tampering, comes from a trusted source and the application of security policies always takes place during the boot process.&lt;br /&gt;
&lt;br /&gt;
[[File:Secure Boot Generic en.png|600px|Secure Boot Generic]]&lt;br /&gt;
&lt;br /&gt;
The figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]] shows an example of a secure boot process that leads to a reset in the event of an error in the signature check. Each stage uses the certificate and signature to check the origin and integrity of the next stage. If successful, the next stage is executed, and in the event of an error, this always leads to a defined error state. In the simplest case, the certificates are integrated into the binary image of the previous stage.&lt;br /&gt;
&lt;br /&gt;
The program code and the certificate must be trusted and protected against tampering in each stage, otherwise the boot chain can be compromised. Except for the first stage, all binary images are protected against third-party tampering by the signature. Since it is practically impossible to verify the first stage, but this must still be protected against manipulation, the program code for the first stage and the certificate for the verification of the second stage are stored in a ROM, for example.&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Secure Boot with basic/trusted boot? ===&lt;br /&gt;
&lt;br /&gt;
When booting Linux on the STM32MP1 SoC&#039;s with U-Boot SPL and U-Boot only, STM speaks of &amp;quot;Basic Boot&amp;quot;&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
However, if Linux is booted with a combination of TF-A, U-Boot and OP-TEE, STM refers to this as &amp;quot;Trusted Boot&amp;quot;&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Boot chain !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Basic boot || BootROM -&amp;gt; U-Boot SPL -&amp;gt; U-Boot -&amp;gt; Linux&lt;br /&gt;
|-&lt;br /&gt;
| Trusted boot || BootROM -&amp;gt; TF-A -&amp;gt; U-Boot + OP-TEE -&amp;gt; Linux&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Basic Boot with BootROM authentication and Verified Boot ==&lt;br /&gt;
&lt;br /&gt;
This Secure Boot implementation does use the the BootROM integrated image authentication to authenticate the U-Boot SPL as FSBL.&lt;br /&gt;
Authentication of U-Boot as SSBL by the U-Boot SPL and authentication of the Linux kernel, Device Tree and ramdisk by U-Boot is done using the open source implementation [[#What is meant by Verified Boot?|Verified Boot]].&lt;br /&gt;
&amp;lt;!--The authentication of U-Boot as an SSBL image and the Linux kernel, Device Tree and ramdisk is done by the open source [[#What is meant by Verified Boot?|Verified Boot]] implementation of U-Boot itself.--&amp;gt;&lt;br /&gt;
This also means that everything from U-Boot SPL onwards is platform independent, as we do not rely on hardware specific implementations.&lt;br /&gt;
&lt;br /&gt;
=== What is meant by Verified Boot? ===&lt;br /&gt;
&lt;br /&gt;
Developers of Google&#039;s Chromium project worked out a concept for the Verified Boot called Secure Boot mechanism on the basis of the boot loader &amp;quot;Das U-Boot&amp;quot;.&lt;br /&gt;
They use the existing infrastructure of the FIT images and for the system configuration at runtime via a Device Tree.&lt;br /&gt;
The description language for the FIT images was extended by an additional signature node and the Device Tree of the platform was used to store the certificate(s) for the authentication of the images.&lt;br /&gt;
The signature node can be used to sign individual subimages as well as combinations of individual subimages in the FIT image.&lt;br /&gt;
The tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; takes over the creation of the signatures in the FIT images and the addition of the certificate in a Device Tree.&lt;br /&gt;
&lt;br /&gt;
With Verified Boot, the Device Tree with the included public key is integrated into the program image of the stage, which accomplishes the authentication and is thus very similar to the general procedure shown in figure [[Media:Secure Boot Generic en.png|Secure Boot Generic]].&lt;br /&gt;
The number of public keys that can be integrated is theoretically unlimited, but they must be distinguishable by name.&lt;br /&gt;
&lt;br /&gt;
==== Technical details of Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039;&lt;br /&gt;
| Verified Boot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Implementierung&#039;&#039;&#039;&lt;br /&gt;
| Software (Open Source)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Hash algorithms&#039;&#039;&#039;&lt;br /&gt;
|&lt;br /&gt;
* SHA1 (deprecated)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* SHA256&lt;br /&gt;
* SHA384&lt;br /&gt;
* SHA512&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Crypto algorithms&lt;br /&gt;
|&lt;br /&gt;
* RSA2048 (deprecated as of 2024)&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot; /&amp;gt;&lt;br /&gt;
* RSA4096&lt;br /&gt;
&amp;lt;!--TODO: Mention ECDSA limitations--&amp;gt;&lt;br /&gt;
* ECDSA256 (currently limited to U-Boot SPL)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Number of key pairs&#039;&#039;&#039;&lt;br /&gt;
| unlimited&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== In-depth references for Verified Boot ====&lt;br /&gt;
&amp;lt;!--TODO: Use &amp;lt;references group=&amp;quot;XYZ&amp;quot;&amp;gt;&amp;lt;ref group=&amp;quot;A&amp;quot; name=&amp;quot;O&amp;quot;&amp;gt;ABCDEF&amp;lt;/ref&amp;gt;&amp;lt;/references&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Flatten Image Tree =====&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT U-Boot Documentation: doc/uImage.FIT]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/d5934ad7 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add dual format uImage support framework&amp;quot;]&lt;br /&gt;
* ...&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3310c549 U-Boot Commit d5934ad7: &amp;quot;new uImage: Add new uImage format documentation and examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== Verified Boot =====&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/tree/master/doc/uImage.FIT/signature.txt U-Boot Documentation: doc/uImage.FIT/signature.txt]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/3e569a6b U-Boot Commit 3e569a6b: &amp;quot;image: Add signing infrastructure&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/56518e71 U-Boot Commit 56518e71: &amp;quot;image: Support signing of images&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/4d098529 U-Boot Commit 4d098529: &amp;quot;image: Add support for signing of FIT configurations&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===== ECDSA signature verification =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Mention ECDSA limitations&amp;lt;/div&amp;gt;&lt;br /&gt;
Note: This has currently some limitations!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&amp;lt;references group=&amp;quot;Verified Boot ECDSA&amp;quot;&amp;gt;--&amp;gt;&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/928a8be7 U-Boot Commit 928a8be7: &amp;quot;lib: ecdsa: Implement UCLASS_ECDSA verification on target&amp;quot;]&lt;br /&gt;
* [https://source.denx.de/u-boot/u-boot/-/commit/ee870859 U-Boot Commit ee870859: &amp;quot;arm: stm32mp1: Implement ECDSA signature verification&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
=== Tutorial: Secure boot from BootROM to Linux with basic boot ===&lt;br /&gt;
&lt;br /&gt;
==== System requirements and needed tools ====&lt;br /&gt;
&lt;br /&gt;
The following table lists all requirements to create the key pairs and build the signed images with embedded public keys.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Category !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Host operating system&#039;&#039;&#039; ||&lt;br /&gt;
* Linux (Debian 9, Ubuntu 18.04 or higher prefered)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Debian packages&#039;&#039;&#039; ||&lt;br /&gt;
* bison&lt;br /&gt;
* device-tree-compiler&lt;br /&gt;
* flex&lt;br /&gt;
* gcc-arm-linux-gnueabihf (&amp;gt;= gcc 6)&lt;br /&gt;
* git&lt;br /&gt;
* make&lt;br /&gt;
* openssl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;STM32 Tools&#039;&#039;&#039; ||&lt;br /&gt;
* [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer]&lt;br /&gt;
** STM32MP_KeyGen_CLI&lt;br /&gt;
** STM32MP_SigningTool_CLI&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Should we give host setup instructions?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&#039;&#039;&#039;Install debian packages:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install bison device-tree-compiler flex gcc-arm-linux-gnueabihf git make openssl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download and install STM32CubeProgrammer:&#039;&#039;&#039; [https://www.st.com/en/development-tools/stm32cubeprog.html STM32CubeProgrammer].&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Intended use of the four generated key pairs ====&lt;br /&gt;
&lt;br /&gt;
We&#039;ve decided to create and use as few certificates as reasonable to ensure a high level of security.&lt;br /&gt;
Therefore, we chose a separate key pair for each boot stage and also a separate key pair for image and configuration nodes.&lt;br /&gt;
If you&#039;re confused about the difference between image and configuration nodes, head over to [[#Flatten Image Tree|Flatten Image Tree]] to refresh your knowledge.&lt;br /&gt;
The exact purpose of the four key pairs generated for Verified Boot is described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Intended use&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot SPL (U-Boot, Device Tree, firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;fsbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot SPL (U-Boot + Device Tree + firmware)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-img&#039;&#039;&#039; || Authenticate image nodes of FIT images loaded by U-Boot (Kernel, Device Tree, InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ssbl-cfg&#039;&#039;&#039; || Authenticate config nodes of FIT images loaded by U-Boot (Kernel + Device Tree + InitRamFS)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Created/Modified files in the U-Boot source for Verified Boot ====&lt;br /&gt;
&lt;br /&gt;
The created or modified files to build U-Boot with Verified Boot on STM32MP15 are described in the following table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| build_signed_uboot.sh&lt;br /&gt;
| Shell script that automates the creation of key pairs, the modification of FIT source files and Device Tree&#039;s and building of U-Boot SPL and U-Boot.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/u-boot-dhco?.its&lt;br /&gt;
| FIT source files with defined U-Boot image and Device Tree&#039;s for DHSOM platforms.&lt;br /&gt;
|-&lt;br /&gt;
| board/dhelectronics/dh_stm32mp1/linux-dhcom.its&lt;br /&gt;
| Dummy FIT source file with defined dummy kernel image and dummy Device Tree for DHSOM platforms.&amp;lt;br&amp;gt;To avoid relying on a built kernel image on a fixed path, we created this dummy, since adding the public keys with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;mkimage&amp;lt;/syntaxhighlight&amp;gt; requires a valid FIT source file.&lt;br /&gt;
|-&lt;br /&gt;
| configs/stm32mp15_dhco?_secure_defconfig&lt;br /&gt;
| Example U-Boot defconfig&#039;s with enabled &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;CONFIG_SPL_FIT_SIGNATURE&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Build Verified Boot enabled U-Boot SPL and U-Boot ====&lt;br /&gt;
&lt;br /&gt;
To build the U-Boot SPL and U-Boot images, you need to check out the source code and run a build script that automates everything from key generation to image creation and signing.&lt;br /&gt;
&lt;br /&gt;
===== Checkout source code for Verified Boot =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: Replace my personal GitLab by a public available repository&amp;lt;/div&amp;gt;&lt;br /&gt;
Checkout the branch &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;v2022.01_dhcom_secure_boot&amp;lt;/syntaxhighlight&amp;gt; of my personal GitLab repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@dhplgl01:jneuhauser/u-boot.git -b v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already have a cloned U-Boot source code, you can also fetch it into your existing repository with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
git remote add jneuhauser git@dhplgl01:jneuhauser/u-boot.git&lt;br /&gt;
git fetch jneuhauser&lt;br /&gt;
git checkout v2022.01_dhcom_secure_boot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Run the build script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
The shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; included in the U-Boot source performs the following steps.&lt;br /&gt;
# Prebuild U-Boat SPL and U-Boat to build the required tools and Device Tree&#039;s&lt;br /&gt;
# Generate the [[#Intended use of the four generated key pairs|four key pairs]] if not already created&lt;br /&gt;
# Generate/Modify FIT image source files for Linux (dummy) and U-Boot&lt;br /&gt;
# Add public keys to the built Device Tree&#039;s used by U-Boot SPL and U-Boot&lt;br /&gt;
# Rebuild U-Boot SPL and U-Boot with new Device Tree&#039;s containing the public keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script supports the following environment variables to configure the target architecture, the cross compiler, the defconfig, the key algorithm, the key directory, and a key postfix.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Default&lt;br /&gt;
|-&lt;br /&gt;
| ARCH || Target architecture for the U-Boot build || arm&lt;br /&gt;
|-&lt;br /&gt;
| CROSS_COMPILE || Used cross compiler to build U-Boot || arm-linux-gnueabihf-&lt;br /&gt;
|-&lt;br /&gt;
| DEFCONFIG || Used defconfig for the U-Boot build || stm32mp15_dhcom_secure_defconfig&lt;br /&gt;
|-&lt;br /&gt;
| KEY_ALGO || Signature algorithm used for Verified Boot || rsa&lt;br /&gt;
|-&lt;br /&gt;
| KEY_DIR || Directory where the key pairs are stored || ../keys&lt;br /&gt;
|-&lt;br /&gt;
| KEY_POSTFIX || Postfix which is appended to the key names || -$(date +%F)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To perform the steps mentioned above, you just need to run the shell script &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;build_signed_uboot.sh&amp;lt;/syntaxhighlight&amp;gt; like below.&lt;br /&gt;
In this example, we override the default value for &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;KEY_POSTFIX&amp;lt;/syntaxhighlight&amp;gt; with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;-testing&amp;lt;/syntaxhighlight&amp;gt; to append this string to the [[#Intended use of the four generated key pairs|four key file names]].&lt;br /&gt;
The script has debug output enabled by default, which should output all the statements in the script itself and the output of the commands used in the script.&lt;br /&gt;
If you have any problems with the script, feel free to get in touch with the script author [mailto:jneuhauser@dh-electronics.com Johann Neuhauser]  and attach a logfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
cd /path/to/u-boot&lt;br /&gt;
KEY_POSTFIX=&amp;quot;-testing&amp;quot; ./build_signed_uboot.sh | tee build_signed_uboot.log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this process completes without error, there are two boot loader images in the root directory of the U-Boot source.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File name !! Stage !! Description&lt;br /&gt;
|-&lt;br /&gt;
| u-boot-spl.stm32 || FSBL || U-Boot SPL binary with appended Device Tree and prepended STM32 image header&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot; /&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| u-boot.itb || SSBL || U-Boot and Device Tree&#039;s contained in a signed FIT image.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Generate key pair and sign U-Boot SPL for BootROM authentication ====&lt;br /&gt;
&lt;br /&gt;
To sign the U-Boot SPL as SSBL image for authentication with the BootROM we have to use the STM32 tools &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===== Generate key pair with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
All STM32MP15 SoC&#039;s only support one key pair for authenticating images through the BootROM.&lt;br /&gt;
To generate ECDSA key pairs for the STM32MP Secure Boot we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_KeyGen_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot; /&amp;gt; to generate a single key pair.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_KeyGen_CLI --absolute-path &amp;quot;$(pwd)&amp;quot; --password 12345678&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Key Generator v2.9.0                              &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 AES_256_cbc algorithm is selected for private key encryption&lt;br /&gt;
 Generating Prime256v1 keys... &lt;br /&gt;
 Private key PEM file created &lt;br /&gt;
 Public key PEM file created &lt;br /&gt;
 public key hash file created &lt;br /&gt;
 Keys generated successfully.&lt;br /&gt;
 + public key:       publicKey.pem&lt;br /&gt;
 + private key:      privateKey.pem&lt;br /&gt;
 + public hash key:  publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Sign U-Boot SPL with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
To add the public key and the image signature to our built U-Boot SPL binary with STM32 image header, we are using the tool &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;STM32MP_SigningTool_CLI&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot; /&amp;gt; to update the existing STM32 image header of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; with the required details.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --binary-image /path/to/u-boot/u-boot-spl.stm32 --public-key publicKey.pem --private-key privateKey.pem --password 12345678 --output /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 Prime256v1 curve is selected. &lt;br /&gt;
 Header version 1 preparation ... &lt;br /&gt;
 Reading Private Key File... &lt;br /&gt;
 ECDSA signature generated.&lt;br /&gt;
 Signature verification:  SUCCESS &lt;br /&gt;
 The Signed image file generated successfully:  /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check the STM32 image header details with:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
STM32MP_SigningTool_CLI --dump-header /path/to/u-boot/u-boot-spl.stm32&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
                       STM32MP Signing Tool v2.9.0                     &lt;br /&gt;
       -------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Header description:&lt;br /&gt;
&lt;br /&gt;
    Magic: 0x53544d32&lt;br /&gt;
    Signature: c8 30 a0 62 2d 6d 4e 1b b9 f7 fe 38 27 65 e0 44 f0 f5 9d e6 8a a6 02 cb 74 52 26 9c 1e e9 07 17 &lt;br /&gt;
               1a c7 da 8e 96 fa 82 d3 b1 dc d5 3a 05 0e 87 83 94 4d 47 ad 17 07 88 0d b5 ae 2e 38 1d 90 22 ad &lt;br /&gt;
    Checksum: 0xa8ca85&lt;br /&gt;
    Header version: 0x10000&lt;br /&gt;
    Size: 0x22dec&lt;br /&gt;
    Load address: 0x2ffc2500&lt;br /&gt;
    Entry point: 0x2ffc2500&lt;br /&gt;
    Image version: 0x0&lt;br /&gt;
    Option flags: 0x0&lt;br /&gt;
    ECDSA Algo: 0x1&lt;br /&gt;
    ECDSA pub key: 3b 71 8e 59 f1 ee 4c a8 4b 72 5f 4a 1c 63 8b 6e b8 01 ec 1a 3f 8c 98 2f d2 1d 77 f9 09 10 8f 04 &lt;br /&gt;
                   30 da 5c 3a 24 53 0d 71 93 f0 a5 d9 c9 a7 27 b4 5f a5 c4 4d 55 8b 7a 25 e3 03 ef ca 87 ff 04 25 &lt;br /&gt;
    Binary type: 0x0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The difference to an unsigned STM32 image header is that the values for &amp;quot;Signature&amp;quot; and &amp;quot;ECDSA pub key&amp;quot; are not all zeros and that &amp;quot;Option flags&amp;quot; is 0x0 for enabled signature verification instead of 0x1 for disabled signature verification.&lt;br /&gt;
&lt;br /&gt;
==== Write U-Boot SPL and U-Boot to your boot media ====&lt;br /&gt;
&lt;br /&gt;
The first step to verify that the built U-Boot SPL and U-Boot works as expected is to program both images to your boot media.&lt;br /&gt;
Depending on the boot configuration, your DHSOM will boot from the module&#039;s SPI-NOR flash, from the module&#039;s or baseboard&#039;s eMMC or from an SD card.&lt;br /&gt;
The boot configuration is always defined by the boot pins by default, because the boot pins have no alternative function on the STM32MP15 SoC&#039;s.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How can a user determine the used boot media?&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO: How to enforce boot media on Secure Boot enabled devices?&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the SPI-NOR flash of the SoM =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; calculate some addresses based on the image offsets expected by the BootROM, load the required images from SD card or via TFTP into memory and finally write the prepared memory into the SPI-NOR flash on the SoM.&lt;br /&gt;
&lt;br /&gt;
Prepare for loading &amp;lt;syntaxhighlight inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; into memory:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mw.b ${loadaddr} 0xff 0x200000&lt;br /&gt;
setexpr fsbl1addr ${loadaddr} + 0x0&lt;br /&gt;
setexpr fsbl2addr ${loadaddr} + 0x40000&lt;br /&gt;
setexpr ssbl1addr ${loadaddr} + 0x80000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${fsbl1addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${fsbl2addr} u-boot-spl.stm32&lt;br /&gt;
load mmc 0:4 ${ssbl1addr} u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; from tftp server:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${fsbl1addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${fsbl2addr} ${serverip}:u-boot-spl.stm32&lt;br /&gt;
tftp ${ssbl1addr} ${serverip}:u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check for magic numbers of expected image headers and conditionally program the SPI-NOR flash:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
if itest *${fsbl1addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${fsbl2addr} == 0x324d5453 &amp;amp;&amp;amp; itest *${ssbl1addr} == 0xedfe0dd0; then&lt;br /&gt;
  sf probe &amp;amp;&amp;amp; sf update ${loadaddr} 0 0x200000&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to an SD card =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Make on module SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make on baseboard SD card of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Write U-Boot SPL and U-Boot to the eMMC =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Write &amp;lt;syntaxhighlight inline&amp;gt;u-boot-spl.stm32&amp;lt;/syntaxhighlight&amp;gt; and &amp;lt;syntaxhighlight inline&amp;gt;u-boot.itb&amp;lt;/syntaxhighlight&amp;gt; to eMMC boot hardware partition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
mmc dev 1 1&lt;br /&gt;
mmc write X X X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make eMMC of STM32MP15xx on PDK2 with cmd &amp;quot;ums&amp;quot; available per USB-OTG-Port:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
usb start&lt;br /&gt;
ums 0 mmc 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enroll, test and enforce BootROM image authentication ====&lt;br /&gt;
&lt;br /&gt;
To enroll, test and enforce image authentication by the BootROM you need to program the PKH into the OTP of the STM32MP15 SoC.&lt;br /&gt;
The &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; file that you created in the [[#Generate key pair with STM32MP_KeyGen_CLI|Generate key pair with STM32MP_KeyGen_CLI]] step contains the PKH in binary format for use with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; U-Boot command.&lt;br /&gt;
If the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command does fail or is not available on the target U-Boot, you can also write the PKH manually with the more generic &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command into the OTP.&lt;br /&gt;
&lt;br /&gt;
===== Program public key hash to eFuses =====&lt;br /&gt;
&lt;br /&gt;
The following &#039;&#039;&#039;commands for the U-Boot Shell&#039;&#039;&#039; load the file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into memory and program the contained PKH to the OTP of the STM32MP15 SoC.&lt;br /&gt;
The used command &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; writes and locks the words of the OTP automatically without knowing anything about the OTP layout/addresses.&lt;br /&gt;
If this fails or the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command is not available, you can also write and lock the OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command &lt;br /&gt;
&lt;br /&gt;
====== Program &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command ====== &lt;br /&gt;
&lt;br /&gt;
Load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; by SD card:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
load mmc 0:4 ${loadaddr} publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or load &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; by TFTP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
setenv serverip 10.20.30.1&lt;br /&gt;
setenv ipaddr 10.20.30.100&lt;br /&gt;
setenv netmask 255.255.255.0&lt;br /&gt;
tftp ${loadaddr} ${serverip}:publicKeyhash.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Show the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key read ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Read KEY at 0xc2000000&lt;br /&gt;
OTP value 24: 4e31bbcd&lt;br /&gt;
OTP value 25: 51e827dd&lt;br /&gt;
OTP value 26: 3511f521&lt;br /&gt;
OTP value 27: fd9c11a2&lt;br /&gt;
OTP value 28: 5b997b82&lt;br /&gt;
OTP value 29: 8150adc5&lt;br /&gt;
OTP value 30: a9c68fa9&lt;br /&gt;
OTP value 31: 72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the contents of &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; to OTP with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key fuse ${loadaddr}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
TODO: Add output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Program PKH manually into OTP with &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command ======&lt;br /&gt;
&lt;br /&gt;
Generate fuse command with hexdump from file &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;publicKeyhash.bin&amp;lt;/syntaxhighlight&amp;gt; on linux host:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example output! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
echo fuse prog -y 0 0x18 $(hexdump -e &#039;/4 &amp;quot;0x&amp;quot;&#039; -e &#039;/1 &amp;quot;%x&amp;quot;&#039; -e &#039;&amp;quot; &amp;quot;&#039; /path/to/publicKeyhash.bin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Write the PKH into OTP manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: Do not use the example command! Only use your unique values for programming the PKH in the OTP!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x18 0x4e31bbcd 0x51e827dd 0x3511f521 0xfd9c11a2 0x5b997b82 0x8150adc5 0xa9c68fa9 0x72a3ba74&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lock the related OTP words manually with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog -y 0 0x10000018 1 1 1 1 1 1 1 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Test BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
To verify the image authentication by the BootROM with the programmed PKH and the programmed signed images, you must reboot your device.&lt;br /&gt;
&lt;br /&gt;
On the third line of the U-Boot SPL output, check the BootROM authentication status.&lt;br /&gt;
The status output should look like this: &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;Bootrom authentication: succeeded&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
Note the &amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; inline&amp;gt;succeeded&amp;lt;/syntaxhighlight&amp;gt; status for successful authentication of the U-Boot SPL image by the BootROM.&lt;br /&gt;
&lt;br /&gt;
The following output shows successful authentication of the U-Boot-SPL image in line 3, as well as successful authentication of the used configuration in line 7 and the U-Boot and Device Tree subimages in lines 8 and 9 of the U-Boot-FIT image.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot; line highlight=&amp;quot;3,7-9&amp;quot;&amp;gt;&lt;br /&gt;
U-Boot SPL 2022.01-00012-g6c5892c90c28 (Feb 16 2022 - 11:11:16 +0100)&lt;br /&gt;
Model: STMicroelectronics STM32MP15xx DHCOM Premium Developer Kit (2)&lt;br /&gt;
Bootrom authentication: succeeded&lt;br /&gt;
Code:  SoM:rev=1,ddr3=3 Board:rev=0&lt;br /&gt;
RAM: DDR3L 32bits 2x4Gb 533MHz&lt;br /&gt;
Trying to boot from SPI&lt;br /&gt;
## Checking hash(es) for config config-2 ... sha256,rsa4096:fsbl-cfg-2022-02-16+ OK&lt;br /&gt;
## Checking hash(es) for Image uboot ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
## Checking hash(es) for Image fdt-1 ... sha256,rsa4096:fsbl-img-2022-02-16+ sha256+ OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Enforce BootROM image authentication =====&lt;br /&gt;
&lt;br /&gt;
Without any further changes, the BootROM is able to perform authentication of the FSBL image, but unauthenticated images can still be used and executed.&lt;br /&gt;
The device is still open, let&#039;s see this as a kind of test mode to check if the PKH is set correctly.&lt;br /&gt;
&lt;br /&gt;
Once the authentication process is confirmed, the device can be closed and the user is forced to use signed images.&lt;br /&gt;
&lt;br /&gt;
The 6th bit in the 1st word of the OTP is responsible that the BootROM only accepts signed images.&lt;br /&gt;
Burning this bit enforces authentication of images by the BootROM and unsigned binaries are no longer supported on the target device.&lt;br /&gt;
&lt;br /&gt;
To program this bit, the U-Boot Shell can be used with the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command or with the more general &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
With usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;stm32key&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
stm32key close&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or with usage of the &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot; inline&amp;gt;fuse&amp;lt;/syntaxhighlight&amp;gt; command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;Warning: After running the following command, your device will only be able to boot signed images!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
fuse prog 0 0x0 0x40&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Secure Boot in Trusted Boot with BootROM authentication, TF-A and OP-TEE ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:red&amp;quot;&amp;gt;TODO:&amp;lt;/div&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;TF-A&amp;quot; /&amp;gt;&lt;br /&gt;
# Add support for STM32MP15 DHCOM in &amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot; /&amp;gt;&lt;br /&gt;
# Create stm32mp15_dhcom_trusted_defconfig???&lt;br /&gt;
# Integrate STM32MP15 DHCOM into &amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;UEFI specification&amp;quot;&amp;gt;[http://www.uefi.org/specifications http://www.uefi.org/specifications]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Basic Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_basic_defconfig U-Boot Source stm32mp15_basic_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Trusted Boot&amp;quot;&amp;gt;[https://source.denx.de/u-boot/u-boot/-/blob/master/configs/stm32mp15_trusted_defconfig U-Boot Source stm32mp15_trusted_defconfig]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;BSI TR-02102&amp;quot;&amp;gt;[https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf BSI - Technische Richtlinie, &amp;quot;Kryptographische Algorithmen und Schlüssellängen&amp;quot;, BSI TR-02102-1]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;STM32 image header&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/STM32_header_for_binary_files STM32 header for binary files]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;KeyGen_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/KeyGen_tool STM32MP KeyGen tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Signing_tool&amp;quot;&amp;gt;[https://wiki.st.com/stm32mpu/wiki/Signing_tool STM32MP Signing tool]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;TF-A&amp;quot;&amp;gt;[https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ Trusted Firmware-A (TF-A)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/optee_os&amp;quot;&amp;gt;[https://github.com/OP-TEE/optee_os OP-TEE Trusted OS]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;OP-TEE/build&amp;quot;&amp;gt;[https://github.com/OP-TEE/build Makefiles to use OP-TEE on various platforms]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
	<entry>
		<id>https://wiki.dh-electronics.com/index.php?title=User:Jneuhauser/vector.css&amp;diff=3618</id>
		<title>User:Jneuhauser/vector.css</title>
		<link rel="alternate" type="text/html" href="https://wiki.dh-electronics.com/index.php?title=User:Jneuhauser/vector.css&amp;diff=3618"/>
		<updated>2022-03-16T08:55:34Z</updated>

		<summary type="html">&lt;p&gt;Jneuhauser: Add required css for TOC limit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;/* https://www.mediawiki.org/wiki/Template:TOC */&lt;br /&gt;
.toclimit-2 .toclevel-1 ul,&lt;br /&gt;
.toclimit-3 .toclevel-2 ul,&lt;br /&gt;
.toclimit-4 .toclevel-3 ul,&lt;br /&gt;
.toclimit-5 .toclevel-4 ul,&lt;br /&gt;
.toclimit-6 .toclevel-5 ul,&lt;br /&gt;
.toclimit-7 .toclevel-6 ul {&lt;br /&gt;
	display: none;&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Jneuhauser</name></author>
	</entry>
</feed>