Re: 'of_compatible' and 'model' imd records are unusable

2021-10-04 Thread Sascha Hauer
On Sat, Oct 02, 2021 at 12:44:47PM +0300, Antony Pavlov wrote:
> On Sat, 2 Oct 2021 10:48:50 +0200
> Sascha Hauer  wrote:
> 
> Hi Sascha!
> 
> > 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: 0x
> > > 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.
> 
> 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.

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

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

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: 'of_compatible' and 'model' imd records are unusable

2021-10-02 Thread Antony Pavlov
On Sat, 2 Oct 2021 10:48:50 +0200
Sascha Hauer  wrote:

Hi Sascha!

> 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: 0x
> > 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.

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?

-- 
Best regards,
  Antony Pavlov


> 
> Sascha
> 
> 8<-
> 
> From 456d90992fe0b9f4258b693a946f8d13ba5b0b4c Mon Sep 17 00:00:00 2001
> From: Sascha Hauer 
> 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 
> ---
>  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 
>  #include 
>  #include 
> +#include 
>  
>  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 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -189,5 +190,7 @@ ENTRY_FUNCTION(start_nxp_imx8mp_evk, r0, r1, r2)
>   relocate_to_current_adr();
>   setup_c();
>  
> + IMD_USED_O

Re: 'of_compatible' and 'model' imd records are unusable

2021-10-02 Thread Sascha Hauer
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: 0x
> 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 
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 
---
 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 
 #include 
 #include 
+#include 
 
 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 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -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 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -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 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -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_s

Re: 'of_compatible' and 'model' imd records are unusable

2021-10-01 Thread Antony Pavlov
On Fri, 1 Oct 2021 14:46:19 +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.

I have found a quick-and-dirty solution for the problem.

of_compatible and model imd types were introduced in

commit 97e81f2d78f30fb4936f0f6fe52b317d8dbc9881
Author: Sascha Hauer 
Date:   Mon Jul 28 07:22:40 2014 +0200

Add support for metadata in barebox images


the commit
commit 58eae8361c10fea661bcb48c4c5e75e7ad19e1c1
Author: Sascha Hauer 
Date:   Fri Oct 23 09:14:54 2015 +0200

ARM: Allow compressed dtb binaries

breaks adding of of_compatible and model records
by changing in scripts/gen-dtb-s.


the commit 
commit c1c818735caa8222d88aa9286a219d6055c1699d
Author: Uwe Kleine-König 
Date:   Thu Feb 21 11:25:30 2019 +0100

imd: create new helper macro to add data from oftree to image meta data

introduces macro for explicit adding of of_compatible
imd record from C code.


You can resurrect of_compatible and model imd records adding
by partialy reverting c1c818735caa822:scripts/gen-dtb-s and 
58eae8361c10fea66:scripts/gen-dtb-s
e.g.

barebox$ make rpi_defconfig
...
barebox$ make
...
barebox$ ./scripts/bareboximd images/barebox-raspberry-pi-3.img
buildsystem version: 
crc32: 0x
build: #8 Fri Oct 1 23:23:30 UTC 2021
release: 2021.08.0

barebox$ patch -p1 < 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: 0x
> release: 2021.08.0
> barebox$ 
> 
> There is no 'of_compatible' and 'model' imd records in bareboximd output.
> 

-- 
Best regards,
  Antony Pavlov

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


'of_compatible' and 'model' imd records are unusable

2021-10-01 Thread 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: 0x
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":

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

barebox$ ./scripts/bareboximd images/barebox-prt-prt8mm.img
build: #2 Fri Oct 1 10:19:07 UTC 2021
buildsystem version: 
crc32: 0x
release: 2021.08.0-dirty
of_compatible: fsl,imx8mm-evk fsl,imx8mm
model: FSL i.MX8MM EVK board
of_compatible: prt,prt8mm fsl,imx8mm
model: Protonic PRT8MM
of_compatible: fsl,imx8mp-evk fsl,imx8mp
model: NXP i.MX8MPlus EVK board
of_compatible: fsl,imx8mq-evk fsl,imx8mq
model: NXP i.MX8MQ EVK
of_compatible: phytec,imx8mq-pcl066 fsl,imx8mq
model: Phytec phyCORE-i.MX8
of_compatible: zii,imx8mq-ultra-rmb3 zii,imx8mq-ultra fsl,imx8mq
model: ZII Ultra RMB3 Board
of_compatible: zii,imx8mq-ultra-zest zii,imx8mq-ultra fsl,imx8mq
model: ZII Ultra Zest Board
builduser@ae676260680c:~/barebox$ 

-- 
Best regards,
  Antony Pavlov

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox