From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17D0CC433EF for ; Fri, 15 Jul 2022 07:52:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3F1048025C; Fri, 15 Jul 2022 09:52:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="mYgrtHDF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2AD438036E; Fri, 15 Jul 2022 09:52:56 +0200 (CEST) Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2AD318020B for ; Fri, 15 Jul 2022 09:52:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-yb1-xb31.google.com with SMTP id n74so7234017yba.3 for ; Fri, 15 Jul 2022 00:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6Dly9nKIpPzgdffvl6qgUS3EsgsZ7rIh2T50yZal+6s=; b=mYgrtHDFhNvROVfX7h+EgRGoxgfNNhjOX7TvUah9feR2IJ7HBfCyKh8DdkhAir1eHj k92CwRaZtQo0eRhUWyGIFJU96XF2Kg/8y/wocupGT979NOQQxbI3TTg6CoTyUejSKcYm ZsaWPO98Z5KCnqtAiEBd60KugHvUXjmPH0KfFqu2ieYHTYEjAN0neqe5sqSgsSq4Imv4 langwBz5xjgurYCYywhROxCxEMqivqzSuNDP7QhtE21GkepFpz2MaX0+16+crW0fgLIf 4d+cj6muJeRaKOv4HkCqHt8EqWjsRdnuGZLtjfhggfh1Fd6TyDLvdv7YbGxNS8zBJVYA UPGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6Dly9nKIpPzgdffvl6qgUS3EsgsZ7rIh2T50yZal+6s=; b=EUX7H8EL3of/KgPWVRkuF1jP+njd4oAPQKrUVKrCVgvw1UMNSxHVFfjnPea5NiwD6X 6sGNTMMAg5kP8yYzhjJeijaxt4Y0bmVpjOM/1kVuMURiTygv5bqrsfWkFMfRmZHQ+sSC isdjgOLJyZnL4R29rqhKq6Yodgw9mmIsHqU24JlB0bUeUlaNsPtwko810eGUCe5ij39L JpWqC5OSRZABgExe4aP65gG9lA+HnUN5h3CF+mNcPeAk5SnCJpsM2cfvIHiRk0TKJ78r dGUfhYv1+CLqcO3j1cMTSbv+c5kQ7VY98rrDjAa9MoOkbUoQZAClmBOM2uCjswc5DNFC ppeA== X-Gm-Message-State: AJIora+1Vs1yAS+BINMOYgSzC6EhTQ7vVVT7zyoZ42qtj4+vxZcI+QSu Rafbow2Fl2qdms1OLCqFQuqchU1ecIhpXhKzhnPnyg== X-Google-Smtp-Source: AGRyM1tBwo6CnUmBLK/hy9XtyEPDI/HAe3NvSoOclnVBfkvOKAQygGzHWnfwAH7fkRusHvse/UVCkIBeIgM4bAgm8KI= X-Received: by 2002:a25:3895:0:b0:66e:341e:2286 with SMTP id f143-20020a253895000000b0066e341e2286mr12670124yba.579.1657871571963; Fri, 15 Jul 2022 00:52:51 -0700 (PDT) MIME-Version: 1.0 References: <20220714183913.118505-1-sughosh.ganu@linaro.org> <20220714183913.118505-7-sughosh.ganu@linaro.org> In-Reply-To: <20220714183913.118505-7-sughosh.ganu@linaro.org> From: Ilias Apalodimas Date: Fri, 15 Jul 2022 10:52:15 +0300 Message-ID: Subject: Re: [PATCH v7 06/13] FWU: stm32mp1: Add helper functions for accessing FWU metadata To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Takahiro Akashi , Patrick Delaunay , Patrice Chotard , Simon Glass , Bin Meng , Tom Rini , Etienne Carriere , Michal Simek , Jassi Brar Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hi Sughosh, On Thu, 14 Jul 2022 at 21:40, Sughosh Ganu wrote: > > Add helper functions needed for accessing the FWU metadata which > contains information on the updatable images. These functions have > been added for the STM32MP157C-DK2 board which has the updatable > images on the uSD card, formatted as GPT partitions. > > Signed-off-by: Sughosh Ganu > Reviewed-by: Patrick Delaunay > --- > Changes since V6: None > > board/st/stm32mp1/stm32mp1.c | 40 ++++++++++++++++ > include/fwu.h | 3 ++ > lib/fwu_updates/Makefile | 6 +++ > lib/fwu_updates/fwu_gpt.c | 88 ++++++++++++++++++++++++++++++++++++ > 4 files changed, 137 insertions(+) > create mode 100644 lib/fwu_updates/Makefile > create mode 100644 lib/fwu_updates/fwu_gpt.c > > diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c > index e3a04f8d8a..44c7943f1d 100644 > --- a/board/st/stm32mp1/stm32mp1.c > +++ b/board/st/stm32mp1/stm32mp1.c > @@ -7,9 +7,11 @@ > > #include > #include > +#include > #include > #include > #include > +#include > #include > #include > #include > @@ -25,9 +27,11 @@ > #include > #include > #include > +#include > #include > #include > #include > +#include > #include > #include > #include > @@ -962,3 +966,39 @@ static void board_copro_image_process(ulong fw_image, size_t fw_size) > } > > U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process); > + > +#if defined(CONFIG_FWU_MULTI_BANK_UPDATE) > + > +#include > +#include > + > +int fwu_plat_get_alt_num(struct udevice *dev, efi_guid_t *image_guid, > + int *alt_num) > +{ > + struct blk_desc *desc; > + struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev); > + > + desc = dev_get_uclass_plat(priv->blk_dev); > + if (!desc) { > + log_err("Block device not found\n"); > + return -ENODEV; > + } > + > + return fwu_gpt_get_alt_num(desc, image_guid, alt_num, DFU_DEV_MMC); > +} > + > +int fwu_plat_get_update_index(u32 *update_idx) > +{ > + int ret; > + u32 active_idx; > + > + ret = fwu_get_active_index(&active_idx); > + > + if (ret < 0) > + return -1; > + > + *update_idx = active_idx ^= 0x1; > + > + return ret; > +} I'dl ike to move those 2 out to the generic API as well. Sure a device might be paranoid and have more than 2 banks for firmware redundancy, however I believe 2 will be the main case. So we can use these 2 as generic weak functions and special devices can override that Regards /Ilias > +#endif /* CONFIG_FWU_MULTI_BANK_UPDATE */ > diff --git a/include/fwu.h b/include/fwu.h > index 8259c75d12..38dceca9c5 100644 > --- a/include/fwu.h > +++ b/include/fwu.h [...]