riscv: sifive/fu540: SPI boot
Subsystems (2)
v5 cover riscv: sifive/fu540: SPI boot
Updated series with boot device detection directly on spl_boot_device function instead of having separate board driver.
Changes for v5:
- rebase on master
Changes for v4:
- fix typo and unneeded configs.
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
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 | 13 ++++++ .../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, 96 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
PATCH v5 1/6 sifive: fu540: Add runtime boot mode detection
Add support to detect boot mode at runtime for
SiFive FU540 boards.
---
Changes for v5:
- rebase on master
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>
@@ -128,14 +129,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 v5 2/6 sifive: fu540: Add Booting from SPI
In reply to Jagan TekiAdd booting from SPI for SiFive Unleashed board.
---
Changes for v5:
- rebase on master
.../dts/hifive-unleashed-a00-u-boot.dtsi | 12 ++++++ configs/sifive_fu540_defconfig | 4 ++ doc/board/sifive/fu540.rst | 41 +++++++++++++++++++ 3 files changed, 57 insertions(+)
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +12 -0
@@ -16,6 +16,10 @@ spi2 = &qspi2; }; + config { + u-boot,spl-payload-offset = <0x105000>; /* loader2 @1044KB */ + }; + hfclk { u-boot,dm-spl; };
@@ -26,6 +30,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
@@ -6,6 +6,7 @@ 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
@@ -16,8 +17,11 @@ CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_BOARDINFO=y CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SPL_DM_SPI_FLASH=y +CONFIG_SPL_SPI_LOAD=y CONFIG_SPL_YMODEM_SUPPORT=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 v5 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 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.?
---
Changes for v5:
- rebase on master
arch/riscv/cpu/fu540/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/riscv/cpu/fu540/Kconfig +13 -0
@@ -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
Signature · 1 line
2.25.1
PATCH v5 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 v5:
- rebase on master
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 v5 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 v5:
- rebase on master
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 v5 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 v5:
- rebase on master
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
v5 cover riscv: sifive/fu540: SPI boot
In reply to Jagan TekiHi Rick,
Quoted 37 lines · Jagan Teki
Updated series with boot device detection directly on
spl_boot_devicefunction instead of having separate board driver.Changes for v5:
- rebase on master
Changes for v4:
- fix typo and unneeded configs.
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 seriesAny 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 bootcmdarch/riscv/cpu/fu540/Kconfig | 13 ++++++ .../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, 96 insertions(+), 7 deletions(-)
Quoted 3 lines
--
2.25.1
Any chance to pick this?
Jagan.
A message that is not in the archive (sent off-list or not yet received): [email protected]
v5 cover riscv: sifive/fu540: SPI boot
Hi Jagan
Quoted 44 lines
From: Jagan Teki [mailto:jagan at amarulasolutions.com]
Sent: Tuesday, July 21, 2020 2:26 PM
To: Rick Jian-Zhi Chen(???); Atish Patra; Palmer Dabbelt; Bin Meng; Paul Walmsley; Anup Patel; Sagar Kadam
Cc: U-Boot-Denx; linux-amarula
Subject: Re: [PATCH v5 0/6] riscv: sifive/fu540: SPI bootHi Rick,
Quoted 35 lines · Jagan Teki
Updated series with boot device detection directly on
spl_boot_devicefunction instead of having separate board driver.Changes for v5:
- rebase on master
Changes for v4:
- fix typo and unneeded configs.
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 seriesAny 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 bootcmdarch/riscv/cpu/fu540/Kconfig | 13 ++++++ .../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, 96 insertions(+), 7 deletions(-)
Quoted 5 lines
Quoted 3 lines
--
2.25.1Any chance to pick this?
Applied to u-boot-riscv/master !
Thanks,
Rick
Quoted 2 lines
Jagan.