[PATCH v2 02/23] bbu: make it possible to check multiple of-compatibles

Marco Felsch m.felsch at pengutronix.de
Tue Apr 4 01:01:42 PDT 2023


On 23-04-04, Sascha Hauer wrote:
> On Mon, Mar 13, 2023 at 02:41:41PM +0100, Marco Felsch wrote:
> > It is possible that one barebox can rule multiple platforms e.g.
> > multiple platform revision each has a dedicated device tree and of
> > compatible. While it is possible to add multiple of-compatibles via
> > IMD_USED_OF() (see: zii-imx8mq-dev) we didn't allowed it to flash it
> > without 'force'. Fix this by check all possible IMD_TYPE_OF_COMPATIBLE
> > image metadata types.
> > 
> > Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
> > ---
> >  common/bbu.c | 42 +++++++++++++++++++++++++++---------------
> >  1 file changed, 27 insertions(+), 15 deletions(-)
> > 
> > diff --git a/common/bbu.c b/common/bbu.c
> > index 3ec17216cb..a9b3fef7a0 100644
> > --- a/common/bbu.c
> > +++ b/common/bbu.c
> > @@ -154,36 +154,44 @@ struct bbu_handler *bbu_find_handler_by_device(const char *devicepath)
> >  	return NULL;
> >  }
> >  
> > -static int bbu_check_of_compat(struct bbu_data *data)
> > +static int bbu_check_of_compat(struct bbu_data *data, unsigned short of_compat_nr)
> >  {
> > +	const struct imd_header *imd = data->imd_data;
> > +	const struct imd_header *of_compat;
> >  	struct device_node *root_node;
> >  	const char *machine, *str;
> >  	int ret;
> > -	const struct imd_header *of_compat;
> >  
> >  	if (!IS_ENABLED(CONFIG_OFDEVICE) || !IS_ENABLED(CONFIG_IMD))
> >  		return 0;
> 
> This patch breaks barebox update when the update image doesn't contain
> any IMD_TYPE_OF_COMPATIBLE entries. To fix this we need this here:
> 
> 	if (!of_compat_nr)
> 		return 0;
> 
> I fixed this up.

Argh.. thanks :) To make even more robust and forcable by board we could
replace it with a dedicated CONFIG_IMD_OF_COMPATIBLE. This way boards
can select it to enforce the check or we skip the check. Since just
checking:

  if (!of_comat_nr)
     return 0;

could also hide board code issues.

Regards,
  Marco


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



More information about the barebox mailing list