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 |
chao zeng | 2275043 | 2023-02-28 19:19:22 +0100 | [diff] [blame] | 9 | variant is prepared for secure boot. M.2 Variant also uses the AM6548 HS. |
| 10 | Instead of a MiniPCI connector, it comes with two M.2 connectors and can |
| 11 | support 5G/WIFI/BT applications or connect an SSD. |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 12 | |
| 13 | The IOT2050 starts only from OSPI. It loads a Siemens-provided bootloader |
| 14 | called SE-Boot for the MCU domain (R5F cores), then hands over to ATF and |
| 15 | OP-TEE, before booting U-Boot on the A53 cores. This describes how to build all |
| 16 | open artifacts into a flashable image for the OSPI flash. The flash image will |
| 17 | work on both variants. |
| 18 | |
| 19 | Dependencies |
| 20 | ------------ |
| 21 | |
| 22 | ATF: Upstream release 2.4 or newer |
| 23 | OP-TEE: Upstream release 3.10.0 or newer |
| 24 | |
| 25 | Binary dependencies can be found in |
| 26 | https://github.com/siemens/meta-iot2050/tree/master/recipes-bsp/u-boot/files/prebuild. |
| 27 | The following binaries from that source need to be present in the build folder: |
| 28 | |
Su Baocheng | 0dcd337 | 2023-02-28 19:19:09 +0100 | [diff] [blame] | 29 | - seboot_pg1.bin |
Su Baocheng | 0dcd337 | 2023-02-28 19:19:09 +0100 | [diff] [blame] | 30 | - seboot_pg2.bin |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 31 | |
Jan Kiszka | 90ea232 | 2023-02-28 19:19:19 +0100 | [diff] [blame] | 32 | When using the watchdog, a related firmware for the R5 core(s) is needed, e.g. |
| 33 | https://github.com/siemens/k3-rti-wdt. The name and location of the image is |
| 34 | configured via CONFIG_WDT_K3_RTI_FW_FILE. |
| 35 | |
Jan Kiszka | aebb5b9 | 2023-02-28 19:19:18 +0100 | [diff] [blame] | 36 | For building an image containing the OTP key provisioning data, below binary |
| 37 | needs to be present in the build folder: |
| 38 | |
| 39 | - otpcmd.bin |
| 40 | |
| 41 | Regarding how to generating this otpcmd.bin, please refer to: |
| 42 | https://github.com/siemens/meta-iot2050/tree/master/recipes-bsp/secure-boot-otp-provisioning/files/make-otpcmd.sh |
| 43 | |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 44 | Building |
| 45 | -------- |
| 46 | |
| 47 | Make sure that CROSS_COMPILE is set appropriately: |
| 48 | |
| 49 | .. code-block:: text |
| 50 | |
| 51 | $ export CROSS_COMPILE=aarch64-linux-gnu- |
| 52 | |
| 53 | ATF: |
| 54 | |
| 55 | .. code-block:: text |
| 56 | |
| 57 | $ make PLAT=k3 SPD=opteed K3_USART=1 |
| 58 | |
| 59 | OP-TEE: |
| 60 | |
| 61 | .. code-block:: text |
| 62 | |
Ivan Mikhaylov | 07bc02a | 2021-11-28 21:57:01 +0000 | [diff] [blame] | 63 | $ 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] | 64 | |
| 65 | U-Boot: |
| 66 | |
| 67 | .. code-block:: text |
| 68 | |
Jan Kiszka | be6052f | 2023-07-27 06:34:55 +0200 | [diff] [blame] | 69 | $ export BL31=/path/to/bl31.bin |
| 70 | $ export TEE=/path/to/tee-raw.bin |
Jan Kiszka | b2d24f9 | 2023-07-27 06:34:54 +0200 | [diff] [blame] | 71 | $ make iot2050_defconfig |
Su Baocheng | 0dcd337 | 2023-02-28 19:19:09 +0100 | [diff] [blame] | 72 | |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 73 | $ make |
| 74 | |
Jan Kiszka | b2d24f9 | 2023-07-27 06:34:54 +0200 | [diff] [blame] | 75 | This will generate two different flash images: flash-p1.bin that targets the |
| 76 | first generation of IOT2050 devices and flash-pg2.bin that runs on PG2 |
| 77 | including M.2 devices. |
| 78 | |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 79 | Flashing |
| 80 | -------- |
| 81 | |
| 82 | Via U-Boot: |
| 83 | |
| 84 | .. code-block:: text |
| 85 | |
| 86 | IOT2050> sf probe |
Jan Kiszka | b2d24f9 | 2023-07-27 06:34:54 +0200 | [diff] [blame] | 87 | IOT2050> load mmc 0:1 $loadaddr /path/to/flash-pgX.bin |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 88 | IOT2050> sf update $loadaddr 0x0 $filesize |
| 89 | |
| 90 | Via external programmer Dediprog SF100 or SF600: |
| 91 | |
| 92 | .. code-block:: text |
| 93 | |
Jan Kiszka | b2d24f9 | 2023-07-27 06:34:54 +0200 | [diff] [blame] | 94 | $ dpcmd --vcc 2 -v -u flash-pgX.bin |
Jan Kiszka | 15bb43b | 2023-02-28 19:19:17 +0100 | [diff] [blame] | 95 | |
| 96 | Signing (optional) |
| 97 | ------------------ |
| 98 | |
| 99 | To enable verified boot for the firmware artifacts after the Siemens-managed |
Jan Kiszka | b2d24f9 | 2023-07-27 06:34:54 +0200 | [diff] [blame] | 100 | first-stage loader (seboot_pgX.bin), the following steps need to be taken |
Jan Kiszka | 15bb43b | 2023-02-28 19:19:17 +0100 | [diff] [blame] | 101 | before and after the build: |
| 102 | |
| 103 | Generate dtsi holding the public key |
| 104 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 105 | |
| 106 | .. code-block:: text |
| 107 | |
| 108 | tools/key2dtsi.py -c -s key.pem public-key.dtsi |
| 109 | |
| 110 | This will be used to embed the public key into U-Boot SPL and main so that each |
| 111 | step can validate signatures of the succeeding one. |
| 112 | |
| 113 | Adjust U-Boot configuration |
| 114 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 115 | |
| 116 | Enabled at least the following options in U-Boot: |
| 117 | |
| 118 | .. code-block:: text |
| 119 | |
| 120 | CONFIG_SPL_FIT_SIGNATURE=y |
| 121 | CONFIG_DEVICE_TREE_INCLUDES="/path/to/public-key.dtsi" |
| 122 | CONFIG_RSA=y |
| 123 | |
| 124 | Note that there are more configuration changes needed in order to lock-down |
| 125 | the command line and the boot process of U-Boot for secure scenarios. These are |
| 126 | not in scope here. |
| 127 | |
| 128 | Build U-Boot |
| 129 | ^^^^^^^^^^^^ |
| 130 | |
| 131 | See related section above. |
| 132 | |
Jan Kiszka | b2d24f9 | 2023-07-27 06:34:54 +0200 | [diff] [blame] | 133 | Sign flash-pgX.bin |
| 134 | ^^^^^^^^^^^^^^^^^^ |
Jan Kiszka | 15bb43b | 2023-02-28 19:19:17 +0100 | [diff] [blame] | 135 | |
| 136 | In the build folder still containing artifacts from step 3, invoke: |
| 137 | |
| 138 | .. code-block:: text |
| 139 | |
| 140 | tools/iot2050-sign-fw.sh /path/to/key.pem |
| 141 | |
Jan Kiszka | b2d24f9 | 2023-07-27 06:34:54 +0200 | [diff] [blame] | 142 | Flash signed flash-pgX.bin |
| 143 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Jan Kiszka | 15bb43b | 2023-02-28 19:19:17 +0100 | [diff] [blame] | 144 | |
Jan Kiszka | b2d24f9 | 2023-07-27 06:34:54 +0200 | [diff] [blame] | 145 | The signing has happen in-place in flash-pgX.bin, thus the flashing procedure |
Jan Kiszka | 15bb43b | 2023-02-28 19:19:17 +0100 | [diff] [blame] | 146 | described above. |
Jan Kiszka | e31f16c | 2023-02-28 19:19:23 +0100 | [diff] [blame] | 147 | |
| 148 | M.2 slot configuration |
| 149 | ---------------------- |
| 150 | |
| 151 | The M.2 variant of the IOT2050 comes with one B-keyed and one E-keyed slot. |
| 152 | These are configured by U-Boot depending on the detected usage (auto |
| 153 | configuration). The device tree loaded later on for the OS will be fixed up |
| 154 | by U-Boot according to this configuration. |
| 155 | |
| 156 | For the case auto configuration does not work reliably, it is possible to set |
| 157 | the U-Boot environment variable "m2_manual_config" to select the mode manually: |
| 158 | |
| 159 | "0" - B-key: PCIe x2, USB 2.0 |
| 160 | E-key: USB 2.0 |
| 161 | "1" - B-key: PCIe, USB 2.0 |
| 162 | E-key: PCIe, USB 2.0 |
| 163 | "2" - B-key: USB 3.0, |
| 164 | E-key: PCIe, USB 2.0 |