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 | |
| 69 | $ export ATF=/path/to/bl31.bin |
| 70 | $ export TEE=/path/to/tee-pager_v2.bin |
Su Baocheng | 0dcd337 | 2023-02-28 19:19:09 +0100 | [diff] [blame] | 71 | |
| 72 | # configure for PG1 |
| 73 | $ make iot2050_pg1_defconfig |
| 74 | |
chao zeng | 2275043 | 2023-02-28 19:19:22 +0100 | [diff] [blame] | 75 | # or configure for PG2 or the M.2 variant |
Su Baocheng | 0dcd337 | 2023-02-28 19:19:09 +0100 | [diff] [blame] | 76 | $ make iot2050_pg2_defconfig |
| 77 | |
Jan Kiszka | 8ff2ff8 | 2021-09-18 08:17:53 +0200 | [diff] [blame] | 78 | $ make |
| 79 | |
| 80 | Flashing |
| 81 | -------- |
| 82 | |
| 83 | Via U-Boot: |
| 84 | |
| 85 | .. code-block:: text |
| 86 | |
| 87 | IOT2050> sf probe |
| 88 | IOT2050> load mmc 0:1 $loadaddr /path/to/flash.bin |
| 89 | IOT2050> sf update $loadaddr 0x0 $filesize |
| 90 | |
| 91 | Via external programmer Dediprog SF100 or SF600: |
| 92 | |
| 93 | .. code-block:: text |
| 94 | |
| 95 | $ dpcmd --vcc 2 -v -u flash.bin |
Jan Kiszka | 15bb43b | 2023-02-28 19:19:17 +0100 | [diff] [blame] | 96 | |
| 97 | Signing (optional) |
| 98 | ------------------ |
| 99 | |
| 100 | To enable verified boot for the firmware artifacts after the Siemens-managed |
| 101 | first-stage loader (seboot_pg*.bin), the following steps need to be taken |
| 102 | before and after the build: |
| 103 | |
| 104 | Generate dtsi holding the public key |
| 105 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 106 | |
| 107 | .. code-block:: text |
| 108 | |
| 109 | tools/key2dtsi.py -c -s key.pem public-key.dtsi |
| 110 | |
| 111 | This will be used to embed the public key into U-Boot SPL and main so that each |
| 112 | step can validate signatures of the succeeding one. |
| 113 | |
| 114 | Adjust U-Boot configuration |
| 115 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 116 | |
| 117 | Enabled at least the following options in U-Boot: |
| 118 | |
| 119 | .. code-block:: text |
| 120 | |
| 121 | CONFIG_SPL_FIT_SIGNATURE=y |
| 122 | CONFIG_DEVICE_TREE_INCLUDES="/path/to/public-key.dtsi" |
| 123 | CONFIG_RSA=y |
| 124 | |
| 125 | Note that there are more configuration changes needed in order to lock-down |
| 126 | the command line and the boot process of U-Boot for secure scenarios. These are |
| 127 | not in scope here. |
| 128 | |
| 129 | Build U-Boot |
| 130 | ^^^^^^^^^^^^ |
| 131 | |
| 132 | See related section above. |
| 133 | |
| 134 | Sign flash.bin |
| 135 | ^^^^^^^^^^^^^^ |
| 136 | |
| 137 | In the build folder still containing artifacts from step 3, invoke: |
| 138 | |
| 139 | .. code-block:: text |
| 140 | |
| 141 | tools/iot2050-sign-fw.sh /path/to/key.pem |
| 142 | |
| 143 | Flash signed flash.bin |
| 144 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 145 | |
| 146 | The signing has happen in-place in flash.bin, thus the flashing procedure |
| 147 | described above. |
Jan Kiszka | e31f16c | 2023-02-28 19:19:23 +0100 | [diff] [blame] | 148 | |
| 149 | M.2 slot configuration |
| 150 | ---------------------- |
| 151 | |
| 152 | The M.2 variant of the IOT2050 comes with one B-keyed and one E-keyed slot. |
| 153 | These are configured by U-Boot depending on the detected usage (auto |
| 154 | configuration). The device tree loaded later on for the OS will be fixed up |
| 155 | by U-Boot according to this configuration. |
| 156 | |
| 157 | For the case auto configuration does not work reliably, it is possible to set |
| 158 | the U-Boot environment variable "m2_manual_config" to select the mode manually: |
| 159 | |
| 160 | "0" - B-key: PCIe x2, USB 2.0 |
| 161 | E-key: USB 2.0 |
| 162 | "1" - B-key: PCIe, USB 2.0 |
| 163 | E-key: PCIe, USB 2.0 |
| 164 | "2" - B-key: USB 3.0, |
| 165 | E-key: PCIe, USB 2.0 |