Bug 15448

Summary: Possible failure in do_uboot_assemble_fitimage task
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Michał Frynas <mfrynas>
Component: meta-yoctoAssignee: Michał Frynas <mfrynas>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: poky.bs.watcher, poky.watcher, randy.macleod
Version: 4.2   
Target Milestone: 5.0   
Hardware: Other   
OS: arm   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know
Attachments:
Description Flags
adjustment of do_uboot_assemble_fitimage task to multiple UBOOT_CONFIG definitions
none
Patch with fix proposal
none
Fix iteration over UBOOT_BINARIES in uboot-sign.bbclass none

Description Michał Frynas 2024-03-20 12:02:44 UTC
Created attachment 5033 [details]
adjustment of do_uboot_assemble_fitimage task to multiple UBOOT_CONFIG definitions

Possible issue in UBOOT_CONFIG interation in code located in uboot-sign.bbclass, task do_uboot_assemble_fitimage():

	unset i j k                              <------- possible issue
	for config in ${UBOOT_MACHINE}; do
		i=$(expr $i + 1);
                bberror "i = $i, config = ${config}"
		for type in ${UBOOT_CONFIG}; do
			j=$(expr $j + 1);
                        bberror "j = $j, type = ${type}"
			if [ $j -eq $i ]; then
				break;
			fi
		done

		for binary in ${UBOOT_BINARIES}; do
			k=$(expr $j + 1);        <------- possible issue
                        bberror "k = $k, binary = ${binary}"
			if [ $k -eq $i ]; then
				break;
			fi
		done

		cd ${B}/${config}
                bberror "uboot_assemble_fitimage ${type} ${binary}"
		uboot_assemble_fitimage_helper ${type} ${binary}
	done

For following definitions:
	UBOOT_CONFIG[conf_1] = "conf_1_defconfig,,u-boot.bin_1"
	UBOOT_CONFIG[conf_2] = "conf_2_defconfig,,u-boot.bin_2"

I get following log prints:
	i = 1, config = conf_1_defconfig
	j = 1, type = conf_1
	k = 2, binary = u-boot.bin_1
	k = 2, binary = u-boot.bin_2
	uboot_assemble_fitimage conf_1 u-boot.bin_2

	i = 2, config = conf_2_defconfig
	j = 2, type = conf_1
	k = 3, binary = u-boot.bin_1
	k = 3, binary = u-boot.bin_2
	uboot_assemble_fitimage conf_1 u-boot.bin_2

The correct binary file never gets hit ($k never equals $i) and the one from last iteration is passed do uboot_assemble_fitimage() function.

What's more, the $j is not reset after upper loop iteration, and while iterating over UBOOT_CONFIG the second time the condition $j -eq $i is true for the first entry (conf_1 in my example, whereas it should be conf_2).

With change in attacked diff file it is working for me correctly.
Comment 1 Randy MacLeod 2024-03-21 14:45:18 UTC
Please send the patch to the list with a good commit log.
Patch reviewed quickly in a meeting...
Thanks,
../Randy
Comment 2 Michał Frynas 2024-03-25 13:20:44 UTC
Created attachment 5036 [details]
Patch with fix proposal

Patch proposal with detailed description.
Comment 3 Michał Frynas 2024-03-25 16:12:45 UTC
Created attachment 5037 [details]
Fix iteration over UBOOT_BINARIES in uboot-sign.bbclass
Comment 4 Randy MacLeod 2024-05-23 15:12:18 UTC
Likley fixed. Randy to find the commit.
Comment 5 Randy MacLeod 2024-05-23 15:18:55 UTC
Seems to be fixed by:
https://git.yoctoproject.org/poky/commit/?id=ed7cd56a8ac50ce77bc33cd10354862ce5260f8f