riscv: sifive/fu540: SPI boot
Subsystems (2)
v3 cover riscv: sifive/fu540: SPI boot
Updated series with boot device detection directly on spl_boot_device function instead of having separate board driver.
Previous version changes are at [1].
Changes for v3:
- fixed env definitions build
- added boot device detection in board
Changes for v2:
- fu540 board driver
- runtime bootmode detection
- rebase on Pragnesh v11 series
[1] https://patchwork.ozlabs.org/project/uboot/cover/20200519192340.16624-1-jagan at amarulasolutions.com/
Any inputs?
Jagan.
Jagan Teki (6):
sifive: fu540: Add runtime boot mode detection
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
arch/riscv/cpu/fu540/Kconfig | 15 +++++++ .../dts/hifive-unleashed-a00-u-boot.dtsi | 12 ++++++ board/sifive/fu540/Kconfig | 1 + board/sifive/fu540/fu540.c | 25 ++++++++--- configs/sifive_fu540_defconfig | 4 ++ doc/board/sifive/fu540.rst | 41 +++++++++++++++++++ include/configs/sifive-fu540.h | 7 +++- 7 files changed, 98 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/6 sifive: fu540: Add runtime boot mode detection
Add support to detect boot mode at runtime for
SiFive FU540 boards.
---
Changes for v3:
- new patch
board/sifive/fu540/fu540.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
board/sifive/fu540/fu540.c +19 -6
@@ -10,6 +10,7 @@#include <env.h> #include <init.h> #include <log.h> +#include <linux/bitops.h> #include <linux/bug.h> #include <linux/delay.h> #include <linux/io.h>
@@ -120,14 +121,26 @@ int board_init(void) }#ifdef CONFIG_SPL +#define MODE_SELECT_REG 0x1000 +#define MODE_SELECT_QSPI 0x6 +#define MODE_SELECT_SD 0xb +#define MODE_SELECT_MASK GENMASK(3, 0) +u32 spl_boot_device (void ) { -#ifdef CONFIG_SPL_MMC_SUPPORT -return BOOT_DEVICE_MMC1 ; -#else -puts ("Unknown boot device\n" ); -hang (); -#endif +u32 mode_select =readl ((void *)MODE_SELECT_REG ); +u32 boot_device = mode_select &MODE_SELECT_MASK ; + +switch (boot_device) { +case MODE_SELECT_QSPI : +return BOOT_DEVICE_SPI ; +case MODE_SELECT_SD : +return BOOT_DEVICE_MMC1 ; +default : +debug ("Unsupported boot device 0x%x but trying MMC1\n" , + boot_device); +return BOOT_DEVICE_MMC1 ; + } }#endif
Signature · 1 line
2.25.1
PATCH v3 1/6 sifive: fu540: Add runtime boot mode detection
Quoted 4 lines · Jagan Teki
Add support to detect boot mode at runtime for
SiFive FU540 boards.
Quoted 8 lines
Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- new patchboard/sifive/fu540/fu540.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
PATCH v3 2/6 sifive: fu540: Add Booting from SPI
In reply to Jagan TekiAdd booting from SPI for SiFive Unleashed board.
---
Changes for v3:
- updated based on master
arch/riscv/cpu/fu540/Kconfig | 2 + .../dts/hifive-unleashed-a00-u-boot.dtsi | 12 ++++++ configs/sifive_fu540_defconfig | 4 ++ doc/board/sifive/fu540.rst | 41 +++++++++++++++++++ 4 files changed, 59 insertions(+)
arch/riscv/cpu/fu540/Kconfig +2 -0
@@ -5,6 +5,8 @@ config SIFIVE_FU540 bool select ARCH_EARLY_INIT_R + imply BOARD + imply BOARD_FU540 imply CPU imply CPU_RISCV imply RISCV_TIMER
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +12 -0
@@ -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;
configs/sifive_fu540_defconfig +4 -0
@@ -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
doc/board/sifive/fu540.rst +41 -0
44 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 2/6 sifive: fu540: Add Booting from SPI
Quoted 19 lines · Jagan Teki
Add booting from SPI for SiFive Unleashed board.
Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- updated based on masterarch/riscv/cpu/fu540/Kconfig | 2 + .../dts/hifive-unleashed-a00-u-boot.dtsi | 12 ++++++ configs/sifive_fu540_defconfig | 4 ++ doc/board/sifive/fu540.rst | 41 +++++++++++++++++++ 4 files changed, 59 insertions(+)arch/riscv/cpu/fu540/Kconfig +0
-0
arch/riscv/cpu/fu540/Kconfig line 9
Quoted 5 lines
arch/riscv/cpu/fu540/Kconfig +2
-0@@ -5,6 +5,8 @@ config SIFIVE_FU540 bool select ARCH_EARLY_INIT_R + imply BOARD + imply BOARD_FU540
These 2 are not needed in v3.
Quoted 23 lines
arch/riscv/cpu/fu540/Kconfig +0
-0imply CPU imply CPU_RISCV imply RISCV_TIMERarch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +5
-0@@ -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 {
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi line 39
Quoted 10 lines
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +7
-0+ u-boot,dm-spl; + + flash at 0 { + u-boot,dm-spl; + }; +}; + &qspi2 { mmc at 0 { u-boot,dm-spl;
Other than above,
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v3 2/6 sifive: fu540: Add Booting from SPI
Hi Jagan
Quoted 21 lines
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, June 22, 2020 9:53 PM
To: Jagan Teki
Cc: Rick Jian-Zhi Chen(???); Atish Patra; Palmer Dabbelt; Paul Walmsley; Anup Patel; Sagar Kadam; U-Boot Mailing List; linux-amarula
Subject: Re: [PATCH v3 2/6] sifive: fu540: Add Booting from SPIQuoted 14 lines · Jagan Teki
Add booting from SPI for SiFive Unleashed board.
Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- updated based on masterarch/riscv/cpu/fu540/Kconfig | 2 + .../dts/hifive-unleashed-a00-u-boot.dtsi | 12 ++++++ configs/sifive_fu540_defconfig | 4 ++ doc/board/sifive/fu540.rst | 41 +++++++++++++++++++ 4 files changed, 59 insertions(+)
Quoted 12 lines
arch/riscv/cpu/fu540/Kconfig line 9
Quoted 10 lines
(quoted diff) +0
-0b/arch/riscv/cpu/fu540/Kconfig index
e9302e87c0..7a813a9ac8100644arch/riscv/cpu/fu540/Kconfig +2
-0@@ -5,6 +5,8 @@ config SIFIVE_FU540 bool select ARCH_EARLY_INIT_R + imply BOARD + imply BOARD_FU540These 2 are not needed in v3.
How is your opinion here ?
Quoted 39 lines
Quoted 25 lines
arch/riscv/cpu/fu540/Kconfig +0
-0imply CPU imply CPU_RISCV imply RISCV_TIMERarch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +5
-0@@ -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 {arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi line 39
Quoted 10 lines
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +7
-0+ u-boot,dm-spl; + + flash at 0 { + u-boot,dm-spl; + }; +}; + &qspi2 { mmc at 0 { u-boot,dm-spl;Other than above,
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
PATCH v3 3/6 env: Enable SPI flash env for SiFive FU540
In reply to Jagan TekiSPI 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
Note: the loader1 must start from 40th sector even though there are 6 free sectors prior since 40th sector is nearest flash sector boundary.?
---
Changes for v3:
- fixed build issues
arch/riscv/cpu/fu540/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/riscv/cpu/fu540/Kconfig +13 -0
@@ -15,3 +15,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
Signature · 1 line
2.25.1
PATCH v3 3/6 env: Enable SPI flash env for SiFive FU540
Quoted 19 lines · Jagan Teki
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 scriptNote: the loader1 must start from 40th sector even though there are 6 free sectors prior since 40th sector is nearest flash sector boundary.
Quoted 8 lines
Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- fixed build issuesarch/riscv/cpu/fu540/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+)
PATCH v3 3/6 env: Enable SPI flash env for SiFive FU540
Quoted 6 lines · Bin Meng
Quoted 4 lines · Jagan Teki
SPI flash device on HiFive Unleashed has 32MiB Size.
This patch add SPI flash environment after U-Boot proper
Forgot to mention a nit:
add -> adds
Quoted 26 lines
Quoted 15 lines
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 scriptNote: the loader1 must start from 40th sector even though there are 6 free sectors prior since 40th sector is nearest flash sector boundary.
Quoted 8 lines
Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- fixed build issuesarch/riscv/cpu/fu540/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+)Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>
PATCH v3 4/6 sifive: fu540: Mark the default env as SPI flash
In reply to Jagan TekiMark the default U-Boot environment as SPI flash since this is an on board flash device.
---
Changes for v3:
- none
board/sifive/fu540/Kconfig | 1 + 1 file changed, 1 insertion(+)
board/sifive/fu540/Kconfig +1 -0
@@ -27,6 +27,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select SIFIVE_FU540 select SUPPORT_SPL + select ENV_IS_IN_SPI_FLASH select RAM select SPL_RAM if SPL imply CMD_DHCP
Signature · 1 line
2.25.1
PATCH v3 4/6 sifive: fu540: Mark the default env as SPI flash
Quoted 4 lines · Jagan Teki
Mark the default U-Boot environment as SPI flash since this is an on board flash device.
Quoted 9 lines
Reviewed-by Bin Meng <[email protected]>Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- noneboard/sifive/fu540/Kconfig | 1 + 1 file changed, 1 insertion(+)
PATCH v3 5/6 sifive: fu540: Add boot flash script offset, size
In reply to Jagan TekiHiFive-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.
---
Changes for v3:
- none
include/configs/sifive-fu540.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/sifive-fu540.h +2 -0
@@ -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" \
Signature · 1 line
2.25.1
PATCH v3 5/6 sifive: fu540: Add boot flash script offset, size
Quoted 9 lines · Jagan Teki
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.
Quoted 8 lines
Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- noneinclude/configs/sifive-fu540.h | 2 ++ 1 file changed, 2 insertions(+)
PATCH v3 6/6 sifive: fu540: Enable SF distro bootcmd
In reply to Jagan TekiEnable 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.
---
Changes for v3:
- none
include/configs/sifive-fu540.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/configs/sifive-fu540.h +4 -1
@@ -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};" \
Signature · 1 line
2.25.1
PATCH v3 6/6 sifive: fu540: Enable SF distro bootcmd
Quoted 11 lines · Jagan Teki
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.
Quoted 8 lines
Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- noneinclude/configs/sifive-fu540.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
v3 cover riscv: sifive/fu540: SPI boot
In reply to Jagan TekiHi,
Quoted 20 lines · Jagan Teki
Updated series with boot device detection directly on
spl_boot_devicefunction instead of having separate board driver.Previous version changes are at [1].
Changes for v3:
- fixed env definitions build
- added boot device detection in board
Changes for v2:
- fu540 board driver
- runtime bootmode detection
- rebase on Pragnesh v11 series[1] https://patchwork.ozlabs.org/project/uboot/cover/20200519192340.16624-1-jagan at amarulasolutions.com/
Any inputs?
Jagan.
Quoted 7 lines
Jagan Teki (6):
sifive: fu540: Add runtime boot mode detection
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
Hope these will push for the release?
Jagan.