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 D47D9C433EF for ; Fri, 17 Jun 2022 14:02:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 23916843AF; Fri, 17 Jun 2022 16:02:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="a8ZWHaT0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74F6E843C9; Fri, 17 Jun 2022 16:02:19 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D81C5841D6 for ; Fri, 17 Jun 2022 16:02:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=michal.simek@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WNyoFoSy8tPOwaXP61MwZJ5aj+iD1Sc1MwS/j+dfCx+TMCK706QsVow8cNBbZFrqaKRvJDnsFflhpZBcklXImMsafTfVgiopmZ4K3mo+uf2uNnPVv7qNKAE8kTXTHDDWA1drOsstZ2l7tzjwWSOphGwrOF/exqzZ/wwyqPi39j6zCkpef+MoSOzKiPDptDMW5e4WBa4vy6SR0x8liERFdj9MSxpOuc1iaQeKgEfiZ+0UIsTvreAtBBtjLJnuJj4uDoOPSR3gp9605jkJcB3i9XHv4HZc9Xq0p4KsNA9PKQnMVS0qb6TlnKvukj2DUaU+KEgvCfMna0TOfHov+05V4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a+9fvQyqdMhoGvvm7sVpxRyNtXXZhHCGJ4dUU9v2+i4=; b=YOrKyl8HVC7KnfOWaWOsFEIPM8Km2aoLv80HmjO9yH8fOEPn/FT1W4fYAL6Xp7o8yw5Rpnv0YJeXOyt+Xa9rLqCAztiW5k9K0aTmPMkrWGVIioOIvY3bUSJpko0eqEA4WK93/6oAzvQkZ8MRClJCiu+TaRTAKOJCfMbVq8nUMReNfaKf+eDpShqNjBYg8HHYWFG/8VZldOanpNwGTFT2HUHl4Ev/l/SbJ7p5FOGvEaIqgyK2ZrE//7tls+OqQCsJ4GnKCmIJylXCABWg9zjlTDZ94tW/GfHozeHKDg+dmxNqojcZ5pjAsd3U9ou1agARg3OFO4V7ylZ5yQwQ8NJS9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linaro.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a+9fvQyqdMhoGvvm7sVpxRyNtXXZhHCGJ4dUU9v2+i4=; b=a8ZWHaT0K6JBWFzjXBG5nNIxwZUI4c+Jltu4TisfR7gqbIViEU1+ANWqItoU8GeWtluljUYz7ujMzJBkQrvz+N4CyJakR2XfnqdebUSbI9zCf9Q2mpAtRQhRVwu4IkKPrLbNtvAV95LUIwWbdtaERvkk5V9khl1AGWvFzeQCUno= Received: from MW4P221CA0010.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::15) by CY4PR12MB1127.namprd12.prod.outlook.com (2603:10b6:903:44::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.16; Fri, 17 Jun 2022 14:02:13 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::33) by MW4P221CA0010.outlook.office365.com (2603:10b6:303:8b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.16 via Frontend Transport; Fri, 17 Jun 2022 14:02:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5353.14 via Frontend Transport; Fri, 17 Jun 2022 14:02:13 +0000 Received: from [10.254.241.52] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Fri, 17 Jun 2022 09:02:09 -0500 Message-ID: Date: Fri, 17 Jun 2022 16:02:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v5 20/23] FWU: synquacer: Generate dfu_alt_info from devicetree partition Content-Language: en-US To: Sughosh Ganu , CC: Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Patrick Delaunay , Patrice Chotard , Simon Glass , Bin Meng , Tom Rini , Etienne Carriere , Jassi Brar , Masami Hiramatsu References: <20220609123010.1017463-1-sughosh.ganu@linaro.org> <20220609123010.1017463-21-sughosh.ganu@linaro.org> From: Michal Simek In-Reply-To: <20220609123010.1017463-21-sughosh.ganu@linaro.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b09a7d32-bdf6-4feb-3b77-08da5069fae1 X-MS-TrafficTypeDiagnostic: CY4PR12MB1127:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HxCLZuO1tyl8jSV2Vds2QsfPxfnPeA0b4UJlNU8LoviqoW7FvDwQBdCuz3kFz1dRD7nzqFLvAAnnGjrmN8Mi50wxMhdq52/1ZKP+16BriZdEol2L1RQNYaDtzT/XVPEqivRYIFpNEP7xfLK9A+t+arASb2/KCbW1NTp+mT06ox0zupzMw/zQhRBSBT/xQkKJMsQtD+Ej6rPriWez5Ll/eZH31nyJka/Rsm0Cnu6SyBoAvJYjr5TYf7972IpmoCzQMBzZ4PZGp6zRBEJ4iOpHSpiKIiwcerdz5v73eXha/6s4Yp5r9nG7orX45xryEAO91hrzUDtI3gxxWajHovXNbG8mnAEJeTF7W+dB/djLHwANvUOFjF3e//1uCn6WhXiITp4seRZL5hBN2Qzo6kYR12Wls7HY+hp4BT/y1ED+XhwzYeWPOGdXEXOQMSuWOC7aKB1TLay97ceg4JMWnrsjD9U1zPNEoDYHSdxDgHHgmUJGAhO8/FEcfEYknwStj1ENMk+PzcNBUMVEDd6WKXjsnhZwTgH/MykCkZ4VTPOeNyS0xt9S2aNPpMoXT+CvL3jjGGAI7sK0iUFpYyt2hEyL1NJziRLoot5E2X0HON6DfQavz363dlubVlFdc90woim41Rr4qYyu40zOBgSXwr6VTVsaEgGiJckDo+S+u8zq8NHalZVDKLwg3xfDGbTjmWRfxaTZ9s3tLfOEHHaS6rgs77VtPBVu4rQmq0PHabpIL+Q= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230016)(4636009)(40470700004)(46966006)(36840700001)(86362001)(83380400001)(82310400005)(8936002)(81166007)(31686004)(2616005)(36756003)(70206006)(110136005)(316002)(44832011)(54906003)(8676002)(16576012)(2906002)(498600001)(31696002)(70586007)(40460700003)(16526019)(5660300002)(7416002)(6666004)(4326008)(356005)(53546011)(36860700001)(186003)(336012)(426003)(26005)(47076005)(43740500002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 14:02:13.4543 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b09a7d32-bdf6-4feb-3b77-08da5069fae1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1127 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.5 at phobos.denx.de X-Virus-Status: Clean On 6/9/22 14:30, Sughosh Ganu wrote: > From: Masami Hiramatsu > > Generate dfu_alt_info from the partition uuid information in the > devicetree, and record the mapping of partition uuid and the > index of dfu_alt_num. > > This could be a reference implementation of the automatic DFU > generation for FWU multi-bank update for non GPT firmware > platforms. > > Signed-off-by: Masami Hiramatsu > Signed-off-by: Sughosh Ganu > --- > .../synquacer-sc2a11-developerbox-u-boot.dtsi | 3 + > board/socionext/developerbox/Kconfig | 1 + > board/socionext/developerbox/fwu_plat.c | 79 ++++---- > include/configs/synquacer.h | 6 +- > include/fwu.h | 6 + > lib/fwu_updates/Makefile | 1 + > lib/fwu_updates/fwu_mtd.c | 173 ++++++++++++++++++ > 7 files changed, 221 insertions(+), 48 deletions(-) > create mode 100644 lib/fwu_updates/fwu_mtd.c > > diff --git a/arch/arm/dts/synquacer-sc2a11-developerbox-u-boot.dtsi b/arch/arm/dts/synquacer-sc2a11-developerbox-u-boot.dtsi > index ab4e3d1c2b..c7ec8a0321 100644 > --- a/arch/arm/dts/synquacer-sc2a11-developerbox-u-boot.dtsi > +++ b/arch/arm/dts/synquacer-sc2a11-developerbox-u-boot.dtsi > @@ -36,6 +36,7 @@ > compatible = "fixed-partitions"; > #address-cells = <1>; > #size-cells = <1>; > + uuid = "17e86d77-41f9-4fd7-87ec-a55df9842de5"; > > partition@0 { > label = "BootStrap-BL1"; > @@ -88,10 +89,12 @@ > partition@600000 { > label = "FIP-Bank0"; > reg = <0x600000 0x400000>; > + uuid = "5a66a702-99fd-4fef-a392-c26e261a2828"; > }; > partition@a00000 { > label = "FIP-Bank1"; > reg = <0xa00000 0x400000>; > + uuid = "a8f868a1-6e5c-4757-878d-ce63375ef2c0"; > }; > }; > }; > diff --git a/board/socionext/developerbox/Kconfig b/board/socionext/developerbox/Kconfig > index 7df6750baf..ad2a284f13 100644 > --- a/board/socionext/developerbox/Kconfig > +++ b/board/socionext/developerbox/Kconfig > @@ -38,6 +38,7 @@ config FWU_MULTI_BANK_UPDATE > select DM_SPI_FLASH > select DM_FWU_MDATA > select BOARD_LATE_INIT > + select SET_DFU_ALT_INFO > > config FWU_NUM_BANKS > default 2 > diff --git a/board/socionext/developerbox/fwu_plat.c b/board/socionext/developerbox/fwu_plat.c > index fd6d0e3659..ff06eade7d 100644 > --- a/board/socionext/developerbox/fwu_plat.c > +++ b/board/socionext/developerbox/fwu_plat.c > @@ -10,8 +10,10 @@ > #include > #include > #include > +#include > #include > #include > +#include > > #include > #include > @@ -94,6 +96,36 @@ static int sf_save_data(u32 offs, u32 size, void *data) > return ret; > } > > +#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; > + static char *buf = NULL; > + > + if (!buf) { > + buf = malloc_cache_aligned(DFU_ALT_BUF_LEN); > + memset(buf, 0, DFU_ALT_BUF_LEN); > + > + 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); > +} > + > #define PLAT_METADATA_OFFSET 0x510000 > #define PLAT_METADATA_SIZE (sizeof(struct devbox_metadata)) > > @@ -105,49 +137,7 @@ struct __packed devbox_metadata { > int fwu_plat_get_alt_num(struct udevice __always_unused *dev, > efi_guid_t *image_id, int *alt_num) > { > - struct fwu_image_bank_info *bank; > - struct fwu_mdata *mdata; > - int i, ret; > - > - ret = fwu_get_mdata(&mdata); > - if (ret < 0) > - return ret; > - > - /* > - * DeveloperBox FWU expects Bank:Image = 1:1, and the dfu_alt_info > - * only has the entries for banks. Thus the alt_no should be equal > - * to the bank index number. > - */ > - ret = -ENOENT; > - for (i = 0; i < CONFIG_FWU_NUM_BANKS; i++) { > - bank = &mdata->img_entry[0].img_bank_info[i]; > - if (guidcmp(image_id, &bank->image_uuid) == 0) { > - *alt_num = i; > - ret = 0; > - break; > - } > - } > - > - free(mdata); > - > - return ret; > -} > - > -/* This assumes that user doesn't change system default dfu_alt_info */ > -efi_status_t fill_image_type_guid_array(const efi_guid_t __always_unused > - *default_guid, > - efi_guid_t **part_guid_arr) > -{ > - int i; > - > - *part_guid_arr = malloc(sizeof(efi_guid_t) * DEFAULT_DFU_ALT_NUM); > - if (!*part_guid_arr) > - return EFI_OUT_OF_RESOURCES; > - > - for (i = 0; i < DEFAULT_DFU_ALT_NUM; i++) > - guidcpy((*part_guid_arr + i), &devbox_fip_image_type_guid); > - > - return EFI_SUCCESS; > + return fwu_get_mtd_alt_num(image_id, alt_num, "nor1", 0); > } > > int fwu_plat_get_update_index(u32 *update_idx) > @@ -188,6 +178,9 @@ int board_late_init(void) > { > int ret; > > + /* Make mmc available for EFI */ > + run_command("mmc dev 0", 0); > + What is this for? And I can't see any single note about in commit message. Thanks, Michal