From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [PATCH 06/14] qemu: arm64: Set dfu_alt_info variable for the platform
Date: Tue, 8 Dec 2020 07:20:29 -0500 [thread overview]
Message-ID: <20201208122029.GM32272@bill-the-cat> (raw)
In-Reply-To: <CADg8p97LCE0xGJayP5wnEyYt+zxAtTMRfjDX4RyKnubo2gGgKQ@mail.gmail.com>
On Tue, Dec 08, 2020 at 10:48:57AM +0530, Sughosh Ganu wrote:
> On Tue, 8 Dec 2020 at 00:17, Tom Rini <trini@konsulko.com> wrote:
>
> > On Sat, Dec 05, 2020 at 11:31:49AM +0100, Heinrich Schuchardt wrote:
> > > On 11/26/20 7:41 PM, Sughosh Ganu wrote:
> > > > The dfu framework uses the dfu_alt_info environment variable to get
> > > > information that is needed for performing the firmware update. Set the
> > > > dfu_alt_info for the platform to reflect the two mtd partitions
> > > > created for the u-boot env and the firmware image.
> > > >
> > > > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > >
> > > I can't see anything QEMU specific in this patch. Why is the code under
> > > board/emulation/?
> > >
> > > Best regards
> > >
> > > Heinrich
> > >
> > > > ---
> > > > board/emulation/qemu-arm/qemu-arm.c | 55
> > +++++++++++++++++++++++++++++
> > > > include/configs/qemu-arm.h | 1 +
> > > > 2 files changed, 56 insertions(+)
> > > >
> > > > diff --git a/board/emulation/qemu-arm/qemu-arm.c
> > b/board/emulation/qemu-arm/qemu-arm.c
> > > > index d5ed3eebaf..8cad54c76f 100644
> > > > --- a/board/emulation/qemu-arm/qemu-arm.c
> > > > +++ b/board/emulation/qemu-arm/qemu-arm.c
> > > > @@ -200,8 +200,63 @@ void flash_write32(u32 value, void *addr)
> > > >
> > > > #if defined(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT)
> > > >
> > > > +#include <memalign.h>
> > > > #include <mtd.h>
> > > >
> > > > +#define MTDPARTS_LEN 256
> > > > +#define MTDIDS_LEN 128
> > > > +
> > > > +#define DFU_ALT_BUF_LEN SZ_1K
> > > > +
> > > > +static void board_get_alt_info(struct mtd_info *mtd, char *buf)
> > > > +{
> > > > + struct mtd_info *part;
> > > > + bool first = true;
> > > > + const char *name;
> > > > + int len, partnum = 0;
> > > > +
> > > > + name = mtd->name;
> > > > + len = strlen(buf);
> > > > +
> > > > + if (buf[0] != '\0')
> > > > + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, "&");
> > > > + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> > > > + "mtd %s=", name);
> > > > +
> > > > + list_for_each_entry(part, &mtd->partitions, node) {
> > > > + partnum++;
> > > > + if (!first)
> > > > + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> > ";");
> > > > + first = false;
> > > > +
> > > > + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
> > > > + "%s part %d",
> > > > + part->name, partnum);
> > > > + }
> > > > +}
> > > > +
> > > > +void set_dfu_alt_info(char *interface, char *devstr)
> > > > +{
> > > > + struct mtd_info *mtd;
> > > > +
> > > > + ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
> > > > +
> > > > + if (env_get("dfu_alt_info"))
> > > > + return;
> > > > +
> > > > + memset(buf, 0, sizeof(buf));
> > > > +
> > > > + /* probe all MTD devices */
> > > > + mtd_probe_devices();
> > > > +
> > > > + mtd = get_mtd_device_nm("nor0");
> > > > + if (!IS_ERR_OR_NULL(mtd))
> > > > + board_get_alt_info(mtd, buf);
> > > > +
> > > > + env_set("dfu_alt_info", buf);
> > > > + printf("dfu_alt_info set\n");
> > > > +}
> > > > +
> > > > static void board_get_mtdparts(const char *dev, const char
> > *partition,
> > > > char *mtdids, char *mtdparts)
> > > > {
> > > > diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h
> > > > index 69ff329434..726f985d35 100644
> > > > --- a/include/configs/qemu-arm.h
> > > > +++ b/include/configs/qemu-arm.h
> > > > @@ -33,6 +33,7 @@
> > > > #include <config_distro_bootcmd.h>
> > > >
> > > > #if defined(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT)
> > > > +#define CONFIG_SET_DFU_ALT_INFO
> > > > #define CONFIG_SYS_MTDPARTS_RUNTIME
> >
> > First, CONFIG_SET_DFU_ALT_INFO is in Kconfig and needs to be enabled
> > that way.
>
>
> Will change in the next version.
>
>
> > Second, typically we just set the information in the
> > environment part of the header. This is especially true if in both this
> > case and the previous patch to add mtdparts, we don't really have this
> > being dynamic? Or are we really expecting / supporting arbitrary sized
> > flash as this is qemu? Thanks.
> >
>
> I am not sure I understand this. One thing that can be done is to move the
> setting of the mtd partitions to the Kconfig file, on similar lines to what
> is being done for the st platforms, e.g MTDPARTS_NOR0_TEE. I can move the
> mtd partition definitions to the Kconfig file if that is what you are
> asking for.
Environment manipulation via C code is possible, but discouraged. What
can be set via Kconfig should be set that way, and what can be put in
the environment part of the header should be done that way. Does that
help clarify?
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201208/f6a6772a/attachment.sig>
next prev parent reply other threads:[~2020-12-08 12:20 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-26 18:40 [PATCH 00/14] qemu: arm64: Add support for uefi capsule update on qemu arm64 platform Sughosh Ganu
2020-11-26 18:40 ` [PATCH 01/14] qemu: arm: Use the generated DTB only when CONGIG_OF_BOARD is defined Sughosh Ganu
2020-12-05 9:31 ` Heinrich Schuchardt
2020-12-07 5:15 ` Sughosh Ganu
2020-12-07 12:50 ` Heinrich Schuchardt
2020-12-07 17:58 ` Heinrich Schuchardt
2020-12-08 5:28 ` Sughosh Ganu
2020-12-08 9:02 ` Heinrich Schuchardt
2020-12-08 9:19 ` Sughosh Ganu
2020-12-08 21:54 ` Heinrich Schuchardt
2020-12-09 5:25 ` Sughosh Ganu
2020-12-09 7:26 ` Heinrich Schuchardt
2020-12-09 8:26 ` Sughosh Ganu
2020-12-15 11:10 ` Sughosh Ganu
2020-12-15 12:55 ` Heinrich Schuchardt
2020-12-15 15:35 ` Sughosh Ganu
2020-11-26 18:40 ` [PATCH 02/14] mkeficapsule: Add support for embedding public key in a dtb Sughosh Ganu
2020-11-26 18:40 ` [PATCH 03/14] qemu: arm: Scan the pci bus in board_init Sughosh Ganu
2020-12-05 9:45 ` Heinrich Schuchardt
2020-12-07 5:16 ` Sughosh Ganu
2020-11-26 18:41 ` [PATCH 04/14] crypto: Fix the logic to calculate hash with authattributes set Sughosh Ganu
2020-12-05 10:21 ` Heinrich Schuchardt
2020-11-26 18:41 ` [PATCH 05/14] qemu: arm64: Add support for dynamic mtdparts for the platform Sughosh Ganu
2020-12-05 10:29 ` Heinrich Schuchardt
2020-12-07 5:30 ` Sughosh Ganu
2020-12-07 18:44 ` Tom Rini
2020-12-08 5:12 ` Sughosh Ganu
2020-11-26 18:41 ` [PATCH 06/14] qemu: arm64: Set dfu_alt_info variable " Sughosh Ganu
2020-12-05 10:31 ` Heinrich Schuchardt
2020-12-07 5:42 ` Sughosh Ganu
2020-12-07 6:56 ` Heinrich Schuchardt
2020-12-07 7:45 ` Sughosh Ganu
2020-12-07 18:47 ` Tom Rini
2020-12-08 5:18 ` Sughosh Ganu
2020-12-08 12:20 ` Tom Rini [this message]
2020-12-08 17:03 ` Sughosh Ganu
2020-11-26 18:41 ` [PATCH 07/14] efi_loader: Add config option to indicate fmp header presence Sughosh Ganu
2020-12-05 10:34 ` Heinrich Schuchardt
2020-12-07 6:02 ` Sughosh Ganu
2020-11-26 18:41 ` [PATCH 08/14] dfu_mtd: Add provision to unlock mtd device Sughosh Ganu
2020-11-26 18:41 ` [PATCH 09/14] efi_loader: Make the pkcs7 header parsing function an extern Sughosh Ganu
2020-12-05 10:40 ` Heinrich Schuchardt
2020-11-26 18:41 ` [PATCH 10/14] efi_loader: Re-factor code to build the signature store from efi signature list Sughosh Ganu
2020-11-26 18:41 ` [PATCH 11/14] efi: capsule: Add support for uefi capsule authentication Sughosh Ganu
2020-11-26 18:41 ` [PATCH 12/14] efi_loader: Enable " Sughosh Ganu
2020-12-05 10:47 ` Heinrich Schuchardt
2020-11-26 18:41 ` [PATCH 13/14] efidebug: capsule: Add a command to update capsule on disk Sughosh Ganu
2020-11-26 18:41 ` [PATCH 14/14] qemu: arm64: Add documentation for capsule update Sughosh Ganu
2020-12-05 10:16 ` Heinrich Schuchardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201208122029.GM32272@bill-the-cat \
--to=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox