{"id":1745889,"url":"http://patchwork.ozlabs.org/api/patches/1745889/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20230221201925.9644-21-pali@kernel.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20230221201925.9644-21-pali@kernel.org>","list_archive_url":null,"date":"2023-02-21T20:18:46","name":"[RFC,u-boot-mvebu,20/59] cmd: mvebu/bubt: Add support for selecting eMMC HW partition","commit_ref":"fc10a926ec43250914de6fd69e4258f39c79c8aa","pull_url":null,"state":"accepted","archived":false,"hash":"634a607938b56b609e3f1203f93c3129251304ea","submitter":{"id":78810,"url":"http://patchwork.ozlabs.org/api/people/78810/?format=json","name":"Pali Rohár","email":"pali@kernel.org"},"delegate":{"id":1696,"url":"http://patchwork.ozlabs.org/api/users/1696/?format=json","username":"stroese","first_name":"Stefan","last_name":"Roese","email":"sr@denx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20230221201925.9644-21-pali@kernel.org/mbox/","series":[{"id":343058,"url":"http://patchwork.ozlabs.org/api/series/343058/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=343058","date":"2023-02-21T20:18:27","name":"arm: mvebu: Various fixes","version":1,"mbox":"http://patchwork.ozlabs.org/series/343058/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1745889/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1745889/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)","legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=SP0ENlAQ;\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=kernel.org","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.b=\"SP0ENlAQ\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=kernel.org","phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org"],"Received":["from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (P-384))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4PLrTx5jgRz23yr\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Feb 2023 07:28:53 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 4713185B1F;\n\tTue, 21 Feb 2023 21:23:48 +0100 (CET)","by phobos.denx.de (Postfix, from userid 109)\n id 06FF385A73; Tue, 21 Feb 2023 21:23:10 +0100 (CET)","from dfw.source.kernel.org (dfw.source.kernel.org\n [IPv6:2604:1380:4641:c500::1])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 9B6D785A9C\n for <u-boot@lists.denx.de>; Tue, 21 Feb 2023 21:22:34 +0100 (CET)","from smtp.kernel.org (relay.kernel.org [52.25.139.140])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by dfw.source.kernel.org (Postfix) with ESMTPS id 6BB82611CA;\n Tue, 21 Feb 2023 20:22:32 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 7D8DFC433A8;\n Tue, 21 Feb 2023 20:22:31 +0000 (UTC)","by pali.im (Postfix)\n id 6E1629E0; Tue, 21 Feb 2023 21:22:30 +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,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,\n SPF_PASS autolearn=ham autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n s=k20201202; t=1677010951;\n bh=VMQXZEppxTkyWmdT3mkEzefGU/WxU+nlPedoJwcU3TE=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=SP0ENlAQVxoHEojx/rr0gcjYQtDueCPA7Gp+IpiVJ97xCiaWkgcF8lgtUUoNx4pzY\n Kg3omtnw3OBuAI/sv9U95vE8VgtTJZo4UaF2f7Db4g1lOd2vmQXJu56OlvzpSwgN9q\n nAyv/XaGSNkA3Jg0tbRKWBlK43moxzob7e8y/dJZuWVQLZmhjVxPoYoqrYpKUsQeUZ\n YEgPHhLIb8h9EX2KOpSzhDc1AhhGtV5FTXXptyh6L7KJJ0qCXupWSYNDs5RnsBiR8D\n Dg5Sp2/5i0oDisLvMvU+Q+qgZKc586mSeSVN5EyQzfZ/EqD/iOSoMDoekwPzitmdYm\n bxSnl8jMFM3cQ==","From":"=?utf-8?q?Pali_Roh=C3=A1r?= <pali@kernel.org>","To":"u-boot@lists.denx.de","Cc":"Stefan Roese <sr@denx.de>, Tony Dinh <mibodhi@gmail.com>,\n Josua Mayer <josua@solid-run.com>","Subject":"[PATCH RFC u-boot-mvebu 20/59] cmd: mvebu/bubt: Add support for\n selecting eMMC HW partition","Date":"Tue, 21 Feb 2023 21:18:46 +0100","Message-Id":"<20230221201925.9644-21-pali@kernel.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20230221201925.9644-1-pali@kernel.org>","References":"<20230221201925.9644-1-pali@kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.6 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"Support for burning into the correct eMMC HW boot partition was broken and\nremoved in commit 96be2f072768 (\"mvebu: bubt: Drop dead code\"). Reimplement\nthis functionality and bring it back again.\n\nFixes: 96be2f072768 (\"mvebu: bubt: Drop dead code\")\nSigned-off-by: Pali Rohár <pali@kernel.org>\n---\n cmd/mvebu/bubt.c       | 53 ++++++++++++++++++++++++++++++++++++++----\n doc/mvebu/cmd/bubt.txt | 21 ++++++++++++-----\n 2 files changed, 63 insertions(+), 11 deletions(-)","diff":"diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c\nindex 2bcdf145f64a..4bad9a69527c 100644\n--- a/cmd/mvebu/bubt.c\n+++ b/cmd/mvebu/bubt.c\n@@ -189,6 +189,11 @@ static int mmc_burn_image(size_t image_size)\n #ifdef CONFIG_BLK\n \tstruct blk_desc *blk_desc;\n #endif\n+#ifdef CONFIG_SUPPORT_EMMC_BOOT\n+\tu8\t\tpart;\n+\tu8\t\torig_part;\n+#endif\n+\n \tmmc = find_mmc_device(mmc_dev_num);\n \tif (!mmc) {\n \t\tprintf(\"No SD/MMC/eMMC card found\\n\");\n@@ -202,6 +207,38 @@ static int mmc_burn_image(size_t image_size)\n \t\treturn err;\n \t}\n \n+#ifdef CONFIG_BLK\n+\tblk_desc = mmc_get_blk_desc(mmc);\n+\tif (!blk_desc) {\n+\t\tprintf(\"Error - failed to obtain block descriptor\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+#endif\n+\n+#ifdef CONFIG_SUPPORT_EMMC_BOOT\n+#ifdef CONFIG_BLK\n+\torig_part = blk_desc->hwpart;\n+#else\n+\torig_part = mmc->block_dev.hwpart;\n+#endif\n+\n+\tpart = (mmc->part_config >> 3) & PART_ACCESS_MASK;\n+\n+\tif (part == 7)\n+\t\tpart = 0;\n+\n+#ifdef CONFIG_BLK\n+\terr = blk_dselect_hwpart(blk_desc, part);\n+#else\n+\terr = mmc_switch_part(mmc, part);\n+#endif\n+\n+\tif (err) {\n+\t\tprintf(\"Error - MMC partition switch failed\\n\");\n+\t\treturn err;\n+\t}\n+#endif\n+\n \t/* SD reserves LBA-0 for MBR and boots from LBA-1,\n \t * MMC/eMMC boots from LBA-0\n \t */\n@@ -211,11 +248,6 @@ static int mmc_burn_image(size_t image_size)\n \tif (image_size % mmc->write_bl_len)\n \t\tblk_count += 1;\n \n-\tblk_desc = mmc_get_blk_desc(mmc);\n-\tif (!blk_desc) {\n-\t\tprintf(\"Error - failed to obtain block descriptor\\n\");\n-\t\treturn -ENODEV;\n-\t}\n \tblk_written = blk_dwrite(blk_desc, start_lba, blk_count,\n \t\t\t\t (void *)get_load_addr());\n #else\n@@ -227,6 +259,17 @@ static int mmc_burn_image(size_t image_size)\n \t\t\t\t\t\t start_lba, blk_count,\n \t\t\t\t\t\t (void *)get_load_addr());\n #endif /* CONFIG_BLK */\n+\n+#ifdef CONFIG_SUPPORT_EMMC_BOOT\n+#ifdef CONFIG_BLK\n+\terr = blk_dselect_hwpart(blk_desc, orig_part);\n+#else\n+\terr = mmc_switch_part(mmc, orig_part);\n+#endif\n+\tif (err)\n+\t\tprintf(\"Error - MMC failed to switch back to original partition\\n\");\n+#endif\n+\n \tif (blk_written != blk_count) {\n \t\tprintf(\"Error - written %#lx blocks\\n\", blk_written);\n \t\treturn -ENOSPC;\ndiff --git a/doc/mvebu/cmd/bubt.txt b/doc/mvebu/cmd/bubt.txt\nindex 6051243f1165..1fe1f07dd187 100644\n--- a/doc/mvebu/cmd/bubt.txt\n+++ b/doc/mvebu/cmd/bubt.txt\n@@ -14,8 +14,7 @@ Examples:\n \n Notes:\n - For the TFTP interface set serverip and ipaddr.\n-- To burn image to SD/eMMC device, the target is defined\n-  by parameters CONFIG_SYS_MMC_ENV_DEV and CONFIG_SYS_MMC_ENV_PART.\n+- To burn image to SD/eMMC device, the target is defined by HW partition.\n \n Bubt command details (burn image step by-step)\n ----------------------------------------------\n@@ -40,10 +39,20 @@ Notes:\n   Number 0 is used for user data partition and should not be utilized for storing\n   boot images and U-Boot environment in RAW mode since it will break file system\n   structures usually located here.\n-  The default boot partition is BOOT0. It is selected by the following parameter:\n-  CONFIG_SYS_MMC_ENV_PART=1\n-  Valid values for this parameter are 1 for BOOT0 and 2 for BOOT1.\n-  Please never use partition number 0 here!\n+\n+  Currently configured boot partition can be printed by command:\n+  # mmc partconf 0\n+  (search for BOOT_PARTITION_ACCESS output, number 7 is user data)\n+\n+  Change it to BOOT0:\n+  # mmc partconf 0 0 1 1\n+\n+  Change it to BOOT1:\n+  # mmc partconf 0 0 2 2\n+\n+  Change it to user data:\n+  # mmc partconf 0 0 7 0\n+\n - The partition number is ignored if the target device is SD card.\n - The boot image offset starts at block 0 for eMMC and block 1 for SD devices.\n   The block 0 on SD devices is left for MBR storage.\n","prefixes":["RFC","u-boot-mvebu","20/59"]}