summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel-fitimage.bbclass
diff options
context:
space:
mode:
authorAndrej Valek <andrej.valek@siemens.com>2021-10-16 22:01:46 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-18 13:48:17 +0100
commit2b5f5e295e9a2765809929fda4e0a76c77e4a6fe (patch)
tree0561d69533fac1d956285cf330bf0778c9b5fe43 /meta/classes/kernel-fitimage.bbclass
parentd3b5389e7dfe082b872ffbd290578ed216603cc3 (diff)
downloadpoky-2b5f5e295e9a2765809929fda4e0a76c77e4a6fe.tar.gz
featimage: refactor style
- use bash variable notation without {} where possible - just to make sure it looks like bash variable not bitbake variable one - fix indent style in "cat" commands - replace "! -z" -> "-n" - make debug info in ramdisk section creation more verbose (From OE-Core rev: f44bb458884da64356ee188917094b5515d3b159) Signed-off-by: Andrej Valek <andrej.valek@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel-fitimage.bbclass')
-rw-r--r--meta/classes/kernel-fitimage.bbclass297
1 files changed, 150 insertions, 147 deletions
diff --git a/meta/classes/kernel-fitimage.bbclass b/meta/classes/kernel-fitimage.bbclass
index 38e05153e3..886ed13029 100644
--- a/meta/classes/kernel-fitimage.bbclass
+++ b/meta/classes/kernel-fitimage.bbclass
@@ -73,7 +73,7 @@ FIT_SIGN_INDIVIDUAL ?= "0"
73# 73#
74# $1 ... .its filename 74# $1 ... .its filename
75fitimage_emit_fit_header() { 75fitimage_emit_fit_header() {
76 cat << EOF >> ${1} 76 cat << EOF >> $1
77/dts-v1/; 77/dts-v1/;
78 78
79/ { 79/ {
@@ -94,24 +94,24 @@ EOF
94fitimage_emit_section_maint() { 94fitimage_emit_section_maint() {
95 case $2 in 95 case $2 in
96 imagestart) 96 imagestart)
97 cat << EOF >> ${1} 97 cat << EOF >> $1
98 98
99 images { 99 images {
100EOF 100EOF
101 ;; 101 ;;
102 confstart) 102 confstart)
103 cat << EOF >> ${1} 103 cat << EOF >> $1
104 104
105 configurations { 105 configurations {
106EOF 106EOF
107 ;; 107 ;;
108 sectend) 108 sectend)
109 cat << EOF >> ${1} 109 cat << EOF >> $1
110 }; 110 };
111EOF 111EOF
112 ;; 112 ;;
113 fitend) 113 fitend)
114 cat << EOF >> ${1} 114 cat << EOF >> $1
115}; 115};
116EOF 116EOF
117 ;; 117 ;;
@@ -137,28 +137,28 @@ fitimage_emit_section_kernel() {
137 awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'` 137 awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
138 fi 138 fi
139 139
140 cat << EOF >> ${1} 140 cat << EOF >> $1
141 kernel-${2} { 141 kernel-$2 {
142 description = "Linux kernel"; 142 description = "Linux kernel";
143 data = /incbin/("${3}"); 143 data = /incbin/("$3");
144 type = "kernel"; 144 type = "kernel";
145 arch = "${UBOOT_ARCH}"; 145 arch = "${UBOOT_ARCH}";
146 os = "linux"; 146 os = "linux";
147 compression = "${4}"; 147 compression = "$4";
148 load = <${UBOOT_LOADADDRESS}>; 148 load = <${UBOOT_LOADADDRESS}>;
149 entry = <${ENTRYPOINT}>; 149 entry = <$ENTRYPOINT>;
150 hash-1 { 150 hash-1 {
151 algo = "${kernel_csum}"; 151 algo = "$kernel_csum";
152 }; 152 };
153 }; 153 };
154EOF 154EOF
155 155
156 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${kernel_sign_keyname}" ] ; then 156 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$kernel_sign_keyname" ] ; then
157 sed -i '$ d' ${1} 157 sed -i '$ d' $1
158 cat << EOF >> ${1} 158 cat << EOF >> $1
159 signature-1 { 159 signature-1 {
160 algo = "${kernel_csum},${kernel_sign_algo}"; 160 algo = "$kernel_csum,$kernel_sign_algo";
161 key-name-hint = "${kernel_sign_keyname}"; 161 key-name-hint = "$kernel_sign_keyname";
162 }; 162 };
163 }; 163 };
164EOF 164EOF
@@ -186,26 +186,26 @@ fitimage_emit_section_dtb() {
186 elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then 186 elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
187 dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;" 187 dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
188 fi 188 fi
189 cat << EOF >> ${1} 189 cat << EOF >> $1
190 fdt-${2} { 190 fdt-$2 {
191 description = "Flattened Device Tree blob"; 191 description = "Flattened Device Tree blob";
192 data = /incbin/("${3}"); 192 data = /incbin/("$3");
193 type = "flat_dt"; 193 type = "flat_dt";
194 arch = "${UBOOT_ARCH}"; 194 arch = "${UBOOT_ARCH}";
195 compression = "none"; 195 compression = "none";
196 ${dtb_loadline} 196 $dtb_loadline
197 hash-1 { 197 hash-1 {
198 algo = "${dtb_csum}"; 198 algo = "$dtb_csum";
199 }; 199 };
200 }; 200 };
201EOF 201EOF
202 202
203 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${dtb_sign_keyname}" ] ; then 203 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$dtb_sign_keyname" ] ; then
204 sed -i '$ d' ${1} 204 sed -i '$ d' $1
205 cat << EOF >> ${1} 205 cat << EOF >> $1
206 signature-1 { 206 signature-1 {
207 algo = "${dtb_csum},${dtb_sign_algo}"; 207 algo = "$dtb_csum,$dtb_sign_algo";
208 key-name-hint = "${dtb_sign_keyname}"; 208 key-name-hint = "$dtb_sign_keyname";
209 }; 209 };
210 }; 210 };
211EOF 211EOF
@@ -220,29 +220,29 @@ EOF
220# $3 ... Path to boot script image 220# $3 ... Path to boot script image
221fitimage_emit_section_boot_script() { 221fitimage_emit_section_boot_script() {
222 222
223 bootscr_csum="${FIT_HASH_ALG}" 223 bootscr_csum="${FIT_HASH_ALG}"
224 bootscr_sign_algo="${FIT_SIGN_ALG}" 224 bootscr_sign_algo="${FIT_SIGN_ALG}"
225 bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}" 225 bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
226 226
227 cat << EOF >> ${1} 227 cat << EOF >> $1
228 bootscr-${2} { 228 bootscr-$2 {
229 description = "U-boot script"; 229 description = "U-boot script";
230 data = /incbin/("${3}"); 230 data = /incbin/("$3");
231 type = "script"; 231 type = "script";
232 arch = "${UBOOT_ARCH}"; 232 arch = "${UBOOT_ARCH}";
233 compression = "none"; 233 compression = "none";
234 hash-1 { 234 hash-1 {
235 algo = "${bootscr_csum}"; 235 algo = "$bootscr_csum";
236 }; 236 };
237 }; 237 };
238EOF 238EOF
239 239
240 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${bootscr_sign_keyname}" ] ; then 240 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$bootscr_sign_keyname" ] ; then
241 sed -i '$ d' ${1} 241 sed -i '$ d' $1
242 cat << EOF >> ${1} 242 cat << EOF >> $1
243 signature-1 { 243 signature-1 {
244 algo = "${bootscr_csum},${bootscr_sign_algo}"; 244 algo = "$bootscr_csum,$bootscr_sign_algo";
245 key-name-hint = "${bootscr_sign_keyname}"; 245 key-name-hint = "$bootscr_sign_keyname";
246 }; 246 };
247 }; 247 };
248EOF 248EOF
@@ -259,10 +259,10 @@ fitimage_emit_section_setup() {
259 259
260 setup_csum="${FIT_HASH_ALG}" 260 setup_csum="${FIT_HASH_ALG}"
261 261
262 cat << EOF >> ${1} 262 cat << EOF >> $1
263 setup-${2} { 263 setup-$2 {
264 description = "Linux setup.bin"; 264 description = "Linux setup.bin";
265 data = /incbin/("${3}"); 265 data = /incbin/("$3");
266 type = "x86_setup"; 266 type = "x86_setup";
267 arch = "${UBOOT_ARCH}"; 267 arch = "${UBOOT_ARCH}";
268 os = "linux"; 268 os = "linux";
@@ -270,7 +270,7 @@ fitimage_emit_section_setup() {
270 load = <0x00090000>; 270 load = <0x00090000>;
271 entry = <0x00090000>; 271 entry = <0x00090000>;
272 hash-1 { 272 hash-1 {
273 algo = "${setup_csum}"; 273 algo = "$setup_csum";
274 }; 274 };
275 }; 275 };
276EOF 276EOF
@@ -297,28 +297,28 @@ fitimage_emit_section_ramdisk() {
297 ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;" 297 ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
298 fi 298 fi
299 299
300 cat << EOF >> ${1} 300 cat << EOF >> $1
301 ramdisk-${2} { 301 ramdisk-$2 {
302 description = "${INITRAMFS_IMAGE}"; 302 description = "${INITRAMFS_IMAGE}";
303 data = /incbin/("${3}"); 303 data = /incbin/("$3");
304 type = "ramdisk"; 304 type = "ramdisk";
305 arch = "${UBOOT_ARCH}"; 305 arch = "${UBOOT_ARCH}";
306 os = "linux"; 306 os = "linux";
307 compression = "none"; 307 compression = "none";
308 ${ramdisk_loadline} 308 $ramdisk_loadline
309 ${ramdisk_entryline} 309 $ramdisk_entryline
310 hash-1 { 310 hash-1 {
311 algo = "${ramdisk_csum}"; 311 algo = "$ramdisk_csum";
312 }; 312 };
313 }; 313 };
314EOF 314EOF
315 315
316 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "${ramdisk_sign_keyname}" ] ; then 316 if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$ramdisk_sign_keyname" ] ; then
317 sed -i '$ d' ${1} 317 sed -i '$ d' $1
318 cat << EOF >> ${1} 318 cat << EOF >> $1
319 signature-1 { 319 signature-1 {
320 algo = "${ramdisk_csum},${ramdisk_sign_algo}"; 320 algo = "$ramdisk_csum,$ramdisk_sign_algo";
321 key-name-hint = "${ramdisk_sign_keyname}"; 321 key-name-hint = "$ramdisk_sign_keyname";
322 }; 322 };
323 }; 323 };
324EOF 324EOF
@@ -343,13 +343,13 @@ fitimage_emit_section_config() {
343 conf_sign_keyname="${UBOOT_SIGN_KEYNAME}" 343 conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
344 fi 344 fi
345 345
346 its_file="${1}" 346 its_file="$1"
347 kernel_id="${2}" 347 kernel_id="$2"
348 dtb_image="${3}" 348 dtb_image="$3"
349 ramdisk_id="${4}" 349 ramdisk_id="$4"
350 bootscr_id="${5}" 350 bootscr_id="$5"
351 config_id="${6}" 351 config_id="$6"
352 default_flag="${7}" 352 default_flag="$7"
353 353
354 # Test if we have any DTBs at all 354 # Test if we have any DTBs at all
355 sep="" 355 sep=""
@@ -364,106 +364,106 @@ fitimage_emit_section_config() {
364 364
365 # conf node name is selected based on dtb ID if it is present, 365 # conf node name is selected based on dtb ID if it is present,
366 # otherwise its selected based on kernel ID 366 # otherwise its selected based on kernel ID
367 if [ -n "${dtb_image}" ]; then 367 if [ -n "$dtb_image" ]; then
368 conf_node=$conf_node${dtb_image} 368 conf_node=$conf_node$dtb_image
369 else 369 else
370 conf_node=$conf_node${kernel_id} 370 conf_node=$conf_node$kernel_id
371 fi 371 fi
372 372
373 if [ -n "${kernel_id}" ]; then 373 if [ -n "$kernel_id" ]; then
374 conf_desc="Linux kernel" 374 conf_desc="Linux kernel"
375 sep=", " 375 sep=", "
376 kernel_line="kernel = \"kernel-${kernel_id}\";" 376 kernel_line="kernel = \"kernel-$kernel_id\";"
377 fi 377 fi
378 378
379 if [ -n "${dtb_image}" ]; then 379 if [ -n "$dtb_image" ]; then
380 conf_desc="${conf_desc}${sep}FDT blob" 380 conf_desc="$conf_desc${sep}FDT blob"
381 sep=", " 381 sep=", "
382 fdt_line="fdt = \"fdt-${dtb_image}\";" 382 fdt_line="fdt = \"fdt-$dtb_image\";"
383 fi 383 fi
384 384
385 if [ -n "${ramdisk_id}" ]; then 385 if [ -n "$ramdisk_id" ]; then
386 conf_desc="${conf_desc}${sep}ramdisk" 386 conf_desc="$conf_desc${sep}ramdisk"
387 sep=", " 387 sep=", "
388 ramdisk_line="ramdisk = \"ramdisk-${ramdisk_id}\";" 388 ramdisk_line="ramdisk = \"ramdisk-$ramdisk_id\";"
389 fi 389 fi
390 390
391 if [ -n "${bootscr_id}" ]; then 391 if [ -n "$bootscr_id" ]; then
392 conf_desc="${conf_desc}${sep}u-boot script" 392 conf_desc="$conf_desc${sep}u-boot script"
393 sep=", " 393 sep=", "
394 bootscr_line="bootscr = \"bootscr-${bootscr_id}\";" 394 bootscr_line="bootscr = \"bootscr-$bootscr_id\";"
395 fi 395 fi
396 396
397 if [ -n "${config_id}" ]; then 397 if [ -n "$config_id" ]; then
398 conf_desc="${conf_desc}${sep}setup" 398 conf_desc="$conf_desc${sep}setup"
399 setup_line="setup = \"setup-${config_id}\";" 399 setup_line="setup = \"setup-$config_id\";"
400 fi 400 fi
401 401
402 if [ "${default_flag}" = "1" ]; then 402 if [ "$default_flag" = "1" ]; then
403 # default node is selected based on dtb ID if it is present, 403 # default node is selected based on dtb ID if it is present,
404 # otherwise its selected based on kernel ID 404 # otherwise its selected based on kernel ID
405 if [ -n "${dtb_image}" ]; then 405 if [ -n "$dtb_image" ]; then
406 default_line="default = \"conf-${dtb_image}\";" 406 default_line="default = \"conf-$dtb_image\";"
407 else 407 else
408 default_line="default = \"conf-${kernel_id}\";" 408 default_line="default = \"conf-$kernel_id\";"
409 fi 409 fi
410 fi 410 fi
411 411
412 cat << EOF >> ${its_file} 412 cat << EOF >> $its_file
413 ${default_line} 413 $default_line
414 $conf_node { 414 $conf_node {
415 description = "${default_flag} ${conf_desc}"; 415 description = "$default_flag $conf_desc";
416 ${kernel_line} 416 $kernel_line
417 ${fdt_line} 417 $fdt_line
418 ${ramdisk_line} 418 $ramdisk_line
419 ${bootscr_line} 419 $bootscr_line
420 ${setup_line} 420 $setup_line
421 hash-1 { 421 hash-1 {
422 algo = "${conf_csum}"; 422 algo = "$conf_csum";
423 }; 423 };
424EOF 424EOF
425 425
426 if [ ! -z "${conf_sign_keyname}" ] ; then 426 if [ -n "$conf_sign_keyname" ] ; then
427 427
428 sign_line="sign-images = " 428 sign_line="sign-images = "
429 sep="" 429 sep=""
430 430
431 if [ -n "${kernel_id}" ]; then 431 if [ -n "$kernel_id" ]; then
432 sign_line="${sign_line}${sep}\"kernel\"" 432 sign_line="$sign_line${sep}\"kernel\""
433 sep=", " 433 sep=", "
434 fi 434 fi
435 435
436 if [ -n "${dtb_image}" ]; then 436 if [ -n "$dtb_image" ]; then
437 sign_line="${sign_line}${sep}\"fdt\"" 437 sign_line="$sign_line${sep}\"fdt\""
438 sep=", " 438 sep=", "
439 fi 439 fi
440 440
441 if [ -n "${ramdisk_id}" ]; then 441 if [ -n "$ramdisk_id" ]; then
442 sign_line="${sign_line}${sep}\"ramdisk\"" 442 sign_line="$sign_line${sep}\"ramdisk\""
443 sep=", " 443 sep=", "
444 fi 444 fi
445 445
446 if [ -n "${bootscr_id}" ]; then 446 if [ -n "$bootscr_id" ]; then
447 sign_line="${sign_line}${sep}\"bootscr\"" 447 sign_line="$sign_line${sep}\"bootscr\""
448 sep=", " 448 sep=", "
449 fi 449 fi
450 450
451 if [ -n "${config_id}" ]; then 451 if [ -n "$config_id" ]; then
452 sign_line="${sign_line}${sep}\"setup\"" 452 sign_line="$sign_line${sep}\"setup\""
453 fi 453 fi
454 454
455 sign_line="${sign_line};" 455 sign_line="$sign_line;"
456 456
457 cat << EOF >> ${its_file} 457 cat << EOF >> $its_file
458 signature-1 { 458 signature-1 {
459 algo = "${conf_csum},${conf_sign_algo}"; 459 algo = "$conf_csum,$conf_sign_algo";
460 key-name-hint = "${conf_sign_keyname}"; 460 key-name-hint = "$conf_sign_keyname";
461 ${sign_line} 461 $sign_line
462 }; 462 };
463EOF 463EOF
464 fi 464 fi
465 465
466 cat << EOF >> ${its_file} 466 cat << EOF >> $its_file
467 }; 467 };
468EOF 468EOF
469} 469}
@@ -478,38 +478,38 @@ fitimage_assemble() {
478 kernelcount=1 478 kernelcount=1
479 dtbcount="" 479 dtbcount=""
480 DTBS="" 480 DTBS=""
481 ramdiskcount=${3} 481 ramdiskcount=$3
482 setupcount="" 482 setupcount=""
483 bootscr_id="" 483 bootscr_id=""
484 rm -f ${1} arch/${ARCH}/boot/${2} 484 rm -f $1 arch/${ARCH}/boot/$2
485 485
486 if [ ! -z "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then 486 if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
487 bbfatal "Keys used to sign images and configuration nodes must be different." 487 bbfatal "Keys used to sign images and configuration nodes must be different."
488 fi 488 fi
489 489
490 fitimage_emit_fit_header ${1} 490 fitimage_emit_fit_header $1
491 491
492 # 492 #
493 # Step 1: Prepare a kernel image section. 493 # Step 1: Prepare a kernel image section.
494 # 494 #
495 fitimage_emit_section_maint ${1} imagestart 495 fitimage_emit_section_maint $1 imagestart
496 496
497 uboot_prep_kimage 497 uboot_prep_kimage
498 498
499 if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then 499 if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
500 initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs" 500 initramfs_bundle_path="arch/"${UBOOT_ARCH}"/boot/"${KERNEL_IMAGETYPE_REPLACEMENT}".initramfs"
501 if [ -e "${initramfs_bundle_path}" ]; then 501 if [ -e "$initramfs_bundle_path" ]; then
502 502
503 # 503 #
504 # Include the kernel/rootfs bundle. 504 # Include the kernel/rootfs bundle.
505 # 505 #
506 506
507 fitimage_emit_section_kernel ${1} "${kernelcount}" "${initramfs_bundle_path}" "${linux_comp}" 507 fitimage_emit_section_kernel $1 $kernelcount "$initramfs_bundle_path" "$linux_comp"
508 else 508 else
509 bbwarn "${initramfs_bundle_path} not found." 509 bbwarn "$initramfs_bundle_pat not found."
510 fi 510 fi
511 else 511 else
512 fitimage_emit_section_kernel ${1} "${kernelcount}" linux.bin "${linux_comp}" 512 fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
513 fi 513 fi
514 514
515 # 515 #
@@ -519,9 +519,9 @@ fitimage_assemble() {
519 if [ -n "${KERNEL_DEVICETREE}" ]; then 519 if [ -n "${KERNEL_DEVICETREE}" ]; then
520 dtbcount=1 520 dtbcount=1
521 for DTB in ${KERNEL_DEVICETREE}; do 521 for DTB in ${KERNEL_DEVICETREE}; do
522 if echo ${DTB} | grep -q '/dts/'; then 522 if echo $DTB | grep -q '/dts/'; then
523 bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used." 523 bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used."
524 DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'` 524 DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'`
525 fi 525 fi
526 526
527 # Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE} 527 # Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
@@ -529,23 +529,23 @@ fitimage_assemble() {
529 continue 529 continue
530 fi 530 fi
531 531
532 DTB_PATH="arch/${ARCH}/boot/dts/${DTB}" 532 DTB_PATH="arch/${ARCH}/boot/dts/$DTB"
533 if [ ! -e "${DTB_PATH}" ]; then 533 if [ ! -e "$DTB_PATH" ]; then
534 DTB_PATH="arch/${ARCH}/boot/${DTB}" 534 DTB_PATH="arch/${ARCH}/boot/$DTB"
535 fi 535 fi
536 536
537 DTB=$(echo "${DTB}" | tr '/' '_') 537 DTB=$(echo "$DTB" | tr '/' '_')
538 DTBS="${DTBS} ${DTB}" 538 DTBS="$DTBS $DTB"
539 fitimage_emit_section_dtb ${1} ${DTB} ${DTB_PATH} 539 fitimage_emit_section_dtb $1 $DTB $DTB_PATH
540 done 540 done
541 fi 541 fi
542 542
543 if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then 543 if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
544 dtbcount=1 544 dtbcount=1
545 for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do 545 for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do
546 DTB=$(echo "${DTB}" | tr '/' '_') 546 DTB=$(echo "$DTB" | tr '/' '_')
547 DTBS="${DTBS} ${DTB}" 547 DTBS="$DTBS $DTB"
548 fitimage_emit_section_dtb ${1} ${DTB} "${EXTERNAL_KERNEL_DEVICETREE}/${DTB}" 548 fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB"
549 done 549 done
550 fi 550 fi
551 551
@@ -557,7 +557,7 @@ fitimage_assemble() {
557 if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then 557 if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
558 cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B} 558 cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
559 bootscr_id="${UBOOT_ENV_BINARY}" 559 bootscr_id="${UBOOT_ENV_BINARY}"
560 fitimage_emit_section_boot_script ${1} "${bootscr_id}" ${UBOOT_ENV_BINARY} 560 fitimage_emit_section_boot_script $1 "$bootscr_id" ${UBOOT_ENV_BINARY}
561 else 561 else
562 bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found." 562 bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
563 fi 563 fi
@@ -568,7 +568,7 @@ fitimage_assemble() {
568 # 568 #
569 if [ -e arch/${ARCH}/boot/setup.bin ]; then 569 if [ -e arch/${ARCH}/boot/setup.bin ]; then
570 setupcount=1 570 setupcount=1
571 fitimage_emit_section_setup ${1} "${setupcount}" arch/${ARCH}/boot/setup.bin 571 fitimage_emit_section_setup $1 $setupcount arch/${ARCH}/boot/setup.bin
572 fi 572 fi
573 573
574 # 574 #
@@ -577,27 +577,30 @@ fitimage_assemble() {
577 if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then 577 if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
578 # Find and use the first initramfs image archive type we find 578 # Find and use the first initramfs image archive type we find
579 for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio; do 579 for img in cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio; do
580 initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.${img}" 580 initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img"
581 echo "Using $initramfs_path" 581 echo -n "Searching for $initramfs_path..."
582 if [ -e "${initramfs_path}" ]; then 582 if [ -e "$initramfs_path" ]; then
583 fitimage_emit_section_ramdisk ${1} "${ramdiskcount}" "${initramfs_path}" 583 echo "found"
584 fitimage_emit_section_ramdisk $1 "$ramdiskcount" "$initramfs_path"
584 break 585 break
586 else
587 echo "not found"
585 fi 588 fi
586 done 589 done
587 fi 590 fi
588 591
589 fitimage_emit_section_maint ${1} sectend 592 fitimage_emit_section_maint $1 sectend
590 593
591 # Force the first Kernel and DTB in the default config 594 # Force the first Kernel and DTB in the default config
592 kernelcount=1 595 kernelcount=1
593 if [ -n "${dtbcount}" ]; then 596 if [ -n "$dtbcount" ]; then
594 dtbcount=1 597 dtbcount=1
595 fi 598 fi
596 599
597 # 600 #
598 # Step 6: Prepare a configurations section 601 # Step 6: Prepare a configurations section
599 # 602 #
600 fitimage_emit_section_maint ${1} confstart 603 fitimage_emit_section_maint $1 confstart
601 604
602 # kernel-fitimage.bbclass currently only supports a single kernel (no less or 605 # kernel-fitimage.bbclass currently only supports a single kernel (no less or
603 # more) to be added to the FIT image along with 0 or more device trees and 606 # more) to be added to the FIT image along with 0 or more device trees and
@@ -608,33 +611,33 @@ fitimage_assemble() {
608 # the default configuration to be used is based on the dtbcount. If there is 611 # the default configuration to be used is based on the dtbcount. If there is
609 # no dtb present than select the default configuation to be based on 612 # no dtb present than select the default configuation to be based on
610 # the kernelcount. 613 # the kernelcount.
611 if [ -n "${DTBS}" ]; then 614 if [ -n "$DTBS" ]; then
612 i=1 615 i=1
613 for DTB in ${DTBS}; do 616 for DTB in ${DTBS}; do
614 dtb_ext=${DTB##*.} 617 dtb_ext=${DTB##*.}
615 if [ "${dtb_ext}" = "dtbo" ]; then 618 if [ "$dtb_ext" = "dtbo" ]; then
616 fitimage_emit_section_config ${1} "" "${DTB}" "" "${bootscr_id}" "" "`expr ${i} = ${dtbcount}`" 619 fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`"
617 else 620 else
618 fitimage_emit_section_config ${1} "${kernelcount}" "${DTB}" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "`expr ${i} = ${dtbcount}`" 621 fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`"
619 fi 622 fi
620 i=`expr ${i} + 1` 623 i=`expr $i + 1`
621 done 624 done
622 else 625 else
623 defaultconfigcount=1 626 defaultconfigcount=1
624 fitimage_emit_section_config ${1} "${kernelcount}" "" "${ramdiskcount}" "${bootscr_id}" "${setupcount}" "${defaultconfigcount}" 627 fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id" "$setupcount" $defaultconfigcount
625 fi 628 fi
626 629
627 fitimage_emit_section_maint ${1} sectend 630 fitimage_emit_section_maint $1 sectend
628 631
629 fitimage_emit_section_maint ${1} fitend 632 fitimage_emit_section_maint $1 fitend
630 633
631 # 634 #
632 # Step 7: Assemble the image 635 # Step 7: Assemble the image
633 # 636 #
634 ${UBOOT_MKIMAGE} \ 637 ${UBOOT_MKIMAGE} \
635 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ 638 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
636 -f ${1} \ 639 -f $1 \
637 arch/${ARCH}/boot/${2} 640 arch/${ARCH}/boot/$2
638 641
639 # 642 #
640 # Step 8: Sign the image and add public key to U-Boot dtb 643 # Step 8: Sign the image and add public key to U-Boot dtb
@@ -651,7 +654,7 @@ fitimage_assemble() {
651 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ 654 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
652 -F -k "${UBOOT_SIGN_KEYDIR}" \ 655 -F -k "${UBOOT_SIGN_KEYDIR}" \
653 $add_key_to_u_boot \ 656 $add_key_to_u_boot \
654 -r arch/${ARCH}/boot/${2} \ 657 -r arch/${ARCH}/boot/$2 \
655 ${UBOOT_MKIMAGE_SIGN_ARGS} 658 ${UBOOT_MKIMAGE_SIGN_ARGS}
656 fi 659 fi
657} 660}
@@ -659,7 +662,7 @@ fitimage_assemble() {
659do_assemble_fitimage() { 662do_assemble_fitimage() {
660 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then 663 if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage"; then
661 cd ${B} 664 cd ${B}
662 fitimage_assemble fit-image.its fitImage 665 fitimage_assemble fit-image.its fitImage ""
663 fi 666 fi
664} 667}
665 668