From patchwork Thu Dec 17 12:10:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 344927 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1109244jai; Thu, 17 Dec 2020 04:11:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDuwEXQBYLU+pzMfJAXwCC0v65IBNX6sPnVCzx9hqClkyxsTe31ubPpp3c5wyNOED+qp5T X-Received: by 2002:a50:f604:: with SMTP id c4mr26737169edn.307.1608207065365; Thu, 17 Dec 2020 04:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608207065; cv=none; d=google.com; s=arc-20160816; b=LAg2NYegiGrjJ/4USvD4ir04nBSa9MZl1y125I8NDF7ck4cJXmgbZc/aXu9L83zBpN 5+6ns3hQCvwTMs+/mJcyTrMrxMKOHU9+Fs0OIKajzIk0i9HRkdbntmzARjpaQvKYZnHV wU3FvmmdhBtniF0579sM6IJqfwLQwk7tpIKQPwnlMEEjQnghB/KsTm4bkoJjT8d6PxN1 G0W7qZgbJsY4JP3GQ05GGvzVxOY7cSQQuq79suvY5EdESnHZTvBoNhIZp/VTBW1I1/+v xgQJAQD/g/9Wl6NF1BXhceH2/fM52tPWlJ9r3HJzzlidy8WSUIZPgq8ee2b9YRYjdS5R yR8g== 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:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=lvoJiVIOAxL1HGagwyZsenifsZq8AjD8aiOR8AcClf8=; b=s6l/yfGeJL4AgXkM8vkoHLCjxrZsF+vCAJucSFGc3QX/tlvqb7rO/YUh2Dc5pQQfSl HckSpQ2l040r5HS6g3AuWO2e12KeVe7UL7ii9G8EUo83OhYL5tRGNLviy+rYNqb5/eUq q1HvSxhwi6pESZsk2tDbmSOvaNMHb6fRagY0Rqy279u2fYhQPaLvpxbKQf/ORXiXrZuj IdSM540r5NDjBhGvXfkqTfops6dJLw9NaRUp2V8yaoJBsgPj0UooV7/ptQocP5jqM6i8 suZsNYCXmXHUPpb7XH2sQJueunV4dQVP88z8nSa8dqclrhgUUgusC35VAZDDR9+8y3cC OBuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ig0SqoM9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id i3si4384176edj.120.2020.12.17.04.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 04:11:05 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ig0SqoM9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 707E582BAE; Thu, 17 Dec 2020 13:10:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.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=samsung.com header.i=@samsung.com header.b="ig0SqoM9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8588E82BB2; Thu, 17 Dec 2020 13:10:56 +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=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5D7BA82BA1 for ; Thu, 17 Dec 2020 13:10:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201217121042euoutp0243a21977c7131bcddc338091b6c969ce~Rf8jx6AUi2104421044euoutp02R for ; Thu, 17 Dec 2020 12:10:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201217121042euoutp0243a21977c7131bcddc338091b6c969ce~Rf8jx6AUi2104421044euoutp02R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608207043; bh=lvoJiVIOAxL1HGagwyZsenifsZq8AjD8aiOR8AcClf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ig0SqoM9LbAUgamTeJXma9iDRkrKZM/7DFub509Gu7mxDKQMF+rU+CuwgvVhX4gow w2MAdzhVby1U4p/9rjFGk6FYhkn9TZ7caCwzNY6jrFLd8wDhOwJGkzZPV/b4LNlolc YGtRA0CLBf/Pt/lfxiV29KDZ3mVodDevedTLvci4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201217121042eucas1p14f79ae91beeb3b2ee08cc4442a1777c8~Rf8jho0b_1504015040eucas1p1w; Thu, 17 Dec 2020 12:10:42 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id AA.A0.45488.2CA4BDF5; Thu, 17 Dec 2020 12:10:42 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201217121042eucas1p117e69fd3f2c47558a0be7211c3fe5f2c~Rf8jBGlow0442304423eucas1p1f; Thu, 17 Dec 2020 12:10:42 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201217121042eusmtrp284c35080179a618400aa5aa7024121d2~Rf8i7ASfz1817818178eusmtrp2R; Thu, 17 Dec 2020 12:10:42 +0000 (GMT) X-AuditID: cbfec7f5-c77ff7000000b1b0-3c-5fdb4ac2dbd0 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 35.08.16282.1CA4BDF5; Thu, 17 Dec 2020 12:10:41 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201217121041eusmtip19550587b7af0d246e38d180769a4ad71~Rf8ikPMJS0781407814eusmtip16; Thu, 17 Dec 2020 12:10:41 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Cc: Marek Szyprowski , Lukasz Majewski , Marek Vasut , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH 3/5] dfu: add 'SCRIPT' entity Date: Thu, 17 Dec 2020 13:10:28 +0100 Message-Id: <20201217121030.6352-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217121030.6352-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsWy7djP87qHvG7HG/S1qltsnLGe1eLGrzZW i+fvLjNZrD1yl93iTVsjo8XbvZ3sDmwe82adYPE4e2cHo0ffllWMAcxRXDYpqTmZZalF+nYJ XBn3t75nLvguW3Hj7wvmBsbv4l2MnBwSAiYSM163snYxcnEICaxglLj76RcTSEJI4AujxOq9 9RCJz4wS12ZuZoHpeLDnATNEYjmjxPPzlxghHKCO2y8XsYFUsQkYSnS97QKzRQQkJH71X2UE sZkFLjJK/P5vDGILC+hKHLv1H2wdi4CqxNIln8BsXgEbibv3vjJDbJOXWL3hAJjNKWAr0XHy HRvIMgmBVg6JeY8/sEMUuUjM2N4KZQtLvDq+BcqWkfi/cz4TREMzo8TDc2vZIZweRonLTTMY IaqsJe6c+wU0lgPoPE2J9bv0IcKOEucfv2YECUsI8EnceCsI8QCfxKRt05khwrwSHW1CENVq ErOOr4Nbe/DCJaj7PSTebPrPBgmgCUC/P/jAMoFRfhbCsgWMjKsYxVNLi3PTU4uN81LL9YoT c4tL89L1kvNzNzECU8Hpf8e/7mBc8eqj3iFGJg7GQ4wSHMxKIrwJB27GC/GmJFZWpRblxxeV 5qQWH2KU5mBREufdtXVNvJBAemJJanZqakFqEUyWiYNTqoFphYbdHAGetPJvRleYOL6IVl1e 8JI1lfv1sU9Sl9V9/DgcPv2bm5P3lk9464wrdRLrX00/uKJ6Bv8E1oKXYfNPqllcTfjmYh9U 2D5/1unWxs827JEM3M+LTkf7uh0UCS6eNefNo5w1lzZ95WfcdTPo4rejnu8Ca1p8tIMvXu0M sbNJFZuzc9EH+z035KUaGgO8dpq8XOC5+PjlphjpSU9Ylt9VXBFncaeRKb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rzA4eTWBvZik5c1xxZ9ufJ+ 3hdFJZbijERDLeai4kQAWrmYctYCAAA= X-CMS-MailID: 20201217121042eucas1p117e69fd3f2c47558a0be7211c3fe5f2c X-Msg-Generator: CA X-RootMTR: 20201217121042eucas1p117e69fd3f2c47558a0be7211c3fe5f2c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201217121042eucas1p117e69fd3f2c47558a0be7211c3fe5f2c References: <20201217121030.6352-1-m.szyprowski@samsung.com> 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 Define a new 'SCRIPT' type for DFU entities. The downloaded data are treated as simple u-boot's scripts and executed with run_command_list() function. Flashing the 'SCRIPT' entity might result in changing the 'dfu_alt_info' environment variable from the flashed script, so add a global variable for tracking the potential need to reinitialize the dfu_alt_info related structures. Signed-off-by: Marek Szyprowski --- drivers/dfu/dfu.c | 6 +++++- drivers/dfu/dfu_mmc.c | 23 +++++++++++++++++++++-- include/dfu.h | 3 +++ 3 files changed, 29 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index fc32a53323..eccfb4c745 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -26,6 +26,8 @@ static struct hash_algo *dfu_hash_algo; static unsigned long dfu_timeout = 0; #endif +bool dfu_reinit_needed = false; + /* * The purpose of the dfu_flush_callback() function is to * provide callback for dfu user @@ -139,6 +141,8 @@ int dfu_init_env_entities(char *interface, char *devstr) char *env_bkp; int ret = 0; + dfu_reinit_needed = false; + #ifdef CONFIG_SET_DFU_ALT_INFO set_dfu_alt_info(interface, devstr); #endif @@ -614,7 +618,7 @@ const char *dfu_get_dev_type(enum dfu_device_type t) const char *dfu_get_layout(enum dfu_layout l) { const char *const dfu_layout[] = {NULL, "RAW_ADDR", "FAT", "EXT2", - "EXT3", "EXT4", "RAM_ADDR", "SKIP" }; + "EXT3", "EXT4", "RAM_ADDR", "SKIP", "SCRIPT" }; return dfu_layout[l]; } diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index d1af11d94c..e63fa84ce4 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -16,6 +16,7 @@ #include #include #include +#include static unsigned char *dfu_file_buf; static u64 dfu_file_buf_len; @@ -206,6 +207,9 @@ int dfu_write_medium_mmc(struct dfu_entity *dfu, case DFU_FS_EXT4: ret = mmc_file_buf_write(dfu, offset, buf, len); break; + case DFU_SCRIPT: + ret = run_command_list(buf, *len, 0); + break; case DFU_SKIP: ret = 0; break; @@ -221,9 +225,21 @@ int dfu_flush_medium_mmc(struct dfu_entity *dfu) { int ret = 0; - if (dfu->layout != DFU_RAW_ADDR) { - /* Do stuff here. */ + switch (dfu->layout) { + case DFU_FS_FAT: + case DFU_FS_EXT4: ret = mmc_file_buf_write_finish(dfu); + break; + case DFU_SCRIPT: + /* script may have changed the dfu_alt_info */ + dfu_reinit_needed = true; + break; + case DFU_RAW_ADDR: + case DFU_SKIP: + break; + default: + printf("%s: Layout (%s) not (yet) supported!\n", __func__, + dfu_get_layout(dfu->layout)); } return ret; @@ -243,6 +259,7 @@ int dfu_get_medium_size_mmc(struct dfu_entity *dfu, u64 *size) if (ret < 0) return ret; return 0; + case DFU_SCRIPT: case DFU_SKIP: return 0; default: @@ -408,6 +425,8 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s) dfu->layout = DFU_FS_EXT4; } else if (!strcmp(entity_type, "skip")) { dfu->layout = DFU_SKIP; + } else if (!strcmp(entity_type, "script")) { + dfu->layout = DFU_SCRIPT; } else { pr_err("Memory layout (%s) not supported!\n", entity_type); return -ENODEV; diff --git a/include/dfu.h b/include/dfu.h index 0b1dae0b3b..d18b701728 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -34,6 +34,7 @@ enum dfu_layout { DFU_FS_EXT4, DFU_RAM_ADDR, DFU_SKIP, + DFU_SCRIPT, }; enum dfu_op { @@ -497,6 +498,8 @@ static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, } #endif +extern bool dfu_reinit_needed; + #if CONFIG_IS_ENABLED(DFU_WRITE_ALT) /** * dfu_write_by_name() - write data to DFU medium