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