public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v4 2/6] sifive: fu540: Add Booting from SPI
@ 2020-07-02  8:02 Jagan Teki
  2020-07-02  8:02 ` [PATCH v4 3/6] env: Enable SPI flash env for SiFive FU540 Jagan Teki
       [not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA47261AD@ATCPCS16.andestech.com>
  0 siblings, 2 replies; 3+ messages in thread
From: Jagan Teki @ 2020-07-02  8:02 UTC (permalink / raw)
  To: u-boot

Add booting from SPI for SiFive Unleashed board.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Tested-by: Bin Meng <bin.meng@windriver.com>
---
Changes for v4:
- drop BOARD configs

 .../dts/hifive-unleashed-a00-u-boot.dtsi      | 12 ++++++
 configs/sifive_fu540_defconfig                |  4 ++
 doc/board/sifive/fu540.rst                    | 41 +++++++++++++++++++
 3 files changed, 57 insertions(+)

diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
index 303806454b..4b2b242deb 100644
--- a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
+++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
@@ -12,6 +12,10 @@
 		spi2 = &qspi2;
 	};
 
+	config {
+		u-boot,spl-payload-offset = <0x105000>; /* loader2 @1044KB */
+	};
+
 	hfclk {
 		u-boot,dm-spl;
 	};
@@ -22,6 +26,14 @@
 
 };
 
+&qspi0 {
+	u-boot,dm-spl;
+
+	flash at 0 {
+		u-boot,dm-spl;
+	};
+};
+
 &qspi2 {
 	mmc at 0 {
 		u-boot,dm-spl;
diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig
index 8d412f8d6a..551d4b04a5 100644
--- a/configs/sifive_fu540_defconfig
+++ b/configs/sifive_fu540_defconfig
@@ -2,9 +2,11 @@ CONFIG_RISCV=y
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SYS_MALLOC_F_LEN=0x3000
 CONFIG_ENV_SIZE=0x20000
+CONFIG_SPL_DM_SPI=y
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SPL=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_TARGET_SIFIVE_FU540=y
 CONFIG_ARCH_RV64I=y
@@ -15,9 +17,11 @@ CONFIG_MISC_INIT_R=y
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
 CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SPL_SPI_LOAD=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_OF_BOARD_FIXUP=y
 CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_CLK=y
 CONFIG_DM_MTD=y
diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index 739eefa669..1ce9ab14f5 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -533,3 +533,44 @@ Sample boot log from HiFive Unleashed board
 	type:   0fc63daf-8483-4772-8e79-3d69d8477de4
 	type:   linux
 	guid:   9faa81b6-39b1-4418-af5e-89c48f29c20d
+
+Booting from SPI
+----------------
+
+Use Building steps from "Booting from MMC using U-Boot SPL" section.
+
+Partition the SPI in Linux via mtdblock. (Require to boot the board in
+SD boot mode by enabling MTD block in Linux)
+
+Use prebuilt image from here [1], which support to partition the SPI flash.
+
+.. code-block:: none
+
+  # sgdisk --clear \
+  > --set-alignment=2 \
+  > --new=1:40:2087 --change-name=1:loader1 --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \
+  > --new=2:2088:10279 --change-name=2:loader2 --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \
+  > --new=3:10536:65494 --change-name=3:rootfs --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \
+  > /dev/mtdblock0
+
+Program the SPI (Require to boot the board in SD boot mode)
+
+Execute below steps on U-Boot proper,
+
+.. code-block:: none
+
+  tftpboot $kernel_addr_r u-boot-spl.bin
+  sf erase 0x5000 $filesize
+  sf write $kernel_addr_r 0x5000 $filesize
+
+  tftpboot $kernel_addr_r u-boot.itb
+  sf erase 0x105000 $filesize
+  sf write $kernel_addr_r 0x105000 $filesize
+
+Power off the board
+
+Change DIP switches MSEL[3:0] are set to 0110
+
+Power up the board.
+
+[1] https://github.com/amarula/bsp-sifive
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v4 3/6] env: Enable SPI flash env for SiFive FU540
  2020-07-02  8:02 [PATCH v4 2/6] sifive: fu540: Add Booting from SPI Jagan Teki
@ 2020-07-02  8:02 ` Jagan Teki
       [not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA47261AD@ATCPCS16.andestech.com>
  1 sibling, 0 replies; 3+ messages in thread
From: Jagan Teki @ 2020-07-02  8:02 UTC (permalink / raw)
  To: u-boot

SPI flash device on HiFive Unleashed has 32MiB Size.

This patch adds SPI flash environment after U-Boot proper
partition with a size of 128KiB.

SPI flash partition layout(32MiB):
    0 - 34	: reserved for GPT header
   35 - 39	: unused
   40 - 2087	: loader1 (SPL, FSBL)
 2088 - 10279	: loader2 (U-Boot proper, U-Boot)
10280 - 10535	: environment
10536 - 65494	: rootfs
65528 - 65536	: distro script

Note: the loader1 must start from 40th sector even though
there are 6 free sectors prior since 40th sector is nearest
flash sector boundary.?

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Tested-by: Bin Meng <bin.meng@windriver.com>
---
Changes for v4:
- %s/add/adds

 arch/riscv/cpu/fu540/Kconfig | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig
index e9302e87c0..2dcad8e27f 100644
--- a/arch/riscv/cpu/fu540/Kconfig
+++ b/arch/riscv/cpu/fu540/Kconfig
@@ -13,3 +13,16 @@ config SIFIVE_FU540
 	imply SPL_CPU_SUPPORT
 	imply SPL_OPENSBI
 	imply SPL_LOAD_FIT
+
+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
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v4 2/6] sifive: fu540: Add Booting from SPI
       [not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA47261AD@ATCPCS16.andestech.com>
@ 2020-07-13  2:32   ` Rick Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Rick Chen @ 2020-07-13  2:32 UTC (permalink / raw)
  To: u-boot

Hi Jagan

> From: Jagan Teki [mailto:jagan at amarulasolutions.com]
> Sent: Thursday, July 02, 2020 4:03 PM
> To: Rick Jian-Zhi Chen(???); Atish Patra; Palmer Dabbelt; Bin Meng; Paul Walmsley; Anup Patel; Sagar Kadam
> Cc: u-boot at lists.denx.de; linux-amarula at amarulasolutions.com; Jagan Teki; Bin Meng
> Subject: [PATCH v4 2/6] sifive: fu540: Add Booting from SPI
>
> Add booting from SPI for SiFive Unleashed board.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> Reviewed-by: Bin Meng <bin.meng@windriver.com>
> Tested-by: Bin Meng <bin.meng@windriver.com>
> ---
> Changes for v4:
> - drop BOARD configs
>

Can you rebase and send the whole patches of v4 again ?
When I tried to pick up others from v3, there have some conflicts.

Thanks,
Rick

>  .../dts/hifive-unleashed-a00-u-boot.dtsi      | 12 ++++++
>  configs/sifive_fu540_defconfig                |  4 ++
>  doc/board/sifive/fu540.rst                    | 41 +++++++++++++++++++
>  3 files changed, 57 insertions(+)
>
> diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
> index 303806454b..4b2b242deb 100644
> --- a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
> +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
> @@ -12,6 +12,10 @@
>                 spi2 = &qspi2;
>         };
>
> +       config {
> +               u-boot,spl-payload-offset = <0x105000>; /* loader2 @1044KB */
> +       };
> +
>         hfclk {
>                 u-boot,dm-spl;
>         };
> @@ -22,6 +26,14 @@
>
>  };
>
> +&qspi0 {
> +       u-boot,dm-spl;
> +
> +       flash at 0 {
> +               u-boot,dm-spl;
> +       };
> +};
> +
>  &qspi2 {
>         mmc at 0 {
>                 u-boot,dm-spl;
> diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig index 8d412f8d6a..551d4b04a5 100644
> --- a/configs/sifive_fu540_defconfig
> +++ b/configs/sifive_fu540_defconfig
> @@ -2,9 +2,11 @@ CONFIG_RISCV=y
>  CONFIG_SPL_GPIO_SUPPORT=y
>  CONFIG_SYS_MALLOC_F_LEN=0x3000
>  CONFIG_ENV_SIZE=0x20000
> +CONFIG_SPL_DM_SPI=y
>  CONFIG_SPL_MMC_SUPPORT=y
>  CONFIG_NR_DRAM_BANKS=1
>  CONFIG_SPL=y
> +CONFIG_SPL_SPI_FLASH_SUPPORT=y
>  CONFIG_SPL_SPI_SUPPORT=y
>  CONFIG_TARGET_SIFIVE_FU540=y
>  CONFIG_ARCH_RV64I=y
> @@ -15,9 +17,11 @@ CONFIG_MISC_INIT_R=y
>  CONFIG_DISPLAY_CPUINFO=y
>  CONFIG_DISPLAY_BOARDINFO=y
>  CONFIG_SPL_SEPARATE_BSS=y
> +CONFIG_SPL_SPI_LOAD=y
>  CONFIG_SPL_YMODEM_SUPPORT=y
>  CONFIG_OF_BOARD_FIXUP=y
>  CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_SPL_DM_SEQ_ALIAS=y
>  CONFIG_SPL_CLK=y
>  CONFIG_DM_MTD=y
> diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst index 739eefa669..1ce9ab14f5 100644
> --- a/doc/board/sifive/fu540.rst
> +++ b/doc/board/sifive/fu540.rst
> @@ -533,3 +533,44 @@ Sample boot log from HiFive Unleashed board
>         type:   0fc63daf-8483-4772-8e79-3d69d8477de4
>         type:   linux
>         guid:   9faa81b6-39b1-4418-af5e-89c48f29c20d
> +
> +Booting from SPI
> +----------------
> +
> +Use Building steps from "Booting from MMC using U-Boot SPL" section.
> +
> +Partition the SPI in Linux via mtdblock. (Require to boot the board in
> +SD boot mode by enabling MTD block in Linux)
> +
> +Use prebuilt image from here [1], which support to partition the SPI flash.
> +
> +.. code-block:: none
> +
> +  # sgdisk --clear \
> +  > --set-alignment=2 \
> +  > --new=1:40:2087 --change-name=1:loader1
> + --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \  >
> + --new=2:2088:10279 --change-name=2:loader2
> + --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \  >
> + --new=3:10536:65494 --change-name=3:rootfs
> + --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \  > /dev/mtdblock0
> +
> +Program the SPI (Require to boot the board in SD boot mode)
> +
> +Execute below steps on U-Boot proper,
> +
> +.. code-block:: none
> +
> +  tftpboot $kernel_addr_r u-boot-spl.bin  sf erase 0x5000 $filesize  sf
> + write $kernel_addr_r 0x5000 $filesize
> +
> +  tftpboot $kernel_addr_r u-boot.itb
> +  sf erase 0x105000 $filesize
> +  sf write $kernel_addr_r 0x105000 $filesize
> +
> +Power off the board
> +
> +Change DIP switches MSEL[3:0] are set to 0110
> +
> +Power up the board.
> +
> +[1] https://github.com/amarula/bsp-sifive
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-13  2:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-02  8:02 [PATCH v4 2/6] sifive: fu540: Add Booting from SPI Jagan Teki
2020-07-02  8:02 ` [PATCH v4 3/6] env: Enable SPI flash env for SiFive FU540 Jagan Teki
     [not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA47261AD@ATCPCS16.andestech.com>
2020-07-13  2:32   ` [PATCH v4 2/6] sifive: fu540: Add Booting from SPI Rick Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox