|
| 1 | +================== |
| 2 | +U-Boot Falcon Mode |
| 3 | +================== |
| 4 | + |
| 5 | +U-Boot's falcon mode on |__PART_FAMILY_DEVICE_NAMES__| bypasses the A-core SPL |
| 6 | +and U-Boot stage, which allows for booting straight to linux kernel after OP-TEE |
| 7 | +and ATF. |
| 8 | + |
| 9 | +**Normal boot flow:** |
| 10 | + |
| 11 | +* R5 SPL -> ATF -> OP-TEE -> *Cortex-A SPL* -> *U-Boot* -> Kernel |
| 12 | + |
| 13 | +**With falcon mode:** |
| 14 | + |
| 15 | +* R5 SPL -> ATF -> OP-TEE -> Kernel |
| 16 | + |
| 17 | +Falcon boot support is added by the ``ti-falcon`` yocto override which can be |
| 18 | +enabled before :ref:`building the SDK <building-the-sdk-with-yocto>` as follows: |
| 19 | + |
| 20 | +.. code-block:: console |
| 21 | +
|
| 22 | + $ echo 'DISTROOVERRIDES:append = ":ti-falcon"' >> conf/local.conf |
| 23 | + $ # build the SDK |
| 24 | + $ MACHINE=<machine> bitbake -k tisdk-default-image |
| 25 | +
|
| 26 | +------------------------------------- |
| 27 | +Changes made by *ti-falcon* override: |
| 28 | +------------------------------------- |
| 29 | + |
| 30 | +ATF: |
| 31 | +---- |
| 32 | + |
| 33 | +To meet the 2MiB alignment requirement for the linux kernel's load address, |
| 34 | +the ``K3_HW_CONFIG_BASE`` *(kernel address)* and ``PRELOADED_BL33_BASE`` |
| 35 | +*(DTB address)* for ATF are modified from K3 defaults to ``0x82000000`` and |
| 36 | +``0x88000000`` respectively. |
| 37 | + |
| 38 | +TISPL: |
| 39 | +------ |
| 40 | + |
| 41 | +Falcon mode makes use of a cut down variant of the tispl binary called |
| 42 | +``tifalcon.bin`` with the Cortex-A SPL and it’s corresponding DTB removed. |
| 43 | +This file is deployed to the boot directory inside rootfs so it can be picked by |
| 44 | +the R5 SPL at boot time. |
| 45 | + |
| 46 | +R5 SPL: |
| 47 | +------- |
| 48 | + |
| 49 | +The R5 SPL is used for loading the kernel ``fitImage`` as well as the |
| 50 | +``tifalcon.bin`` file, though the ``fitImage`` for falcon boot is signed |
| 51 | +using an x509 certificate with TIFS keys instead of making use of signature |
| 52 | +nodes and keys present in the DT. This allows for faster authentication since |
| 53 | +TIFS uses the security accelerator for authentication which is much faster than |
| 54 | +doing the same on R5 core. |
| 55 | + |
| 56 | +This support depends on the U-Boot's ``k3_r5_falcon.config`` fragment, which is |
| 57 | +built alongside the standard R5 defconfig when ``ti-falcon`` is enabled. |
| 58 | + |
| 59 | +fitImage: |
| 60 | +--------- |
| 61 | + |
| 62 | +The resulting ``fitImage`` file in the boot directory of rootfs is produced |
| 63 | +with the constituent binaries pre-signed with x509 certificates. This file is |
| 64 | +authenticated from TIFS at boot time which allows for a lower boot time than |
| 65 | +authenticating on the R5 core. |
| 66 | + |
| 67 | +------------------- |
| 68 | +Extra Configuration |
| 69 | +------------------- |
| 70 | + |
| 71 | +.. ifconfig:: CONFIG_part_variant not in ('AM62AX') |
| 72 | + |
| 73 | + OSPI boot: |
| 74 | + ---------- |
| 75 | + |
| 76 | + For OSPI boot, the ``tiboot3.bin`` and ``tifalcon.bin`` files should be |
| 77 | + flashed to the same addresses in flash as regular boot flow but the DTB and |
| 78 | + the ``fitImage`` are read from the rootfs's boot directory. |
| 79 | + |
| 80 | + Below U-Boot commands can be used to download ``tiboot3.bin`` and |
| 81 | + ``tifalcon.bin`` over tftp and then flash those to OSPI at their respective |
| 82 | + addresses. |
| 83 | + |
| 84 | + .. code-block:: console |
| 85 | +
|
| 86 | + => sf probe |
| 87 | + => tftp ${loadaddr} tiboot3.bin |
| 88 | + => sf update $loadaddr 0x0 $filesize |
| 89 | + => tftp ${loadaddr} tifalcon.bin |
| 90 | + => sf update $loadaddr 0x80000 $filesize |
| 91 | +
|
| 92 | +eMMC Boot: |
| 93 | +---------- |
| 94 | + |
| 95 | +In eMMC boot mode, the ``tiboot3.bin`` file should be flashed to the hardware |
| 96 | +boot partition whereas ``tifalcon.bin`` and the ``fitImage`` are read from |
| 97 | +the rootfs inside UDA. Use the U-Boot commands below to set the correct boot |
| 98 | +partition and write ``tiboot3.bin`` to the correct offset. |
| 99 | + |
| 100 | +.. code-block:: console |
| 101 | +
|
| 102 | + => # Set boot0 as the boot partition |
| 103 | + => mmc partconf 0 1 1 1 |
| 104 | + => mmc bootbus 0 2 0 0 |
| 105 | + => # Flash tiboot3.bin to boot0 |
| 106 | + => mmc dev 0 1 |
| 107 | + => fatload mmc 1 ${loadaddr} tiboot3.bin |
| 108 | + => mmc write ${loadaddr} 0x0 0x400 |
| 109 | +
|
| 110 | +For more information check: :ref:`How to flash eMMC and boot with eMMC Boot |
| 111 | +<how-to-emmc-boot>`. |
| 112 | + |
| 113 | +Custom fitImage creation: |
| 114 | +------------------------- |
| 115 | + |
| 116 | +Clone the `core-secdev-k3 source <https://git.ti.com/cgit/security-development-tools/core-secdev-k3>`__: |
| 117 | + |
| 118 | +.. code-block:: console |
| 119 | +
|
| 120 | + $ git clone https://git.ti.com/cgit/security-development-tools/core-secdev-k3 |
| 121 | +
|
| 122 | +Copy the required kernel image renamed to ``Image`` and the DTB renamed to |
| 123 | +``falcon.dtb`` inside the core-secdev-k3 source directory. |
| 124 | + |
| 125 | +Copy the following contents to a file named ``fitImage.its`` inside |
| 126 | +core-secdev-k3 source: |
| 127 | + |
| 128 | +.. code-block:: dts |
| 129 | +
|
| 130 | + /dts-v1/; |
| 131 | +
|
| 132 | + / { |
| 133 | + description = "Kernel fitImage for falcon mode"; |
| 134 | + #address-cells = <1>; |
| 135 | +
|
| 136 | + images { |
| 137 | + kernel-1 { |
| 138 | + description = "Linux kernel"; |
| 139 | + data = /incbin/("Image.sec"); |
| 140 | + type = "kernel"; |
| 141 | + arch = "arm64"; |
| 142 | + os = "linux"; |
| 143 | + compression = "none"; |
| 144 | + load = <0x82000000>; |
| 145 | + entry = <0x82000000>; |
| 146 | + }; |
| 147 | + falcon.dtb { |
| 148 | + description = "Flattened Device Tree blob"; |
| 149 | + data = /incbin/("falcon.dtb.sec"); |
| 150 | + type = "flat_dt"; |
| 151 | + arch = "arm64"; |
| 152 | + compression = "none"; |
| 153 | + load = <0x88000000>; |
| 154 | + }; |
| 155 | + }; |
| 156 | +
|
| 157 | + configurations { |
| 158 | + default = "conf-falcon"; |
| 159 | + conf-falcon { |
| 160 | + description = "Presigned Kernel and DTB"; |
| 161 | + kernel = "kernel-1"; |
| 162 | + fdt = "falcon.dtb"; |
| 163 | + }; |
| 164 | + }; |
| 165 | + }; |
| 166 | +
|
| 167 | +Sign the kernel and dtb using ``secure-binary-image.sh`` and create the |
| 168 | +``fitImage`` using mkimage: |
| 169 | + |
| 170 | +.. code-block:: console |
| 171 | +
|
| 172 | + $ # inside core-secdev-k3 source |
| 173 | + $ ./scripts/secure-binary-image.sh Image Image.sec |
| 174 | + $ ./scripts/secure-binary-image.sh falcon.dtb falcon.dtb.sec |
| 175 | + $ mkimage -f fitImage.its fitImage |
| 176 | +
|
| 177 | +---------------------- |
| 178 | +Boot time comparisons: |
| 179 | +---------------------- |
| 180 | + |
| 181 | +Removing A-core SPL and U-Boot from the boot process leads to ~60% reduction in |
| 182 | +time to kernel. Saving about 1-2 seconds during boot depending on the platform. |
| 183 | + |
| 184 | +**Falcon Mode (Left) vs Regular Boot (Right):** |
| 185 | + |
| 186 | + .. Image:: /images/U-Boot_Falcon_Comparison.gif |
0 commit comments