From patchwork Thu Jan 20 15:29:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 533539 Delivered-To: patch@linaro.org Received: by 2002:ad5:5d50:0:0:0:0:0 with SMTP id x16csp1675520imu; Thu, 20 Jan 2022 07:29:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUHinFGOQN99tpYewFWaLEaQpkSg9JjepL2PbJHQEXUdLMf8et93EjB2oGkNg89DKJlp9m X-Received: by 2002:a17:907:7f01:: with SMTP id qf1mr28925449ejc.240.1642692573549; Thu, 20 Jan 2022 07:29:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642692573; cv=none; d=google.com; s=arc-20160816; b=hnO7U+RgFpZEXY0Lm1PBNt/43kPMj+XeAVxFleULzeoywCDyEzaCQqWxUJXfFV/7Dq Zn3DKV4zwlF2BfBTOZadZGYzd50ao3tPwwvbYeJZ5vNHFm8gGw+WqW7r8zVSZiCykA+h 4v8fwjQlB2vx4GEEHvABFuAwie1kchCjhl2AXa/6Pw54tunZe6uK497ztP24lE+A0nUE wA+NIlR2/kfjKFfV69fi5MrB9F/TnFP5VxhBsrMYWDn9ukdMuY48SGIniSRmE0r0bD72 ZV01g3ms/gfie1fybiMWZouxmYBqLGE2tdbbDKwboW0F8zx0tPHiuU7ZejN7mtgKgfc5 Oj8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:message-id:date:subject:cc:to:from :dkim-signature; bh=nC+RuZCT5dsBXy3YJ7FauMjEKRiKSFY529MaMmiGuzA=; b=c24f+RBJHNF43YzxSSrRInNiPiTVSHf8yJVRbCl+B+Eb46rbpmglfhnA8BJpq8jXzx zZnfsHaU2hNwFOok0nkQCDeWg7a0xPu0Mqbeop/edlaKbQoXOnjmupWtaryrYIp2wVED 6gFM67ixZ8ZjlThi97tccvQw3DhuqZ7yudl6iaby4q5cBtZaHFUQo/xIh+/JJjxUjCwv LhIp3YsKbsPz/YMN8uCIbPIU3+CZSFt2Y3GkuyM1n5DZhcC7Hm9YiCDP67R6vSFjDEq3 DqU/g8Zxi/bzfWdBXusKnn6hB6twQ467C6N7eyRquzuaGqO2HTgHSBQWP0NIzdbVr4F6 8gxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="e/DSN6Nd"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ch10si2058655edb.505.2022.01.20.07.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 07:29:33 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="e/DSN6Nd"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A4D0183890; Thu, 20 Jan 2022 16:29:31 +0100 (CET) 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="e/DSN6Nd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EFA398389E; Thu, 20 Jan 2022 16:29:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) (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 722498339D for ; Thu, 20 Jan 2022 16:29:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pf1-x435.google.com with SMTP id 128so5873917pfe.12 for ; Thu, 20 Jan 2022 07:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=nC+RuZCT5dsBXy3YJ7FauMjEKRiKSFY529MaMmiGuzA=; b=e/DSN6NdoNEWgiAM02m2Eg8imfvM2qGtc58VxGG2yWQFyvnCxqka9puB+1otDX6ehu 0aFG96opaCIoOkZ6q6w0DdGptPTo6p9Ak6sHR1Y9L7D0t4Qp4heVRp97pxUcTKDZaF7d yX1A8INZV1ql9s2eWtcpz8+DTi+C7Mnr1MY8EaEQ99C3Bf4kzuEI0eDFx4Uaou1pgOqq fiZXS5J/rofkHdHOLVZfbI+GGNDGJ6ESl/zLD4lC+BSt74BnczsyI8Qj+/e17Vx19IJy HLaAjXBmTY3R4F4BlTM4a0OfEhom0lyM6dz0iMY9crottw+PvOVOji1CS8ulI5sertY4 chcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=nC+RuZCT5dsBXy3YJ7FauMjEKRiKSFY529MaMmiGuzA=; b=UcA+e39UctSSEAv/WaJjGwLbKcXOistKpK+lv7M1FWyAdfOaVofqq6TWB7vPgJ5joP Zt3iwkiVy0gs09cN1JWPThdmaPOJaUn8ziw+uiS1R4k3VDAAL+bjL7H2HKA/CqHK38em k5Z90PCkbPTE4xnDuWxFcwrOJLCW2zNBFTMeg3uT0owvdmX8nemAE9+5tooBhmRMobWg MgS+KhEjCkn/hZj618CoBaBbvzXxeJLYLBM1DWKSV2lE9tWSc566mrTq4u8l3AoOtN24 Nbn08AKaTyWN6ZFL0R535hhWA4eYNlFHmyF5/sMQXk9lEQb4tlWixgIK2zTeOwfnbxkl qezA== X-Gm-Message-State: AOAM531siBBva6h0Clh9gHRs3EWNNL1pAbMDtECTWvOGmtsHDgLonhzL 8rrIy/D4zpYFEw1CdEXN5eRhkRSKiYE2Vg== X-Received: by 2002:a05:6a00:1505:b0:4c4:330:b86d with SMTP id q5-20020a056a00150500b004c40330b86dmr22113966pfu.82.1642692564516; Thu, 20 Jan 2022 07:29:24 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id p17sm9569865pjo.37.2022.01.20.07.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 07:29:24 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [RFC PATCH 00/14] FWU: Add FWU Multi Bank Update for DeveloerBox Date: Fri, 21 Jan 2022 00:29:19 +0900 Message-Id: <164269255955.39378.260729958623102750.stgit@localhost> X-Mailer: git-send-email 2.25.1 User-Agent: StGit/0.19 MIME-Version: 1.0 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.2 at phobos.denx.de X-Virus-Status: Clean Hi, Here is an RFC series of patches for the FWU Multi Bank Update support for the DeveloperBox platform. This series depends on Sughosh's Multi Bank Update v3 [1]. Thus if that is updated, this must be rebased and updated too. [1] https://patchwork.ozlabs.org/project/uboot/list/?series=281875 This series includes my previous DFU updates[2] as [01/14]-[05/14], which is still under review in the U-Boot ML. For "nicely" indent the dfu_alt_info lines, I need that series. :-) [2] https://patchwork.ozlabs.org/project/uboot/list/?series=275293 I also added some patches which updates Sughosh's series as [06/14] - [08/14]. Thus the [09/14] - [14/14] are the changes for DeveloperBox. Unlike the STM32MP board, DeveloperBox (SynQuacer) loads the firmware from SPI NOR flash. Thus it doesn't use GPT partitions to store the firmware banks and the FWU metadata. Instead, it stores those data at fixed address areas on SPI NOR flash. I carefully chose the areas which doesn't overlap the previous firmware and EDK2. I introduced fwu_metadata_sf.c driver for this FWU multi bank support on SPI flash, which does not use GPT too. Since there is no GPT, the location GUID for images and the image GUID for banks are Null GUID. Anyway, for managing firmware image banks, we only need the ImageType GUID. And the SynQuacer also does not have any non-volatile register. Thus this allocates the platform defined boot index on the SPI flash too. So, in summary, on the DeveloperBox, this FWU Multi Bank update is only for avoidance of unexpected bricking by firmware update. If there are multiple banks, when the user (or firmware developer) update it with a wrong image, they can revert the wrong one. Even if it does not boot, SCP firmware can detect it and roll back to the previous bank. But please note that this is not "security" enhancement at all at least on the DeveloperBox because all images are still on normal SPI NOR flash. This is rather like a "safety" feature like a fool proof. NOTE: To use this series, you also need to update SCP firmware[3] and TF-A[4] on the DeveloperBox. Those are under cleaning up. [3] https://git.linaro.org/people/masami.hiramatsu/SCP-firmware.git/ [4] https://git.linaro.org/people/masami.hiramatsu/arm-trusted-firmware.git/ Thank you, --- Masami Hiramatsu (14): DFU: Do not copy the entity name over the buffer size DFU: Accept redundant spaces and tabs in dfu_alt_info DFU: Check the number of arguments and argument string strictly doc: usage: DFU: Fix dfu_alt_info document cmd/dfu: Enable 'dfu list' command without DFU_OVER_USB FWU: Calculate CRC32 in gpt_update_mdata() FWU: Free metadata copy if gpt_get_mdata() failed FWU: Move FWU metadata operation code in fwu_mdata.c synquacer: Update for TBBR based new FIP layout FWU: Reboot soon after successfully install the new firmware FWU: Add FWU Multi Bank Update on SPI Flash FWU: synquacer: Add FWU Multi bank update support for DeveloperBox FWU: synquacer: Initialize broken metadata configs: synquacer: Add FWU support for DeveloperBox .../dts/synquacer-sc2a11-developerbox-u-boot.dtsi | 26 +- board/socionext/developerbox/Kconfig | 31 +++ board/socionext/developerbox/Makefile | 1 board/socionext/developerbox/fwu_plat.c | 217 ++++++++++++++++++ cmd/dfu.c | 6 configs/synquacer_developerbox_defconfig | 12 + doc/usage/dfu.rst | 45 +++- drivers/dfu/dfu.c | 37 ++- drivers/dfu/dfu_mmc.c | 55 +++-- drivers/dfu/dfu_mtd.c | 34 ++- drivers/dfu/dfu_nand.c | 34 ++- drivers/dfu/dfu_ram.c | 24 +- drivers/dfu/dfu_sf.c | 34 ++- drivers/dfu/dfu_virt.c | 5 include/configs/synquacer.h | 14 + include/dfu.h | 33 ++- include/efi_loader.h | 3 include/fwu.h | 22 +- lib/efi_loader/efi_capsule.c | 10 + lib/efi_loader/efi_firmware.c | 14 + lib/fwu_updates/Kconfig | 43 ++++ lib/fwu_updates/Makefile | 5 lib/fwu_updates/fwu_mdata.c | 123 ++++++---- lib/fwu_updates/fwu_mdata_gpt_blk.c | 109 +-------- lib/fwu_updates/fwu_mdata_sf.c | 241 ++++++++++++++++++++ 25 files changed, 888 insertions(+), 290 deletions(-) create mode 100644 board/socionext/developerbox/fwu_plat.c create mode 100644 lib/fwu_updates/fwu_mdata_sf.c -- Masami Hiramatsu