Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | inherit kernel-uboot kernel-artifact-names uboot-sign |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 3 | KERNEL_IMAGETYPE_REPLACEMENT = "" |
| 4 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | python __anonymous () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 6 | kerneltypes = d.getVar('KERNEL_IMAGETYPES') or "" |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 7 | if 'fitImage' in kerneltypes.split(): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8 | depends = d.getVar("DEPENDS") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 9 | depends = "%s u-boot-tools-native dtc-native" % depends |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | d.setVar("DEPENDS", depends) |
| 11 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | uarch = d.getVar("UBOOT_ARCH") |
| 13 | if uarch == "arm64": |
| 14 | replacementtype = "Image" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 15 | elif uarch == "riscv": |
| 16 | replacementtype = "Image" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 17 | elif uarch == "mips": |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 18 | replacementtype = "vmlinuz.bin" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | elif uarch == "x86": |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 20 | replacementtype = "bzImage" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 21 | elif uarch == "microblaze": |
| 22 | replacementtype = "linux.bin" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 23 | else: |
| 24 | replacementtype = "zImage" |
| 25 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 26 | d.setVar("KERNEL_IMAGETYPE_REPLACEMENT", replacementtype) |
| 27 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 28 | # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal |
| 29 | # to kernel.bbclass . We have to override it, since we pack zImage |
| 30 | # (at least for now) into the fitImage . |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 31 | typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or "" |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 32 | if 'fitImage' in typeformake.split(): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', replacementtype)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 35 | image = d.getVar('INITRAMFS_IMAGE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | if image: |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 37 | d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') |
| 38 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame^] | 39 | ubootenv = d.getVar('UBOOT_ENV') |
| 40 | if ubootenv: |
| 41 | d.appendVarFlag('do_assemble_fitimage', 'depends', ' virtual/bootloader:do_populate_sysroot') |
| 42 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 43 | #check if there are any dtb providers |
| 44 | providerdtb = d.getVar("PREFERRED_PROVIDER_virtual/dtb") |
| 45 | if providerdtb: |
| 46 | d.appendVarFlag('do_assemble_fitimage', 'depends', ' virtual/dtb:do_populate_sysroot') |
| 47 | d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' virtual/dtb:do_populate_sysroot') |
| 48 | d.setVar('EXTERNAL_KERNEL_DEVICETREE', "${RECIPE_SYSROOT}/boot/devicetree") |
| 49 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 50 | # Verified boot will sign the fitImage and append the public key to |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 51 | # U-Boot dtb. We ensure the U-Boot dtb is deployed before assembling |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 52 | # the fitImage: |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 53 | if d.getVar('UBOOT_SIGN_ENABLE') == "1" and d.getVar('UBOOT_DTB_BINARY'): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 54 | uboot_pn = d.getVar('PREFERRED_PROVIDER_u-boot') or 'u-boot' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 55 | d.appendVarFlag('do_assemble_fitimage', 'depends', ' %s:do_populate_sysroot' % uboot_pn) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 56 | if d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1": |
| 57 | d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' %s:do_populate_sysroot' % uboot_pn) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 58 | } |
| 59 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 60 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 61 | # Description string |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 62 | FIT_DESC ?= "Kernel fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 63 | |
| 64 | # Sign individual images as well |
| 65 | FIT_SIGN_INDIVIDUAL ?= "0" |
| 66 | |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 67 | # Keys used to sign individually image nodes. |
| 68 | # The keys to sign image nodes must be different from those used to sign |
| 69 | # configuration nodes, otherwise the "required" property, from |
| 70 | # UBOOT_DTB_BINARY, will be set to "conf", because "conf" prevails on "image". |
| 71 | # Then the images signature checking will not be mandatory and no error will be |
| 72 | # raised in case of failure. |
| 73 | # UBOOT_SIGN_IMG_KEYNAME = "dev2" # keys name in keydir (eg. "dev2.crt", "dev2.key") |
| 74 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | # |
| 76 | # Emit the fitImage ITS header |
| 77 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 78 | # $1 ... .its filename |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | fitimage_emit_fit_header() { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 80 | cat << EOF >> $1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | /dts-v1/; |
| 82 | |
| 83 | / { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 84 | description = "${FIT_DESC}"; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | #address-cells = <1>; |
| 86 | EOF |
| 87 | } |
| 88 | |
| 89 | # |
| 90 | # Emit the fitImage section bits |
| 91 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 92 | # $1 ... .its filename |
| 93 | # $2 ... Section bit type: imagestart - image section start |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | # confstart - configuration section start |
| 95 | # sectend - section end |
| 96 | # fitend - fitimage end |
| 97 | # |
| 98 | fitimage_emit_section_maint() { |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 99 | case $2 in |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | imagestart) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 101 | cat << EOF >> $1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 102 | |
| 103 | images { |
| 104 | EOF |
| 105 | ;; |
| 106 | confstart) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 107 | cat << EOF >> $1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 | |
| 109 | configurations { |
| 110 | EOF |
| 111 | ;; |
| 112 | sectend) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 113 | cat << EOF >> $1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | }; |
| 115 | EOF |
| 116 | ;; |
| 117 | fitend) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 118 | cat << EOF >> $1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 119 | }; |
| 120 | EOF |
| 121 | ;; |
| 122 | esac |
| 123 | } |
| 124 | |
| 125 | # |
| 126 | # Emit the fitImage ITS kernel section |
| 127 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 128 | # $1 ... .its filename |
| 129 | # $2 ... Image counter |
| 130 | # $3 ... Path to kernel image |
| 131 | # $4 ... Compression type |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 132 | fitimage_emit_section_kernel() { |
| 133 | |
Brad Bishop | f3fd288 | 2019-06-21 08:06:37 -0400 | [diff] [blame] | 134 | kernel_csum="${FIT_HASH_ALG}" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 135 | kernel_sign_algo="${FIT_SIGN_ALG}" |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 136 | kernel_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 137 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 138 | ENTRYPOINT="${UBOOT_ENTRYPOINT}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 139 | if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then |
| 140 | ENTRYPOINT=`${HOST_PREFIX}nm vmlinux | \ |
| 141 | awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 142 | fi |
| 143 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 144 | cat << EOF >> $1 |
| 145 | kernel-$2 { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 146 | description = "Linux kernel"; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 147 | data = /incbin/("$3"); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 148 | type = "kernel"; |
| 149 | arch = "${UBOOT_ARCH}"; |
| 150 | os = "linux"; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 151 | compression = "$4"; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 152 | load = <${UBOOT_LOADADDRESS}>; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 153 | entry = <$ENTRYPOINT>; |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 154 | hash-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 155 | algo = "$kernel_csum"; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 156 | }; |
| 157 | }; |
| 158 | EOF |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 159 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 160 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$kernel_sign_keyname" ] ; then |
| 161 | sed -i '$ d' $1 |
| 162 | cat << EOF >> $1 |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 163 | signature-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 164 | algo = "$kernel_csum,$kernel_sign_algo"; |
| 165 | key-name-hint = "$kernel_sign_keyname"; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 166 | }; |
| 167 | }; |
| 168 | EOF |
| 169 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | # |
| 173 | # Emit the fitImage ITS DTB section |
| 174 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 175 | # $1 ... .its filename |
| 176 | # $2 ... Image counter |
| 177 | # $3 ... Path to DTB image |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 178 | fitimage_emit_section_dtb() { |
| 179 | |
Brad Bishop | f3fd288 | 2019-06-21 08:06:37 -0400 | [diff] [blame] | 180 | dtb_csum="${FIT_HASH_ALG}" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 181 | dtb_sign_algo="${FIT_SIGN_ALG}" |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 182 | dtb_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 183 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 184 | dtb_loadline="" |
| 185 | dtb_ext=${DTB##*.} |
| 186 | if [ "${dtb_ext}" = "dtbo" ]; then |
| 187 | if [ -n "${UBOOT_DTBO_LOADADDRESS}" ]; then |
| 188 | dtb_loadline="load = <${UBOOT_DTBO_LOADADDRESS}>;" |
| 189 | fi |
| 190 | elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then |
| 191 | dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;" |
| 192 | fi |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 193 | cat << EOF >> $1 |
| 194 | fdt-$2 { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 195 | description = "Flattened Device Tree blob"; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 196 | data = /incbin/("$3"); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 197 | type = "flat_dt"; |
| 198 | arch = "${UBOOT_ARCH}"; |
| 199 | compression = "none"; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 200 | $dtb_loadline |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 201 | hash-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 202 | algo = "$dtb_csum"; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 203 | }; |
| 204 | }; |
| 205 | EOF |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 206 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 207 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$dtb_sign_keyname" ] ; then |
| 208 | sed -i '$ d' $1 |
| 209 | cat << EOF >> $1 |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 210 | signature-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 211 | algo = "$dtb_csum,$dtb_sign_algo"; |
| 212 | key-name-hint = "$dtb_sign_keyname"; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 213 | }; |
| 214 | }; |
| 215 | EOF |
| 216 | fi |
| 217 | } |
| 218 | |
| 219 | # |
| 220 | # Emit the fitImage ITS u-boot script section |
| 221 | # |
| 222 | # $1 ... .its filename |
| 223 | # $2 ... Image counter |
| 224 | # $3 ... Path to boot script image |
| 225 | fitimage_emit_section_boot_script() { |
| 226 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 227 | bootscr_csum="${FIT_HASH_ALG}" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 228 | bootscr_sign_algo="${FIT_SIGN_ALG}" |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 229 | bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 230 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 231 | cat << EOF >> $1 |
| 232 | bootscr-$2 { |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 233 | description = "U-boot script"; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 234 | data = /incbin/("$3"); |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 235 | type = "script"; |
| 236 | arch = "${UBOOT_ARCH}"; |
| 237 | compression = "none"; |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 238 | hash-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 239 | algo = "$bootscr_csum"; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 240 | }; |
| 241 | }; |
| 242 | EOF |
| 243 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 244 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$bootscr_sign_keyname" ] ; then |
| 245 | sed -i '$ d' $1 |
| 246 | cat << EOF >> $1 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 247 | signature-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 248 | algo = "$bootscr_csum,$bootscr_sign_algo"; |
| 249 | key-name-hint = "$bootscr_sign_keyname"; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 250 | }; |
| 251 | }; |
| 252 | EOF |
| 253 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | # |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 257 | # Emit the fitImage ITS setup section |
| 258 | # |
| 259 | # $1 ... .its filename |
| 260 | # $2 ... Image counter |
| 261 | # $3 ... Path to setup image |
| 262 | fitimage_emit_section_setup() { |
| 263 | |
Brad Bishop | f3fd288 | 2019-06-21 08:06:37 -0400 | [diff] [blame] | 264 | setup_csum="${FIT_HASH_ALG}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 265 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 266 | cat << EOF >> $1 |
| 267 | setup-$2 { |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 268 | description = "Linux setup.bin"; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 269 | data = /incbin/("$3"); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 270 | type = "x86_setup"; |
| 271 | arch = "${UBOOT_ARCH}"; |
| 272 | os = "linux"; |
| 273 | compression = "none"; |
| 274 | load = <0x00090000>; |
| 275 | entry = <0x00090000>; |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 276 | hash-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 277 | algo = "$setup_csum"; |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 278 | }; |
| 279 | }; |
| 280 | EOF |
| 281 | } |
| 282 | |
| 283 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 284 | # Emit the fitImage ITS ramdisk section |
| 285 | # |
| 286 | # $1 ... .its filename |
| 287 | # $2 ... Image counter |
| 288 | # $3 ... Path to ramdisk image |
| 289 | fitimage_emit_section_ramdisk() { |
| 290 | |
Brad Bishop | f3fd288 | 2019-06-21 08:06:37 -0400 | [diff] [blame] | 291 | ramdisk_csum="${FIT_HASH_ALG}" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 292 | ramdisk_sign_algo="${FIT_SIGN_ALG}" |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 293 | ramdisk_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" |
Nathan Rossi | b4a4dc0 | 2016-10-21 22:07:27 +1000 | [diff] [blame] | 294 | ramdisk_loadline="" |
| 295 | ramdisk_entryline="" |
| 296 | |
| 297 | if [ -n "${UBOOT_RD_LOADADDRESS}" ]; then |
| 298 | ramdisk_loadline="load = <${UBOOT_RD_LOADADDRESS}>;" |
| 299 | fi |
| 300 | if [ -n "${UBOOT_RD_ENTRYPOINT}" ]; then |
| 301 | ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;" |
| 302 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 303 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 304 | cat << EOF >> $1 |
| 305 | ramdisk-$2 { |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 306 | description = "${INITRAMFS_IMAGE}"; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 307 | data = /incbin/("$3"); |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 308 | type = "ramdisk"; |
| 309 | arch = "${UBOOT_ARCH}"; |
| 310 | os = "linux"; |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 311 | compression = "none"; |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 312 | $ramdisk_loadline |
| 313 | $ramdisk_entryline |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 314 | hash-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 315 | algo = "$ramdisk_csum"; |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 316 | }; |
| 317 | }; |
| 318 | EOF |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 319 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 320 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$ramdisk_sign_keyname" ] ; then |
| 321 | sed -i '$ d' $1 |
| 322 | cat << EOF >> $1 |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 323 | signature-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 324 | algo = "$ramdisk_csum,$ramdisk_sign_algo"; |
| 325 | key-name-hint = "$ramdisk_sign_keyname"; |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 326 | }; |
| 327 | }; |
| 328 | EOF |
| 329 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | # |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 333 | # Emit the fitImage ITS configuration section |
| 334 | # |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 335 | # $1 ... .its filename |
| 336 | # $2 ... Linux kernel ID |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 337 | # $3 ... DTB image name |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 338 | # $4 ... ramdisk ID |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 339 | # $5 ... u-boot script ID |
| 340 | # $6 ... config ID |
| 341 | # $7 ... default flag |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 342 | fitimage_emit_section_config() { |
| 343 | |
Brad Bishop | f3fd288 | 2019-06-21 08:06:37 -0400 | [diff] [blame] | 344 | conf_csum="${FIT_HASH_ALG}" |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 345 | conf_sign_algo="${FIT_SIGN_ALG}" |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 346 | if [ "${UBOOT_SIGN_ENABLE}" = "1" ] ; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 347 | conf_sign_keyname="${UBOOT_SIGN_KEYNAME}" |
| 348 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 349 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 350 | its_file="$1" |
| 351 | kernel_id="$2" |
| 352 | dtb_image="$3" |
| 353 | ramdisk_id="$4" |
| 354 | bootscr_id="$5" |
| 355 | config_id="$6" |
| 356 | default_flag="$7" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 357 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 358 | # Test if we have any DTBs at all |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 359 | sep="" |
| 360 | conf_desc="" |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 361 | conf_node="conf-" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 362 | kernel_line="" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 363 | fdt_line="" |
| 364 | ramdisk_line="" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 365 | bootscr_line="" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 366 | setup_line="" |
| 367 | default_line="" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 368 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 369 | # conf node name is selected based on dtb ID if it is present, |
| 370 | # otherwise its selected based on kernel ID |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 371 | if [ -n "$dtb_image" ]; then |
| 372 | conf_node=$conf_node$dtb_image |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 373 | else |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 374 | conf_node=$conf_node$kernel_id |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 375 | fi |
| 376 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 377 | if [ -n "$kernel_id" ]; then |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 378 | conf_desc="Linux kernel" |
| 379 | sep=", " |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 380 | kernel_line="kernel = \"kernel-$kernel_id\";" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 381 | fi |
| 382 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 383 | if [ -n "$dtb_image" ]; then |
| 384 | conf_desc="$conf_desc${sep}FDT blob" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 385 | sep=", " |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 386 | fdt_line="fdt = \"fdt-$dtb_image\";" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 387 | fi |
| 388 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 389 | if [ -n "$ramdisk_id" ]; then |
| 390 | conf_desc="$conf_desc${sep}ramdisk" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 391 | sep=", " |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 392 | ramdisk_line="ramdisk = \"ramdisk-$ramdisk_id\";" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 393 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 394 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 395 | if [ -n "$bootscr_id" ]; then |
| 396 | conf_desc="$conf_desc${sep}u-boot script" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 397 | sep=", " |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 398 | bootscr_line="bootscr = \"bootscr-$bootscr_id\";" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 399 | fi |
| 400 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 401 | if [ -n "$config_id" ]; then |
| 402 | conf_desc="$conf_desc${sep}setup" |
| 403 | setup_line="setup = \"setup-$config_id\";" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 404 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 405 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 406 | if [ "$default_flag" = "1" ]; then |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 407 | # default node is selected based on dtb ID if it is present, |
| 408 | # otherwise its selected based on kernel ID |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 409 | if [ -n "$dtb_image" ]; then |
| 410 | default_line="default = \"conf-$dtb_image\";" |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 411 | else |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 412 | default_line="default = \"conf-$kernel_id\";" |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 413 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 414 | fi |
| 415 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 416 | cat << EOF >> $its_file |
| 417 | $default_line |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 418 | $conf_node { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 419 | description = "$default_flag $conf_desc"; |
| 420 | $kernel_line |
| 421 | $fdt_line |
| 422 | $ramdisk_line |
| 423 | $bootscr_line |
| 424 | $setup_line |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 425 | hash-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 426 | algo = "$conf_csum"; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 427 | }; |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 428 | EOF |
| 429 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 430 | if [ -n "$conf_sign_keyname" ] ; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 431 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 432 | sign_line="sign-images = " |
| 433 | sep="" |
| 434 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 435 | if [ -n "$kernel_id" ]; then |
| 436 | sign_line="$sign_line${sep}\"kernel\"" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 437 | sep=", " |
| 438 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 439 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 440 | if [ -n "$dtb_image" ]; then |
| 441 | sign_line="$sign_line${sep}\"fdt\"" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 442 | sep=", " |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 443 | fi |
| 444 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 445 | if [ -n "$ramdisk_id" ]; then |
| 446 | sign_line="$sign_line${sep}\"ramdisk\"" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 447 | sep=", " |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 448 | fi |
| 449 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 450 | if [ -n "$bootscr_id" ]; then |
| 451 | sign_line="$sign_line${sep}\"bootscr\"" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 452 | sep=", " |
| 453 | fi |
| 454 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 455 | if [ -n "$config_id" ]; then |
| 456 | sign_line="$sign_line${sep}\"setup\"" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 457 | fi |
| 458 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 459 | sign_line="$sign_line;" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 460 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 461 | cat << EOF >> $its_file |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 462 | signature-1 { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 463 | algo = "$conf_csum,$conf_sign_algo"; |
| 464 | key-name-hint = "$conf_sign_keyname"; |
| 465 | $sign_line |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 466 | }; |
| 467 | EOF |
| 468 | fi |
| 469 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 470 | cat << EOF >> $its_file |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 471 | }; |
| 472 | EOF |
| 473 | } |
| 474 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 475 | # |
| 476 | # Assemble fitImage |
| 477 | # |
| 478 | # $1 ... .its filename |
| 479 | # $2 ... fitImage name |
| 480 | # $3 ... include ramdisk |
| 481 | fitimage_assemble() { |
| 482 | kernelcount=1 |
| 483 | dtbcount="" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 484 | DTBS="" |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 485 | ramdiskcount=$3 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 486 | setupcount="" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 487 | bootscr_id="" |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 488 | rm -f $1 arch/${ARCH}/boot/$2 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 489 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 490 | if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 491 | bbfatal "Keys used to sign images and configuration nodes must be different." |
| 492 | fi |
| 493 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 494 | fitimage_emit_fit_header $1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 495 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 496 | # |
| 497 | # Step 1: Prepare a kernel image section. |
| 498 | # |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 499 | fitimage_emit_section_maint $1 imagestart |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 500 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 501 | uboot_prep_kimage |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 502 | fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 503 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 504 | # |
| 505 | # Step 2: Prepare a DTB image section |
| 506 | # |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 507 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 508 | if [ -n "${KERNEL_DEVICETREE}" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 509 | dtbcount=1 |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 510 | for DTB in ${KERNEL_DEVICETREE}; do |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 511 | if echo $DTB | grep -q '/dts/'; then |
| 512 | bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used." |
| 513 | DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'` |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 514 | fi |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 515 | |
| 516 | # Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE} |
| 517 | if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ] && [ -s ${EXTERNAL_KERNEL_DEVICETREE}/${DTB} ]; then |
| 518 | continue |
| 519 | fi |
| 520 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 521 | DTB_PATH="arch/${ARCH}/boot/dts/$DTB" |
| 522 | if [ ! -e "$DTB_PATH" ]; then |
| 523 | DTB_PATH="arch/${ARCH}/boot/$DTB" |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 524 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 525 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 526 | DTB=$(echo "$DTB" | tr '/' '_') |
| 527 | DTBS="$DTBS $DTB" |
| 528 | fitimage_emit_section_dtb $1 $DTB $DTB_PATH |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 529 | done |
| 530 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 531 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 532 | if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then |
| 533 | dtbcount=1 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 534 | for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 535 | DTB=$(echo "$DTB" | tr '/' '_') |
| 536 | DTBS="$DTBS $DTB" |
| 537 | fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 538 | done |
| 539 | fi |
| 540 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 541 | # |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 542 | # Step 3: Prepare a u-boot script section |
| 543 | # |
| 544 | |
| 545 | if [ -n "${UBOOT_ENV}" ] && [ -d "${STAGING_DIR_HOST}/boot" ]; then |
| 546 | if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then |
| 547 | cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B} |
| 548 | bootscr_id="${UBOOT_ENV_BINARY}" |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 549 | fitimage_emit_section_boot_script $1 "$bootscr_id" ${UBOOT_ENV_BINARY} |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 550 | else |
| 551 | bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found." |
| 552 | fi |
| 553 | fi |
| 554 | |
| 555 | # |
| 556 | # Step 4: Prepare a setup section. (For x86) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 557 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 558 | if [ -e arch/${ARCH}/boot/setup.bin ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 559 | setupcount=1 |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 560 | fitimage_emit_section_setup $1 $setupcount arch/${ARCH}/boot/setup.bin |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 561 | fi |
| 562 | |
| 563 | # |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 564 | # Step 5: Prepare a ramdisk section. |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 565 | # |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 566 | if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 567 | # Find and use the first initramfs image archive type we find |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 568 | for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio; do |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 569 | initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" |
| 570 | echo -n "Searching for $initramfs_path..." |
| 571 | if [ -e "$initramfs_path" ]; then |
| 572 | echo "found" |
| 573 | fitimage_emit_section_ramdisk $1 "$ramdiskcount" "$initramfs_path" |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 574 | break |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 575 | else |
| 576 | echo "not found" |
Rick Altherr | bc1b880 | 2017-01-20 11:28:53 -0800 | [diff] [blame] | 577 | fi |
| 578 | done |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 579 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 580 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 581 | fitimage_emit_section_maint $1 sectend |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 582 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 583 | # Force the first Kernel and DTB in the default config |
| 584 | kernelcount=1 |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 585 | if [ -n "$dtbcount" ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 586 | dtbcount=1 |
| 587 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 588 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 589 | # |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 590 | # Step 6: Prepare a configurations section |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 591 | # |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 592 | fitimage_emit_section_maint $1 confstart |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 593 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 594 | # kernel-fitimage.bbclass currently only supports a single kernel (no less or |
| 595 | # more) to be added to the FIT image along with 0 or more device trees and |
| 596 | # 0 or 1 ramdisk. |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 597 | # It is also possible to include an initramfs bundle (kernel and rootfs in one binary) |
| 598 | # When the initramfs bundle is used ramdisk is disabled. |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 599 | # If a device tree is to be part of the FIT image, then select |
| 600 | # the default configuration to be used is based on the dtbcount. If there is |
| 601 | # no dtb present than select the default configuation to be based on |
| 602 | # the kernelcount. |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 603 | if [ -n "$DTBS" ]; then |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 604 | i=1 |
| 605 | for DTB in ${DTBS}; do |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 606 | dtb_ext=${DTB##*.} |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 607 | if [ "$dtb_ext" = "dtbo" ]; then |
| 608 | fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 609 | else |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 610 | fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 611 | fi |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 612 | i=`expr $i + 1` |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 613 | done |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 614 | else |
| 615 | defaultconfigcount=1 |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 616 | fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id" "$setupcount" $defaultconfigcount |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 617 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 618 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 619 | fitimage_emit_section_maint $1 sectend |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 620 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 621 | fitimage_emit_section_maint $1 fitend |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 622 | |
| 623 | # |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 624 | # Step 7: Assemble the image |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 625 | # |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 626 | ${UBOOT_MKIMAGE} \ |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 627 | ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 628 | -f $1 \ |
| 629 | arch/${ARCH}/boot/$2 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 630 | |
| 631 | # |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 632 | # Step 8: Sign the image and add public key to U-Boot dtb |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 633 | # |
| 634 | if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 635 | add_key_to_u_boot="" |
| 636 | if [ -n "${UBOOT_DTB_BINARY}" ]; then |
| 637 | # The u-boot.dtb is a symlink to UBOOT_DTB_IMAGE, so we need copy |
| 638 | # both of them, and don't dereference the symlink. |
| 639 | cp -P ${STAGING_DATADIR}/u-boot*.dtb ${B} |
| 640 | add_key_to_u_boot="-K ${B}/${UBOOT_DTB_BINARY}" |
| 641 | fi |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 642 | ${UBOOT_MKIMAGE_SIGN} \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 643 | ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ |
| 644 | -F -k "${UBOOT_SIGN_KEYDIR}" \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 645 | $add_key_to_u_boot \ |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 646 | -r arch/${ARCH}/boot/$2 \ |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 647 | ${UBOOT_MKIMAGE_SIGN_ARGS} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 648 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | do_assemble_fitimage() { |
| 652 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then |
| 653 | cd ${B} |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 654 | fitimage_assemble fit-image.its fitImage "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 655 | fi |
| 656 | } |
| 657 | |
| 658 | addtask assemble_fitimage before do_install after do_compile |
| 659 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 660 | do_assemble_fitimage_initramfs() { |
| 661 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \ |
| 662 | test -n "${INITRAMFS_IMAGE}" ; then |
| 663 | cd ${B} |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 664 | if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then |
| 665 | fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage "" |
| 666 | else |
| 667 | fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage-${INITRAMFS_IMAGE} 1 |
| 668 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 669 | fi |
| 670 | } |
| 671 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 672 | addtask assemble_fitimage_initramfs before do_deploy after do_bundle_initramfs |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 673 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 674 | do_kernel_generate_rsa_keys() { |
| 675 | if [ "${UBOOT_SIGN_ENABLE}" = "0" ] && [ "${FIT_GENERATE_KEYS}" = "1" ]; then |
| 676 | bbwarn "FIT_GENERATE_KEYS is set to 1 even though UBOOT_SIGN_ENABLE is set to 0. The keys will not be generated as they won't be used." |
| 677 | fi |
| 678 | |
| 679 | if [ "${UBOOT_SIGN_ENABLE}" = "1" ] && [ "${FIT_GENERATE_KEYS}" = "1" ]; then |
| 680 | |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 681 | # Generate keys to sign configuration nodes, only if they don't already exist |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 682 | if [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key ] || \ |
| 683 | [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".crt ]; then |
| 684 | |
| 685 | # make directory if it does not already exist |
| 686 | mkdir -p "${UBOOT_SIGN_KEYDIR}" |
| 687 | |
| 688 | echo "Generating RSA private key for signing fitImage" |
| 689 | openssl genrsa ${FIT_KEY_GENRSA_ARGS} -out \ |
| 690 | "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key \ |
| 691 | "${FIT_SIGN_NUMBITS}" |
| 692 | |
| 693 | echo "Generating certificate for signing fitImage" |
| 694 | openssl req ${FIT_KEY_REQ_ARGS} "${FIT_KEY_SIGN_PKCS}" \ |
| 695 | -key "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key \ |
| 696 | -out "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".crt |
| 697 | fi |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 698 | |
| 699 | # Generate keys to sign image nodes, only if they don't already exist |
| 700 | if [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".key ] || \ |
| 701 | [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".crt ]; then |
| 702 | |
| 703 | # make directory if it does not already exist |
| 704 | mkdir -p "${UBOOT_SIGN_KEYDIR}" |
| 705 | |
| 706 | echo "Generating RSA private key for signing fitImage" |
| 707 | openssl genrsa ${FIT_KEY_GENRSA_ARGS} -out \ |
| 708 | "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".key \ |
| 709 | "${FIT_SIGN_NUMBITS}" |
| 710 | |
| 711 | echo "Generating certificate for signing fitImage" |
| 712 | openssl req ${FIT_KEY_REQ_ARGS} "${FIT_KEY_SIGN_PKCS}" \ |
| 713 | -key "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".key \ |
| 714 | -out "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_IMG_KEYNAME}".crt |
| 715 | fi |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 716 | fi |
| 717 | } |
| 718 | |
| 719 | addtask kernel_generate_rsa_keys before do_assemble_fitimage after do_compile |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 720 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 721 | kernel_do_deploy[vardepsexclude] = "DATETIME" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 722 | kernel_do_deploy:append() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 723 | # Update deploy directory |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 724 | if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 725 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 726 | if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then |
| 727 | echo "Copying fit-image.its source file..." |
| 728 | install -m 0644 ${B}/fit-image.its "$deployDir/fitImage-its-${KERNEL_FIT_NAME}.its" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 729 | if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then |
| 730 | ln -snf fitImage-its-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${KERNEL_FIT_LINK_NAME}" |
| 731 | fi |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 732 | |
| 733 | echo "Copying linux.bin file..." |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 734 | install -m 0644 ${B}/linux.bin $deployDir/fitImage-linux.bin-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT} |
| 735 | if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then |
| 736 | ln -snf fitImage-linux.bin-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT} "$deployDir/fitImage-linux.bin-${KERNEL_FIT_LINK_NAME}" |
| 737 | fi |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 738 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 739 | |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 740 | if [ -n "${INITRAMFS_IMAGE}" ]; then |
| 741 | echo "Copying fit-image-${INITRAMFS_IMAGE}.its source file..." |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 742 | install -m 0644 ${B}/fit-image-${INITRAMFS_IMAGE}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 743 | if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then |
| 744 | ln -snf fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" |
| 745 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 746 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 747 | if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then |
| 748 | echo "Copying fitImage-${INITRAMFS_IMAGE} file..." |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 749 | install -m 0644 ${B}/arch/${ARCH}/boot/fitImage-${INITRAMFS_IMAGE} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT}" |
| 750 | if [ -n "${KERNEL_FIT_LINK_NAME}" ] ; then |
| 751 | ln -snf fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}${KERNEL_FIT_BIN_EXT} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}" |
| 752 | fi |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 753 | fi |
George McCollister | 185c8ae | 2016-05-26 08:55:16 -0500 | [diff] [blame] | 754 | fi |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 755 | fi |
| 756 | if [ "${UBOOT_SIGN_ENABLE}" = "1" -o "${UBOOT_FITIMAGE_ENABLE}" = "1" ] && \ |
| 757 | [ -n "${UBOOT_DTB_BINARY}" ] ; then |
| 758 | # UBOOT_DTB_IMAGE is a realfile, but we can't use |
| 759 | # ${UBOOT_DTB_IMAGE} since it contains ${PV} which is aimed |
| 760 | # for u-boot, but we are in kernel env now. |
| 761 | install -m 0644 ${B}/u-boot-${MACHINE}*.dtb "$deployDir/" |
| 762 | fi |
| 763 | if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" -a -n "${UBOOT_BINARY}" -a -n "${SPL_DTB_BINARY}" ] ; then |
| 764 | # If we're also creating and/or signing the uboot fit, now we need to |
| 765 | # deploy it, it's its file, as well as u-boot-spl.dtb |
| 766 | install -m 0644 ${B}/u-boot-spl-${MACHINE}*.dtb "$deployDir/" |
| 767 | echo "Copying u-boot-fitImage file..." |
| 768 | install -m 0644 ${B}/u-boot-fitImage-* "$deployDir/" |
| 769 | echo "Copying u-boot-its file..." |
| 770 | install -m 0644 ${B}/u-boot-its-* "$deployDir/" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 771 | fi |
| 772 | } |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 773 | |
| 774 | # The function below performs the following in case of initramfs bundles: |
| 775 | # - Removes do_assemble_fitimage. FIT generation is done through |
| 776 | # do_assemble_fitimage_initramfs. do_assemble_fitimage is not needed |
| 777 | # and should not be part of the tasks to be executed. |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 778 | # - Since do_kernel_generate_rsa_keys is inserted by default |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 779 | # between do_compile and do_assemble_fitimage, this is |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 780 | # not suitable in case of initramfs bundles. do_kernel_generate_rsa_keys |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 781 | # should be between do_bundle_initramfs and do_assemble_fitimage_initramfs. |
| 782 | python () { |
| 783 | if d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1": |
| 784 | bb.build.deltask('do_assemble_fitimage', d) |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 785 | bb.build.deltask('kernel_generate_rsa_keys', d) |
| 786 | bb.build.addtask('kernel_generate_rsa_keys', 'do_assemble_fitimage_initramfs', 'do_bundle_initramfs', d) |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 787 | } |