blob: b9d82700274a3d4ebe2613def49c17542e951999 [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
Yannick Gicqueld5813b42016-04-27 16:20:55 +020056# Options for the device tree compiler passed to mkimage '-D' feature:
57UBOOT_MKIMAGE_DTCOPTS ??= ""
58
Brad Bishopf3fd2882019-06-21 08:06:37 -040059# fitImage Hash Algo
60FIT_HASH_ALG ?= "sha256"
61
Brad Bishop64c979e2019-11-04 13:55:29 -050062# fitImage Signature Algo
63FIT_SIGN_ALG ?= "rsa2048"
64
Andrew Geisslerf0343792020-11-18 10:42:21 -060065# Generate keys for signing fitImage
66FIT_GENERATE_KEYS ?= "0"
67
68# Size of private key in number of bits
69FIT_SIGN_NUMBITS ?= "2048"
70
71# args to openssl genrsa (Default is just the public exponent)
72FIT_KEY_GENRSA_ARGS ?= "-F4"
73
74# args to openssl req (Default is -batch for non interactive mode and
75# -new for new certificate)
76FIT_KEY_REQ_ARGS ?= "-batch -new"
77
78# Standard format for public key certificate
79FIT_KEY_SIGN_PKCS ?= "-x509"
80
Andrew Geisslerd1e89492021-02-12 15:35:20 -060081# Description string
82FIT_DESC ?= "U-Boot fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}"
83
84# Sign individual images as well
85FIT_SIGN_INDIVIDUAL ?= "0"
86
87# mkimage command
88UBOOT_MKIMAGE ?= "uboot-mkimage"
89UBOOT_MKIMAGE_SIGN ?= "${UBOOT_MKIMAGE}"
90
91# Arguments passed to mkimage for signing
92UBOOT_MKIMAGE_SIGN_ARGS ?= ""
93
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094#
95# Emit the fitImage ITS header
96#
George McCollister185c8ae2016-05-26 08:55:16 -050097# $1 ... .its filename
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098fitimage_emit_fit_header() {
George McCollister185c8ae2016-05-26 08:55:16 -050099 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100/dts-v1/;
101
102/ {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600103 description = "${FIT_DESC}";
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104 #address-cells = <1>;
105EOF
106}
107
108#
109# Emit the fitImage section bits
110#
George McCollister185c8ae2016-05-26 08:55:16 -0500111# $1 ... .its filename
112# $2 ... Section bit type: imagestart - image section start
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113# confstart - configuration section start
114# sectend - section end
115# fitend - fitimage end
116#
117fitimage_emit_section_maint() {
George McCollister185c8ae2016-05-26 08:55:16 -0500118 case $2 in
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119 imagestart)
George McCollister185c8ae2016-05-26 08:55:16 -0500120 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121
122 images {
123EOF
124 ;;
125 confstart)
George McCollister185c8ae2016-05-26 08:55:16 -0500126 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500127
128 configurations {
129EOF
130 ;;
131 sectend)
George McCollister185c8ae2016-05-26 08:55:16 -0500132 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500133 };
134EOF
135 ;;
136 fitend)
George McCollister185c8ae2016-05-26 08:55:16 -0500137 cat << EOF >> ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138};
139EOF
140 ;;
141 esac
142}
143
144#
145# Emit the fitImage ITS kernel section
146#
George McCollister185c8ae2016-05-26 08:55:16 -0500147# $1 ... .its filename
148# $2 ... Image counter
149# $3 ... Path to kernel image
150# $4 ... Compression type
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151fitimage_emit_section_kernel() {
152
Brad Bishopf3fd2882019-06-21 08:06:37 -0400153 kernel_csum="${FIT_HASH_ALG}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600154 kernel_sign_algo="${FIT_SIGN_ALG}"
155 kernel_sign_keyname="${UBOOT_SIGN_KEYNAME}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156
Brad Bishop316dfdd2018-06-25 12:45:53 -0400157 ENTRYPOINT="${UBOOT_ENTRYPOINT}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158 if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then
159 ENTRYPOINT=`${HOST_PREFIX}nm vmlinux | \
160 awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500161 fi
162
George McCollister185c8ae2016-05-26 08:55:16 -0500163 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600164 kernel-${2} {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500165 description = "Linux kernel";
George McCollister185c8ae2016-05-26 08:55:16 -0500166 data = /incbin/("${3}");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167 type = "kernel";
168 arch = "${UBOOT_ARCH}";
169 os = "linux";
George McCollister185c8ae2016-05-26 08:55:16 -0500170 compression = "${4}";
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171 load = <${UBOOT_LOADADDRESS}>;
172 entry = <${ENTRYPOINT}>;
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600173 hash-1 {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174 algo = "${kernel_csum}";
175 };
176 };
177EOF
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600178
179 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${kernel_sign_keyname}" ] ; then
180 sed -i '$ d' ${1}
181 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600182 signature-1 {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600183 algo = "${kernel_csum},${kernel_sign_algo}";
184 key-name-hint = "${kernel_sign_keyname}";
185 };
186 };
187EOF
188 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189}
190
191#
192# Emit the fitImage ITS DTB section
193#
George McCollister185c8ae2016-05-26 08:55:16 -0500194# $1 ... .its filename
195# $2 ... Image counter
196# $3 ... Path to DTB image
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500197fitimage_emit_section_dtb() {
198
Brad Bishopf3fd2882019-06-21 08:06:37 -0400199 dtb_csum="${FIT_HASH_ALG}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600200 dtb_sign_algo="${FIT_SIGN_ALG}"
201 dtb_sign_keyname="${UBOOT_SIGN_KEYNAME}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500202
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800203 dtb_loadline=""
204 dtb_ext=${DTB##*.}
205 if [ "${dtb_ext}" = "dtbo" ]; then
206 if [ -n "${UBOOT_DTBO_LOADADDRESS}" ]; then
207 dtb_loadline="load = <${UBOOT_DTBO_LOADADDRESS}>;"
208 fi
209 elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
210 dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
211 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500212 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600213 fdt-${2} {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500214 description = "Flattened Device Tree blob";
George McCollister185c8ae2016-05-26 08:55:16 -0500215 data = /incbin/("${3}");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500216 type = "flat_dt";
217 arch = "${UBOOT_ARCH}";
218 compression = "none";
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800219 ${dtb_loadline}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600220 hash-1 {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500221 algo = "${dtb_csum}";
222 };
223 };
224EOF
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600225
226 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${dtb_sign_keyname}" ] ; then
227 sed -i '$ d' ${1}
228 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600229 signature-1 {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600230 algo = "${dtb_csum},${dtb_sign_algo}";
231 key-name-hint = "${dtb_sign_keyname}";
232 };
233 };
234EOF
235 fi
236}
237
238#
239# Emit the fitImage ITS u-boot script section
240#
241# $1 ... .its filename
242# $2 ... Image counter
243# $3 ... Path to boot script image
244fitimage_emit_section_boot_script() {
245
246 bootscr_csum="${FIT_HASH_ALG}"
247 bootscr_sign_algo="${FIT_SIGN_ALG}"
248 bootscr_sign_keyname="${UBOOT_SIGN_KEYNAME}"
249
250 cat << EOF >> ${1}
251 bootscr@${2} {
252 description = "U-boot script";
253 data = /incbin/("${3}");
254 type = "script";
255 arch = "${UBOOT_ARCH}";
256 compression = "none";
257 hash@1 {
258 algo = "${bootscr_csum}";
259 };
260 };
261EOF
262
263 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${bootscr_sign_keyname}" ] ; then
264 sed -i '$ d' ${1}
265 cat << EOF >> ${1}
266 signature@1 {
267 algo = "${bootscr_csum},${bootscr_sign_algo}";
268 key-name-hint = "${bootscr_sign_keyname}";
269 };
270 };
271EOF
272 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500273}
274
275#
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600276# Emit the fitImage ITS setup section
277#
278# $1 ... .its filename
279# $2 ... Image counter
280# $3 ... Path to setup image
281fitimage_emit_section_setup() {
282
Brad Bishopf3fd2882019-06-21 08:06:37 -0400283 setup_csum="${FIT_HASH_ALG}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600284
285 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600286 setup-${2} {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600287 description = "Linux setup.bin";
288 data = /incbin/("${3}");
289 type = "x86_setup";
290 arch = "${UBOOT_ARCH}";
291 os = "linux";
292 compression = "none";
293 load = <0x00090000>;
294 entry = <0x00090000>;
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600295 hash-1 {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600296 algo = "${setup_csum}";
297 };
298 };
299EOF
300}
301
302#
George McCollister185c8ae2016-05-26 08:55:16 -0500303# Emit the fitImage ITS ramdisk section
304#
305# $1 ... .its filename
306# $2 ... Image counter
307# $3 ... Path to ramdisk image
308fitimage_emit_section_ramdisk() {
309
Brad Bishopf3fd2882019-06-21 08:06:37 -0400310 ramdisk_csum="${FIT_HASH_ALG}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600311 ramdisk_sign_algo="${FIT_SIGN_ALG}"
312 ramdisk_sign_keyname="${UBOOT_SIGN_KEYNAME}"
Nathan Rossib4a4dc02016-10-21 22:07:27 +1000313 ramdisk_loadline=""
314 ramdisk_entryline=""
315
316 if [ -n "${UBOOT_RD_LOADADDRESS}" ]; then
317 ramdisk_loadline="load = <${UBOOT_RD_LOADADDRESS}>;"
318 fi
319 if [ -n "${UBOOT_RD_ENTRYPOINT}" ]; then
320 ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
321 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500322
323 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600324 ramdisk-${2} {
Rick Altherrbc1b8802017-01-20 11:28:53 -0800325 description = "${INITRAMFS_IMAGE}";
George McCollister185c8ae2016-05-26 08:55:16 -0500326 data = /incbin/("${3}");
327 type = "ramdisk";
328 arch = "${UBOOT_ARCH}";
329 os = "linux";
Brad Bishop00e122a2019-10-05 11:10:57 -0400330 compression = "none";
Nathan Rossib4a4dc02016-10-21 22:07:27 +1000331 ${ramdisk_loadline}
332 ${ramdisk_entryline}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600333 hash-1 {
George McCollister185c8ae2016-05-26 08:55:16 -0500334 algo = "${ramdisk_csum}";
335 };
336 };
337EOF
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600338
339 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${ramdisk_sign_keyname}" ] ; then
340 sed -i '$ d' ${1}
341 cat << EOF >> ${1}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600342 signature-1 {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600343 algo = "${ramdisk_csum},${ramdisk_sign_algo}";
344 key-name-hint = "${ramdisk_sign_keyname}";
345 };
346 };
347EOF
348 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500349}
350
351#
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500352# Emit the fitImage ITS configuration section
353#
George McCollister185c8ae2016-05-26 08:55:16 -0500354# $1 ... .its filename
355# $2 ... Linux kernel ID
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500356# $3 ... DTB image name
George McCollister185c8ae2016-05-26 08:55:16 -0500357# $4 ... ramdisk ID
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600358# $5 ... u-boot script ID
359# $6 ... config ID
360# $7 ... default flag
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500361fitimage_emit_section_config() {
362
Brad Bishopf3fd2882019-06-21 08:06:37 -0400363 conf_csum="${FIT_HASH_ALG}"
Brad Bishop64c979e2019-11-04 13:55:29 -0500364 conf_sign_algo="${FIT_SIGN_ALG}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600365 if [ -n "${UBOOT_SIGN_ENABLE}" ] ; then
366 conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
367 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500368
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600369 its_file="${1}"
370 kernel_id="${2}"
371 dtb_image="${3}"
372 ramdisk_id="${4}"
373 bootscr_id="${5}"
374 config_id="${6}"
375 default_flag="${7}"
376
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500377 # Test if we have any DTBs at all
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800378 sep=""
379 conf_desc=""
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600380 conf_node="conf-"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800381 kernel_line=""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600382 fdt_line=""
383 ramdisk_line=""
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600384 bootscr_line=""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500385 setup_line=""
386 default_line=""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600387
Andrew Geissler635e0e42020-08-21 15:58:33 -0500388 # conf node name is selected based on dtb ID if it is present,
389 # otherwise its selected based on kernel ID
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600390 if [ -n "${dtb_image}" ]; then
391 conf_node=$conf_node${dtb_image}
Andrew Geissler635e0e42020-08-21 15:58:33 -0500392 else
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600393 conf_node=$conf_node${kernel_id}
Andrew Geissler635e0e42020-08-21 15:58:33 -0500394 fi
395
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600396 if [ -n "${kernel_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800397 conf_desc="Linux kernel"
398 sep=", "
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600399 kernel_line="kernel = \"kernel-${kernel_id}\";"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800400 fi
401
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600402 if [ -n "${dtb_image}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800403 conf_desc="${conf_desc}${sep}FDT blob"
404 sep=", "
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600405 fdt_line="fdt = \"fdt-${dtb_image}\";"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600406 fi
407
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600408 if [ -n "${ramdisk_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800409 conf_desc="${conf_desc}${sep}ramdisk"
410 sep=", "
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600411 ramdisk_line="ramdisk = \"ramdisk-${ramdisk_id}\";"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500412 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600413
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600414 if [ -n "${bootscr_id}" ]; then
415 conf_desc="${conf_desc}${sep}u-boot script"
416 sep=", "
417 bootscr_line="bootscr = \"bootscr@${bootscr_id}\";"
418 fi
419
420 if [ -n "${config_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800421 conf_desc="${conf_desc}${sep}setup"
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600422 setup_line="setup = \"setup-${config_id}\";"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600423 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500424
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600425 if [ "${default_flag}" = "1" ]; then
Andrew Geissler635e0e42020-08-21 15:58:33 -0500426 # default node is selected based on dtb ID if it is present,
427 # otherwise its selected based on kernel ID
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600428 if [ -n "${dtb_image}" ]; then
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600429 default_line="default = \"conf-${dtb_image}\";"
Andrew Geissler635e0e42020-08-21 15:58:33 -0500430 else
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600431 default_line="default = \"conf-${kernel_id}\";"
Andrew Geissler635e0e42020-08-21 15:58:33 -0500432 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500433 fi
434
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600435 cat << EOF >> ${its_file}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500436 ${default_line}
Andrew Geissler635e0e42020-08-21 15:58:33 -0500437 $conf_node {
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600438 description = "${default_flag} ${conf_desc}";
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500439 ${kernel_line}
440 ${fdt_line}
George McCollister185c8ae2016-05-26 08:55:16 -0500441 ${ramdisk_line}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600442 ${bootscr_line}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600443 ${setup_line}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600444 hash-1 {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500445 algo = "${conf_csum}";
446 };
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600447EOF
448
449 if [ ! -z "${conf_sign_keyname}" ] ; then
450
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800451 sign_line="sign-images = "
452 sep=""
453
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600454 if [ -n "${kernel_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800455 sign_line="${sign_line}${sep}\"kernel\""
456 sep=", "
457 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600458
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600459 if [ -n "${dtb_image}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800460 sign_line="${sign_line}${sep}\"fdt\""
461 sep=", "
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600462 fi
463
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600464 if [ -n "${ramdisk_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800465 sign_line="${sign_line}${sep}\"ramdisk\""
466 sep=", "
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600467 fi
468
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600469 if [ -n "${bootscr_id}" ]; then
470 sign_line="${sign_line}${sep}\"bootscr\""
471 sep=", "
472 fi
473
474 if [ -n "${config_id}" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800475 sign_line="${sign_line}${sep}\"setup\""
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600476 fi
477
478 sign_line="${sign_line};"
479
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600480 cat << EOF >> ${its_file}
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600481 signature-1 {
Brad Bishop64c979e2019-11-04 13:55:29 -0500482 algo = "${conf_csum},${conf_sign_algo}";
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600483 key-name-hint = "${conf_sign_keyname}";
484 ${sign_line}
485 };
486EOF
487 fi
488
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600489 cat << EOF >> ${its_file}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500490 };
491EOF
492}
493
George McCollister185c8ae2016-05-26 08:55:16 -0500494#
495# Assemble fitImage
496#
497# $1 ... .its filename
498# $2 ... fitImage name
499# $3 ... include ramdisk
500fitimage_assemble() {
501 kernelcount=1
502 dtbcount=""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500503 DTBS=""
George McCollister185c8ae2016-05-26 08:55:16 -0500504 ramdiskcount=${3}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600505 setupcount=""
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600506 bootscr_id=""
George McCollister185c8ae2016-05-26 08:55:16 -0500507 rm -f ${1} arch/${ARCH}/boot/${2}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500508
George McCollister185c8ae2016-05-26 08:55:16 -0500509 fitimage_emit_fit_header ${1}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500510
George McCollister185c8ae2016-05-26 08:55:16 -0500511 #
512 # Step 1: Prepare a kernel image section.
513 #
514 fitimage_emit_section_maint ${1} imagestart
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500515
George McCollister185c8ae2016-05-26 08:55:16 -0500516 uboot_prep_kimage
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600517
518 if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
519 initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
520 if [ -e "${initramfs_bundle_path}" ]; then
521
522 #
523 # Include the kernel/rootfs bundle.
524 #
525
526 fitimage_emit_section_kernel ${1} "${kernelcount}" "${initramfs_bundle_path}" "${linux_comp}"
527 else
528 bbwarn "${initramfs_bundle_path} not found."
529 fi
530 else
531 fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}"
532 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500533
George McCollister185c8ae2016-05-26 08:55:16 -0500534 #
535 # Step 2: Prepare a DTB image section
536 #
Brad Bishop19323692019-04-05 15:28:33 -0400537
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500538 if [ -n "${KERNEL_DEVICETREE}" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500539 dtbcount=1
George McCollister185c8ae2016-05-26 08:55:16 -0500540 for DTB in ${KERNEL_DEVICETREE}; do
541 if echo ${DTB} | grep -q '/dts/'; then
542 bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
543 DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
544 fi
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500545
546 # Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
547 if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ] && [ -s ${EXTERNAL_KERNEL_DEVICETREE}/${DTB} ]; then
548 continue
549 fi
550
George McCollister185c8ae2016-05-26 08:55:16 -0500551 DTB_PATH="arch/${ARCH}/boot/dts/${DTB}"
552 if [ ! -e "${DTB_PATH}" ]; then
553 DTB_PATH="arch/${ARCH}/boot/${DTB}"
554 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500555
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500556 DTB=$(echo "${DTB}" | tr '/' '_')
557 DTBS="${DTBS} ${DTB}"
558 fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH}
George McCollister185c8ae2016-05-26 08:55:16 -0500559 done
560 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500561
Brad Bishop19323692019-04-05 15:28:33 -0400562 if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
563 dtbcount=1
Andrew Geissler82c905d2020-04-13 13:39:40 -0500564 for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do
Brad Bishop19323692019-04-05 15:28:33 -0400565 DTB=$(echo "${DTB}" | tr '/' '_')
566 DTBS="${DTBS} ${DTB}"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500567 fitimage_emit_section_dtb ${1} ${DTB} "${EXTERNAL_KERNEL_DEVICETREE}/${DTB}"
Brad Bishop19323692019-04-05 15:28:33 -0400568 done
569 fi
570
George McCollister185c8ae2016-05-26 08:55:16 -0500571 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600572 # Step 3: Prepare a u-boot script section
573 #
574
575 if [ -n "${UBOOT_ENV}" ] && [ -d "${STAGING_DIR_HOST}/boot" ]; then
576 if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
577 cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
578 bootscr_id="${UBOOT_ENV_BINARY}"
579 fitimage_emit_section_boot_script ${1} "${bootscr_id}" ${UBOOT_ENV_BINARY}
580 else
581 bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
582 fi
583 fi
584
585 #
586 # Step 4: Prepare a setup section. (For x86)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600587 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500588 if [ -e arch/${ARCH}/boot/setup.bin ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600589 setupcount=1
590 fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin
591 fi
592
593 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600594 # Step 5: Prepare a ramdisk section.
George McCollister185c8ae2016-05-26 08:55:16 -0500595 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600596 if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
Rick Altherrbc1b8802017-01-20 11:28:53 -0800597 # Find and use the first initramfs image archive type we find
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800598 for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.gz ext2.gz cpio; do
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500599 initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}"
Rick Altherrbc1b8802017-01-20 11:28:53 -0800600 echo "Using $initramfs_path"
601 if [ -e "${initramfs_path}" ]; then
602 fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}"
603 break
604 fi
605 done
George McCollister185c8ae2016-05-26 08:55:16 -0500606 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500607
George McCollister185c8ae2016-05-26 08:55:16 -0500608 fitimage_emit_section_maint ${1} sectend
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500609
George McCollister185c8ae2016-05-26 08:55:16 -0500610 # Force the first Kernel and DTB in the default config
611 kernelcount=1
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500612 if [ -n "${dtbcount}" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600613 dtbcount=1
614 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500615
George McCollister185c8ae2016-05-26 08:55:16 -0500616 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600617 # Step 6: Prepare a configurations section
George McCollister185c8ae2016-05-26 08:55:16 -0500618 #
619 fitimage_emit_section_maint ${1} confstart
620
Andrew Geissler635e0e42020-08-21 15:58:33 -0500621 # kernel-fitimage.bbclass currently only supports a single kernel (no less or
622 # more) to be added to the FIT image along with 0 or more device trees and
623 # 0 or 1 ramdisk.
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600624 # It is also possible to include an initramfs bundle (kernel and rootfs in one binary)
625 # When the initramfs bundle is used ramdisk is disabled.
Andrew Geissler635e0e42020-08-21 15:58:33 -0500626 # If a device tree is to be part of the FIT image, then select
627 # the default configuration to be used is based on the dtbcount. If there is
628 # no dtb present than select the default configuation to be based on
629 # the kernelcount.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500630 if [ -n "${DTBS}" ]; then
631 i=1
632 for DTB in ${DTBS}; do
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800633 dtb_ext=${DTB##*.}
634 if [ "${dtb_ext}" = "dtbo" ]; then
Andrew Geissler9b4d8b02021-02-19 12:26:16 -0600635 fitimage_emit_section_config ${1} "" "${DTB}" "" "${bootscr_id}" "" "`expr ${i} = ${dtbcount}`"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800636 else
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600637 fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "`expr ${i} = ${dtbcount}`"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800638 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500639 i=`expr ${i} + 1`
640 done
Andrew Geissler635e0e42020-08-21 15:58:33 -0500641 else
642 defaultconfigcount=1
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600643 fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "${defaultconfigcount}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500644 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500645
646 fitimage_emit_section_maint ${1} sectend
647
648 fitimage_emit_section_maint ${1} fitend
649
650 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600651 # Step 7: Assemble the image
George McCollister185c8ae2016-05-26 08:55:16 -0500652 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600653 ${UBOOT_MKIMAGE} \
George McCollister185c8ae2016-05-26 08:55:16 -0500654 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
655 -f ${1} \
656 arch/${ARCH}/boot/${2}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600657
658 #
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600659 # Step 8: Sign the image and add public key to U-Boot dtb
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600660 #
661 if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then
Brad Bishop19323692019-04-05 15:28:33 -0400662 add_key_to_u_boot=""
663 if [ -n "${UBOOT_DTB_BINARY}" ]; then
664 # The u-boot.dtb is a symlink to UBOOT_DTB_IMAGE, so we need copy
665 # both of them, and don't dereference the symlink.
666 cp -P ${STAGING_DATADIR}/u-boot*.dtb ${B}
667 add_key_to_u_boot="-K ${B}/${UBOOT_DTB_BINARY}"
668 fi
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600669 ${UBOOT_MKIMAGE_SIGN} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600670 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
671 -F -k "${UBOOT_SIGN_KEYDIR}" \
Brad Bishop19323692019-04-05 15:28:33 -0400672 $add_key_to_u_boot \
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600673 -r arch/${ARCH}/boot/${2} \
674 ${UBOOT_MKIMAGE_SIGN_ARGS}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600675 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500676}
677
678do_assemble_fitimage() {
679 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
680 cd ${B}
681 fitimage_assemble fit-image.its fitImage
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500682 fi
683}
684
685addtask assemble_fitimage before do_install after do_compile
686
George McCollister185c8ae2016-05-26 08:55:16 -0500687do_assemble_fitimage_initramfs() {
688 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \
689 test -n "${INITRAMFS_IMAGE}" ; then
690 cd ${B}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600691 if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
692 fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage ""
693 else
694 fitimage_assemble fit-image-${INITRAMFS_IMAGE}.its fitImage-${INITRAMFS_IMAGE} 1
695 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500696 fi
697}
698
Brad Bishop19323692019-04-05 15:28:33 -0400699addtask assemble_fitimage_initramfs before do_deploy after do_bundle_initramfs
George McCollister185c8ae2016-05-26 08:55:16 -0500700
Andrew Geisslerf0343792020-11-18 10:42:21 -0600701do_generate_rsa_keys() {
702 if [ "${UBOOT_SIGN_ENABLE}" = "0" ] && [ "${FIT_GENERATE_KEYS}" = "1" ]; then
703 bbwarn "FIT_GENERATE_KEYS is set to 1 eventhough UBOOT_SIGN_ENABLE is set to 0. The keys will not be generated as they won't be used."
704 fi
705
706 if [ "${UBOOT_SIGN_ENABLE}" = "1" ] && [ "${FIT_GENERATE_KEYS}" = "1" ]; then
707
708 # Generate keys only if they don't already exist
709 if [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key ] || \
710 [ ! -f "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".crt]; then
711
712 # make directory if it does not already exist
713 mkdir -p "${UBOOT_SIGN_KEYDIR}"
714
715 echo "Generating RSA private key for signing fitImage"
716 openssl genrsa ${FIT_KEY_GENRSA_ARGS} -out \
717 "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key \
718 "${FIT_SIGN_NUMBITS}"
719
720 echo "Generating certificate for signing fitImage"
721 openssl req ${FIT_KEY_REQ_ARGS} "${FIT_KEY_SIGN_PKCS}" \
722 -key "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".key \
723 -out "${UBOOT_SIGN_KEYDIR}/${UBOOT_SIGN_KEYNAME}".crt
724 fi
725 fi
726}
727
728addtask generate_rsa_keys before do_assemble_fitimage after do_compile
George McCollister185c8ae2016-05-26 08:55:16 -0500729
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500730kernel_do_deploy[vardepsexclude] = "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500731kernel_do_deploy_append() {
732 # Update deploy directory
He Zhefe76b1e2016-05-25 04:47:16 -0400733 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800734
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600735 if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
736 echo "Copying fit-image.its source file..."
737 install -m 0644 ${B}/fit-image.its "$deployDir/fitImage-its-${KERNEL_FIT_NAME}.its"
738 ln -snf fitImage-its-${KERNEL_FIT_NAME}.its "$deployDir/fitImage-its-${KERNEL_FIT_LINK_NAME}"
739
740 echo "Copying linux.bin file..."
741 install -m 0644 ${B}/linux.bin $deployDir/fitImage-linux.bin-${KERNEL_FIT_NAME}.bin
742 ln -snf fitImage-linux.bin-${KERNEL_FIT_NAME}.bin "$deployDir/fitImage-linux.bin-${KERNEL_FIT_LINK_NAME}"
743 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500744
George McCollister185c8ae2016-05-26 08:55:16 -0500745 if [ -n "${INITRAMFS_IMAGE}" ]; then
746 echo "Copying fit-image-${INITRAMFS_IMAGE}.its source file..."
Brad Bishop64c979e2019-11-04 13:55:29 -0500747 install -m 0644 ${B}/fit-image-${INITRAMFS_IMAGE}.its "$deployDir/fitImage-its-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.its"
748 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 -0500749
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600750 if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
751 echo "Copying fitImage-${INITRAMFS_IMAGE} file..."
752 install -m 0644 ${B}/arch/${ARCH}/boot/fitImage-${INITRAMFS_IMAGE} "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.bin"
753 ln -snf fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_NAME}.bin "$deployDir/fitImage-${INITRAMFS_IMAGE_NAME}-${KERNEL_FIT_LINK_NAME}"
754 fi
George McCollister185c8ae2016-05-26 08:55:16 -0500755 fi
Brad Bishop19323692019-04-05 15:28:33 -0400756 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a -n "${UBOOT_DTB_BINARY}" ] ; then
757 # UBOOT_DTB_IMAGE is a realfile, but we can't use
758 # ${UBOOT_DTB_IMAGE} since it contains ${PV} which is aimed
759 # for u-boot, but we are in kernel env now.
Brad Bishop64c979e2019-11-04 13:55:29 -0500760 install -m 0644 ${B}/u-boot-${MACHINE}*.dtb "$deployDir/"
Brad Bishop19323692019-04-05 15:28:33 -0400761 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500762 fi
763}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600764
765# The function below performs the following in case of initramfs bundles:
766# - Removes do_assemble_fitimage. FIT generation is done through
767# do_assemble_fitimage_initramfs. do_assemble_fitimage is not needed
768# and should not be part of the tasks to be executed.
769# - Since do_generate_rsa_keys is inserted by default
770# between do_compile and do_assemble_fitimage, this is
771# not suitable in case of initramfs bundles. do_generate_rsa_keys
772# should be between do_bundle_initramfs and do_assemble_fitimage_initramfs.
773python () {
774 if d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1":
775 bb.build.deltask('do_assemble_fitimage', d)
776 bb.build.deltask('generate_rsa_keys', d)
777 bb.build.addtask('generate_rsa_keys', 'do_assemble_fitimage_initramfs', 'do_bundle_initramfs', d)
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500778}