[PATCH] fixup! console: add new CONFIG_CONSOLE_DISABLE_INPUT option

2021-10-02 Thread Ahmad Fatoum
Fix typo in CONFIG_CONSOLE_DISABLE_INPUT case for simple console.

Signed-off-by: Ahmad Fatoum 
---
Sorry, just noticed it when looking again at the diff. Please squash.
---
 common/console_simple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/console_simple.c b/common/console_simple.c
index 3b95570e5e76..8c404ad264c4 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -95,7 +95,7 @@ int console_register(struct console_device *newcdev)
newcdev->f_active = CONSOLE_STDIOE;
 
if (IS_ENABLED(CONFIG_CONSOLE_DISABLE_INPUT))
-   newcdev->f_active = ~CONSOLE_STDIN;
+   newcdev->f_active &= ~CONSOLE_STDIN;
 
barebox_banner();
 
-- 
2.30.2


___
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_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();
>   

Re: [PATCH] net: add virtio network driver

2021-10-02 Thread Sascha Hauer
On Mon, Sep 13, 2021 at 10:30:47AM +0200, Ahmad Fatoum wrote:
> This gives virtio-enabled boards an easy route to network connectivity:
> 
>   qemu-system-aarch64 -M virt  -serial mon:stdio -trace file=/dev/null \
>   -kernel images/barebox-dt-2nd.img -cpu cortex-a57 -nographic \
>   -device virtio-net-device,netdev=network0 -netdev 
> tap,id=network0,ifname=tap0
> 
> The tap0 interface created by QEMU can then be bridged/listened on.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
>  Documentation/user/virtio.rst   |   2 +-
>  drivers/net/Kconfig |   7 +
>  drivers/net/Makefile|   1 +
>  drivers/net/virtio.c| 236 +
>  include/linux/virtio_config.h   |   7 +-
>  include/uapi/linux/virtio_net.h | 358 
>  6 files changed, 608 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/net/virtio.c
>  create mode 100644 include/uapi/linux/virtio_net.h

Applied, thanks

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: [PATCH master v2] base: driver: fix double removal of child devices

2021-10-02 Thread Sascha Hauer
On Mon, Sep 13, 2021 at 12:17:53PM +0200, Ahmad Fatoum wrote:
> Child devices like an ext4 file system on a partition may be removed
> twice: Once because they're in the active devices list and then once
> more, because unregister_device is called for the children of its parent.
> 
> As struct bus_type::remove clears association of a driver with its
> device, we can set struct device_d::driver to NULL. unregister_device
> will then skip the second dev->bus->remove.
> 
> Fixes: 29f1c211d86c ("fs: don't free device in remove callback")
> Signed-off-by: Ahmad Fatoum 
> ---
> v1 -> v2:
>   - remove left-over if condition line (Jules)
> ---
>  drivers/base/driver.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks

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: [PATCH v1] net: dhcp: set default DHCP vendor ID to "barebox"

2021-10-02 Thread Sascha Hauer
On Tue, Sep 14, 2021 at 08:48:53AM +0200, Oleksij Rempel wrote:
> To make debugging of DHCP related issues easier, set DHCP vendor ID to
> "barebox" by default.
> 
> Signed-off-by: Oleksij Rempel 
> ---
>  net/dhcp.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks

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: [PATCH v1] net: dhcp: send current hostname as part of the DHCP request

2021-10-02 Thread Sascha Hauer
On Tue, Sep 14, 2021 at 08:30:01AM +0200, Oleksij Rempel wrote:
> To be able to use more advanced DHCP server configurations, for example
> host name pattern matching, barebox should send some name.
> 
> With this patch, barebox will send barebox_hostname, if dhcp.hostname is
> not configured.
> 
> Signed-off-by: Oleksij Rempel 
> ---
>  net/dhcp.c | 8 
>  1 file changed, 8 insertions(+)

Applied, thanks

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: [PATCH] mci: Improve error message for non-existent vmmc regulator

2021-10-02 Thread Sascha Hauer
On Tue, Sep 14, 2021 at 11:00:17AM +0200, Uwe Kleine-König wrote:
> There are three improvements: a) Use a already initialized device as first
> parameter to dev_err() and b) indicate that the error will be ignored, and
> c) downgrade to a warning.
> 
> This changes the error message from
> 
>   ERROR: : Failed to get 'vmmc' regulator.
> 
> to
> 
>   WARNING: bcm2835_mci fe34@7e34.of: Failed to get 'vmmc' 
> regulator (ignored).
> 
> on a Raspberry Pi 4.
> 
> Signed-off-by: Uwe Kleine-König 
> ---
>  drivers/mci/mci-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

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: [PATCH v2] console: add new CONFIG_CONSOLE_DISABLE_INPUT option

2021-10-02 Thread Sascha Hauer
On Wed, Sep 15, 2021 at 02:36:44PM +0200, Ahmad Fatoum wrote:
> From: Rouven Czerwinski 
> 
> Add CONFIG_CONSOLE_DISABLE_INPUT to initialize the consoles without
> input support, making default bootup effectively non-interactive.
> 
> Signed-off-by: Rouven Czerwinski 
> Signed-off-by: Ahmad Fatoum 
> ---
> v1 is <20201013075925.2984-1-r.czerwin...@pengutronix.de>
> v1 -> v2:
>   - Make it the default for CONSOLE_NONE. This allows skipping
> count down there early.
>   - rename write-only to disable input. This is arguably clearer
>   - allow re-enabling input on a per console basis. This way
> e.g. a gpio-key with limited function can be reenabled,
> but all other consoles have input disabled by default.
>   - add new CONSOLE_STDIOE to make the three bits easier to
> write as a group.
> ---
>  common/Kconfig  | 11 +++
>  common/console.c| 12 +++-
>  common/console_simple.c |  5 -
>  common/startup.c|  5 +
>  include/console.h   |  2 ++
>  5 files changed, 29 insertions(+), 6 deletions(-)

Applied, thanks

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: [PATCH master] RISC-V: board-dt-2nd: move low level init into nonnaked function

2021-10-02 Thread Sascha Hauer
On Thu, Sep 16, 2021 at 11:35:14AM +0200, Ahmad Fatoum wrote:
> The generic DT image for RISC-V mimics a kernel image and specifies
> a load offset that it expects to be honoured. The stack should then
> grow down from the load address. This didn't work as intended though
> with riscv64-linux-gnu-gcc (Debian 10.2.1-6), because of the entry
> point's __naked attribute: local variables overwrote the first bytes
> of the entry point. Fix this by using a noinline nonnaked function.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
>  arch/riscv/boot/board-dt-2nd.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Applied, thanks

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: [PATCH] arm64: Don't truncate upper 32 bits in ENTRY_FUNCTION arg registers

2021-10-02 Thread Sascha Hauer
On Thu, Sep 16, 2021 at 11:33:56AM +0200, Uwe Kleine-König wrote:
> From: Ahmad Fatoum 
> 
> Use a long instead of an u32. For 32-bit arm there is no difference, for
> arm64 this results in being able to use the whole register size of 64
> bits.
> 
> Signed-off-by: Ahmad Fatoum 
> Signed-off-by: Uwe Kleine-König 
> ---
>  arch/arm/include/asm/barebox-arm.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks

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: [PATCH master] virtio: implement remove callbacks

2021-10-02 Thread Sascha Hauer
On Thu, Sep 16, 2021 at 11:34:58AM +0200, Ahmad Fatoum wrote:
> virtio parent device drivers (e.g. PCI and MMIO) create child devices
> and free them on remove. The virtio drivers for the child devices (e.g.
> block and console) however don't unregister with their respective
> subsystems in the remove callbacks. So these subsystems may have stale
> pointers pointing at removed devices. This is especially problematic for
> the console driver, because the virtio console device_d will be removed,
> but the console itself remains registered leading to a use-after-free
> as soon as printf is invoked for the previously active console.
> 
> This leads to a crash when typing reset in
> 
>   https://www.barebox.org/jsbarebox/?graphic=0
> 
> Fix this for all virtio drivers.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
>  drivers/block/virtio_blk.c  |  6 ++
>  drivers/hw_random/core.c| 12 
>  drivers/hw_random/virtio-rng.c  |  6 ++
>  drivers/input/virtio_input.c|  5 +++--
>  drivers/serial/virtio_console.c | 14 ++
>  include/linux/hw_random.h   |  2 ++
>  6 files changed, 43 insertions(+), 2 deletions(-)

Applied, thanks

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: [PATCH 1/2] mci-bcm2835: Don't block infinitely while waiting for a command completion

2021-10-02 Thread Sascha Hauer
On Thu, Sep 16, 2021 at 11:36:26AM +0200, Uwe Kleine-König wrote:
> Instead abort with a timeout error. This prevents getting a hung barebox
> when a command doesn't complete.
> 
> Signed-off-by: Uwe Kleine-König 
> ---
>  drivers/mci/mci-bcm2835.c | 4 
>  1 file changed, 4 insertions(+)

Applied, thanks

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: [PATCH v2 1/4] common: remove !SANDBOX dependency for target tools

2021-10-02 Thread Sascha Hauer
On Fri, Sep 17, 2021 at 07:41:24PM +0200, Ahmad Fatoum wrote:
> d4aa01503348 ("common: add dependency !SANDBOX on target tools") and
> later commits disabled building the target tools with sandbox, because
> the build failed when they were enabled.
> 
> This has been fixed since then. Remove the limitation, so target tools
> can be cross-compiled when using the ARCH=sandbox.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
> v1 -> v2:
>   - no change
> ---
>  common/Kconfig | 3 ---
>  1 file changed, 3 deletions(-)

Applied, thanks

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: [PATCH v3] ARM: document arm_setup_stack() pitfalls

2021-10-02 Thread Sascha Hauer
On Fri, Sep 17, 2021 at 02:11:52PM +0200, Ahmad Fatoum wrote:
> Many arm32 board entry points use arm_setup_stack() to set up
> the stack from C code. This necessitates using __naked, which
> probably has been our most frequent cause of misscompiled C code.
> 
> GCC is quite clear that:
> 
>   Only basic asm statements can safely be included in naked functions
>   While using extended asm or a mixture of basic asm and C code may
>   appear to work, they cannot be depended upon to work reliably and
>   are not supported.
> 
> But some boards use it anyway, because it's nice to avoid writing
> assembly. Reading generated assembly to spot compiler miscompilation
> isn't that nice though, so add some documentation, comments
> and compiler diagnostics to hopefully reduce future porting effort.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
> v2 -> v3:
>   - fix typos (Uwe)
>   - use better matching CONFIG_CPU_64 instead of CONFIG_CPU_V8
>   - clarify 'bad' stack manipulation
> v1 -> v2:
>   - fix commit message title

Applied, thanks

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: [PATCH 1/2] pinctrl: bcm2835: Probe driver earlier

2021-10-02 Thread Sascha Hauer
On Fri, Sep 17, 2021 at 11:41:51AM +0200, Uwe Kleine-König wrote:
> From: Ahmad Fatoum 
> 
> coredevice is too late for the console driver and all other pinctrl drivers
> are using "core", too.
> 
> Signed-off-by: Uwe Kleine-König 
> ---
>  drivers/pinctrl/pinctrl-bcm2835.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

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