[PATCH v5 00/23] FWU: Add FWU Multi Bank Update feature support

Sughosh Ganu
2022-06-09T12:30:36Z

The patchset adds support for the FWU Multi Bank Update[1]
feature. Certain aspects of the Dependable Boot[2] specification have
also been implemented.

The FWU multi bank update feature is used for supporting multiple
sets(also called banks) of firmware image(s), allowing the platform to
boot from a different bank, in case it fails to boot from the active
bank. This functionality is supported by keeping the relevant
information in a structure called metadata, which provides information
on the images. Among other parameters, the metadata structure contains
information on the currect active bank that is being used to boot
image(s).

Functionality is being added to work with the UEFI capsule driver in
u-boot. The metadata is read to gather information on the update bank,
which is the bank to which the firmware images would be flashed to. On
a successful completion of the update of all components, the active
bank field in the metadata is updated, to reflect the bank from which
the platform will boot on the subsequent boots.

Currently, the feature is being enabled on the STM32MP157C-DK2 and
Synquacer boards. The DK2 board boots a FIP image from a uSD card
partitioned with the GPT partioning scheme, while the Synquacer board
boots a FIP image from a MTD partitioned SPI NOR flash device.

This feature also requires changes in a previous stage of
bootloader, which parses the metadata and selects the bank to boot the
image(s) from. Support has being added in tf-a(BL2 stage) for the
STM32MP157C-DK2 board to boot the active bank images. These changes
have been merged to the upstream tf-a repository.

Earlier, two separate patchsets were being sent. The patchset sent by
me was adding support for the feature, and enabling the feature on the
ST board. The other set of patches were being sent by Masami
Hiramatsu, which were enabling the feature on the Synquacer
platform. This patchset contains both set of patches, along with the
associated documentation and the python test script for testing the
feature.

The upstreaming effort for this feature had been put on a temporary
hold to address the fixing of some issues in the capsule update code,
primarily using a per platform image GUID for the updatable
images. Now that the series has been merged, upstreaming effort for
the FWU update feature is being resumed. Hence, this version does not
have any review comments being addressed.

[1] - https://developer.arm.com/documentation/den0118/a
[2] - https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf

Jassi Brar (1):
developerbox: synquacer: Use FIP as the updatable image

Masami Hiramatsu (9):
FWU: Add FWU metadata access driver for non-GPT MTD devices
dt/bindings: firmware: Add FWU metadata on MTD devices binding
tools: Add mkfwumdata tool for FWU metadata image
FWU: doc: Update documentation for the FWU non-GPT MTD
synquacer: Update for TBBR (BL2) based new FIP layout
FWU: synquacer: Add FWU Multi bank update support for DeveloperBox
FWU: synquacer: Generate dfu_alt_info from devicetree partition
doc: synquacer: Add how to enable FWU Multi Bank Update
[TEMP]configs: synquacer: Add FWU support for DeveloperBox

Sughosh Ganu (13):
dt/bindings: Add bindings for FWU Metadata storage device
FWU: Add FWU metadata structure and driver for accessing metadata
FWU: Add FWU metadata access driver for GPT partitioned block devices
stm32mp1: dk2: Add a node for the FWU metadata device
stm32mp1: dk2: Add image information for capsule updates
FWU: stm32mp1: Add helper functions for accessing FWU metadata
FWU: STM32MP1: Add support to read boot index from backup register
FWU: Add boot time checks as highlighted by the FWU specification
FWU: Add support for the FWU Multi Bank Update feature
FWU: cmd: Add a command to read FWU metadata
mkeficapsule: Add support for generating empty capsules
FWU: doc: Add documentation for the FWU feature
sandbox: fwu: Add support for testing FWU feature on sandbox

arch/arm/dts/stm32mp157c-dk2-u-boot.dtsi | 7 +
.../synquacer-sc2a11-developerbox-u-boot.dtsi | 40 +-
arch/arm/mach-stm32mp/include/mach/stm32.h | 4 +
arch/sandbox/Kconfig | 6 +
arch/sandbox/dts/test.dts | 45 +-
board/sandbox/sandbox.c | 49 ++
board/socionext/developerbox/Kconfig | 14 +
board/socionext/developerbox/Makefile | 1 +
board/socionext/developerbox/developerbox.c | 17 +-
board/socionext/developerbox/fwu_plat.c | 200 ++++++++
board/st/stm32mp1/stm32mp1.c | 141 ++++++
cmd/Kconfig | 7 +
cmd/Makefile | 1 +
cmd/fwu_mdata.c | 74 +++
common/board_r.c | 5 +
configs/sandbox64_defconfig | 12 +-
configs/synquacer_developerbox_defconfig | 10 +-
doc/board/socionext/developerbox.rst | 110 +++++
doc/develop/uefi/fwu_updates.rst | 200 ++++++++
doc/develop/uefi/index.rst | 1 +
doc/develop/uefi/uefi.rst | 2 +
.../firmware/fwu-mdata.txt | 18 +
.../firmware/uboot,fwu-mdata-mtd.yaml | 38 ++
doc/mkeficapsule.1 | 29 +-
drivers/Kconfig | 2 +
drivers/Makefile | 1 +
drivers/fwu-mdata/Kconfig | 24 +
drivers/fwu-mdata/Makefile | 8 +
drivers/fwu-mdata/fwu-mdata-uclass.c | 459 ++++++++++++++++++
drivers/fwu-mdata/fwu_mdata_gpt_blk.c | 404 +++++++++++++++
drivers/fwu-mdata/fwu_mdata_mtd.c | 308 ++++++++++++
include/configs/stm32mp15_common.h | 4 +
include/configs/synquacer.h | 21 +-
include/dm/uclass-id.h | 1 +
include/fwu.h | 74 +++
include/fwu_mdata.h | 67 +++
lib/Kconfig | 6 +
lib/Makefile | 1 +
lib/efi_loader/efi_capsule.c | 231 ++++++++-
lib/efi_loader/efi_setup.c | 3 +-
lib/fwu_updates/Kconfig | 31 ++
lib/fwu_updates/Makefile | 7 +
lib/fwu_updates/fwu.c | 206 ++++++++
lib/fwu_updates/fwu_mtd.c | 173 +++++++
.../test_capsule_firmware_fit.py | 1 -
.../py/tests/test_fwu_updates/capsule_defs.py | 10 +
test/py/tests/test_fwu_updates/conftest.py | 78 +++
.../test_fwu_updates/test_fwu_updates.py | 367 ++++++++++++++
tools/Kconfig | 9 +
tools/Makefile | 4 +
tools/eficapsule.h | 8 +
tools/mkeficapsule.c | 139 +++++-
tools/mkfwumdata.c | 298 ++++++++++++
53 files changed, 3903 insertions(+), 73 deletions(-)
create mode 100644 board/socionext/developerbox/fwu_plat.c
create mode 100644 cmd/fwu_mdata.c
create mode 100644 doc/develop/uefi/fwu_updates.rst
create mode 100644 doc/device-tree-bindings/firmware/fwu-mdata.txt
create mode 100644 doc/device-tree-bindings/firmware/uboot,fwu-mdata-mtd.yaml
create mode 100644 drivers/fwu-mdata/Kconfig
create mode 100644 drivers/fwu-mdata/Makefile
create mode 100644 drivers/fwu-mdata/fwu-mdata-uclass.c
create mode 100644 drivers/fwu-mdata/fwu_mdata_gpt_blk.c
create mode 100644 drivers/fwu-mdata/fwu_mdata_mtd.c
create mode 100644 include/fwu.h
create mode 100644 include/fwu_mdata.h
create mode 100644 lib/fwu_updates/Kconfig
create mode 100644 lib/fwu_updates/Makefile
create mode 100644 lib/fwu_updates/fwu.c
create mode 100644 lib/fwu_updates/fwu_mtd.c
create mode 100644 test/py/tests/test_fwu_updates/capsule_defs.py
create mode 100644 test/py/tests/test_fwu_updates/conftest.py
create mode 100644 test/py/tests/test_fwu_updates/test_fwu_updates.py
create mode 100644 tools/mkfwumdata.c

--
2.25.1