diff mbox series

[v4,06/16] kernel-fitimage: refactor order in its

Message ID 20250519110838.82978-7-adrian.freihofer@siemens.com
State New
Headers show
Series FIT image improvements | expand

Commit Message

AdrianF May 19, 2025, 11:07 a.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

When the ITS file is created, the mandatory properties are written first
before the optional properties are written.
This is not really useful for the current implementation. But it is a
preparation for a new Python-based implementation that will expect
mandatory properties first. This change makes it possible to run the
tests with both the old and the new implementation.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 meta/classes-recipe/kernel-fitimage.bbclass | 20 ++++++++++----------
 meta/lib/oeqa/selftest/cases/fitimage.py    |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

Comments

Marco Felsch May 19, 2025, 7:41 p.m. UTC | #1
On 25-05-19, AdrianF wrote:
> From: Adrian Freihofer <adrian.freihofer@siemens.com>
> 
> When the ITS file is created, the mandatory properties are written first
> before the optional properties are written.
> This is not really useful for the current implementation. But it is a
> preparation for a new Python-based implementation that will expect
> mandatory properties first. This change makes it possible to run the
> tests with both the old and the new implementation.

Why does your python based implementation require the mandatory
properties written first? According the spec, as in [1], the root-node
description starts with an optional property.

[1] https://fitspec.osfw.foundation/#root-node-properties

Regards,
  Marco
AdrianF May 20, 2025, 6:04 a.m. UTC | #2
On Mon, 2025-05-19 at 21:41 +0200, Marco Felsch wrote:
> On 25-05-19, AdrianF wrote:
> > From: Adrian Freihofer <adrian.freihofer@siemens.com>
> >
> > When the ITS file is created, the mandatory properties are written
> > first
> > before the optional properties are written.
> > This is not really useful for the current implementation. But it is
> > a
> > preparation for a new Python-based implementation that will expect
> > mandatory properties first. This change makes it possible to run
> > the
> > tests with both the old and the new implementation.
>
> Why does your python based implementation require the mandatory
> properties written first? According the spec, as in [1], the root-
> node
> description starts with an optional property.
>
> [1]
> https://fitspec.osfw.foundation/#root-node-properties
>

There are some mandatory nodes and properties acc. to the spec.
But it's an implementation detail which allows to simplify the code
slightly. Similar to Python functions where mandatory parameters must
be passed before optional arguments with default values. The assumption
is that the order is random anyway, and this commit is a pure
refactoring without functional change.

Regards,
Adrian


> Regards,
>   Marco
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-fitimage.bbclass b/meta/classes-recipe/kernel-fitimage.bbclass
index f5f02f30f0a..8e66f326766 100644
--- a/meta/classes-recipe/kernel-fitimage.bbclass
+++ b/meta/classes-recipe/kernel-fitimage.bbclass
@@ -128,11 +128,11 @@  fitimage_emit_section_kernel() {
 	cat << EOF >> $1
                 kernel-$2 {
                         description = "Linux kernel";
-                        data = /incbin/("$3");
                         type = "${UBOOT_MKIMAGE_KERNEL_TYPE}";
+                        compression = "$4";
+                        data = /incbin/("$3");
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
-                        compression = "$4";
                         load = <${UBOOT_LOADADDRESS}>;
                         entry = <$ENTRYPOINT>;
                         hash-1 {
@@ -177,10 +177,10 @@  fitimage_emit_section_dtb() {
 	cat << EOF >> $1
                 fdt-$2 {
                         description = "Flattened Device Tree blob";
-                        data = /incbin/("$3");
                         type = "flat_dt";
-                        arch = "${UBOOT_ARCH}";
                         compression = "none";
+                        data = /incbin/("$3");
+                        arch = "${UBOOT_ARCH}";
                         $dtb_loadline
                         hash-1 {
                                 algo = "$dtb_csum";
@@ -215,10 +215,10 @@  fitimage_emit_section_boot_script() {
         cat << EOF >> $1
                 bootscr-$2 {
                         description = "U-boot script";
-                        data = /incbin/("$3");
                         type = "script";
-                        arch = "${UBOOT_ARCH}";
                         compression = "none";
+                        data = /incbin/("$3");
+                        arch = "${UBOOT_ARCH}";
                         hash-1 {
                                 algo = "$bootscr_csum";
                         };
@@ -252,11 +252,11 @@  fitimage_emit_section_setup() {
 	cat << EOF >> $1
                 setup-$2 {
                         description = "Linux setup.bin";
-                        data = /incbin/("$3");
                         type = "x86_setup";
+                        compression = "none";
+                        data = /incbin/("$3");
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
-                        compression = "none";
                         load = <0x00090000>;
                         entry = <0x00090000>;
                         hash-1 {
@@ -301,11 +301,11 @@  fitimage_emit_section_ramdisk() {
 	cat << EOF >> $1
                 ramdisk-$2 {
                         description = "${INITRAMFS_IMAGE}";
-                        data = /incbin/("$3");
                         type = "ramdisk";
+                        compression = "none";
+                        data = /incbin/("$3");
                         arch = "${UBOOT_ARCH}";
                         os = "linux";
-                        compression = "none";
                         $ramdisk_loadline
                         $ramdisk_entryline
                         hash-1 {
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py
index c3554d4499a..47fb8534b37 100644
--- a/meta/lib/oeqa/selftest/cases/fitimage.py
+++ b/meta/lib/oeqa/selftest/cases/fitimage.py
@@ -509,11 +509,11 @@  class KernelFitImageTests(FitImageTestCase):
         its_field_check = [
             'description = "%s";' % bb_vars['FIT_DESC'],
             'description = "Linux kernel";',
-            'data = /incbin/("linux.bin");',
             'type = "' + str(bb_vars['UBOOT_MKIMAGE_KERNEL_TYPE']) + '";',
+            # 'compression = "' + str(bb_vars['FIT_KERNEL_COMP_ALG']) + '";', defined based on files in TMPDIR, not ideal...
+            'data = /incbin/("linux.bin");',
             'arch = "' + str(bb_vars['UBOOT_ARCH']) + '";',
             'os = "linux";',
-            # 'compression = "' + str(bb_vars['FIT_KERNEL_COMP_ALG']) + '";', defined based on files in TMPDIR, not ideal...
             'load = <' + str(bb_vars['UBOOT_LOADADDRESS']) + '>;',
             'entry = <' + str(bb_vars['UBOOT_ENTRYPOINT']) + '>;',
         ]