blob: a9d1002200c935f5f82fe63ebb63cacd164e6415 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001inherit kernel-uboot kernel-artifact-names uboot-sign
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002
Andrew Geisslerd1e89492021-02-12 15:35:20 -06003KERNEL_IMAGETYPE_REPLACEMENT = ""
4
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005python __anonymous () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006 kerneltypes = d.getVar('KERNEL_IMAGETYPES') or ""
He Zhefe76b1e2016-05-25 04:47:16 -04007 if 'fitImage' in kerneltypes.split():
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008 depends = d.getVar("DEPENDS")
Brad Bishop19323692019-04-05 15:28:33 -04009 depends = "%s u-boot-tools-native dtc-native" % depends
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010 d.setVar("DEPENDS", depends)
11
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012 uarch = d.getVar("UBOOT_ARCH")
13 if uarch == "arm64":
14 replacementtype = "Image"
Brad Bishopc342db32019-05-15 21:57:59 -040015 elif uarch == "riscv":
16 replacementtype = "Image"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050017 elif uarch == "mips":
Brad Bishop6e60e8b2018-02-01 10:27:11 -050018 replacementtype = "vmlinuz.bin"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019 elif uarch == "x86":
Patrick Williamsc0f7c042017-02-23 20:41:17 -060020 replacementtype = "bzImage"
Brad Bishop316dfdd2018-06-25 12:45:53 -040021 elif uarch == "microblaze":
22 replacementtype = "linux.bin"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060023 else:
24 replacementtype = "zImage"
25
Andrew Geisslerd1e89492021-02-12 15:35:20 -060026 d.setVar("KERNEL_IMAGETYPE_REPLACEMENT", replacementtype)
27
Brad Bishop19323692019-04-05 15:28:33 -040028 # 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 Bishop6e60e8b2018-02-01 10:27:11 -050031 typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or ""
He Zhefe76b1e2016-05-25 04:47:16 -040032 if 'fitImage' in typeformake.split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('fitImage', replacementtype))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034
Brad Bishop6e60e8b2018-02-01 10:27:11 -050035 image = d.getVar('INITRAMFS_IMAGE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036 if image:
George McCollister185c8ae2016-05-26 08:55:16 -050037 d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
38
Brad Bishop19323692019-04-05 15:28:33 -040039 #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 Williamsc0f7c042017-02-23 20:41:17 -060046 # Verified boot will sign the fitImage and append the public key to
Brad Bishop6e60e8b2018-02-01 10:27:11 -050047 # U-Boot dtb. We ensure the U-Boot dtb is deployed before assembling
Patrick Williamsc0f7c042017-02-23 20:41:17 -060048 # the fitImage:
Brad Bishop15ae2502019-06-18 21:44:24 -040049 if d.getVar('UBOOT_SIGN_ENABLE') == "1" and d.getVar('UBOOT_DTB_BINARY'):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 uboot_pn = d.getVar('PREFERRED_PROVIDER_u-boot') or 'u-boot'
Brad Bishop19323692019-04-05 15:28:33 -040051 d.appendVarFlag('do_assemble_fitimage', 'depends', ' %s:do_populate_sysroot' % uboot_pn)
Andrew Geisslerd1e89492021-02-12 15:35:20 -060052 if d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1":
53 d.appendVarFlag('do_assemble_fitimage_initramfs', 'depends', ' %s:do_populate_sysroot' % uboot_pn)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054}
55
Andrew Geisslerf0343792020-11-18 10:42:21 -060056
Andrew Geisslerd1e89492021-02-12 15:35:20 -060057# Description string
Andrew Geissler3b8a17c2021-04-15 15:55:55 -050058FIT_DESC ?= "Kernel fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -060059
60# Sign individual images as well
61FIT_SIGN_INDIVIDUAL ?= "0"
62
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063#
64# Emit the fitImage ITS header
65#
George McCollister185c8ae2016-05-26 08:55:16 -050066# $1 ... .its filename
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067fitimage_emit_fit_header() {
George McCollister185c8ae2016-05-26 08:55:16 -050068 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069/dts-v1/;
70
71/ {
Andrew Geisslerd1e89492021-02-12 15:35:20 -060072 description = "${FIT_DESC}";
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 #address-cells = <1>;
74EOF
75}
76
77#
78# Emit the fitImage section bits
79#
George McCollister185c8ae2016-05-26 08:55:16 -050080# $1 ... .its filename
81# $2 ... Section bit type: imagestart - image section start
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082# confstart - configuration section start
83# sectend - section end
84# fitend - fitimage end
85#
86fitimage_emit_section_maint() {
George McCollister185c8ae2016-05-26 08:55:16 -050087 case $2 in
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 imagestart)
George McCollister185c8ae2016-05-26 08:55:16 -050089 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090
91 images {
92EOF
93 ;;
94 confstart)
George McCollister185c8ae2016-05-26 08:55:16 -050095 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096
97 configurations {
98EOF
99 ;;
100 sectend)
George McCollister185c8ae2016-05-26 08:55:16 -0500101 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102 };
103EOF
104 ;;
105 fitend)
George McCollister185c8ae2016-05-26 08:55:16 -0500106 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107};
108EOF
109 ;;
110 esac
111}
112
113#
114# Emit the fitImage ITS kernel section
115#
George McCollister185c8ae2016-05-26 08:55:16 -0500116# $1 ... .its filename
117# $2 ... Image counter
118# $3 ... Path to kernel image
119# $4 ... Compression type
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500120fitimage_emit_section_kernel() {
121
Brad Bishopf3fd2882019-06-21 08:06:37 -0400122 kernel_csum="${FIT_HASH_ALG}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600123 kernel_sign_algo="${FIT_SIGN_ALG}"
124 kernel_sign_keyname="${UBOOT_SIGN_KEYNAME}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125
Brad Bishop316dfdd2018-06-25 12:45:53 -0400126 ENTRYPOINT="${UBOOT_ENTRYPOINT}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500127 if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then
128 ENTRYPOINT=`${HOST_PREFIX}nm vmlinux | \
129 awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130 fi
131
George McCollister185c8ae2016-05-26 08:55:16 -0500132 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600133 kernel-${2} {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134 description = "Linux kernel";
George McCollister185c8ae2016-05-26 08:55:16 -0500135 data = /incbin/("${3}");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136 type = "kernel";
137 arch = "${UBOOT_ARCH}";
138 os = "linux";
George McCollister185c8ae2016-05-26 08:55:16 -0500139 compression = "${4}";
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140 load = <${UBOOT_LOADADDRESS}>;
141 entry = <${ENTRYPOINT}>;
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600142 hash-1 {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500143 algo = "${kernel_csum}";
144 };
145 };
146EOF
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600147
148 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${kernel_sign_keyname}" ] ; then
149 sed -i '$ d' ${1}
150 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600151 signature-1 {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600152 algo = "${kernel_csum},${kernel_sign_algo}";
153 key-name-hint = "${kernel_sign_keyname}";
154 };
155 };
156EOF
157 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158}
159
160#
161# Emit the fitImage ITS DTB section
162#
George McCollister185c8ae2016-05-26 08:55:16 -0500163# $1 ... .its filename
164# $2 ... Image counter
165# $3 ... Path to DTB image
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166fitimage_emit_section_dtb() {
167
Brad Bishopf3fd2882019-06-21 08:06:37 -0400168 dtb_csum="${FIT_HASH_ALG}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600169 dtb_sign_algo="${FIT_SIGN_ALG}"
170 dtb_sign_keyname="${UBOOT_SIGN_KEYNAME}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800172 dtb_loadline=""
173 dtb_ext=${DTB##*.}
174 if [ "${dtb_ext}" = "dtbo" ]; then
175 if [ -n "${UBOOT_DTBO_LOADADDRESS}" ]; then
176 dtb_loadline="load = <${UBOOT_DTBO_LOADADDRESS}>;"
177 fi
178 elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
179 dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
180 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500181 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600182 fdt-${2} {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500183 description = "Flattened Device Tree blob";
George McCollister185c8ae2016-05-26 08:55:16 -0500184 data = /incbin/("${3}");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500185 type = "flat_dt";
186 arch = "${UBOOT_ARCH}";
187 compression = "none";
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800188 ${dtb_loadline}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600189 hash-1 {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500190 algo = "${dtb_csum}";
191 };
192 };
193EOF
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600194
195 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${dtb_sign_keyname}" ] ; then
196 sed -i '$ d' ${1}
197 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600198 signature-1 {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600199 algo = "${dtb_csum},${dtb_sign_algo}";
200 key-name-hint = "${dtb_sign_keyname}";
201 };
202 };
203EOF
204 fi
205}
206
207#
208# Emit the fitImage ITS u-boot script section
209#
210# $1 ... .its filename
211# $2 ... Image counter
212# $3 ... Path to boot script image
213fitimage_emit_section_boot_script() {
214
215 bootscr_csum="${FIT_HASH_ALG}"
216 bootscr_sign_algo="${FIT_SIGN_ALG}"
217 bootscr_sign_keyname="${UBOOT_SIGN_KEYNAME}"
218
219 cat << EOF >> ${1}
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700220 bootscr-${2} {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600221 description = "U-boot script";
222 data = /incbin/("${3}");
223 type = "script";
224 arch = "${UBOOT_ARCH}";
225 compression = "none";
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700226 hash-1 {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600227 algo = "${bootscr_csum}";
228 };
229 };
230EOF
231
232 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${bootscr_sign_keyname}" ] ; then
233 sed -i '$ d' ${1}
234 cat << EOF >> ${1}
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700235 signature-1 {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600236 algo = "${bootscr_csum},${bootscr_sign_algo}";
237 key-name-hint = "${bootscr_sign_keyname}";
238 };
239 };
240EOF
241 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500242}
243
244#
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600245# Emit the fitImage ITS setup section
246#
247# $1 ... .its filename
248# $2 ... Image counter
249# $3 ... Path to setup image
250fitimage_emit_section_setup() {
251
Brad Bishopf3fd2882019-06-21 08:06:37 -0400252 setup_csum="${FIT_HASH_ALG}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600253
254 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600255 setup-${2} {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600256 description = "Linux setup.bin";
257 data = /incbin/("${3}");
258 type = "x86_setup";
259 arch = "${UBOOT_ARCH}";
260 os = "linux";
261 compression = "none";
262 load = <0x00090000>;
263 entry = <0x00090000>;
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600264 hash-1 {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600265 algo = "${setup_csum}";
266 };
267 };
268EOF
269}
270
271#
George McCollister185c8ae2016-05-26 08:55:16 -0500272# Emit the fitImage ITS ramdisk section
273#
274# $1 ... .its filename
275# $2 ... Image counter
276# $3 ... Path to ramdisk image
277fitimage_emit_section_ramdisk() {
278
Brad Bishopf3fd2882019-06-21 08:06:37 -0400279 ramdisk_csum="${FIT_HASH_ALG}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600280 ramdisk_sign_algo="${FIT_SIGN_ALG}"
281 ramdisk_sign_keyname="${UBOOT_SIGN_KEYNAME}"
Nathan Rossib4a4dc02016-10-21 22:07:27 +1000282 ramdisk_loadline=""
283 ramdisk_entryline=""
284
285 if [ -n "${UBOOT_RD_LOADADDRESS}" ]; then
286 ramdisk_loadline="load = <${UBOOT_RD_LOADADDRESS}>;"
287 fi
288 if [ -n "${UBOOT_RD_ENTRYPOINT}" ]; then
289 ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
290 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500291
292 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600293 ramdisk-${2} {
Rick Altherrbc1b8802017-01-20 11:28:53 -0800294 description = "${INITRAMFS_IMAGE}";
George McCollister185c8ae2016-05-26 08:55:16 -0500295 data = /incbin/("${3}");
296 type = "ramdisk";
297 arch = "${UBOOT_ARCH}";
298 os = "linux";
Brad Bishop00e122a2019-10-05 11:10:57 -0400299 compression = "none";
Nathan Rossib4a4dc02016-10-21 22:07:27 +1000300 ${ramdisk_loadline}
301 ${ramdisk_entryline}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600302 hash-1 {
George McCollister185c8ae2016-05-26 08:55:16 -0500303 algo = "${ramdisk_csum}";
304 };
305 };
306EOF
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600307
308 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${ramdisk_sign_keyname}" ] ; then
309 sed -i '$ d' ${1}
310 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600311 signature-1 {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600312 algo = "${ramdisk_csum},${ramdisk_sign_algo}";
313 key-name-hint = "${ramdisk_sign_keyname}";
314 };
315 };
316EOF
317 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500318}
319
320#
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500321# Emit the fitImage ITS configuration section
322#
George McCollister185c8ae2016-05-26 08:55:16 -0500323# $1 ... .its filename
324# $2 ... Linux kernel ID
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500325# $3 ... DTB image name
George McCollister185c8ae2016-05-26 08:55:16 -0500326# $4 ... ramdisk ID
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600327# $5 ... u-boot script ID
328# $6 ... config ID
329# $7 ... default flag
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500330fitimage_emit_section_config() {
331
Brad Bishopf3fd2882019-06-21 08:06:37 -0400332 conf_csum="${FIT_HASH_ALG}"
Brad Bishop64c979e2019-11-04 13:55:29 -0500333 conf_sign_algo="${FIT_SIGN_ALG}"
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700334 if [ "${UBOOT_SIGN_ENABLE}" = "1" ] ; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600335 conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
336 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500337
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600338 its_file="${1}"
339 kernel_id="${2}"
340 dtb_image="${3}"
341 ramdisk_id="${4}"
342 bootscr_id="${5}"
343 config_id="${6}"
344 default_flag="${7}"
345
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500346 # Test if we have any DTBs at all
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800347 sep=""
348 conf_desc=""
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600349 conf_node="conf-"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800350 kernel_line=""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600351 fdt_line=""
352 ramdisk_line=""
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600353 bootscr_line=""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500354 setup_line=""
355 default_line=""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600356
Andrew Geissler635e0e42020-08-21 15:58:33 -0500357 # conf node name is selected based on dtb ID if it is present,
358 # otherwise its selected based on kernel ID
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600359 if [ -n "${dtb_image}" ]; then
360 conf_node=$conf_node${dtb_image}
Andrew Geissler635e0e42020-08-21 15:58:33 -0500361 else
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600362 conf_node=$conf_node${kernel_id}
Andrew Geissler635e0e42020-08-21 15:58:33 -0500363 fi
364
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600365 if [ -n "${kernel_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800366 conf_desc="Linux kernel"
367 sep=", "
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600368 kernel_line="kernel = \"kernel-${kernel_id}\";"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800369 fi
370
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600371 if [ -n "${dtb_image}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800372 conf_desc="${conf_desc}${sep}FDT blob"
373 sep=", "
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600374 fdt_line="fdt = \"fdt-${dtb_image}\";"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600375 fi
376
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600377 if [ -n "${ramdisk_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800378 conf_desc="${conf_desc}${sep}ramdisk"
379 sep=", "
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600380 ramdisk_line="ramdisk = \"ramdisk-${ramdisk_id}\";"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500381 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600382
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600383 if [ -n "${bootscr_id}" ]; then
384 conf_desc="${conf_desc}${sep}u-boot script"
385 sep=", "
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700386 bootscr_line="bootscr = \"bootscr-${bootscr_id}\";"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600387 fi
388
389 if [ -n "${config_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800390 conf_desc="${conf_desc}${sep}setup"
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600391 setup_line="setup = \"setup-${config_id}\";"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600392 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500393
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600394 if [ "${default_flag}" = "1" ]; then
Andrew Geissler635e0e42020-08-21 15:58:33 -0500395 # default node is selected based on dtb ID if it is present,
396 # otherwise its selected based on kernel ID
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600397 if [ -n "${dtb_image}" ]; then
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600398 default_line="default = \"conf-${dtb_image}\";"
Andrew Geissler635e0e42020-08-21 15:58:33 -0500399 else
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600400 default_line="default = \"conf-${kernel_id}\";"
Andrew Geissler635e0e42020-08-21 15:58:33 -0500401 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500402 fi
403
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600404 cat << EOF >> ${its_file}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500405 ${default_line}
Andrew Geissler635e0e42020-08-21 15:58:33 -0500406 $conf_node {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600407 description = "${default_flag} ${conf_desc}";
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500408 ${kernel_line}
409 ${fdt_line}
George McCollister185c8ae2016-05-26 08:55:16 -0500410 ${ramdisk_line}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600411 ${bootscr_line}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600412 ${setup_line}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600413 hash-1 {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500414 algo = "${conf_csum}";
415 };
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600416EOF
417
418 if [ ! -z "${conf_sign_keyname}" ] ; then
419
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800420 sign_line="sign-images = "
421 sep=""
422
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600423 if [ -n "${kernel_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800424 sign_line="${sign_line}${sep}\"kernel\""
425 sep=", "
426 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600427
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600428 if [ -n "${dtb_image}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800429 sign_line="${sign_line}${sep}\"fdt\""
430 sep=", "
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600431 fi
432
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600433 if [ -n "${ramdisk_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800434 sign_line="${sign_line}${sep}\"ramdisk\""
435 sep=", "
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600436 fi
437
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600438 if [ -n "${bootscr_id}" ]; then
439 sign_line="${sign_line}${sep}\"bootscr\""
440 sep=", "
441 fi
442
443 if [ -n "${config_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800444 sign_line="${sign_line}${sep}\"setup\""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600445 fi
446
447 sign_line="${sign_line};"
448
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600449 cat << EOF >> ${its_file}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600450 signature-1 {
Brad Bishop64c979e2019-11-04 13:55:29 -0500451 algo = "${conf_csum},${conf_sign_algo}";
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600452 key-name-hint = "${conf_sign_keyname}";
453 ${sign_line}
454 };
455EOF
456 fi
457
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600458 cat << EOF >> ${its_file}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500459 };
460EOF
461}
462
George McCollister185c8ae2016-05-26 08:55:16 -0500463#
464# Assemble fitImage
465#
466# $1 ... .its filename
467# $2 ... fitImage name
468# $3 ... include ramdisk
469fitimage_assemble() {
470 kernelcount=1
471 dtbcount=""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500472 DTBS=""
George McCollister185c8ae2016-05-26 08:55:16 -0500473 ramdiskcount=${3}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600474 setupcount=""
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600475 bootscr_id=""
George McCollister185c8ae2016-05-26 08:55:16 -0500476 rm -f ${1} arch/${ARCH}/boot/${2}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500477
George McCollister185c8ae2016-05-26 08:55:16 -0500478 fitimage_emit_fit_header ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500479
George McCollister185c8ae2016-05-26 08:55:16 -0500480 #
481 # Step 1: Prepare a kernel image section.
482 #
483 fitimage_emit_section_maint ${1} imagestart
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500484
George McCollister185c8ae2016-05-26 08:55:16 -0500485 uboot_prep_kimage
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600486
487 if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
488 initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
489 if [ -e "${initramfs_bundle_path}" ]; then
490
491 #
492 # Include the kernel/rootfs bundle.
493 #
494
495 fitimage_emit_section_kernel ${1} "${kernelcount}" "${initramfs_bundle_path}" "${linux_comp}"
496 else
497 bbwarn "${initramfs_bundle_path} not found."
498 fi
499 else
500 fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}"
501 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500502
George McCollister185c8ae2016-05-26 08:55:16 -0500503 #
504 # Step 2: Prepare a DTB image section
505 #
Brad Bishop19323692019-04-05 15:28:33 -0400506
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500507 if [ -n "${KERNEL_DEVICETREE}" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500508 dtbcount=1
George McCollister185c8ae2016-05-26 08:55:16 -0500509 for DTB in ${KERNEL_DEVICETREE}; do
510 if echo ${DTB} | grep -q '/dts/'; then
511 bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
512 DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
513 fi
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500514
515 # Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
516 if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ] && [ -s ${EXTERNAL_KERNEL_DEVICETREE}/${DTB} ]; then
517 continue
518 fi
519
George McCollister185c8ae2016-05-26 08:55:16 -0500520 DTB_PATH="arch/${ARCH}/boot/dts/${DTB}"
521 if [ ! -e "${DTB_PATH}" ]; then
522 DTB_PATH="arch/${ARCH}/boot/${DTB}"
523 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500524
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500525 DTB=$(echo "${DTB}" | tr '/' '_')
526 DTBS="${DTBS} ${DTB}"
527 fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
George McCollister185c8ae2016-05-26 08:55:16 -0500528 done
529 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500530
Brad Bishop19323692019-04-05 15:28:33 -0400531 if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
532 dtbcount=1
Andrew Geissler82c905d2020-04-13 13:39:40 -0500533 for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do
Brad Bishop19323692019-04-05 15:28:33 -0400534 DTB=$(echo "${DTB}" | tr '/' '_')
535 DTBS="${DTBS} ${DTB}"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500536 fitimage_emit_section_dtb ${1} ${DTB} "${EXTERNAL_KERNEL_DEVICETREE}/${DTB}"
Brad Bishop19323692019-04-05 15:28:33 -0400537 done
538 fi
539
George McCollister185c8ae2016-05-26 08:55:16 -0500540 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600541 # Step 3: Prepare a u-boot script section
542 #
543
544 if [ -n "${UBOOT_ENV}" ] && [ -d "${STAGING_DIR_HOST}/boot" ]; then
545 if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
546 cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
547 bootscr_id="${UBOOT_ENV_BINARY}"
548 fitimage_emit_section_boot_script ${1} "${bootscr_id}" ${UBOOT_ENV_BINARY}
549 else
550 bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
551 fi
552 fi
553
554 #
555 # Step 4: Prepare a setup section. (For x86)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600556 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500557 if [ -e arch/${ARCH}/boot/setup.bin ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600558 setupcount=1
559 fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
560 fi
561
562 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600563 # Step 5: Prepare a ramdisk section.
George McCollister185c8ae2016-05-26 08:55:16 -0500564 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600565 if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
Rick Altherrbc1b8802017-01-20 11:28:53 -0800566 # Find and use the first initramfs image archive type we find
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800567 for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.gz ext2.gz cpio; do
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500568 initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}"
Rick Altherrbc1b8802017-01-20 11:28:53 -0800569 echo "Using $initramfs_path"
570 if [ -e "${initramfs_path}" ]; then
571 fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
572 break
573 fi
574 done
George McCollister185c8ae2016-05-26 08:55:16 -0500575 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500576
George McCollister185c8ae2016-05-26 08:55:16 -0500577 fitimage_emit_section_maint ${1} sectend
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500578
George McCollister185c8ae2016-05-26 08:55:16 -0500579 # Force the first Kernel and DTB in the default config
580 kernelcount=1
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500581 if [ -n "${dtbcount}" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600582 dtbcount=1
583 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500584
George McCollister185c8ae2016-05-26 08:55:16 -0500585 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600586 # Step 6: Prepare a configurations section
George McCollister185c8ae2016-05-26 08:55:16 -0500587 #
588 fitimage_emit_section_maint ${1} confstart
589
Andrew Geissler635e0e42020-08-21 15:58:33 -0500590 # 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 Geisslerd1e89492021-02-12 15:35:20 -0600593 # 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 Geissler635e0e42020-08-21 15:58:33 -0500595 # 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.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500599 if [ -n "${DTBS}" ]; then
600 i=1
601 for DTB in ${DTBS}; do
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800602 dtb_ext=${DTB##*.}
603 if [ "${dtb_ext}" = "dtbo" ]; then
Andrew Geissler9b4d8b02021-02-19 12:26:16 -0600604 fitimage_emit_section_config ${1} "" "${DTB}" "" "${bootscr_id}" "" "`expr ${i} = ${dtbcount}`"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800605 else
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600606 fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "`expr ${i} = ${dtbcount}`"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800607 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500608 i=`expr ${i} + 1`
609 done
Andrew Geissler635e0e42020-08-21 15:58:33 -0500610 else
611 defaultconfigcount=1
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600612 fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "${defaultconfigcount}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500613 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500614
615 fitimage_emit_section_maint ${1} sectend
616
617 fitimage_emit_section_maint ${1} fitend
618
619 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600620 # Step 7: Assemble the image
George McCollister185c8ae2016-05-26 08:55:16 -0500621 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600622 ${UBOOT_MKIMAGE} \
George McCollister185c8ae2016-05-26 08:55:16 -0500623 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
624 -f ${1} \
625 arch/${ARCH}/boot/${2}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600626
627 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600628 # Step 8: Sign the image and add public key to U-Boot dtb
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600629 #
630 if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then
Brad Bishop19323692019-04-05 15:28:33 -0400631 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 Geisslerd1e89492021-02-12 15:35:20 -0600638 ${UBOOT_MKIMAGE_SIGN} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600639 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
640 -F -k "${UBOOT_SIGN_KEYDIR}" \
Brad Bishop19323692019-04-05 15:28:33 -0400641 $add_key_to_u_boot \
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600642 -r arch/${ARCH}/boot/${2} \
643 ${UBOOT_MKIMAGE_SIGN_ARGS}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600644 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500645}
646
647do_assemble_fitimage() {
648 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
649 cd ${B}
650 fitimage_assemble fit-image.its fitImage
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500651 fi
652}
653
654addtask assemble_fitimage before do_install after do_compile
655
George McCollister185c8ae2016-05-26 08:55:16 -0500656do_assemble_fitimage_initramfs() {
657 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \
658 test -n "${INITRAMFS_IMAGE}" ; then
659 cd ${B}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600660 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 McCollister185c8ae2016-05-26 08:55:16 -0500665 fi
666}
667
Brad Bishop19323692019-04-05 15:28:33 -0400668addtask assemble_fitimage_initramfs before do_deploy after do_bundle_initramfs
George McCollister185c8ae2016-05-26 08:55:16 -0500669
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700670do_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
677 # Generate keys only if they don't already exist
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
694 fi
695}
696
697addtask kernel_generate_rsa_keys before do_assemble_fitimage after do_compile
George McCollister185c8ae2016-05-26 08:55:16 -0500698
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500699kernel_do_deploy[vardepsexclude] = "DATETIME"
Patrick Williams213cb262021-08-07 19:21:33 -0500700kernel_do_deploy:append() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500701 # Update deploy directory
He Zhefe76b1e2016-05-25 04:47:16 -0400702 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800703
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600704 if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
705 echo "Copying fit-image.its source file..."
706 install -m 0644 ${B}/fit-image.its "$deployDir/fitImage-its-${KERNEL_FIT_NAME}.its"
707 ln -snf fitImage-its-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${KERNEL_FIT_LINK_NAME}"
708
709 echo "Copying linux.bin file..."
710 install -m 0644 ${B}/linux.bin $deployDir/fitImage-linux.bin-${KERNEL_FIT_NAME}.bin
711 ln -snf fitImage-linux.bin-${KERNEL_FIT_NAME}.bin "$deployDir/fitImage-linux.bin-${KERNEL_FIT_LINK_NAME}"
712 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500713
George McCollister185c8ae2016-05-26 08:55:16 -0500714 if [ -n "${INITRAMFS_IMAGE}" ]; then
715 echo "Copying fit-image-${INITRAMFS_IMAGE}.its source file..."
Brad Bishop64c979e2019-11-04 13:55:29 -0500716 install -m 0644 ${B}/fit-image-${INITRAMFS_IMAGE}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its"
717 ln -snf fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}"
George McCollister185c8ae2016-05-26 08:55:16 -0500718
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600719 if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
720 echo "Copying fitImage-${INITRAMFS_IMAGE} file..."
721 install -m 0644 ${B}/arch/${ARCH}/boot/fitImage-${INITRAMFS_IMAGE} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.bin"
722 ln -snf fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.bin "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}"
723 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500724 fi
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500725 fi
726 if [ "${UBOOT_SIGN_ENABLE}" = "1" -o "${UBOOT_FITIMAGE_ENABLE}" = "1" ] && \
727 [ -n "${UBOOT_DTB_BINARY}" ] ; then
728 # UBOOT_DTB_IMAGE is a realfile, but we can't use
729 # ${UBOOT_DTB_IMAGE} since it contains ${PV} which is aimed
730 # for u-boot, but we are in kernel env now.
731 install -m 0644 ${B}/u-boot-${MACHINE}*.dtb "$deployDir/"
732 fi
733 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" -a -n "${UBOOT_BINARY}" -a -n "${SPL_DTB_BINARY}" ] ; then
734 # If we're also creating and/or signing the uboot fit, now we need to
735 # deploy it, it's its file, as well as u-boot-spl.dtb
736 install -m 0644 ${B}/u-boot-spl-${MACHINE}*.dtb "$deployDir/"
737 echo "Copying u-boot-fitImage file..."
738 install -m 0644 ${B}/u-boot-fitImage-* "$deployDir/"
739 echo "Copying u-boot-its file..."
740 install -m 0644 ${B}/u-boot-its-* "$deployDir/"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500741 fi
742}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600743
744# The function below performs the following in case of initramfs bundles:
745# - Removes do_assemble_fitimage. FIT generation is done through
746# do_assemble_fitimage_initramfs. do_assemble_fitimage is not needed
747# and should not be part of the tasks to be executed.
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700748# - Since do_kernel_generate_rsa_keys is inserted by default
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600749# between do_compile and do_assemble_fitimage, this is
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700750# not suitable in case of initramfs bundles. do_kernel_generate_rsa_keys
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600751# should be between do_bundle_initramfs and do_assemble_fitimage_initramfs.
752python () {
753 if d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1":
754 bb.build.deltask('do_assemble_fitimage', d)
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700755 bb.build.deltask('kernel_generate_rsa_keys', d)
756 bb.build.addtask('kernel_generate_rsa_keys', 'do_assemble_fitimage_initramfs', 'do_bundle_initramfs', d)
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500757}