From patchwork Fri Aug 27 10:53:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1521638 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=YYqd57j0; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GwxR85Y1Sz9sPf for ; Fri, 27 Aug 2021 20:53:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 84BBF8328D; Fri, 27 Aug 2021 12:53:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="YYqd57j0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C47038328D; Fri, 27 Aug 2021 12:53:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 572C88327E for ; Fri, 27 Aug 2021 12:53:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x530.google.com with SMTP id b7so9299908edu.3 for ; Fri, 27 Aug 2021 03:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WDHAyZpQXW7tNtm3Y4DERWdwVum0i4QEFhwlpGO1kV0=; b=YYqd57j0lmH2R+szJNPG8hbYATd8cAkb1xpsfZnWpWf2eqazK+jJihcAkC2mUhoYea 7XXo5aW6gi+DYoZsZLuRPpJT2aXZqvGUP5hGwWUHHivNdxlWkzu0OIcVY3OXaJQY5NXP e40RDmBarfl7Vxz2+MGf/ecQ5sIYFKT9AYgINezMtB0NqAJARKcb3rCZkCGrQjQmmNUO HQzBUPl9kdWXMuZq/G7jJnVPcYfmVr2vrMGHomJmY7arP/vWwI+64CBbDJaa7sHdyuvl o1hV7l9CT8FYd5h/0sc1CZBMr3vuOs1a3NwdK59mIqVO5qWH3987dFmQy00KsH8OkKxZ uYkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=WDHAyZpQXW7tNtm3Y4DERWdwVum0i4QEFhwlpGO1kV0=; b=nSHQg6bNn4aj/VwsaglRNcQpMyY2alBM9T+U7+7hLLCIcbwkB+4Zle0DYqlLFQFBW+ HbFrx5af3Iq53wEd/UJyM4KjXBOu/2KiXQnyIWG1pHY9/MdDOb5JzwnNwz+VP7ogZHhg X2FFRgESjCyG/Rj1Z+NaOfuj48pfvu1Bbsd5XAUF2cqEmCbkIemxNfRCPPHMG0ICAVUE 1Z9OElJHHKtUwS1Zbi40ILdlknzFPpOniZruLbqgq6lYODMvP+263ZL9eR38jGDdifYP 9LyufBCf0HQeQwlHJDEJIpHI46JgyFq8PueHilzO3NVDXlIrYLbZ2w+/vvWQTr4M4AJu Hp5w== X-Gm-Message-State: AOAM532g4eO5G4ESCO2LbKptdLkhgR7hsqjpznBV5hSntV83d1KTWzWN Ch4+RAjfqeXdcKNLxGYj2fYFdln4WTRQpOdw7bE= X-Google-Smtp-Source: ABdhPJzF1RIh3BFRVtx7+so6vfbRdM5nZN9vBYiEYOtlMlDP2kFs9EYOm/+1L9SU8SEIMPJe06EJDw== X-Received: by 2002:aa7:cd13:: with SMTP id b19mr2541866edw.210.1630061614695; Fri, 27 Aug 2021 03:53:34 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::45a]) by smtp.gmail.com with ESMTPSA id o12sm3229535edv.19.2021.08.27.03.53.33 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Aug 2021 03:53:34 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Alexandre GRIVEAUX , Ashok Reddy Soma , Aswath Govindraju , Michal Simek , Mike Looijmans , Oleksandr Suvorov , Simon Glass , T Karthik Reddy Subject: [PATCH] ARM: zynq: Enable capsule update for qspi and mmc Date: Fri, 27 Aug 2021 12:53:32 +0200 Message-Id: X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 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.103.2 at phobos.denx.de X-Virus-Status: Clean Generate dfu_alt_info setup at runtime for capsule update. Enabling this feature will help with upgrading boards without remembering what is where. The similar change was done for ZynqMP by commit b86f43de0be0 ("xilinx: zynqmp: Add support for runtime dfu_alt_info setup"). Code needs to be enabled by CONFIG_SET_DFU_ALT_INFO. And also enable capsule on disk for RAW firmware images with efidebug command. Two indexes are supported for SPL flow. Images can be generated like: ./tools/mkeficapsule --raw spl/boot.bin --index 1 capsule1.bin ./tools/mkeficapsule --raw u-boot.img --index 2 capsule2.bin Then place them to SD card and load them: load mmc 0 10000000 capsule1.bin && efidebug capsule update -v 10000000 load mmc 0 10000000 capsule2.bin && efidebug capsule update -v 10000000 FSBL flow will also work where only index 1 capsule is used. There should be enough space for using boot.bin with bitstream too. Zynq also support multiple boot locations in SPI or MMC but it is not wired by this patch. Signed-off-by: Michal Simek --- board/xilinx/zynq/board.c | 35 ++++++++++++++++++++++++++++++ configs/xilinx_zynq_virt_defconfig | 6 +++++ 2 files changed, 41 insertions(+) diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 61e0a90c119b..1111ad6fca9c 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -151,3 +152,37 @@ enum env_location env_get_location(enum env_operation op, int prio) return ENVL_NOWHERE; } } + +#if defined(CONFIG_SET_DFU_ALT_INFO) + +#define DFU_ALT_BUF_LEN SZ_1K + +void set_dfu_alt_info(char *interface, char *devstr) +{ + ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); + + if (env_get("dfu_alt_info")) + return; + + memset(buf, 0, sizeof(buf)); + + switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) { + case ZYNQ_BM_SD: + snprintf(buf, DFU_ALT_BUF_LEN, + "mmc 0:1=boot.bin fat 0 1;" + "u-boot.img fat 0 1"); + break; + case ZYNQ_BM_QSPI: + snprintf(buf, DFU_ALT_BUF_LEN, + "sf 0:0=boot.bin raw 0 0x1500000;" + "u-boot.img raw 0x%x 0x500000", + CONFIG_SYS_SPI_U_BOOT_OFFS); + break; + default: + return; + } + + env_set("dfu_alt_info", buf); + puts("DFU alt info setting: done\n"); +} +#endif diff --git a/configs/xilinx_zynq_virt_defconfig b/configs/xilinx_zynq_virt_defconfig index 573a10fe221b..09ee066fdce2 100644 --- a/configs/xilinx_zynq_virt_defconfig +++ b/configs/xilinx_zynq_virt_defconfig @@ -49,6 +49,7 @@ CONFIG_CMD_USB=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y +CONFIG_CMD_EFIDEBUG=y CONFIG_CMD_TIME=y CONFIG_CMD_TIMER=y CONFIG_CMD_EXT4_WRITE=y @@ -69,6 +70,8 @@ CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_DFU_TIMEOUT=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y +CONFIG_DFU_SF=y +CONFIG_SET_DFU_ALT_INFO=y CONFIG_SYS_DFU_DATA_BUF_SIZE=0x600000 CONFIG_FPGA_XILINX=y CONFIG_FPGA_ZYNQPL=y @@ -123,3 +126,6 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_THOR=y CONFIG_DISPLAY=y CONFIG_SPL_GZIP=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y