Skip to contentSkip to conversation

'of_compatible' and 'model' imd records are unusable

DISCUSSION Sascha Hauer 2 participants 3 messages Oct 2, 2021 – Oct 4, 2021 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Sascha Hauer

author maintainer
#1 lore raw

Hi Antony,

+Cc list

Quoted 27 lines · Antony Pavlov

Hi all!

I have cloned barebox c67ada0024da (v2021.08.0) and found that 'of_compatible' and 'model' imd records are unusable.

E.g.

barebox$ make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- imx_v8_defconfig barebox$ make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-
...
images built:
barebox-nxp-imx8mm-evk.img
barebox-prt-prt8mm.img
barebox-nxp-imx8mp-evk.img
barebox-nxp-imx8mq-evk.img
barebox-zii-imx8mq-dev.img
barebox-phytec-phycore-imx8mq.img

barebox$ ./scripts/bareboximd images/barebox-nxp-imx8mm-evk.img
build: #1 Fri Oct 1 10:16:30 UTC 2021
buildsystem version:
crc32: 0x00000000
release: 2021.08.0
barebox$

There is no 'of_compatible' and 'model' imd records in bareboximd output.

Quoted 8 lines

So there is no chance to imd_find_type(..., IMD_TYPE_OF_COMPATIBLE) (see common/bbu.c) in a barebox image file.

scripts/gen-dtb-s puts IMD_TYPE_OF_COMPATIBLE and IMD_TYPE_MODEL records into barebox_imd_0 section.

BAREBOX_IMD macro (include/asm-generic/barebox.lds.h) does not KEEP barebox_imd_0 section":

This is done on purpose because otherwise...

Quoted 10 lines
#define BAREBOX_IMD                             \
        STRUCT_ALIGN();                         \
        KEEP(*(.barebox_imd_start))             \
        KEEP(*(.barebox_imd_1*))                \
        *(.barebox_imd_0*)                      \
        KEEP(*(.barebox_imd_end))

KEEPing barebox_imd_0 leads to several 'of_compatible' and 'model' records in one barebox image file, e.g.:

...exactly this would happen.

To get the of_compatible and model imd tags in an image you have to put IMD_USED_OF() explicitly into the entry function of the image handling this compatible, there's no way for the build process to know which image handles which device tree. See below for an example which adds the tags for the boards you are currently compiling.

Sascha

--------------------------------8<-------------------------

Quoted 1 line

From 456d90992fe0b9f4258b693a946f8d13ba5b0b4c Mon Sep 17 00:00:00 2001

From: Sascha Hauer <[email protected]>
Date: Sat, 2 Oct 2021 10:45:04 +0200
Subject: [PATCH] ARM: i.MX8m: Add of_compatible imd tags for i.MX8 boards

The build process has to be manually told which image is compatible to which device tree. Add the IMD_USED_OF() calls to the i.MX8m based boards.

---
 arch/arm/boards/nxp-imx8mm-evk/lowlevel.c        | 3 +++
 arch/arm/boards/nxp-imx8mp-evk/lowlevel.c        | 3 +++
 arch/arm/boards/nxp-imx8mq-evk/lowlevel.c        | 3 +++
 arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c | 3 +++
 arch/arm/boards/zii-imx8mq-dev/lowlevel.c        | 4 ++++
 5 files changed, 16 insertions(+)
arch/arm/boards/nxp-imx8mm-evk/lowlevel.c +3 -0
index 4bd29c2269..c2f6206cfd 100644
@@ -21,6 +21,7 @@
 #include <mfd/bd71837.h>
 #include <soc/imx8m/ddr.h>
 #include <soc/fsl/fsl_udc.h>
+#include <image-metadata.h>
 
 extern char __dtb_imx8mm_evk_start[];
 
@@ -177,5 +178,7 @@ ENTRY_FUNCTION(start_nxp_imx8mm_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mm_evk);
+
 	nxp_imx8mm_evk_start();
 }
arch/arm/boards/nxp-imx8mp-evk/lowlevel.c +3 -0
index 3298ded586..5732ccc645 100644
@@ -4,6 +4,7 @@
 #include <common.h>
 #include <debug_ll.h>
 #include <firmware.h>
+#include <image-metadata.h>
 #include <asm/mmu.h>
 #include <asm/cache.h>
 #include <asm/sections.h>
@@ -189,5 +190,7 @@ ENTRY_FUNCTION(start_nxp_imx8mp_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mp_evk);
+
 	nxp_imx8mp_evk_start();
 }
arch/arm/boards/nxp-imx8mq-evk/lowlevel.c +3 -0
index 564621abef..92cc22e022 100644
@@ -2,6 +2,7 @@
 
 #include <common.h>
 #include <firmware.h>
+#include <image-metadata.h>
 #include <linux/sizes.h>
 #include <mach/generic.h>
 #include <asm/barebox-arm-head.h>
@@ -106,5 +107,7 @@ ENTRY_FUNCTION(start_nxp_imx8mq_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mq_evk);
+
 	nxp_imx8mq_evk_start();
 }
arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c +3 -0
index 3b8b53b36e..24d98fe6c9 100644
@@ -2,6 +2,7 @@
 
 #include <asm/barebox-arm.h>
 #include <common.h>
+#include <image-metadata.h>
 #include <debug_ll.h>
 #include <firmware.h>
 #include <mach/atf.h>
@@ -118,5 +119,7 @@ ENTRY_FUNCTION(start_prt_prt8mm, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mm_prt8mm);
+
 	prt_prt8mm_start();
 }
arch/arm/boards/zii-imx8mq-dev/lowlevel.c +4 -0
index 311e61fb1d..cf53fb2def 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <firmware.h>
+#include <image-metadata.h>
 #include <linux/sizes.h>
 #include <mach/generic.h>
 #include <asm/barebox-arm-head.h>
@@ -200,5 +201,8 @@ ENTRY_FUNCTION(start_zii_imx8mq_dev, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mq_zii_ultra_rmb3);
+	IMD_USED_OF(imx8mq_zii_ultra_zest);
+
 	zii_imx8mq_dev_start();
 }
Signature · 14 lines
2.30.2



-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

On Sat, 2 Oct 2021 10:48:50 +0200
Sascha Hauer <[email protected]> wrote:

Hi Sascha!

Quoted 50 lines · Antony Pavlov
Quoted 27 lines

Hi all!

I have cloned barebox c67ada0024da (v2021.08.0) and found that 'of_compatible' and 'model' imd records are unusable.

E.g.

barebox$ make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- imx_v8_defconfig barebox$ make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-
...
images built:
barebox-nxp-imx8mm-evk.img
barebox-prt-prt8mm.img
barebox-nxp-imx8mp-evk.img
barebox-nxp-imx8mq-evk.img
barebox-zii-imx8mq-dev.img
barebox-phytec-phycore-imx8mq.img

barebox$ ./scripts/bareboximd images/barebox-nxp-imx8mm-evk.img
build: #1 Fri Oct 1 10:16:30 UTC 2021
buildsystem version:
crc32: 0x00000000
release: 2021.08.0
barebox$

There is no 'of_compatible' and 'model' imd records in bareboximd output.

Quoted 8 lines

So there is no chance to imd_find_type(..., IMD_TYPE_OF_COMPATIBLE) (see common/bbu.c) in a barebox image file.

scripts/gen-dtb-s puts IMD_TYPE_OF_COMPATIBLE and IMD_TYPE_MODEL records into barebox_imd_0 section.

BAREBOX_IMD macro (include/asm-generic/barebox.lds.h) does not KEEP barebox_imd_0 section":

This is done on purpose because otherwise...

Quoted 10 lines
#define BAREBOX_IMD                             \
        STRUCT_ALIGN();                         \
        KEEP(*(.barebox_imd_start))             \
        KEEP(*(.barebox_imd_1*))                \
        *(.barebox_imd_0*)                      \
        KEEP(*(.barebox_imd_end))

KEEPing barebox_imd_0 leads to several 'of_compatible' and 'model' records in one barebox image file, e.g.:

Quoted 7 lines

...exactly this would happen.

To get the of_compatible and model imd tags in an image you have to put IMD_USED_OF() explicitly into the entry function of the image handling this compatible, there's no way for the build process to know which image handles which device tree. See below for an example which adds the tags for the boards you are currently compiling.

There are two remarks:

1. It looks like we still able to automatically add of_compatible and model imd tags. Please see my message http://lists.infradead.org/pipermail/barebox/2021-October/037412.html

2. I have no lowlevel.c board files on MIPS :(

Can we automaticaly generate of_compatible and model imd tags for most of the boards and explicitly generate tags with IMD_USED_OF() just for selected boards?

Signature · 2 lines
Best regards,
  Antony Pavlov
Quoted 134 lines

Sascha

--------------------------------8<-------------------------

From 456d90992fe0b9f4258b693a946f8d13ba5b0b4c Mon Sep 17 00:00:00 2001
From: Sascha Hauer <[email protected]>
Date: Sat, 2 Oct 2021 10:45:04 +0200
Subject: [PATCH] ARM: i.MX8m: Add of_compatible imd tags for i.MX8 boards

The build process has to be manually told which image is compatible to which device tree. Add the IMD_USED_OF() calls to the i.MX8m based boards.

---
 arch/arm/boards/nxp-imx8mm-evk/lowlevel.c        | 3 +++
 arch/arm/boards/nxp-imx8mp-evk/lowlevel.c        | 3 +++
 arch/arm/boards/nxp-imx8mq-evk/lowlevel.c        | 3 +++
 arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c | 3 +++
 arch/arm/boards/zii-imx8mq-dev/lowlevel.c        | 4 ++++
 5 files changed, 16 insertions(+)
arch/arm/boards/nxp-imx8mm-evk/lowlevel.c +3 -0
index 4bd29c2269..c2f6206cfd 100644
@@ -21,6 +21,7 @@
 #include <mfd/bd71837.h>
 #include <soc/imx8m/ddr.h>
 #include <soc/fsl/fsl_udc.h>
+#include <image-metadata.h>
 
 extern char __dtb_imx8mm_evk_start[];
 
@@ -177,5 +178,7 @@ ENTRY_FUNCTION(start_nxp_imx8mm_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mm_evk);
+
 	nxp_imx8mm_evk_start();
 }
arch/arm/boards/nxp-imx8mp-evk/lowlevel.c +3 -0
index 3298ded586..5732ccc645 100644
@@ -4,6 +4,7 @@
 #include <common.h>
 #include <debug_ll.h>
 #include <firmware.h>
+#include <image-metadata.h>
 #include <asm/mmu.h>
 #include <asm/cache.h>
 #include <asm/sections.h>
@@ -189,5 +190,7 @@ ENTRY_FUNCTION(start_nxp_imx8mp_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mp_evk);
+
 	nxp_imx8mp_evk_start();
 }
arch/arm/boards/nxp-imx8mq-evk/lowlevel.c +3 -0
index 564621abef..92cc22e022 100644
@@ -2,6 +2,7 @@
 
 #include <common.h>
 #include <firmware.h>
+#include <image-metadata.h>
 #include <linux/sizes.h>
 #include <mach/generic.h>
 #include <asm/barebox-arm-head.h>
@@ -106,5 +107,7 @@ ENTRY_FUNCTION(start_nxp_imx8mq_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mq_evk);
+
 	nxp_imx8mq_evk_start();
 }
arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c +3 -0
index 3b8b53b36e..24d98fe6c9 100644
@@ -2,6 +2,7 @@
 
 #include <asm/barebox-arm.h>
 #include <common.h>
+#include <image-metadata.h>
 #include <debug_ll.h>
 #include <firmware.h>
 #include <mach/atf.h>
@@ -118,5 +119,7 @@ ENTRY_FUNCTION(start_prt_prt8mm, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mm_prt8mm);
+
 	prt_prt8mm_start();
 }
arch/arm/boards/zii-imx8mq-dev/lowlevel.c +4 -0
index 311e61fb1d..cf53fb2def 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <firmware.h>
+#include <image-metadata.h>
 #include <linux/sizes.h>
 #include <mach/generic.h>
 #include <asm/barebox-arm-head.h>
@@ -200,5 +201,8 @@ ENTRY_FUNCTION(start_zii_imx8mq_dev, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
+	IMD_USED_OF(imx8mq_zii_ultra_rmb3);
+	IMD_USED_OF(imx8mq_zii_ultra_zest);
+
 	zii_imx8mq_dev_start();
 }
Signature · 9 lines
2.30.2



-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

author maintainer
#3 lore raw
Quoted 63 lines · Antony Pavlov

On Sat, 2 Oct 2021 10:48:50 +0200
Sascha Hauer <[email protected]> wrote:

Hi Sascha!

Quoted 50 lines · Antony Pavlov
Quoted 27 lines

Hi all!

I have cloned barebox c67ada0024da (v2021.08.0) and found that 'of_compatible' and 'model' imd records are unusable.

E.g.

barebox$ make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- imx_v8_defconfig barebox$ make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-
...
images built:
barebox-nxp-imx8mm-evk.img
barebox-prt-prt8mm.img
barebox-nxp-imx8mp-evk.img
barebox-nxp-imx8mq-evk.img
barebox-zii-imx8mq-dev.img
barebox-phytec-phycore-imx8mq.img

barebox$ ./scripts/bareboximd images/barebox-nxp-imx8mm-evk.img
build: #1 Fri Oct 1 10:16:30 UTC 2021
buildsystem version:
crc32: 0x00000000
release: 2021.08.0
barebox$

There is no 'of_compatible' and 'model' imd records in bareboximd output.

Quoted 8 lines

So there is no chance to imd_find_type(..., IMD_TYPE_OF_COMPATIBLE) (see common/bbu.c) in a barebox image file.

scripts/gen-dtb-s puts IMD_TYPE_OF_COMPATIBLE and IMD_TYPE_MODEL records into barebox_imd_0 section.

BAREBOX_IMD macro (include/asm-generic/barebox.lds.h) does not KEEP barebox_imd_0 section":

This is done on purpose because otherwise...

Quoted 10 lines
#define BAREBOX_IMD                             \
        STRUCT_ALIGN();                         \
        KEEP(*(.barebox_imd_start))             \
        KEEP(*(.barebox_imd_1*))                \
        *(.barebox_imd_0*)                      \
        KEEP(*(.barebox_imd_end))

KEEPing barebox_imd_0 leads to several 'of_compatible' and 'model' records in one barebox image file, e.g.:

Quoted 7 lines

...exactly this would happen.

To get the of_compatible and model imd tags in an image you have to put IMD_USED_OF() explicitly into the entry function of the image handling this compatible, there's no way for the build process to know which image handles which device tree. See below for an example which adds the tags for the boards you are currently compiling.

Quoted 4 lines

There are two remarks:

1. It looks like we still able to automatically add of_compatible and model imd tags. Please see my message http://lists.infradead.org/pipermail/barebox/2021-October/037412.html

I gave it a try, it works and looks like a good solution. We'll need another

if [ "$imd" = "y" ]; then

       echo ".word __imd_${name}_start"

fi

at the end of scripts/gen-dtb-s to make it work with compressed dtbs as well.

Quoted 3 lines

Can we automaticaly generate of_compatible and model imd tags for most of the boards and explicitly generate tags with IMD_USED_OF() just for selected boards?

With your approach we can drop IMD_USED_OF(), at least I see no more need for it.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox