On Tue, Apr 04, 2023 at 10:01:42AM +0200, Marco Felsch wrote: > 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@xxxxxxxxxxxxxx> > > > --- > > > 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. Making this a compile time option is not a good idea. Should be runtime. > 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. Indeed, yes. Ahmad has a patch in the queue which automatically adds the IMD_TYPE_OF_COMPATIBLE entries for each board based on the device tree that is used in the image. I suggest we wait for this patch, and with it we can re-evaluate this. 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 |