From patchwork Thu Nov 26 18:41:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 333043 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1543024ilb; Thu, 26 Nov 2020 10:43:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzO8yoZlMa3RzfMVhw0IQrZhjT79l6n8ykomk3MMgzsfmzLhRI6R2/LANOkAXqMzsbBVkVj X-Received: by 2002:a05:6402:b02:: with SMTP id bm2mr3948059edb.299.1606416195546; Thu, 26 Nov 2020 10:43:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606416195; cv=none; d=google.com; s=arc-20160816; b=1Dmz/KQbcfIhkYBNjm+WoL8IP39b57CFqQiSxoiyp3xJLLkXMFzSIoECZokeflsqN6 skl/W4nrVUVQ4Idj9SEEqXtumVHf8lLTvvxyTSKZsK4bkw5snXgUNhZ3WL/EzdM1dFwd yj1IvxpG70sFm57mFbqwdtKg9FeUVyX8iterHl5ueiiDKC//iNf2P4w2JoTPBMULUXg2 hFO72VgwXwuWj3CZiQ8NjRSpoQMIGymgDjG7JBVzXHgdvXdB4RFfSYR6O4aBDuaX/Ktg BTOWNUjHRcjCBmtb7NP6mp9BpCeSdH8TmuqL1EC1hKmkzl4Vl5RFpWbv+Ntus0Y8VQXM n6rw== 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:references:in-reply-to :message-id:date:subject:cc:to:from; bh=tOsNE5kZf0Jst+zSSGyicC8KLnOcFeLUb7uNlVme+7Y=; b=VUl18ievEVyWDOAeZinibGJXNSks3YrOm22qORV2TgFbaG5ThwxYSjKxxLWiYpu+ul 56BNgfpuquA6Eg5HuE5Z4GU1v8ujJ4RsGTGta7p3y47/vsKgjQmiR2VuR6kkPbb2j6kX 18TdEXJOL2HHuQHGZiBbP922czLZj8s19+ITc5H4TLHMus+sIJDqM69EbkYH0vj3lbCT UZUyq7m6IVVZM+iOSD9xKz8O22WuxOjITAcfxIDl6ljBWllOW5DOIGfqt0bQbbaY4DJZ 02Z1HSLIzGWUb0+YyBgMo0RO10C3enYZLtk0bSJ8lN1QCLlo4aLz5M5h8ek58/aKmdg2 YsgQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 w13si3534995edf.269.2020.11.26.10.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 10:43:15 -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; 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=fail (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 8D4BE826EE; Thu, 26 Nov 2020 19:42:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 2A1DF826EB; Thu, 26 Nov 2020 19:42:12 +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=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id E1517826E3 for ; Thu, 26 Nov 2020 19:42:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 849511650; Thu, 26 Nov 2020 10:42:06 -0800 (PST) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1CB273F23F; Thu, 26 Nov 2020 10:42:03 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Takahiro Akashi , Heinrich Schuchardt , Alexander Graf , Lukasz Majewski , Tuomas Tynkkynen , Tom Rini , Sughosh Ganu Subject: [PATCH 06/14] qemu: arm64: Set dfu_alt_info variable for the platform Date: Fri, 27 Nov 2020 00:11:02 +0530 Message-Id: <20201126184110.30521-7-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201126184110.30521-1-sughosh.ganu@linaro.org> References: <20201126184110.30521-1-sughosh.ganu@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean 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 --- board/emulation/qemu-arm/qemu-arm.c | 55 +++++++++++++++++++++++++++++ include/configs/qemu-arm.h | 1 + 2 files changed, 56 insertions(+) -- 2.17.1 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 #include +#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 #if defined(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) +#define CONFIG_SET_DFU_ALT_INFO #define CONFIG_SYS_MTDPARTS_RUNTIME #endif