All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] riscv: sifive/fu540: Booting from SPI
@ 2020-04-20 14:05 Jagan Teki
  2020-04-20 14:05 ` [PATCH 1/5] sifive: fu540: Add " Jagan Teki
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Jagan Teki @ 2020-04-20 14:05 UTC (permalink / raw)
  To: u-boot

This series support Boot from SPI on SiFive FU540
HiFive Unleashed board.

SPI uses a separate defconfig and it is possible to reuse
existing one, but it requires runtime detection of boot
mode via MSEL.

Any help? let me know.

Series depends on [1] and [2].

[1] https://patchwork.ozlabs.org/cover/1263480/
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=169649

Any inputs?
Jagan.

Jagan Teki (5):
  sifive: fu540: Add Booting from SPI
  env: Enable SPI flash env for SiFive FU540
  sifive: fu540: Mark the default env as SPI flash
  sifive: fu540: Add boot flash script offset, size
  sifive: fu540: Enable SF distro bootcmd

 .../dts/hifive-unleashed-a00-u-boot.dtsi      | 12 ++++++
 board/sifive/fu540/Kconfig                    |  1 +
 board/sifive/fu540/fu540.c                    |  3 ++
 configs/sifive_fu540_spi_defconfig            | 26 +++++++++++
 doc/board/sifive/fu540.rst                    | 43 +++++++++++++++++++
 env/Kconfig                                   |  3 ++
 include/configs/sifive-fu540.h                |  7 ++-
 7 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 configs/sifive_fu540_spi_defconfig

-- 
2.17.1

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

* [PATCH 1/5] sifive: fu540: Add Booting from SPI
  2020-04-20 14:05 [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Jagan Teki
@ 2020-04-20 14:05 ` Jagan Teki
  2020-04-20 14:24   ` Bin Meng
  2020-04-20 14:05 ` [PATCH 2/5] env: Enable SPI flash env for SiFive FU540 Jagan Teki
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jagan Teki @ 2020-04-20 14:05 UTC (permalink / raw)
  To: u-boot

U-Boot SPL 2020.04-rc4-g0b8ed9b8b6 (Apr 20 2020 - 18:31:50 +0530)
Trying to boot from MMC1

U-Boot 2020.04-rc4-g0b8ed9b8b6 (Apr 20 2020 - 18:31:50 +0530)

CPU:   rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM:  8 GiB
MMC:   spi at 10050000:mmc at 0: 0
Loading Environment from SPI Flash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
*** Warning - bad CRC, using default environment

In:    serial at 10010000
Out:   serial at 10010000
Err:   serial at 10010000
Net:   eth0: ethernet at 10090000
Hit any key to stop autoboot:  0

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      | 12 ++++++
 board/sifive/fu540/fu540.c                    |  3 ++
 configs/sifive_fu540_spi_defconfig            | 26 +++++++++++
 doc/board/sifive/fu540.rst                    | 43 +++++++++++++++++++
 4 files changed, 84 insertions(+)
 create mode 100644 configs/sifive_fu540_spi_defconfig

diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
index 0162f59f60..f5a208398f 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>; /* @ 1044KB */
+	};
+
 	hfclk {
 		u-boot,dm-spl;
 	};
@@ -21,6 +25,14 @@
 	};
 };
 
+&qspi0 {
+	u-boot,dm-spl;
+
+	flash at 0 {
+		u-boot,dm-spl;
+	};
+};
+
 &qspi2 {
 	mmc at 0 {
 		u-boot,dm-spl;
diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
index 131fee8898..84dd20e29d 100644
--- a/board/sifive/fu540/fu540.c
+++ b/board/sifive/fu540/fu540.c
@@ -129,6 +129,9 @@ void board_boot_order(u32 *spl_boot_list)
 	u32 boot_devices[] = {
 #ifdef CONFIG_SPL_MMC_SUPPORT
 		BOOT_DEVICE_MMC1,
+#endif
+#ifdef CONFIG_SPL_SPI_LOAD
+		BOOT_DEVICE_SPI,
 #endif
 	};
 
diff --git a/configs/sifive_fu540_spi_defconfig b/configs/sifive_fu540_spi_defconfig
new file mode 100644
index 0000000000..24d0a9338e
--- /dev/null
+++ b/configs/sifive_fu540_spi_defconfig
@@ -0,0 +1,26 @@
+CONFIG_RISCV=y
+CONFIG_ENV_SIZE=0x20000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_TARGET_SIFIVE_FU540=y
+CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_SMODE=y
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_FIT=y
+CONFIG_MISC_INIT_R=y
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_DM_MTD=y
+CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SPL=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_SPI=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=y
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SPL_YMODEM_SUPPORT=y
+CONFIG_SPL_CLK=y
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x3000
+CONFIG_SIFIVE_FU540_DDR=y
diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index 691ef232e2..14323e0985 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -391,3 +391,46 @@ Program the SD card
 Change DIP switches MSEL[3:0] are set to 1011
 
 Insert the SD card and power up the board.
+
+Booting from SPI
+----------------
+
+Use steps from "Building" section for building the U-Boot
+
+.. code-block:: none
+
+   export ARCH=riscv
+   export CROSS_COMPILE=<riscv64 toolchain prefix>
+   make sifive_fu540_spi_defconfig
+   make
+
+Partition the SPI in Linux via mtdblock. (Require to boot
+the board in SD boot mode by enabling MTD block in Linux)
+
+.. 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)
+on U-Boot proper.
+
+.. code-block:: none
+
+  sf erase 0x5000 0x100000
+  tftpboot $kernel_addr_r u-boot-spl.bin
+  sf write $kernel_addr_r 0x5000 $filesize
+
+  sf erase 0x105000 0x100000
+  tftpboot $kernel_addr_r u-boot.itb
+  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.
-- 
2.17.1

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

* [PATCH 2/5] env: Enable SPI flash env for SiFive FU540
  2020-04-20 14:05 [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Jagan Teki
  2020-04-20 14:05 ` [PATCH 1/5] sifive: fu540: Add " Jagan Teki
@ 2020-04-20 14:05 ` Jagan Teki
  2020-04-20 14:35   ` Bin Meng
  2020-04-20 14:05 ` [PATCH 3/5] sifive: fu540: Mark the default env as SPI flash Jagan Teki
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jagan Teki @ 2020-04-20 14:05 UTC (permalink / raw)
  To: u-boot

SPI flash device on HiFive Unleashed has 32MiB Size.

This patch add 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

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 env/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/env/Kconfig b/env/Kconfig
index 0d6f559b39..67c88fd40b 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -500,6 +500,7 @@ config ENV_OFFSET
 	default 0 if ARC
 	default 0x140000 if ARCH_AT91
 	default 0x260000 if ARCH_OMAP2PLUS
+	default 0x505000 if TARGET_SIFIVE_FU540
 	help
 	  Offset from the start of the device (or partition)
 
@@ -519,6 +520,7 @@ config ENV_SIZE
 	default 0x2000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
 	default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL
 	default 0x4000 if ARC
+	default 0x20000 if TARGET_SIFIVE_FU540
 	default 0x1f000
 	help
 	  Size of the environment storage area
@@ -529,6 +531,7 @@ config ENV_SECT_SIZE
 	default 0x2000 if ARCH_ROCKCHIP
 	default 0x40000 if ARCH_ZYNQMP || ARCH_VERSAL
 	default 0x20000 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91
+	default 0x10000 if TARGET_SIFIVE_FU540
 	help
 	  Size of the sector containing the environment.
 
-- 
2.17.1

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

* [PATCH 3/5] sifive: fu540: Mark the default env as SPI flash
  2020-04-20 14:05 [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Jagan Teki
  2020-04-20 14:05 ` [PATCH 1/5] sifive: fu540: Add " Jagan Teki
  2020-04-20 14:05 ` [PATCH 2/5] env: Enable SPI flash env for SiFive FU540 Jagan Teki
@ 2020-04-20 14:05 ` Jagan Teki
  2020-04-20 14:36   ` Bin Meng
  2020-04-20 14:05 ` [PATCH 4/5] sifive: fu540: Add boot flash script offset, size Jagan Teki
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jagan Teki @ 2020-04-20 14:05 UTC (permalink / raw)
  To: u-boot

Mark the default U-Boot environment as SPI flash since
this is an on board flash device.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 board/sifive/fu540/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig
index 43d01bab8d..7e49feba00 100644
--- a/board/sifive/fu540/Kconfig
+++ b/board/sifive/fu540/Kconfig
@@ -27,6 +27,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	def_bool y
 	select GENERIC_RISCV
 	select SUPPORT_SPL
+	select ENV_IS_IN_SPI_FLASH
 	imply CMD_DHCP
 	imply CMD_EXT2
 	imply CMD_EXT4
-- 
2.17.1

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

* [PATCH 4/5] sifive: fu540: Add boot flash script offset, size
  2020-04-20 14:05 [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Jagan Teki
                   ` (2 preceding siblings ...)
  2020-04-20 14:05 ` [PATCH 3/5] sifive: fu540: Mark the default env as SPI flash Jagan Teki
@ 2020-04-20 14:05 ` Jagan Teki
  2020-04-20 14:05 ` [PATCH 5/5] sifive: fu540: Enable SF distro bootcmd Jagan Teki
  2020-04-20 14:46 ` [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Bin Meng
  5 siblings, 0 replies; 11+ messages in thread
From: Jagan Teki @ 2020-04-20 14:05 UTC (permalink / raw)
  To: u-boot

HiFive-Unleashed-A00 has SPI flash with 32MiB size.
So, let's use the script offset at the end of 4K.
This way it cannot overlap any offsets being used
by software components in flash layout.

So, SF distrocmd will pick the script at desired
script address and run.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 include/configs/sifive-fu540.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/sifive-fu540.h b/include/configs/sifive-fu540.h
index 72c841eb9b..68fda14d76 100644
--- a/include/configs/sifive-fu540.h
+++ b/include/configs/sifive-fu540.h
@@ -62,6 +62,8 @@
 	"kernel_addr_r=0x84000000\0" \
 	"fdt_addr_r=0x88000000\0" \
 	"scriptaddr=0x88100000\0" \
+	"script_offset_f=0x1fff000\0" \
+	"script_size_f=0x1000\0" \
 	"pxefile_addr_r=0x88200000\0" \
 	"ramdisk_addr_r=0x88300000\0" \
 	"type_guid_gpt_loader1=" TYPE_GUID_LOADER1 "\0" \
-- 
2.17.1

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

* [PATCH 5/5] sifive: fu540: Enable SF distro bootcmd
  2020-04-20 14:05 [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Jagan Teki
                   ` (3 preceding siblings ...)
  2020-04-20 14:05 ` [PATCH 4/5] sifive: fu540: Add boot flash script offset, size Jagan Teki
@ 2020-04-20 14:05 ` Jagan Teki
  2020-04-20 14:46 ` [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Bin Meng
  5 siblings, 0 replies; 11+ messages in thread
From: Jagan Teki @ 2020-04-20 14:05 UTC (permalink / raw)
  To: u-boot

Enable SPI flash(SF) distro boot command in Sifive FU540.

This distro boot will read the boot script at specific
location at the flash and start sourcing the same.

Included the SF device at the last of the target devices
list since all the rest of the devices on the list have
more possibility to boot the distribution due to the
size of the SPI flash is concern.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 include/configs/sifive-fu540.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/configs/sifive-fu540.h b/include/configs/sifive-fu540.h
index 68fda14d76..f21411a701 100644
--- a/include/configs/sifive-fu540.h
+++ b/include/configs/sifive-fu540.h
@@ -43,9 +43,11 @@
 #ifndef CONFIG_SPL_BUILD
 #define BOOT_TARGET_DEVICES(func) \
 	func(MMC, mmc, 0) \
+	func(SF, sf, 0) \
 	func(DHCP, dhcp, na)
 
 #include <config_distro_bootcmd.h>
+#include <environment/distro/sf.h>
 
 #define TYPE_GUID_LOADER1	"5B193300-FC78-40CD-8002-E86C45580B47"
 #define TYPE_GUID_LOADER2	"2E54B353-1271-4842-806F-E436D6AF6985"
@@ -70,7 +72,8 @@
 	"type_guid_gpt_loader2=" TYPE_GUID_LOADER2 "\0" \
 	"type_guid_gpt_system=" TYPE_GUID_SYSTEM "\0" \
 	"partitions=" PARTS_DEFAULT "\0" \
-	BOOTENV
+	BOOTENV \
+	BOOTENV_SF
 
 #define CONFIG_PREBOOT \
 	"setenv fdt_addr ${fdtcontroladdr};" \
-- 
2.17.1

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

* [PATCH 1/5] sifive: fu540: Add Booting from SPI
  2020-04-20 14:05 ` [PATCH 1/5] sifive: fu540: Add " Jagan Teki
@ 2020-04-20 14:24   ` Bin Meng
  2020-04-20 14:28     ` Jagan Teki
  0 siblings, 1 reply; 11+ messages in thread
From: Bin Meng @ 2020-04-20 14:24 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

On Mon, Apr 20, 2020 at 10:05 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> U-Boot SPL 2020.04-rc4-g0b8ed9b8b6 (Apr 20 2020 - 18:31:50 +0530)
> Trying to boot from MMC1

This log seems to be SD boot, not SPI boot

>
> U-Boot 2020.04-rc4-g0b8ed9b8b6 (Apr 20 2020 - 18:31:50 +0530)
>
> CPU:   rv64imafdc
> Model: SiFive HiFive Unleashed A00
> DRAM:  8 GiB
> MMC:   spi at 10050000:mmc at 0: 0
> Loading Environment from SPI Flash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
> *** Warning - bad CRC, using default environment
>
> In:    serial at 10010000
> Out:   serial at 10010000
> Err:   serial at 10010000
> Net:   eth0: ethernet at 10090000
> Hit any key to stop autoboot:  0
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  .../dts/hifive-unleashed-a00-u-boot.dtsi      | 12 ++++++
>  board/sifive/fu540/fu540.c                    |  3 ++
>  configs/sifive_fu540_spi_defconfig            | 26 +++++++++++
>  doc/board/sifive/fu540.rst                    | 43 +++++++++++++++++++
>  4 files changed, 84 insertions(+)
>  create mode 100644 configs/sifive_fu540_spi_defconfig
>
> diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
> index 0162f59f60..f5a208398f 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>; /* @ 1044KB */

Can we add some comments about how this is chosen?

> +       };
> +
>         hfclk {
>                 u-boot,dm-spl;
>         };
> @@ -21,6 +25,14 @@
>         };
>  };
>
> +&qspi0 {
> +       u-boot,dm-spl;
> +
> +       flash at 0 {
> +               u-boot,dm-spl;
> +       };
> +};
> +
>  &qspi2 {
>         mmc at 0 {
>                 u-boot,dm-spl;
> diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
> index 131fee8898..84dd20e29d 100644
> --- a/board/sifive/fu540/fu540.c
> +++ b/board/sifive/fu540/fu540.c
> @@ -129,6 +129,9 @@ void board_boot_order(u32 *spl_boot_list)
>         u32 boot_devices[] = {
>  #ifdef CONFIG_SPL_MMC_SUPPORT
>                 BOOT_DEVICE_MMC1,
> +#endif
> +#ifdef CONFIG_SPL_SPI_LOAD
> +               BOOT_DEVICE_SPI,
>  #endif
>         };
>
> diff --git a/configs/sifive_fu540_spi_defconfig b/configs/sifive_fu540_spi_defconfig
> new file mode 100644
> index 0000000000..24d0a9338e
> --- /dev/null
> +++ b/configs/sifive_fu540_spi_defconfig
> @@ -0,0 +1,26 @@
> +CONFIG_RISCV=y
> +CONFIG_ENV_SIZE=0x20000
> +CONFIG_NR_DRAM_BANKS=1
> +CONFIG_TARGET_SIFIVE_FU540=y
> +CONFIG_ARCH_RV64I=y
> +CONFIG_RISCV_SMODE=y
> +CONFIG_DISTRO_DEFAULTS=y
> +CONFIG_FIT=y
> +CONFIG_MISC_INIT_R=y
> +CONFIG_DISPLAY_CPUINFO=y
> +CONFIG_DISPLAY_BOARDINFO=y
> +CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
> +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_DM_MTD=y
> +CONFIG_SPL_SEPARATE_BSS=y
> +CONFIG_SPL=y
> +CONFIG_SPL_DM_SEQ_ALIAS=y
> +CONFIG_SPL_DM_SPI=y
> +CONFIG_SPL_SPI_FLASH_SUPPORT=y
> +CONFIG_SPL_SPI_SUPPORT=y
> +CONFIG_SPL_SPI_LOAD=y
> +CONFIG_SPL_YMODEM_SUPPORT=y
> +CONFIG_SPL_CLK=y
> +CONFIG_SPL_GPIO_SUPPORT=y
> +CONFIG_SYS_MALLOC_F_LEN=0x3000
> +CONFIG_SIFIVE_FU540_DDR=y

These config options should be ordered by "make savedefconfg"

> diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
> index 691ef232e2..14323e0985 100644
> --- a/doc/board/sifive/fu540.rst
> +++ b/doc/board/sifive/fu540.rst
> @@ -391,3 +391,46 @@ Program the SD card
>  Change DIP switches MSEL[3:0] are set to 1011
>
>  Insert the SD card and power up the board.
> +
> +Booting from SPI
> +----------------
> +
> +Use steps from "Building" section for building the U-Boot
> +
> +.. code-block:: none
> +
> +   export ARCH=riscv
> +   export CROSS_COMPILE=<riscv64 toolchain prefix>
> +   make sifive_fu540_spi_defconfig
> +   make
> +
> +Partition the SPI in Linux via mtdblock. (Require to boot
> +the board in SD boot mode by enabling MTD block in Linux)
> +
> +.. 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)
> +on U-Boot proper.
> +
> +.. code-block:: none
> +
> +  sf erase 0x5000 0x100000
> +  tftpboot $kernel_addr_r u-boot-spl.bin
> +  sf write $kernel_addr_r 0x5000 $filesize
> +
> +  sf erase 0x105000 0x100000
> +  tftpboot $kernel_addr_r u-boot.itb
> +  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.
> --

Looks good otherwise:
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Regards,
Bin

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

* [PATCH 1/5] sifive: fu540: Add Booting from SPI
  2020-04-20 14:24   ` Bin Meng
@ 2020-04-20 14:28     ` Jagan Teki
  0 siblings, 0 replies; 11+ messages in thread
From: Jagan Teki @ 2020-04-20 14:28 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 20, 2020 at 7:54 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Jagan,
>
> On Mon, Apr 20, 2020 at 10:05 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
> >
> > U-Boot SPL 2020.04-rc4-g0b8ed9b8b6 (Apr 20 2020 - 18:31:50 +0530)
> > Trying to boot from MMC1
>
> This log seems to be SD boot, not SPI boot

Wrong log added, my bad.

>
> >
> > U-Boot 2020.04-rc4-g0b8ed9b8b6 (Apr 20 2020 - 18:31:50 +0530)
> >
> > CPU:   rv64imafdc
> > Model: SiFive HiFive Unleashed A00
> > DRAM:  8 GiB
> > MMC:   spi at 10050000:mmc at 0: 0
> > Loading Environment from SPI Flash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
> > *** Warning - bad CRC, using default environment
> >
> > In:    serial at 10010000
> > Out:   serial at 10010000
> > Err:   serial at 10010000
> > Net:   eth0: ethernet at 10090000
> > Hit any key to stop autoboot:  0
> >
> > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > ---
> >  .../dts/hifive-unleashed-a00-u-boot.dtsi      | 12 ++++++
> >  board/sifive/fu540/fu540.c                    |  3 ++
> >  configs/sifive_fu540_spi_defconfig            | 26 +++++++++++
> >  doc/board/sifive/fu540.rst                    | 43 +++++++++++++++++++
> >  4 files changed, 84 insertions(+)
> >  create mode 100644 configs/sifive_fu540_spi_defconfig
> >
> > diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
> > index 0162f59f60..f5a208398f 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>; /* @ 1044KB */
>
> Can we add some comments about how this is chosen?

Yes on the doc file of loader2 sector start. Yes will make it more
verbose if it isn't sufficient.

>
> > +       };
> > +
> >         hfclk {
> >                 u-boot,dm-spl;
> >         };
> > @@ -21,6 +25,14 @@
> >         };
> >  };
> >
> > +&qspi0 {
> > +       u-boot,dm-spl;
> > +
> > +       flash at 0 {
> > +               u-boot,dm-spl;
> > +       };
> > +};
> > +
> >  &qspi2 {
> >         mmc at 0 {
> >                 u-boot,dm-spl;
> > diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
> > index 131fee8898..84dd20e29d 100644
> > --- a/board/sifive/fu540/fu540.c
> > +++ b/board/sifive/fu540/fu540.c
> > @@ -129,6 +129,9 @@ void board_boot_order(u32 *spl_boot_list)
> >         u32 boot_devices[] = {
> >  #ifdef CONFIG_SPL_MMC_SUPPORT
> >                 BOOT_DEVICE_MMC1,
> > +#endif
> > +#ifdef CONFIG_SPL_SPI_LOAD
> > +               BOOT_DEVICE_SPI,
> >  #endif
> >         };
> >
> > diff --git a/configs/sifive_fu540_spi_defconfig b/configs/sifive_fu540_spi_defconfig
> > new file mode 100644
> > index 0000000000..24d0a9338e
> > --- /dev/null
> > +++ b/configs/sifive_fu540_spi_defconfig
> > @@ -0,0 +1,26 @@
> > +CONFIG_RISCV=y
> > +CONFIG_ENV_SIZE=0x20000
> > +CONFIG_NR_DRAM_BANKS=1
> > +CONFIG_TARGET_SIFIVE_FU540=y
> > +CONFIG_ARCH_RV64I=y
> > +CONFIG_RISCV_SMODE=y
> > +CONFIG_DISTRO_DEFAULTS=y
> > +CONFIG_FIT=y
> > +CONFIG_MISC_INIT_R=y
> > +CONFIG_DISPLAY_CPUINFO=y
> > +CONFIG_DISPLAY_BOARDINFO=y
> > +CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
> > +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> > +CONFIG_DM_MTD=y
> > +CONFIG_SPL_SEPARATE_BSS=y
> > +CONFIG_SPL=y
> > +CONFIG_SPL_DM_SEQ_ALIAS=y
> > +CONFIG_SPL_DM_SPI=y
> > +CONFIG_SPL_SPI_FLASH_SUPPORT=y
> > +CONFIG_SPL_SPI_SUPPORT=y
> > +CONFIG_SPL_SPI_LOAD=y
> > +CONFIG_SPL_YMODEM_SUPPORT=y
> > +CONFIG_SPL_CLK=y
> > +CONFIG_SPL_GPIO_SUPPORT=y
> > +CONFIG_SYS_MALLOC_F_LEN=0x3000
> > +CONFIG_SIFIVE_FU540_DDR=y
>
> These config options should be ordered by "make savedefconfg"

Yes, I just sent it as the first series. Hoping to reuse existing
defconfig if we have any way to detect the boot mode at runtime like
reading MSEL.

Jagan.

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

* [PATCH 2/5] env: Enable SPI flash env for SiFive FU540
  2020-04-20 14:05 ` [PATCH 2/5] env: Enable SPI flash env for SiFive FU540 Jagan Teki
@ 2020-04-20 14:35   ` Bin Meng
  0 siblings, 0 replies; 11+ messages in thread
From: Bin Meng @ 2020-04-20 14:35 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

On Mon, Apr 20, 2020 at 10:05 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> SPI flash device on HiFive Unleashed has 32MiB Size.
>
> This patch add 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
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  env/Kconfig | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/env/Kconfig b/env/Kconfig
> index 0d6f559b39..67c88fd40b 100644
> --- a/env/Kconfig
> +++ b/env/Kconfig
> @@ -500,6 +500,7 @@ config ENV_OFFSET
>         default 0 if ARC
>         default 0x140000 if ARCH_AT91
>         default 0x260000 if ARCH_OMAP2PLUS
> +       default 0x505000 if TARGET_SIFIVE_FU540
>         help
>           Offset from the start of the device (or partition)
>
> @@ -519,6 +520,7 @@ config ENV_SIZE
>         default 0x2000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
>         default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL
>         default 0x4000 if ARC
> +       default 0x20000 if TARGET_SIFIVE_FU540
>         default 0x1f000
>         help
>           Size of the environment storage area
> @@ -529,6 +531,7 @@ config ENV_SECT_SIZE
>         default 0x2000 if ARCH_ROCKCHIP
>         default 0x40000 if ARCH_ZYNQMP || ARCH_VERSAL
>         default 0x20000 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91
> +       default 0x10000 if TARGET_SIFIVE_FU540
>         help
>           Size of the sector containing the environment.

We really should not touch the generic env/Kconfig file otherwise the
generic Kconfig will soon become unmaintainable.
Instead put it into either board specific Kconfig, or SoC specific
Kconfig. If this should be common layout for all SiFive FU540 SoCs, we
should put it under arch/riscv/cpu/fu540/Kconfig

Regards,
Bin

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

* [PATCH 3/5] sifive: fu540: Mark the default env as SPI flash
  2020-04-20 14:05 ` [PATCH 3/5] sifive: fu540: Mark the default env as SPI flash Jagan Teki
@ 2020-04-20 14:36   ` Bin Meng
  0 siblings, 0 replies; 11+ messages in thread
From: Bin Meng @ 2020-04-20 14:36 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 20, 2020 at 10:05 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> Mark the default U-Boot environment as SPI flash since
> this is an on board flash device.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  board/sifive/fu540/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

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

* [PATCH 0/5] riscv: sifive/fu540: Booting from SPI
  2020-04-20 14:05 [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Jagan Teki
                   ` (4 preceding siblings ...)
  2020-04-20 14:05 ` [PATCH 5/5] sifive: fu540: Enable SF distro bootcmd Jagan Teki
@ 2020-04-20 14:46 ` Bin Meng
  5 siblings, 0 replies; 11+ messages in thread
From: Bin Meng @ 2020-04-20 14:46 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

On Mon, Apr 20, 2020 at 10:05 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> This series support Boot from SPI on SiFive FU540
> HiFive Unleashed board.
>
> SPI uses a separate defconfig and it is possible to reuse
> existing one, but it requires runtime detection of boot
> mode via MSEL.

Should we determine the boot order based on MSEL dynamically?

>
> Any help? let me know.

Thank you very much for get the SPI flash working and bring in
additional booting from SPI flash support.

>
> Series depends on [1] and [2].
>
> [1] https://patchwork.ozlabs.org/cover/1263480/
> [2] https://patchwork.ozlabs.org/project/uboot/list/?series=169649
>
> Any inputs?
> Jagan.

Regards,
Bin

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

end of thread, other threads:[~2020-04-20 14:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 14:05 [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Jagan Teki
2020-04-20 14:05 ` [PATCH 1/5] sifive: fu540: Add " Jagan Teki
2020-04-20 14:24   ` Bin Meng
2020-04-20 14:28     ` Jagan Teki
2020-04-20 14:05 ` [PATCH 2/5] env: Enable SPI flash env for SiFive FU540 Jagan Teki
2020-04-20 14:35   ` Bin Meng
2020-04-20 14:05 ` [PATCH 3/5] sifive: fu540: Mark the default env as SPI flash Jagan Teki
2020-04-20 14:36   ` Bin Meng
2020-04-20 14:05 ` [PATCH 4/5] sifive: fu540: Add boot flash script offset, size Jagan Teki
2020-04-20 14:05 ` [PATCH 5/5] sifive: fu540: Enable SF distro bootcmd Jagan Teki
2020-04-20 14:46 ` [PATCH 0/5] riscv: sifive/fu540: Booting from SPI Bin Meng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.