From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31CE5C61DA3 for ; Tue, 21 Feb 2023 20:32:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 31F2D85B67; Tue, 21 Feb 2023 21:24:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="r/89Tn2F"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AFA2285A60; Tue, 21 Feb 2023 21:23:50 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9164485ABE for ; Tue, 21 Feb 2023 21:22:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EDAE3611E2; Tue, 21 Feb 2023 20:22:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 749B8C433D2; Tue, 21 Feb 2023 20:22:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677010953; bh=iyD9wAGKmVtagSxUXf1PCSSv59YFs6I3npymJQ1IhZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/89Tn2FwWxI4U+KwXbIzqvS/aoYCScFn8+G49LkUbzKYyckI4WjAH/VajX8p/NkY OhAqCkfjoaAc/Z2yPUIZ91+VNVEh5i+8CopGTNglSxdzTWSkfvwhmqb4pOX4+KUDLo VlIZqbdXmgO8O15yzJ04/Z72kSJCbuMd6Ikfr6F94AwyG1e4cjHmV8y8zLrQ89VB/A J4lBolfvtqBwUMj7aY03RxhQaykY8O6fwFdcalgiiK7rD1pOp4C3o7xaJ047whtN98 0uFYNdqYZV/Tz8tHYY1P2LS/O31VPx3fehTQ1opei4khhb8VNJh/SUsrNyo7SEYfLh E2ZJqLjjtUzPg== Received: by pali.im (Postfix) id E721E9FC; Tue, 21 Feb 2023 21:22:30 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Cc: Stefan Roese , Tony Dinh , Josua Mayer Subject: [PATCH RFC u-boot-mvebu 22/59] cmd: mvebu/bubt: Add support for reading image from the SATA disk partition Date: Tue, 21 Feb 2023 21:18:48 +0100 Message-Id: <20230221201925.9644-23-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 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.6 at phobos.denx.de X-Virus-Status: Clean This change allows to load boot image from the first SATA/SCSI device partition and burn it to board boot location (e.g. SPI-NOR). This is particularly when storage device is not handled by U-Boot as USB mass storage (which is already supported by bubt) but as SATA/SCSI device. Signed-off-by: Pali Rohár --- cmd/mvebu/bubt.c | 39 +++++++++++++++++++++++++++++++++++++-- doc/mvebu/cmd/bubt.txt | 2 +- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index 1d51fde579b5..df6b73c6a172 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -420,6 +420,36 @@ static int sata_burn_image(size_t image_size) #endif } +static size_t sata_read_file(const char *file_name) +{ + loff_t act_read = 0; + struct udevice *dev; + int rc; + + /* try to recognize storage devices immediately */ + scsi_scan(false); + + /* Try to recognize storage devices immediately */ + blk_first_device(UCLASS_SCSI, &dev); + if (!dev) { + printf("Error: SATA device not found\n"); + return 0; + } + + /* Always load from scsi 0 */ + if (fs_set_blk_dev("scsi", "0", FS_TYPE_ANY)) { + printf("Error: SATA 0 not found\n"); + return 0; + } + + /* Perfrom file read */ + rc = fs_read(file_name, get_load_addr(), 0, 0, &act_read); + if (rc) + return 0; + + return act_read; +} + static int is_sata_active(void) { return 1; @@ -430,6 +460,11 @@ static int sata_burn_image(size_t image_size) return -ENODEV; } +static size_t sata_read_file(const char *file_name) +{ + return 0; +} + static int is_sata_active(void) { return 0; @@ -656,7 +691,7 @@ struct bubt_dev bubt_devs[BUBT_MAX_DEV] = { {"tftp", tftp_read_file, NULL, is_tftp_active}, {"usb", usb_read_file, NULL, is_usb_active}, {"mmc", mmc_read_file, mmc_burn_image, is_mmc_active}, - {"sata", NULL, sata_burn_image, is_sata_active}, + {"sata", sata_read_file, sata_burn_image, is_sata_active}, {"spi", NULL, spi_burn_image, is_spi_active}, {"nand", NULL, nand_burn_image, is_nand_active}, }; @@ -1206,7 +1241,7 @@ U_BOOT_CMD( "[file-name] [destination [source]]\n" "\t-file-name The image file name to burn. Default = " CONFIG_MVEBU_UBOOT_DFLT_NAME "\n" "\t-destination Flash to burn to [spi, nand, mmc, sata]. Default = " DEFAULT_BUBT_DST "\n" - "\t-source The source to load image from [tftp, usb, mmc]. Default = " DEFAULT_BUBT_SRC "\n" + "\t-source The source to load image from [tftp, usb, mmc, sata]. Default = " DEFAULT_BUBT_SRC "\n" "Examples:\n" "\tbubt - Burn flash-image.bin from tftp to active boot device\n" "\tbubt flash-image-new.bin nand - Burn flash-image-new.bin from tftp to NAND flash\n" diff --git a/doc/mvebu/cmd/bubt.txt b/doc/mvebu/cmd/bubt.txt index 515e4fb1b0e8..52bd3e66c51e 100644 --- a/doc/mvebu/cmd/bubt.txt +++ b/doc/mvebu/cmd/bubt.txt @@ -6,7 +6,7 @@ The bubt command gets the following parameters: ATF file name, destination devic bubt [file-name] [destination [source]] - file-name Image file name to burn. default = flash-image.bin - destination Flash to burn to [spi, nand, mmc, sata]. default = active flash - - source Source to load image from [tftp, usb]. default = tftp + - source Source to load image from [tftp, usb, mmc, sata]. default = tftp Examples: bubt - Burn flash-image.bin from tftp to active flash -- 2.20.1