Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | .. sectionauthor:: Jan Kiszka <jan.kiszka@siemens.com> |
| 3 | |
| 4 | SIMATIC IOT2050 BASIC and ADVANCED |
| 5 | ================================== |
| 6 | |
| 7 | The SIMATIC IOT2050 is an open industrial IoT gateway that is using the TI |
| 8 | AM6528 GP (Basic variant) or the AM6548 HS (Advanced variant). The Advanced |
| 9 | variant is prepared for secure boot. |
| 10 | |
| 11 | The IOT2050 starts only from OSPI. It loads a Siemens-provided bootloader |
| 12 | called SE-Boot for the MCU domain (R5F cores), then hands over to ATF and |
| 13 | OP-TEE, before booting U-Boot on the A53 cores. This describes how to build all |
| 14 | open artifacts into a flashable image for the OSPI flash. The flash image will |
| 15 | work on both variants. |
| 16 | |
| 17 | Dependencies |
| 18 | ------------ |
| 19 | |
| 20 | ATF: Upstream release 2.4 or newer |
| 21 | OP-TEE: Upstream release 3.10.0 or newer |
| 22 | |
| 23 | Binary dependencies can be found in |
| 24 | https://github.com/siemens/meta-iot2050/tree/master/recipes-bsp/u-boot/files/prebuild. |
| 25 | The following binaries from that source need to be present in the build folder: |
| 26 | |
Su Baocheng | 0dcd337 | 2023-02-28 19:19:09 +0100 | [diff] [blame] | 27 | - seboot_pg1.bin |
Su Baocheng | 0dcd337 | 2023-02-28 19:19:09 +0100 | [diff] [blame] | 28 | - seboot_pg2.bin |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 29 | |
Jan Kiszka | aebb5b9 | 2023-02-28 19:19:18 +0100 | [diff] [blame^] | 30 | For building an image containing the OTP key provisioning data, below binary |
| 31 | needs to be present in the build folder: |
| 32 | |
| 33 | - otpcmd.bin |
| 34 | |
| 35 | Regarding how to generating this otpcmd.bin, please refer to: |
| 36 | https://github.com/siemens/meta-iot2050/tree/master/recipes-bsp/secure-boot-otp-provisioning/files/make-otpcmd.sh |
| 37 | |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 38 | Building |
| 39 | -------- |
| 40 | |
| 41 | Make sure that CROSS_COMPILE is set appropriately: |
| 42 | |
| 43 | .. code-block:: text |
| 44 | |
| 45 | $ export CROSS_COMPILE=aarch64-linux-gnu- |
| 46 | |
| 47 | ATF: |
| 48 | |
| 49 | .. code-block:: text |
| 50 | |
| 51 | $ make PLAT=k3 SPD=opteed K3_USART=1 |
| 52 | |
| 53 | OP-TEE: |
| 54 | |
| 55 | .. code-block:: text |
| 56 | |
Ivan Mikhaylov | 07bc02a | 2021-11-28 21:57:01 +0000 | [diff] [blame] | 57 | $ make PLATFORM=k3-am65x CFG_ARM64_core=y CFG_TEE_CORE_LOG_LEVEL=2 CFG_CONSOLE_UART=1 CFG_USER_TA_TARGETS="ta_arm64" |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 58 | |
| 59 | U-Boot: |
| 60 | |
| 61 | .. code-block:: text |
| 62 | |
| 63 | $ export ATF=/path/to/bl31.bin |
| 64 | $ export TEE=/path/to/tee-pager_v2.bin |
Su Baocheng | 0dcd337 | 2023-02-28 19:19:09 +0100 | [diff] [blame] | 65 | |
| 66 | # configure for PG1 |
| 67 | $ make iot2050_pg1_defconfig |
| 68 | |
| 69 | # or configure for PG2 |
| 70 | $ make iot2050_pg2_defconfig |
| 71 | |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 72 | $ make |
| 73 | |
| 74 | Flashing |
| 75 | -------- |
| 76 | |
| 77 | Via U-Boot: |
| 78 | |
| 79 | .. code-block:: text |
| 80 | |
| 81 | IOT2050> sf probe |
| 82 | IOT2050> load mmc 0:1 $loadaddr /path/to/flash.bin |
| 83 | IOT2050> sf update $loadaddr 0x0 $filesize |
| 84 | |
| 85 | Via external programmer Dediprog SF100 or SF600: |
| 86 | |
| 87 | .. code-block:: text |
| 88 | |
| 89 | $ dpcmd --vcc 2 -v -u flash.bin |
Jan Kiszka | 15bb43b | 2023-02-28 19:19:17 +0100 | [diff] [blame] | 90 | |
| 91 | Signing (optional) |
| 92 | ------------------ |
| 93 | |
| 94 | To enable verified boot for the firmware artifacts after the Siemens-managed |
| 95 | first-stage loader (seboot_pg*.bin), the following steps need to be taken |
| 96 | before and after the build: |
| 97 | |
| 98 | Generate dtsi holding the public key |
| 99 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 100 | |
| 101 | .. code-block:: text |
| 102 | |
| 103 | tools/key2dtsi.py -c -s key.pem public-key.dtsi |
| 104 | |
| 105 | This will be used to embed the public key into U-Boot SPL and main so that each |
| 106 | step can validate signatures of the succeeding one. |
| 107 | |
| 108 | Adjust U-Boot configuration |
| 109 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 110 | |
| 111 | Enabled at least the following options in U-Boot: |
| 112 | |
| 113 | .. code-block:: text |
| 114 | |
| 115 | CONFIG_SPL_FIT_SIGNATURE=y |
| 116 | CONFIG_DEVICE_TREE_INCLUDES="/path/to/public-key.dtsi" |
| 117 | CONFIG_RSA=y |
| 118 | |
| 119 | Note that there are more configuration changes needed in order to lock-down |
| 120 | the command line and the boot process of U-Boot for secure scenarios. These are |
| 121 | not in scope here. |
| 122 | |
| 123 | Build U-Boot |
| 124 | ^^^^^^^^^^^^ |
| 125 | |
| 126 | See related section above. |
| 127 | |
| 128 | Sign flash.bin |
| 129 | ^^^^^^^^^^^^^^ |
| 130 | |
| 131 | In the build folder still containing artifacts from step 3, invoke: |
| 132 | |
| 133 | .. code-block:: text |
| 134 | |
| 135 | tools/iot2050-sign-fw.sh /path/to/key.pem |
| 136 | |
| 137 | Flash signed flash.bin |
| 138 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 139 | |
| 140 | The signing has happen in-place in flash.bin, thus the flashing procedure |
| 141 | described above. |