'of_compatible' and 'model' imd records are unusable

Sascha Hauer s.hauer at pengutronix.de
Sat Oct 2 01:48:50 PDT 2021


Hi Antony,

+Cc list

On Fri, Oct 01, 2021 at 02:24:53PM +0300, Antony Pavlov wrote:
> 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.
> 
> 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...

> 
> #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<-------------------------

>From 456d90992fe0b9f4258b693a946f8d13ba5b0b4c Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer at pengutronix.de>
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.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 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(+)

diff --git a/arch/arm/boards/nxp-imx8mm-evk/lowlevel.c b/arch/arm/boards/nxp-imx8mm-evk/lowlevel.c
index 4bd29c2269..c2f6206cfd 100644
--- a/arch/arm/boards/nxp-imx8mm-evk/lowlevel.c
+++ b/arch/arm/boards/nxp-imx8mm-evk/lowlevel.c
@@ -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();
 }
diff --git a/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c b/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
index 3298ded586..5732ccc645 100644
--- a/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
+++ b/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
@@ -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();
 }
diff --git a/arch/arm/boards/nxp-imx8mq-evk/lowlevel.c b/arch/arm/boards/nxp-imx8mq-evk/lowlevel.c
index 564621abef..92cc22e022 100644
--- a/arch/arm/boards/nxp-imx8mq-evk/lowlevel.c
+++ b/arch/arm/boards/nxp-imx8mq-evk/lowlevel.c
@@ -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();
 }
diff --git a/arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c b/arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c
index 3b8b53b36e..24d98fe6c9 100644
--- a/arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c
+++ b/arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c
@@ -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();
 }
diff --git a/arch/arm/boards/zii-imx8mq-dev/lowlevel.c b/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
index 311e61fb1d..cf53fb2def 100644
--- a/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
+++ b/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
@@ -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();
 }
-- 
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 |



More information about the barebox mailing list