From patchwork Wed Nov 24 04:27:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Skibo X-Patchwork-Id: 1558879 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=skibo.net header.i=@skibo.net header.a=rsa-sha1 header.s=skibo.net header.b=V89zBA5X; dkim-atps=neutral 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=) 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)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HzSgF4vgjz9t2p for ; Wed, 24 Nov 2021 15:28:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C48483718; Wed, 24 Nov 2021 05:28:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=skibo.net 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=skibo.net header.i=@skibo.net header.b="V89zBA5X"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1EC5835F9; Wed, 24 Nov 2021 05:28:03 +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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from bumble.maple.relay.mailchannels.net (bumble.maple.relay.mailchannels.net [23.83.214.25]) (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 BFE4382FBC for ; Wed, 24 Nov 2021 05:27:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=skibo.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=thomas-git@skibo.net X-Sender-Id: dreamhost|x-authsender|thomas-git@skibo.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 199FD661366; Wed, 24 Nov 2021 04:27:54 +0000 (UTC) Received: from pdx1-sub0-mail-a224.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id C4C26661354; Wed, 24 Nov 2021 04:27:50 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|thomas-git@skibo.net Received: from pdx1-sub0-mail-a224.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.124.138.98 (trex/6.4.3); Wed, 24 Nov 2021 04:27:54 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|thomas-git@skibo.net X-MailChannels-Auth-Id: dreamhost X-Fumbling-Oafish: 4b90dd4a778f057d_1637728073937_4214100590 X-MC-Loop-Signature: 1637728073937:2389494828 X-MC-Ingress-Time: 1637728073937 Received: from localhost.localdomain (unknown [98.207.154.189]) (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) (Authenticated sender: thomas-git@skibo.net) by pdx1-sub0-mail-a224.dreamhost.com (Postfix) with ESMTPSA id 4HzSfZ2StDz1Rg; Tue, 23 Nov 2021 20:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=skibo.net; s=skibo.net; t=1637728070; bh=QPouDdq0oHKmI9CeOIk3F8ERGwE=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=V89zBA5X7BDPq3YmJSHxOFQopqEob+F2lSDMeJZobDWOX3AiEgd021sGBRbHvawNJ ghIqcwIu6FN2gbqXtW5YQZiKz09SuKScGk5PuXHDmIymhPS6YrDUdkyo9zVoK3+7b8 1kWQwbUpweal7V1i8Vxa2ZQ64gl8EorvK8Kf5mZQ= From: Thomas Skibo To: u-boot@lists.denx.de Cc: ycliang@andestech.com, Thomas Skibo Subject: [PATCH v2 1/2] riscv: Support booting SiFive Unmatched from SPI. Date: Tue, 23 Nov 2021 20:27:36 -0800 Message-Id: <20211124042737.27974-2-thomas-git@skibo.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211124042737.27974-1-thomas-git@skibo.net> References: <20211124042737.27974-1-thomas-git@skibo.net> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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 Configure SPI flash devices into SPL. Add SPI boot option to spl.c. Document how to format flash for booting. Signed-off-by: Thomas Skibo --- .../dts/hifive-unmatched-a00-u-boot.dtsi | 11 +++++++ board/sifive/unmatched/spl.c | 3 ++ configs/sifive_unmatched_defconfig | 6 ++++ doc/board/sifive/unmatched.rst | 29 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi index c5475aa149..1ee8ab1868 100644 --- a/arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi +++ b/arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi @@ -16,6 +16,10 @@ u-boot,dm-spl; }; + config { + u-boot,spl-payload-offset = <0x105000>; /* loader2 @1044KB */ + }; + hfclk { u-boot,dm-spl; }; @@ -30,6 +34,13 @@ clocks = <&rtcclk>; }; +&qspi0 { + u-boot,dm-spl; + flash@0 { + u-boot,dm-spl; + }; +}; + &spi0 { mmc@0 { u-boot,dm-spl; diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c index d5663274cd..7c0beedc08 100644 --- a/board/sifive/unmatched/spl.c +++ b/board/sifive/unmatched/spl.c @@ -22,6 +22,7 @@ #define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12) #define MODE_SELECT_REG 0x1000 +#define MODE_SELECT_SPI 0x6 #define MODE_SELECT_SD 0xb #define MODE_SELECT_MASK GENMASK(3, 0) @@ -123,6 +124,8 @@ u32 spl_boot_device(void) u32 boot_device = mode_select & MODE_SELECT_MASK; switch (boot_device) { + case MODE_SELECT_SPI: + return BOOT_DEVICE_SPI; case MODE_SELECT_SD: return BOOT_DEVICE_MMC1; default: diff --git a/configs/sifive_unmatched_defconfig b/configs/sifive_unmatched_defconfig index 9cc18b029c..d400ed0b23 100644 --- a/configs/sifive_unmatched_defconfig +++ b/configs/sifive_unmatched_defconfig @@ -8,6 +8,7 @@ CONFIG_SPL_DM_SPI=y CONFIG_DEFAULT_DEVICE_TREE="hifive-unmatched-a00" CONFIG_SPL_MMC=y CONFIG_SPL=y +CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y CONFIG_AHCI=y CONFIG_TARGET_SIFIVE_UNMATCHED=y @@ -23,17 +24,22 @@ CONFIG_DISPLAY_BOARDINFO=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ID_EEPROM=y CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SPL_DM_SPI_FLASH=y CONFIG_SPL_DM_RESET=y +CONFIG_SPL_SPI_LOAD=y CONFIG_CMD_EEPROM=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_PWM=y CONFIG_CMD_GPT_RENAME=y CONFIG_CMD_PCI=y CONFIG_CMD_USB=y +CONFIG_USE_ENV_SPI_BUS=y +CONFIG_ENV_SPI_BUS=1 CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_SCSI_AHCI=y CONFIG_AHCI_PCI=y CONFIG_SPL_CLK=y +CONFIG_SPI_FLASH_ISSI=y CONFIG_SYS_I2C_EEPROM_ADDR=0x54 CONFIG_E1000=y CONFIG_NVME=y diff --git a/doc/board/sifive/unmatched.rst b/doc/board/sifive/unmatched.rst index 6b024f07f6..387785d76b 100644 --- a/doc/board/sifive/unmatched.rst +++ b/doc/board/sifive/unmatched.rst @@ -534,3 +534,32 @@ Sample boot log from HiFive Unmatched board OpenEmbedded nodistro.0 unmatched ttySIF0 unmatched login: + + +Booting from SPI +---------------- + +Use Building steps from "Booting from uSD using U-Boot SPL" section. + +Partition the SPI in Linux via mtdblock. + +.. code-block:: none + + sgdisk --clear -a 1 \ + --new=1:40:2087 --change-name=1:spl --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \ + --new=2:2088:10279 --change-name=2:uboot --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \ + --new=3:10280:10535 --change-name=3:env --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \ + /dev/mtdblock0 + +Write U-boot SPL and U-boot to their partitions. + +.. code-block:: none + + dd if=u-boot-spl.bin of=/dev/mtdblock0 bs=4096 seek=5 conv=sync + dd if=u-boot.itb of=/dev/mtdblock0 bs=4096 seek=261 conv=sync + +Power off the board. + +Change DIP switches MSEL[3:0] to 0110. + +Power up the board. From patchwork Wed Nov 24 04:27:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Skibo X-Patchwork-Id: 1558877 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=skibo.net header.i=@skibo.net header.a=rsa-sha1 header.s=skibo.net header.b=yn4Mb9md; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HzSfv4DQ7z9t2p for ; Wed, 24 Nov 2021 15:28:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7F85E82FB0; Wed, 24 Nov 2021 05:28:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=skibo.net 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=skibo.net header.i=@skibo.net header.b="yn4Mb9md"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 409758321B; Wed, 24 Nov 2021 05:27:59 +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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from insect.birch.relay.mailchannels.net (insect.birch.relay.mailchannels.net [23.83.209.93]) (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 BFFE882FAD for ; Wed, 24 Nov 2021 05:27:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=skibo.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=thomas-git@skibo.net X-Sender-Id: dreamhost|x-authsender|thomas-git@skibo.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id DA925340C2F; Wed, 24 Nov 2021 04:27:51 +0000 (UTC) Received: from pdx1-sub0-mail-a224.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0E7B2341139; Wed, 24 Nov 2021 04:27:51 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|thomas-git@skibo.net Received: from pdx1-sub0-mail-a224.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.112.64.117 (trex/6.4.3); Wed, 24 Nov 2021 04:27:51 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|thomas-git@skibo.net X-MailChannels-Auth-Id: dreamhost X-Glossy-Daffy: 42f27a2d08466100_1637728071752_818440118 X-MC-Loop-Signature: 1637728071752:2744467312 X-MC-Ingress-Time: 1637728071751 Received: from localhost.localdomain (unknown [98.207.154.189]) (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) (Authenticated sender: thomas-git@skibo.net) by pdx1-sub0-mail-a224.dreamhost.com (Postfix) with ESMTPSA id 4HzSfZ4pzQz1f5; Tue, 23 Nov 2021 20:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=skibo.net; s=skibo.net; t=1637728070; bh=5+Wzvq7WH9iB8StlnLc0EvhWDHk=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=yn4Mb9mdxM3qxxnylYXi3KrwvvmZeYNxG+j4g5/rAxMtmMvKBJmEu8VsXmdqqwL4T NDdYlkXVCWCm15LLBOC1AT6aPCPXmtdev0UsHpteD5CKACur5TUL6SNFSJizUUEIC1 nOZtJGeFjjsXrqCa59g9cCTDGIU+a82ebil4+zfQ= From: Thomas Skibo To: u-boot@lists.denx.de Cc: ycliang@andestech.com, Thomas Skibo Subject: [PATCH v2 2/2] riscv: Enable SPI flash env for SiFive Unmatched. Date: Tue, 23 Nov 2021 20:27:37 -0800 Message-Id: <20211124042737.27974-3-thomas-git@skibo.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211124042737.27974-1-thomas-git@skibo.net> References: <20211124042737.27974-1-thomas-git@skibo.net> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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 Enable saving environment to SPI flash memory on SiFive Unmatched. Signed-off-by: Thomas Skibo --- arch/riscv/cpu/fu740/Kconfig | 13 +++++++++++++ board/sifive/unmatched/Kconfig | 1 + 2 files changed, 14 insertions(+) diff --git a/arch/riscv/cpu/fu740/Kconfig b/arch/riscv/cpu/fu740/Kconfig index 049a0a0584..3e0c1fddc8 100644 --- a/arch/riscv/cpu/fu740/Kconfig +++ b/arch/riscv/cpu/fu740/Kconfig @@ -40,3 +40,16 @@ config SIFIVE_FU740 imply DM_I2C imply SYS_I2C_OCORES imply SPL_I2C + +if ENV_IS_IN_SPI_FLASH + +config ENV_OFFSET + default 0x505000 + +config ENV_SIZE + default 0x20000 + +config ENV_SECT_SIZE + default 0x10000 + +endif # ENV_IS_IN_SPI_FLASH diff --git a/board/sifive/unmatched/Kconfig b/board/sifive/unmatched/Kconfig index fb2c1fbb58..fe213fd504 100644 --- a/board/sifive/unmatched/Kconfig +++ b/board/sifive/unmatched/Kconfig @@ -26,6 +26,7 @@ config SPL_OPENSBI_LOAD_ADDR config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select SIFIVE_FU740 + select ENV_IS_IN_SPI_FLASH select SUPPORT_SPL select RESET_SIFIVE select BINMAN