{"id":1745962,"url":"http://patchwork.ozlabs.org/api/patches/1745962/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20230221201925.9644-22-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-22-pali@kernel.org>","list_archive_url":null,"date":"2023-02-21T20:18:47","name":"[RFC,u-boot-mvebu,21/59] cmd: mvebu/bubt: Add support for writing image to SATA disk","commit_ref":"c8f5009029d2e00bff45f998996a3e0a37a5aead","pull_url":null,"state":"accepted","archived":false,"hash":"5e8ac88f27c5ce97a1130c9ddc17dec53fa29443","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-22-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/1745962/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1745962/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=i1GaVw2D;\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=\"i1GaVw2D\";\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 4PLvZY0r41z240n\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Feb 2023 09:48:05 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 98E2E85A63;\n\tTue, 21 Feb 2023 23:48:01 +0100 (CET)","by phobos.denx.de (Postfix, from userid 109)\n id EE77485A65; Tue, 21 Feb 2023 23:47:59 +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 25A0F85A5F\n for <u-boot@lists.denx.de>; Tue, 21 Feb 2023 23:47:57 +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 67F2C611F8\n for <u-boot@lists.denx.de>; Tue, 21 Feb 2023 22:47:55 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 896CFC433EF\n for <u-boot@lists.denx.de>; Tue, 21 Feb 2023 22:47:54 +0000 (UTC)","by pali.im (Postfix)\n id 2312470C; Tue, 21 Feb 2023 23:47:52 +0100 (CET)","by pali.im (Postfix)\n id AF129708; 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=unavailable autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n s=k20201202; t=1677019674;\n bh=IUxNn6g5TKKzYeQk9C9Mo5xyMhJR8OsYOacIp5VInrU=;\n h=Resent-From:Resent-Date:Resent-To:From:To:Cc:Subject:Date:\n In-Reply-To:References:From;\n b=i1GaVw2DzzHBhL7ZzdwrVTOnVx64X7g8F3r5Y6eEObeFSKe9UbIDE2KfRRYqQLbHG\n ZIlk+mw7ENE0pjZr8mKOVsxX58d/u8rPJTYJdrJsKvyxVKy9k5UFGxJR1NlLJPm9+k\n WblJIvoHmx4aNrGuu7+g65/Kg//ru19yuLk9TIOWZAQNCXZxZUyKMKGaCjgIUs8vrv\n vyDqDFMoHJm3CJ99/QRe4K/18arpWBev+vs3r+aTZ7IMQPElIPRXxnbwGQTXZEP3hv\n GKwSRTORoTc7YxE51yYoFnfkunaWjLfKjRg3eBnXFDK/IXlQRdbn4z2YgKJthLLufT\n OUAsdp3rpIBUQ==","Resent-From":"Pali =?utf-8?b?Um9ow6Fy?= <pali@kernel.org>","Resent-Date":"Tue, 21 Feb 2023 23:47:52 +0100","Resent-Message-ID":"<20230221224752.7xli7bhscitwkz4x@pali>","Resent-To":"u-boot@lists.denx.de","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 21/59] cmd: mvebu/bubt: Add support for\n writing image to SATA disk","Date":"Tue, 21 Feb 2023 21:18:47 +0100","Message-Id":"<20230221201925.9644-22-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":"All 32-bit Armada SoCs and also 64-bit Armada 3720 SoC can load and boot\nfirmware from SATA disk. This adds support for updating firmware binary for\nthese SoCs. On 32-bit Armada SoC is firmware stored at sector 1 and on\nArmada 3720 is stored at MBR partition 0x4d or GPT partition with type GUID\n6828311A-BA55-42A4-BCDE-A89BB5EDECAE (Marvell Armada 3700 Boot partition).\n\nSigned-off-by: Pali Rohár <pali@kernel.org>\n---\n cmd/mvebu/Kconfig      |  12 +++++\n cmd/mvebu/bubt.c       | 109 ++++++++++++++++++++++++++++++++++++++++-\n doc/mvebu/cmd/bubt.txt |   2 +-\n 3 files changed, 121 insertions(+), 2 deletions(-)","diff":"diff --git a/cmd/mvebu/Kconfig b/cmd/mvebu/Kconfig\nindex 9ec3aa983a51..8f30a0c22be3 100644\n--- a/cmd/mvebu/Kconfig\n+++ b/cmd/mvebu/Kconfig\n@@ -5,6 +5,9 @@ config CMD_MVEBU_BUBT\n \tbool \"bubt\"\n \tselect SHA256 if ARMADA_3700\n \tselect SHA512 if ARMADA_3700\n+\tselect DOS_PARTITION if ARMADA_3700\n+\tselect EFI_PARTITION if ARMADA_3700\n+\tselect PARTITION_TYPE_GUID if ARMADA_3700\n \tselect MVEBU_EFUSE if ARMADA_38X || ARMADA_3700\n \thelp\n \t  bubt - Burn a u-boot image to flash\n@@ -44,6 +47,15 @@ config MVEBU_MMC_BOOT\n \t  For details about bubt command please see the documentation\n \t  in doc/mvebu/cmd/bubt.txt\n \n+config MVEBU_SATA_BOOT\n+\tbool \"SATA flash boot\"\n+\tdepends on SCSI\n+\thelp\n+\t  Enable boot from SATA disk.\n+\t  Allow usage of SATA disk as a target for \"bubt\" command\n+\t  For details about bubt command please see the documentation\n+\t  in doc/mvebu/cmd/bubt.txt\n+\n endchoice\n \n config MVEBU_UBOOT_DFLT_NAME\ndiff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c\nindex 4bad9a69527c..1d51fde579b5 100644\n--- a/cmd/mvebu/bubt.c\n+++ b/cmd/mvebu/bubt.c\n@@ -19,6 +19,7 @@\n #include <spi_flash.h>\n #include <spi.h>\n #include <nand.h>\n+#include <scsi.h>\n #include <usb.h>\n #include <fs.h>\n #include <mmc.h>\n@@ -333,6 +334,108 @@ static int is_mmc_active(void)\n }\n #endif /* CONFIG_DM_MMC */\n \n+/********************************************************************\n+ *     SATA services\n+ ********************************************************************/\n+#if defined(CONFIG_SCSI) && defined(CONFIG_BLK)\n+static int sata_burn_image(size_t image_size)\n+{\n+#if defined(CONFIG_ARMADA_3700) || defined(CONFIG_ARMADA_32BIT)\n+\tlbaint_t\tstart_lba;\n+\tlbaint_t\tblk_count;\n+\tulong\t\tblk_written;\n+\tstruct blk_desc *blk_desc;\n+#ifdef CONFIG_ARMADA_3700\n+\tstruct disk_partition info;\n+\tint\t\tpart;\n+#endif\n+\n+\tscsi_scan(false);\n+\n+\tblk_desc = blk_get_devnum_by_uclass_id(UCLASS_SCSI, 0);\n+\tif (!blk_desc)\n+\t\treturn -ENODEV;\n+\n+#ifdef CONFIG_ARMADA_3700\n+\t/*\n+\t * 64-bit Armada 3700 BootROM loads SATA firmware from\n+\t * GPT 'Marvell Armada 3700 Boot partition' or from\n+\t * MBR 'M' (0x4d) partition.\n+\t */\n+\tswitch (blk_desc->part_type) {\n+\tcase PART_TYPE_DOS:\n+\t\tfor (part = 1; part <= 4; part++) {\n+\t\t\tinfo.sys_ind = 0;\n+\t\t\tif (part_get_info(blk_desc, part, &info))\n+\t\t\t\tcontinue;\n+\t\t\tif (info.sys_ind == 'M')\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (part > 4) {\n+\t\t\tprintf(\"Error - cannot find MBR 'M' (0x4d) partition on SATA disk\\n\");\n+\t\t\treturn -ENODEV;\n+\t\t}\n+\t\tstart_lba = info.start;\n+\t\tbreak;\n+\tcase PART_TYPE_EFI:\n+\t\tfor (part = 1; part <= 64; part++) {\n+\t\t\tinfo.type_guid[0] = 0;\n+\t\t\tif (part_get_info(blk_desc, part, &info))\n+\t\t\t\tcontinue;\n+\t\t\t/* Check for GPT type GUID of 'Marvell Armada 3700 Boot partition' */\n+\t\t\tif (strcmp(info.type_guid, \"6828311A-BA55-42A4-BCDE-A89BB5EDECAE\") == 0)\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (part > 64) {\n+\t\t\tprintf(\"Error - cannot find GPT 'Marvell Armada 3700 Boot partition' on SATA disk\\n\");\n+\t\t\treturn -ENODEV;\n+\t\t}\n+\t\tstart_lba = info.start;\n+\t\tbreak;\n+\tdefault:\n+\t\tprintf(\"Error - no partitions on SATA disk\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+#else\n+\t/* 32-bit Armada BootROM loads SATA firmware from the sector 1. */\n+\tstart_lba = 1;\n+#endif\n+\n+\tblk_count = image_size / blk_desc->blksz;\n+\tif (image_size % blk_desc->blksz)\n+\t\tblk_count += 1;\n+\n+\tblk_written = blk_dwrite(blk_desc, start_lba, blk_count,\n+\t\t\t\t (void *)get_load_addr());\n+\n+\tif (blk_written != blk_count) {\n+\t\tprintf(\"Error - written %#lx blocks\\n\", blk_written);\n+\t\treturn -ENOSPC;\n+\t}\n+\n+\tprintf(\"Done!\\n\");\n+\treturn 0;\n+#else\n+\treturn -ENODEV;\n+#endif\n+}\n+\n+static int is_sata_active(void)\n+{\n+\treturn 1;\n+}\n+#else /* CONFIG_SCSI */\n+static int sata_burn_image(size_t image_size)\n+{\n+\treturn -ENODEV;\n+}\n+\n+static int is_sata_active(void)\n+{\n+\treturn 0;\n+}\n+#endif /* CONFIG_SCSI */\n+\n /********************************************************************\n  *     SPI services\n  ********************************************************************/\n@@ -542,6 +645,7 @@ enum bubt_devices {\n \tBUBT_DEV_NET = 0,\n \tBUBT_DEV_USB,\n \tBUBT_DEV_MMC,\n+\tBUBT_DEV_SATA,\n \tBUBT_DEV_SPI,\n \tBUBT_DEV_NAND,\n \n@@ -552,6 +656,7 @@ struct bubt_dev bubt_devs[BUBT_MAX_DEV] = {\n \t{\"tftp\", tftp_read_file, NULL, is_tftp_active},\n \t{\"usb\",  usb_read_file,  NULL, is_usb_active},\n \t{\"mmc\",  mmc_read_file,  mmc_burn_image, is_mmc_active},\n+\t{\"sata\",  NULL, sata_burn_image,  is_sata_active},\n \t{\"spi\",  NULL, spi_burn_image,  is_spi_active},\n \t{\"nand\", NULL, nand_burn_image, is_nand_active},\n };\n@@ -1021,6 +1126,8 @@ struct bubt_dev *find_bubt_dev(char *dev_name)\n #define DEFAULT_BUBT_DST \"nand\"\n #elif defined(CONFIG_MVEBU_MMC_BOOT)\n #define DEFAULT_BUBT_DST \"mmc\"\n+#elif defined(CONFIG_MVEBU_SATA_BOOT)\n+#define DEFAULT_BUBT_DST \"sata\"\n #else\n #define DEFAULT_BUBT_DST \"error\"\n #endif\n@@ -1098,7 +1205,7 @@ U_BOOT_CMD(\n \t\"Burn a u-boot image to flash\",\n \t\"[file-name] [destination [source]]\\n\"\n \t\"\\t-file-name     The image file name to burn. Default = \" CONFIG_MVEBU_UBOOT_DFLT_NAME \"\\n\"\n-\t\"\\t-destination   Flash to burn to [spi, nand, mmc]. Default = \" DEFAULT_BUBT_DST \"\\n\"\n+\t\"\\t-destination   Flash to burn to [spi, nand, mmc, sata]. Default = \" DEFAULT_BUBT_DST \"\\n\"\n \t\"\\t-source        The source to load image from [tftp, usb, mmc]. Default = \" DEFAULT_BUBT_SRC \"\\n\"\n \t\"Examples:\\n\"\n \t\"\\tbubt - Burn flash-image.bin from tftp to active boot device\\n\"\ndiff --git a/doc/mvebu/cmd/bubt.txt b/doc/mvebu/cmd/bubt.txt\nindex 1fe1f07dd187..515e4fb1b0e8 100644\n--- a/doc/mvebu/cmd/bubt.txt\n+++ b/doc/mvebu/cmd/bubt.txt\n@@ -5,7 +5,7 @@ Bubt command is used to burn a new ATF image to flash device.\n The bubt command gets the following parameters: ATF file name, destination device and source device.\n bubt [file-name] [destination [source]]\n \t- file-name\t\tImage file name to burn. default = flash-image.bin\n-\t- destination\t\tFlash to burn to [spi, nand, mmc]. default = active flash\n+\t- destination\t\tFlash to burn to [spi, nand, mmc, sata]. default = active flash\n \t- source\t\tSource to load image from [tftp, usb]. default = tftp\n \n Examples:\n","prefixes":["RFC","u-boot-mvebu","21/59"]}