From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: jassisinghbrar@gmail.com
Cc: u-boot@lists.denx.de, xypron.glpk@gmx.de,
ilias.apalodimas@linaro.org, sjg@chromium.org,
trini@konsulko.com, etienne.carriere@linaro.org,
monstr@monstr.eu, Masami Hiramatsu <masami.hiramatsu@linaro.org>,
Jassi Brar <jaswinder.singh@linaro.org>
Subject: Re: [PATCHv2 4/5] fwu: DeveloperBox: add support for FWU
Date: Mon, 3 Oct 2022 20:04:26 +0900 [thread overview]
Message-ID: <20221003110426.GB61078@laputa> (raw)
In-Reply-To: <20221002235214.344423-1-jassisinghbrar@gmail.com>
Hi Jassi,
On Sun, Oct 02, 2022 at 06:52:14PM -0500, jassisinghbrar@gmail.com wrote:
> From: Masami Hiramatsu <masami.hiramatsu@linaro.org>
>
> Add code to support FWU_MULTI_BANK_UPDATE.
> The platform does not have gpt-partition storage for
> Banks and MetaData, rather it used SPI-NOR backed
> mtd regions for the purpose.
>
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
> ---
> board/socionext/developerbox/Makefile | 1 +
> board/socionext/developerbox/developerbox.c | 8 ++
> board/socionext/developerbox/fwu_plat.c | 68 +++++++++++++++
> configs/synquacer_developerbox_defconfig | 13 ++-
> doc/board/socionext/developerbox.rst | 96 +++++++++++++++++++++
> include/configs/synquacer.h | 10 +++
> 6 files changed, 194 insertions(+), 2 deletions(-)
> create mode 100644 board/socionext/developerbox/fwu_plat.c
>
> diff --git a/board/socionext/developerbox/Makefile b/board/socionext/developerbox/Makefile
> index 4a46de995a..9b80ee38e7 100644
> --- a/board/socionext/developerbox/Makefile
> +++ b/board/socionext/developerbox/Makefile
> @@ -7,3 +7,4 @@
> #
>
> obj-y := developerbox.o
> +obj-$(CONFIG_FWU_MULTI_BANK_UPDATE) += fwu_plat.o
> diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c
> index f5a5fe0121..a0db26eaf3 100644
> --- a/board/socionext/developerbox/developerbox.c
> +++ b/board/socionext/developerbox/developerbox.c
> @@ -20,6 +20,13 @@
>
> #if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT)
> struct efi_fw_image fw_images[] = {
> +#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
> + {
> + .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
> + .fw_name = u"DEVELOPERBOX-FIP",
> + .image_index = 1,
> + },
> +#else
From curiosity, why do you want to use different capsule formats
for multi-bank update and normal case?
-Takahiro Akashi
> {
> .image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
> .fw_name = u"DEVELOPERBOX-UBOOT",
> @@ -35,6 +42,7 @@ struct efi_fw_image fw_images[] = {
> .fw_name = u"DEVELOPERBOX-OPTEE",
> .image_index = 3,
> },
> +#endif
> };
>
> struct efi_capsule_update_info update_info = {
> diff --git a/board/socionext/developerbox/fwu_plat.c b/board/socionext/developerbox/fwu_plat.c
> new file mode 100644
> index 0000000000..f333cd4027
> --- /dev/null
> +++ b/board/socionext/developerbox/fwu_plat.c
> @@ -0,0 +1,68 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2022, Linaro Limited
> + */
> +
> +#include <dfu.h>
> +#include <efi_loader.h>
> +#include <flash.h>
> +#include <fwu.h>
> +#include <fwu_mdata.h>
> +#include <malloc.h>
> +#include <memalign.h>
> +#include <mtd.h>
> +#include <spi.h>
> +#include <spi_flash.h>
> +#include <uuid.h>
> +
> +#include <linux/errno.h>
> +#include <linux/types.h>
> +#include <u-boot/crc.h>
> +
> +#define DFU_ALT_BUF_LEN 256
> +#define DFU_ALT_NUM_MAX (CONFIG_FWU_NUM_IMAGES_PER_BANK * CONFIG_FWU_NUM_BANKS)
> +
> +/* Generate dfu_alt_info from partitions */
> +void set_dfu_alt_info(char *interface, char *devstr)
> +{
> + int ret;
> + struct mtd_info *mtd;
> +
> + ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
> + memset(buf, 0, sizeof(buf));
> +
> + mtd_probe_devices();
> +
> + mtd = get_mtd_device_nm("nor1");
> + if (IS_ERR_OR_NULL(mtd))
> + return;
> +
> + ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd);
> + if (ret < 0) {
> + log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret);
> + return;
> + }
> + log_debug("Make dfu_alt_info: '%s'\n", buf);
> +
> + env_set("dfu_alt_info", buf);
> +}
> +
> +int fwu_plat_get_alt_num(struct udevice __always_unused *dev,
> + efi_guid_t *image_id, u8 *alt_num)
> +{
> + return fwu_mtd_get_alt_num(image_id, alt_num, "nor1");
> +}
> +
> +void fwu_plat_get_bootidx(uint *boot_idx)
> +{
> + int ret;
> + u32 active_idx;
> + u32 *bootidx = boot_idx;
> +
> + ret = fwu_get_active_index(&active_idx);
> +
> + if (ret < 0)
> + *bootidx = -1;
> +
> + *bootidx = active_idx;
> +}
> diff --git a/configs/synquacer_developerbox_defconfig b/configs/synquacer_developerbox_defconfig
> index c0b784b072..b1085a388e 100644
> --- a/configs/synquacer_developerbox_defconfig
> +++ b/configs/synquacer_developerbox_defconfig
> @@ -1,10 +1,11 @@
> CONFIG_ARM=y
> CONFIG_ARCH_SYNQUACER=y
> -CONFIG_SYS_TEXT_BASE=0x08200000
> +CONFIG_POSITION_INDEPENDENT=y
> +CONFIG_SYS_TEXT_BASE=0
> CONFIG_SYS_MALLOC_LEN=0x1000000
> CONFIG_SYS_MALLOC_F_LEN=0x400
> CONFIG_ENV_SIZE=0x30000
> -CONFIG_ENV_OFFSET=0x300000
> +CONFIG_ENV_OFFSET=0x580000
> CONFIG_ENV_SECT_SIZE=0x10000
> CONFIG_DM_GPIO=y
> CONFIG_DEFAULT_DEVICE_TREE="synquacer-sc2a11-developerbox"
> @@ -96,3 +97,11 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
> CONFIG_EFI_CAPSULE_ON_DISK=y
> CONFIG_EFI_IGNORE_OSINDICATIONS=y
> CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
> +CONFIG_EFI_SECURE_BOOT=y
> +CONFIG_FWU_MULTI_BANK_UPDATE=y
> +CONFIG_FWU_MDATA=y
> +CONFIG_FWU_MDATA_MTD=y
> +CONFIG_FWU_NUM_BANKS=2
> +CONFIG_FWU_NUM_IMAGES_PER_BANK=1
> +CONFIG_CMD_FWU_METADATA=y
> +CONFIG_TOOLS_MKFWUMDATA=y
> diff --git a/doc/board/socionext/developerbox.rst b/doc/board/socionext/developerbox.rst
> index 2d943c23be..be872aa79d 100644
> --- a/doc/board/socionext/developerbox.rst
> +++ b/doc/board/socionext/developerbox.rst
> @@ -85,3 +85,99 @@ Once the flasher tool is running we are ready flash the UEFI image::
>
> After transferring the SPI_NOR_UBOOT.fd, turn off the DSW2-7 and reset the board.
>
> +
> +Enable FWU Multi Bank Update
> +============================
> +
> +DeveloperBox supports the FWU Multi Bank Update. You *MUST* update both *SCP firmware* and *TF-A* for this feature. This will change the layout and the boot process but you can switch back to the normal one by changing the DSW 1-4 off.
> +
> +Configure U-Boot
> +----------------
> +
> +To enable the FWU Multi Bank Update on the DeveloperBox, you need to add following configurations to configs/synquacer_developerbox_defconfig ::
> +
> + CONFIG_FWU_MULTI_BANK_UPDATE=y
> + CONFIG_FWU_MDATA=y
> + CONFIG_FWU_MDATA_MTD=y
> + CONFIG_FWU_NUM_BANKS=2
> + CONFIG_FWU_NUM_IMAGES_PER_BANK=1
> + CONFIG_CMD_FWU_METADATA=y
> +
> +And build it::
> +
> + cd u-boot/
> + export ARCH=arm64
> + export CROSS_COMPILE=aarch64-linux-gnu-
> + make synqucer_developerbox_defconfig
> + make -j `noproc`
> + cd ../
> +
> +By default, the CONFIG_FWU_NUM_BANKS and COFNIG_FWU_NUM_IMAGES_PER_BANKS are set to 2 and 1 respectively. This uses FIP (Firmware Image Package) type image which contains TF-A, U-Boot and OP-TEE (the OP-TEE is optional.)
> +You can use fiptool to compose the FIP image from those firmware images.
> +
> +Rebuild SCP firmware
> +--------------------
> +
> +Rebuild SCP firmware which supports FWU Multi Bank Update as below::
> +
> + cd SCP-firmware/
> + OUT=./build/product/synquacer
> + ROMFW_FILE=$OUT/scp_romfw/$SCP_BUILD_MODE/bin/scp_romfw.bin
> + RAMFW_FILE=$OUT/scp_ramfw/$SCP_BUILD_MODE/bin/scp_ramfw.bin
> + ROMRAMFW_FILE=scp_romramfw_release.bin
> +
> + make CC=$ARM_EMB_GCC PRODUCT=synquacer MODE=release
> + tr "\000" "\377" < /dev/zero | dd of=${ROMRAMFW_FILE} bs=1 count=196608
> + dd if=${ROMFW_FILE} of=${ROMRAMFW_FILE} bs=1 conv=notrunc seek=0
> + dd if=${RAMFW_FILE} of=${ROMRAMFW_FILE} bs=1 seek=65536
> + cd ../
> +
> +And you can get the `scp_romramfw_release.bin` file
> +
> +Rebuild TF-A and FIP
> +--------------------
> +
> +Rebuild TF-A which supports FWU Multi Bank Update as below::
> +
> + cd arm-trusted-firmware/
> + make CROSS_COMPILE=aarch64-linux-gnu- -j`nproc` PLAT=synquacer \
> + SPD=opteed SQ_RESET_TO_BL2=1 GENERATE_COT=1 MBEDTLS_DIR=../mbedtls \
> + BL33=../u-boot/u-boot.bin all fip fiptool
> +
> +And make a FIP image.::
> +
> + cp build/synquacer/release/fip.bin SPI_NOR_NEWFIP.fd
> + tools/fiptool/fiptool update --tb-fw build/synquacer/release/bl2.bin SPI_NOR_NEWFIP.fd
> +
> +
> +UUIDs for the FWU Multi Bank Update
> +-----------------------------------
> +
> +FWU multi-bank update requires some UUIDs. The DeveloperBox platform uses following UUIDs.
> +
> + - Location UUID for the FIP image: 17e86d77-41f9-4fd7-87ec-a55df9842de5
> + - Image type UUID for the FIP image: 10c36d7d-ca52-b843-b7b9-f9d6c501d108
> + - Image UUID for Bank0 : 5a66a702-99fd-4fef-a392-c26e261a2828
> + - Image UUID for Bank1 : a8f868a1-6e5c-4757-878d-ce63375ef2c0
> +
> +These UUIDs are used for making a FWU metadata image.
> +
> +Install via flash writer
> +------------------------
> +
> +As explained in above section, the new FIP image and the FWU metadata image can be installed via NOR flash writer. Note that the installation offsets for the FWU multi bank update supported firmware.
> +
> +Once the flasher tool is running we are ready flash the images.::
> +Write the FIP image to the 0x600000 offset.::
> +
> + flash rawwrite 600000 180000
> + >> Send SPI_NOR_NEWFIP.fd via XMODEM (Control-A S in minicom) <<
> +
> +And write the new SCP firmware.::
> +
> + flash write cm3
> + >> Send scp_romramfw_release.bin via XMODEM (Control-A S in minicom) <<
> +
> +At last, turn on the DSW 3-4 on the board, and reboot.
> +Note that if DSW 3-4 is turned off, the DeveloperBox will boot from
> +the original EDK2 firmware (or non-FWU U-Boot if you already installed.)
> diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h
> index 63d897d090..c798a23bed 100644
> --- a/include/configs/synquacer.h
> +++ b/include/configs/synquacer.h
> @@ -41,19 +41,29 @@
>
> /* Since U-Boot 64bit PCIe support is limited, disable 64bit MMIO support */
>
> +#ifdef CONFIG_FWU_MULTI_BANK_UPDATE
> +#define DEFAULT_DFU_ALT_INFO
> +#else
> #define DEFAULT_DFU_ALT_INFO "dfu_alt_info=" \
> "mtd nor1=u-boot.bin raw 200000 100000;" \
> "fip.bin raw 180000 78000;" \
> "optee.bin raw 500000 100000\0"
> +#endif
>
> /* GUIDs for capsule updatable firmware images */
> #define DEVELOPERBOX_UBOOT_IMAGE_GUID \
> EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \
> 0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00)
>
> +#ifdef CONFIG_FWU_MULTI_BANK_UPDATE
> +#define DEVELOPERBOX_FIP_IMAGE_GUID \
> + EFI_GUID(0x7d6dc310, 0x52ca, 0x43b8, 0xb7, 0xb9, \
> + 0xf9, 0xd6, 0xc5, 0x01, 0xd1, 0x08)
> +#else
> #define DEVELOPERBOX_FIP_IMAGE_GUID \
> EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \
> 0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98)
> +#endif
>
> #define DEVELOPERBOX_OPTEE_IMAGE_GUID \
> EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \
> --
> 2.25.1
>
next prev parent reply other threads:[~2022-10-03 11:04 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 9:29 [PATCH v11 00/15] FWU: Add FWU Multi Bank Update feature support Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 01/15] dt/bindings: Add bindings for GPT based FWU Metadata storage device Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 02/15] FWU: Add FWU metadata structure and driver for accessing metadata Sughosh Ganu
2022-09-30 5:54 ` Etienne Carriere
2022-10-03 6:27 ` Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 03/15] FWU: Add FWU metadata access driver for GPT partitioned block devices Sughosh Ganu
2022-09-30 6:10 ` Etienne Carriere
2022-09-28 9:29 ` [PATCH v11 04/15] stm32mp1: dk2: Add a node for the FWU metadata device Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 05/15] stm32mp1: dk2: Add image information for capsule updates Sughosh Ganu
2022-09-30 5:51 ` Etienne Carriere
2022-10-03 10:56 ` Takahiro Akashi
2022-10-03 11:10 ` Sughosh Ganu
2022-10-04 3:04 ` Takahiro Akashi
2022-09-28 9:29 ` [PATCH v11 06/15] FWU: Add helper functions for accessing FWU metadata Sughosh Ganu
2022-10-03 9:51 ` Ilias Apalodimas
2022-09-28 9:29 ` [PATCH v11 07/15] FWU: STM32MP1: Add support to read boot index from backup register Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 08/15] event: Add an event for main_loop Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 09/15] FWU: Add boot time checks as highlighted by the FWU specification Sughosh Ganu
2022-10-03 9:56 ` Ilias Apalodimas
2022-10-03 10:31 ` Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 10/15] FWU: Add support for the FWU Multi Bank Update feature Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 11/15] FWU: cmd: Add a command to read FWU metadata Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 12/15] test: dm: Add test cases for FWU Metadata uclass Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 13/15] mkeficapsule: Add support for generating empty capsules Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 14/15] mkeficapsule: Add support for setting OEM flags in capsule header Sughosh Ganu
2022-09-28 9:29 ` [PATCH v11 15/15] FWU: doc: Add documentation for the FWU feature Sughosh Ganu
2022-09-30 6:27 ` Etienne Carriere
2022-09-30 8:23 ` Sughosh Ganu
2022-10-04 2:54 ` Takahiro Akashi
2022-10-04 6:40 ` Sughosh Ganu
2022-10-04 7:09 ` Takahiro Akashi
2022-10-04 7:46 ` Ilias Apalodimas
2022-10-02 23:50 ` [PATCHv2 0/5] FWU: Add support for mtd backed feature on DeveloperBox jassisinghbrar
2022-10-02 23:51 ` [PATCHv2 1/5] FWU: Add FWU metadata access driver for MTD storage regions jassisinghbrar
2022-10-14 7:07 ` Ilias Apalodimas
2022-10-31 23:37 ` Jassi Brar
2022-10-02 23:51 ` [PATCHv2 2/5] FWU: mtd: Add helper functions for accessing FWU metadata jassisinghbrar
2022-10-14 7:10 ` Ilias Apalodimas
2022-10-02 23:51 ` [PATCHv2 3/5] dt: fwu: developerbox: enable fwu banks and mdata regions jassisinghbrar
2022-10-14 7:33 ` Ilias Apalodimas
2022-10-02 23:52 ` [PATCHv2 4/5] fwu: DeveloperBox: add support for FWU jassisinghbrar
2022-10-03 11:04 ` AKASHI Takahiro [this message]
2022-10-03 13:40 ` Jassi Brar
2022-10-03 13:51 ` Ilias Apalodimas
2022-10-04 1:06 ` AKASHI Takahiro
2022-10-04 2:00 ` Jassi Brar
2022-10-04 2:44 ` AKASHI Takahiro
2022-10-04 2:53 ` Jassi Brar
2022-10-02 23:52 ` [PATCHv2 5/5] tools: Add mkfwumdata tool for FWU metadata image jassisinghbrar
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=20221003110426.GB61078@laputa \
--to=takahiro.akashi@linaro.org \
--cc=etienne.carriere@linaro.org \
--cc=ilias.apalodimas@linaro.org \
--cc=jassisinghbrar@gmail.com \
--cc=jaswinder.singh@linaro.org \
--cc=masami.hiramatsu@linaro.org \
--cc=monstr@monstr.eu \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.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