u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode
@ 2023-10-06 11:23 Randolph
  2023-10-06 11:23 ` [PATCH RESEND 1/7] riscv: dts: Introduce SPL_LOAD_FIT_CONFIG symbol Randolph
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Randolph @ 2023-10-06 11:23 UTC (permalink / raw)
  To: u-boot; +Cc: randolph.sklin, dylan, tim609, peterlin, Randolph

Introduce a shortcut boot mode for RISC-V. 

As we know, in ARM architecture has the Falcon mode to do the shortcut
boot to the Linux kernel. (by enabling CONFIG_SPL_OS_BOOT)
ARM Falcon mode boot flow would be as follows:
u-boot SPL -> Linux kernel

But for RISC-V, OpenSBI is required to allows the supervisor to execute
some privileged operations.
The RISC-V Normal boot flow as follows:
u-boot SPL -> OpenSBI -> u-boot proper -> Linux kernel

Quoting the same ideas as ARM's Falcon mode,
OpenSBI OS boot flow as follows:
u-boot SPL -> OpenSBI -> Linux kernel

An important part of OpenSBI OS boot mode is to prepare the device tree. 
A normal U-Boot does FDT fixups when booting Linux. 
For OpenSBI OS boot mode, Linux boots directly from SPL, 
skipping the normal U-Boot. 
The device tree has to be prepared in advance.
The device tree in memory is the one needed for OpenSBI OS boot mode.

The Linux kernel image will also need to be provided for the generation
of the FIT file.

Randolph (7):
  riscv: dts: Introduce SPL_LOAD_FIT_CONFIG symbol
  riscv: dts: add binman_linux.dtsi for opensbi os boot mode
  spl: riscv: opensbi: change the default os_type as varible
  riscv: dts: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol
  spl: riscv: add os type for next booting stage
  andes: config: add riscv falcon mode for ae350 platform
  riscv: spl: andes: Move the DTB in front of kernel

 arch/riscv/Kconfig                      | 16 +++++
 arch/riscv/dts/ae350-u-boot.dtsi        |  1 +
 arch/riscv/dts/ae350_32.dts             |  1 -
 arch/riscv/dts/ae350_64.dts             |  1 -
 arch/riscv/dts/binman_linux.dtsi        | 79 +++++++++++++++++++++++++
 board/AndesTech/ae350/ae350.c           | 25 ++++++++
 common/spl/spl_fit.c                    |  4 ++
 common/spl/spl_opensbi.c                | 31 ++++++----
 configs/ae350_rv32_falcon_defconfig     | 60 +++++++++++++++++++
 configs/ae350_rv32_falcon_xip_defconfig | 61 +++++++++++++++++++
 configs/ae350_rv64_falcon_defconfig     | 60 +++++++++++++++++++
 configs/ae350_rv64_falcon_xip_defconfig | 61 +++++++++++++++++++
 12 files changed, 388 insertions(+), 12 deletions(-)
 create mode 100644 arch/riscv/dts/binman_linux.dtsi
 create mode 100644 configs/ae350_rv32_falcon_defconfig
 create mode 100644 configs/ae350_rv32_falcon_xip_defconfig
 create mode 100644 configs/ae350_rv64_falcon_defconfig
 create mode 100644 configs/ae350_rv64_falcon_xip_defconfig

-- 
2.34.1


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

* [PATCH RESEND 1/7] riscv: dts: Introduce SPL_LOAD_FIT_CONFIG symbol
  2023-10-06 11:23 [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode Randolph
@ 2023-10-06 11:23 ` Randolph
  2023-10-07 23:09   ` Simon Glass
  2023-10-06 11:23 ` [PATCH RESEND 2/7] riscv: dts: add binman_linux.dtsi for opensbi os boot mode Randolph
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Randolph @ 2023-10-06 11:23 UTC (permalink / raw)
  To: u-boot; +Cc: randolph.sklin, dylan, tim609, peterlin, Randolph

Introduce common Kconfig symbol for riscv architecture
This symbol SPL_LOAD_FIT_CONFIG for binman itb layout selection
Default is using binman.dtsi

Signed-off-by: Randolph <randolph@andestech.com>
---
 arch/riscv/Kconfig               | 7 +++++++
 arch/riscv/dts/ae350-u-boot.dtsi | 1 +
 arch/riscv/dts/ae350_32.dts      | 1 -
 arch/riscv/dts/ae350_64.dts      | 1 -
 4 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index aff1f33665..ec1cfcaaa7 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -422,4 +422,11 @@ config TPL_USE_ARCH_MEMSET
 
 endmenu
 
+config SPL_LOAD_FIT_CONFIG
+	string "Default FIT configuration for SPL"
+	default "binman.dtsi"
+	depends on SPL_LOAD_FIT
+	help
+	  Specify corresponding FIT configuration for SPL modes.
+
 endmenu
diff --git a/arch/riscv/dts/ae350-u-boot.dtsi b/arch/riscv/dts/ae350-u-boot.dtsi
index aef9159b7a..ff5725501f 100644
--- a/arch/riscv/dts/ae350-u-boot.dtsi
+++ b/arch/riscv/dts/ae350-u-boot.dtsi
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
+#include CONFIG_SPL_LOAD_FIT_CONFIG
 
 / {
 	cpus {
diff --git a/arch/riscv/dts/ae350_32.dts b/arch/riscv/dts/ae350_32.dts
index 61af6d5465..2caabad888 100644
--- a/arch/riscv/dts/ae350_32.dts
+++ b/arch/riscv/dts/ae350_32.dts
@@ -2,7 +2,6 @@
 
 /dts-v1/;
 
-#include "binman.dtsi"
 #include "ae350-u-boot.dtsi"
 
 / {
diff --git a/arch/riscv/dts/ae350_64.dts b/arch/riscv/dts/ae350_64.dts
index 8c7db29b4f..9d5f6c743c 100644
--- a/arch/riscv/dts/ae350_64.dts
+++ b/arch/riscv/dts/ae350_64.dts
@@ -2,7 +2,6 @@
 
 /dts-v1/;
 
-#include "binman.dtsi"
 #include "ae350-u-boot.dtsi"
 
 / {
-- 
2.34.1


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

* [PATCH RESEND 2/7] riscv: dts: add binman_linux.dtsi for opensbi os boot mode
  2023-10-06 11:23 [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode Randolph
  2023-10-06 11:23 ` [PATCH RESEND 1/7] riscv: dts: Introduce SPL_LOAD_FIT_CONFIG symbol Randolph
@ 2023-10-06 11:23 ` Randolph
  2023-10-07 23:09   ` Simon Glass
  2023-10-06 11:23 ` [PATCH RESEND 3/7] spl: riscv: opensbi: change the default os_type as varible Randolph
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Randolph @ 2023-10-06 11:23 UTC (permalink / raw)
  To: u-boot; +Cc: randolph.sklin, dylan, tim609, peterlin, Randolph

The binman_linux.dtsi is a fork of binman.dtsi, just change the first
section image from the "u-boot" to "linux". Note that the filename
is also changed. In binman.dtsi, the filename of u-boot section filename
is called "u-boot-nodtb.bin". In binman_linux.dtsi, the filename should
be called "Image", which is located in linux/arch/riscv/boot.

Signed-off-by: Randolph <randolph@andestech.com>
---
 arch/riscv/dts/binman_linux.dtsi | 79 ++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 arch/riscv/dts/binman_linux.dtsi

diff --git a/arch/riscv/dts/binman_linux.dtsi b/arch/riscv/dts/binman_linux.dtsi
new file mode 100644
index 0000000000..334d64bc40
--- /dev/null
+++ b/arch/riscv/dts/binman_linux.dtsi
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
+ */
+
+#include <config.h>
+
+/ {
+	binman: binman {
+		multiple-images;
+	};
+};
+
+&binman {
+	itb {
+		filename = "linux.itb";
+
+		fit {
+			description = "Configuration to load OpenSBI before Linux";
+			#address-cells = <1>;
+			fit,fdt-list = "of-list";
+
+			images {
+				linux {
+					description = "Linux";
+					type = "standalone";
+					os = "Linux";
+					arch = "riscv";
+					compression = "none";
+					load = <CONFIG_TEXT_BASE>;
+
+					linux_blob: blob-ext {
+						filename = "Image";
+					};
+				};
+
+				opensbi {
+					description = "OpenSBI fw_dynamic Firmware";
+					type = "firmware";
+					os = "opensbi";
+					arch = "riscv";
+					compression = "none";
+					load = <CONFIG_SPL_OPENSBI_LOAD_ADDR>;
+					entry = <CONFIG_SPL_OPENSBI_LOAD_ADDR>;
+
+					opensbi_blob: opensbi {
+						filename = "fw_dynamic.bin";
+						missing-msg = "opensbi";
+					};
+				};
+
+#ifndef CONFIG_OF_BOARD
+				@fdt-SEQ {
+					description = "NAME";
+					type = "flat_dt";
+					compression = "none";
+				};
+#endif
+			};
+
+			configurations {
+				default = "conf-1";
+
+#ifndef CONFIG_OF_BOARD
+				@conf-SEQ {
+#else
+				conf-1 {
+#endif
+					description = "NAME";
+					firmware = "opensbi";
+					loadables = "linux";
+#ifndef CONFIG_OF_BOARD
+					fdt = "fdt-SEQ";
+#endif
+				};
+			};
+		};
+	};
+};
-- 
2.34.1


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

* [PATCH RESEND 3/7] spl: riscv: opensbi: change the default os_type as varible
  2023-10-06 11:23 [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode Randolph
  2023-10-06 11:23 ` [PATCH RESEND 1/7] riscv: dts: Introduce SPL_LOAD_FIT_CONFIG symbol Randolph
  2023-10-06 11:23 ` [PATCH RESEND 2/7] riscv: dts: add binman_linux.dtsi for opensbi os boot mode Randolph
@ 2023-10-06 11:23 ` Randolph
  2023-10-07 23:09   ` Simon Glass
  2023-10-06 11:23 ` [PATCH RESEND 4/7] riscv: dts: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol Randolph
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Randolph @ 2023-10-06 11:23 UTC (permalink / raw)
  To: u-boot; +Cc: randolph.sklin, dylan, tim609, peterlin, Randolph

In order to introduce the Opensbi OS boot mode, the next stage boot
image of OpenSBI should be configurable.

Signed-off-by: Randolph <randolph@andestech.com>
---
 common/spl/spl_opensbi.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
index e2aaa46046..a0c5f35dab 100644
--- a/common/spl/spl_opensbi.c
+++ b/common/spl/spl_opensbi.c
@@ -20,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct fw_dynamic_info opensbi_info;
 
-static int spl_opensbi_find_uboot_node(void *blob, int *uboot_node)
+static int spl_opensbi_find_os_node(void *blob, int *uboot_node, int os_type)
 {
 	int fit_images_node, node;
 	const char *fit_os;
@@ -34,7 +34,7 @@ static int spl_opensbi_find_uboot_node(void *blob, int *uboot_node)
 		if (!fit_os)
 			continue;
 
-		if (genimg_get_os_id(fit_os) == IH_OS_U_BOOT) {
+		if (genimg_get_os_id(fit_os) == os_type) {
 			*uboot_node = node;
 			return 0;
 		}
@@ -45,8 +45,9 @@ static int spl_opensbi_find_uboot_node(void *blob, int *uboot_node)
 
 void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image)
 {
-	int ret, uboot_node;
-	ulong uboot_entry;
+	int ret, os_node;
+	ulong os_entry;
+	int os_type;
 	typedef void __noreturn (*opensbi_entry_t)(ulong hartid, ulong dtb, ulong info);
 	opensbi_entry_t opensbi_entry;
 
@@ -55,22 +56,27 @@ void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image)
 		hang();
 	}
 
-	/* Find U-Boot image in /fit-images */
-	ret = spl_opensbi_find_uboot_node(spl_image->fdt_addr, &uboot_node);
+	/*
+	 * Find next os image in /fit-images
+	 * The next os image default is u-boot proper
+	 */
+	os_type = IH_OS_U_BOOT;
+	ret = spl_opensbi_find_os_node(spl_image->fdt_addr, &os_node, os_type);
 	if (ret) {
-		pr_err("Can't find U-Boot node, %d\n", ret);
+		pr_err("Can't find %s node for opensbi, %d\n",
+		       genimg_get_os_name(os_type), ret);
 		hang();
 	}
 
 	/* Get U-Boot entry point */
-	ret = fit_image_get_entry(spl_image->fdt_addr, uboot_node, &uboot_entry);
+	ret = fit_image_get_entry(spl_image->fdt_addr, os_node, &os_entry);
 	if (ret)
-		ret = fit_image_get_load(spl_image->fdt_addr, uboot_node, &uboot_entry);
+		ret = fit_image_get_load(spl_image->fdt_addr, os_node, &os_entry);
 
 	/* Prepare opensbi_info object */
 	opensbi_info.magic = FW_DYNAMIC_INFO_MAGIC_VALUE;
 	opensbi_info.version = FW_DYNAMIC_INFO_VERSION;
-	opensbi_info.next_addr = uboot_entry;
+	opensbi_info.next_addr = os_entry;
 	opensbi_info.next_mode = FW_DYNAMIC_INFO_NEXT_MODE_S;
 	opensbi_info.options = CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS;
 	opensbi_info.boot_hart = gd->arch.boot_hart;
-- 
2.34.1


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

* [PATCH RESEND 4/7] riscv: dts: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol
  2023-10-06 11:23 [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode Randolph
                   ` (2 preceding siblings ...)
  2023-10-06 11:23 ` [PATCH RESEND 3/7] spl: riscv: opensbi: change the default os_type as varible Randolph
@ 2023-10-06 11:23 ` Randolph
  2023-10-07 23:09   ` Simon Glass
  2023-10-06 11:23 ` [PATCH RESEND 5/7] spl: riscv: add os type for next booting stage Randolph
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Randolph @ 2023-10-06 11:23 UTC (permalink / raw)
  To: u-boot; +Cc: randolph.sklin, dylan, tim609, peterlin, Randolph

Introduce common Kconfig symbol for riscv architecture.
This symbol SPL_LOAD_FIT_OPENSBI_OS_BOOT is like falcon mode on ARM,
the Falcon boot is a shortcut boot method for SD/eMMC targets. It
skips the loading the RAM version U-Boot. Instead, it will loads
the FIT image and boots directly to Linux.

When SPL_OPENSBI_OS_BOOT is enabled, linux.itb is created after
compilation instead of the default u-boot.itb. It initialises memory
with the U-Boot SPL at the first stage, just as a normal boot process
does at the beginning. Instead of jumping to the U-Boot proper from
OpenSBI before booting the Linux kernel, the RISC-V falcon mode
process jumps directly to the Linux kernel to gain shorter booting time.

When SPL_OPENSBI_OS_BOOT is enabled, it will change the default FIT
configure file "binman.dtsi" to "binman_linux.dtsi"
Default is not enabled.

Signed-off-by: Randolph <randolph@andestech.com>
---
 arch/riscv/Kconfig | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index ec1cfcaaa7..4f104789a7 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -422,8 +422,17 @@ config TPL_USE_ARCH_MEMSET
 
 endmenu
 
+config SPL_LOAD_FIT_OPENSBI_OS_BOOT
+	bool "Enable SPL (OpenSBI OS boot mode) applying linux from FIT"
+	depends on SPL_LOAD_FIT
+	help
+	  Use fw_dynamic from the FIT image, and u-boot SPL will invoke it directly.
+	  This is a shortcut boot flow, from u-boot SPL -> OpenSBI -> u-boot proper
+	  -> linux to u-boot SPL -> OpenSBI -> linux.
+
 config SPL_LOAD_FIT_CONFIG
 	string "Default FIT configuration for SPL"
+	default "binman_linux.dtsi" if SPL_LOAD_FIT_OPENSBI_OS_BOOT
 	default "binman.dtsi"
 	depends on SPL_LOAD_FIT
 	help
-- 
2.34.1


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

* [PATCH RESEND 5/7] spl: riscv: add os type for next booting stage
  2023-10-06 11:23 [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode Randolph
                   ` (3 preceding siblings ...)
  2023-10-06 11:23 ` [PATCH RESEND 4/7] riscv: dts: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol Randolph
@ 2023-10-06 11:23 ` Randolph
  2023-10-07 23:09   ` Simon Glass
  2023-10-06 11:23 ` [PATCH RESEND 6/7] andes: config: add riscv falcon mode for ae350 platform Randolph
  2023-10-06 11:23 ` [PATCH RESEND 7/7] riscv: spl: andes: Move the DTB in front of kernel Randolph
  6 siblings, 1 reply; 13+ messages in thread
From: Randolph @ 2023-10-06 11:23 UTC (permalink / raw)
  To: u-boot; +Cc: randolph.sklin, dylan, tim609, peterlin, Randolph

If SPL_LOAD_FIT_OPENSBI_OS_BOOT is enabled, the function
spl_invoke_opensbi should change the target OS type to IH_OS_LINUX.
OpenSBI will load the Linux image as the next boot stage.
The os_takes_devicetree function returns a value of true or false
depending on whether or not SPL_LOAD_FIT_OPENSBI_OS_BOOT is enabled.

Signed-off-by: Randolph <randolph@andestech.com>
---
 common/spl/spl_fit.c     | 4 ++++
 common/spl/spl_opensbi.c | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 730639f756..750562721a 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -351,7 +351,11 @@ static bool os_takes_devicetree(uint8_t os)
 	case IH_OS_U_BOOT:
 		return true;
 	case IH_OS_LINUX:
+#ifdef CONFIG_RISCV
+		return IS_ENABLED(CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT);
+#else
 		return IS_ENABLED(CONFIG_SPL_OS_BOOT);
+#endif
 	default:
 		return false;
 	}
diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
index a0c5f35dab..708869ad48 100644
--- a/common/spl/spl_opensbi.c
+++ b/common/spl/spl_opensbi.c
@@ -58,9 +58,14 @@ void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image)
 
 	/*
 	 * Find next os image in /fit-images
-	 * The next os image default is u-boot proper
+	 * The next os image default is u-boot proper, once enable
+	 * OpenSBI OS boot mode, the OS image should be linux.
 	 */
+#if CONFIG_IS_ENABLED(LOAD_FIT_OPENSBI_OS_BOOT)
+	os_type = IH_OS_LINUX;
+#else
 	os_type = IH_OS_U_BOOT;
+#endif
 	ret = spl_opensbi_find_os_node(spl_image->fdt_addr, &os_node, os_type);
 	if (ret) {
 		pr_err("Can't find %s node for opensbi, %d\n",
-- 
2.34.1


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

* [PATCH RESEND 6/7] andes: config: add riscv falcon mode for ae350 platform
  2023-10-06 11:23 [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode Randolph
                   ` (4 preceding siblings ...)
  2023-10-06 11:23 ` [PATCH RESEND 5/7] spl: riscv: add os type for next booting stage Randolph
@ 2023-10-06 11:23 ` Randolph
  2023-10-06 11:23 ` [PATCH RESEND 7/7] riscv: spl: andes: Move the DTB in front of kernel Randolph
  6 siblings, 0 replies; 13+ messages in thread
From: Randolph @ 2023-10-06 11:23 UTC (permalink / raw)
  To: u-boot; +Cc: randolph.sklin, dylan, tim609, peterlin, Randolph

Fork from ae350_rv[32/64]_spl_[xip]_defconfig and
append CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT=y

Signed-off-by: Randolph <randolph@andestech.com>
---
 configs/ae350_rv32_falcon_defconfig     | 60 ++++++++++++++++++++++++
 configs/ae350_rv32_falcon_xip_defconfig | 61 +++++++++++++++++++++++++
 configs/ae350_rv64_falcon_defconfig     | 60 ++++++++++++++++++++++++
 configs/ae350_rv64_falcon_xip_defconfig | 61 +++++++++++++++++++++++++
 4 files changed, 242 insertions(+)
 create mode 100644 configs/ae350_rv32_falcon_defconfig
 create mode 100644 configs/ae350_rv32_falcon_xip_defconfig
 create mode 100644 configs/ae350_rv64_falcon_defconfig
 create mode 100644 configs/ae350_rv64_falcon_xip_defconfig

diff --git a/configs/ae350_rv32_falcon_defconfig b/configs/ae350_rv32_falcon_defconfig
new file mode 100644
index 0000000000..8f796d88e3
--- /dev/null
+++ b/configs/ae350_rv32_falcon_defconfig
@@ -0,0 +1,60 @@
+CONFIG_RISCV=y
+CONFIG_TEXT_BASE=0x01800000
+CONFIG_SYS_MALLOC_LEN=0x80000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x10000000
+CONFIG_ENV_SECT_SIZE=0x1000
+CONFIG_DEFAULT_DEVICE_TREE="ae350_32"
+CONFIG_SYS_PROMPT="RISC-V # "
+CONFIG_SYS_MONITOR_LEN=786432
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000000
+CONFIG_SPL=y
+CONFIG_SYS_LOAD_ADDR=0x100000
+CONFIG_TARGET_ANDES_AE350=y
+CONFIG_RISCV_SMODE=y
+# CONFIG_AVAILABLE_HARTS is not set
+CONFIG_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x10000000
+CONFIG_SYS_MONITOR_BASE=0x88000000
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTDELAY=3
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_MAX_SIZE=0x100000
+CONFIG_SPL_BSS_START_ADDR=0x400000
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_CACHE=y
+CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0
+CONFIG_SYS_PBSIZE=1050
+CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_IMLS=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF_TEST=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_PREFER_SERVERIP=y
+CONFIG_CMD_CACHE=y
+CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NET_RETRY_COUNT=50
+CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_MMC=y
+CONFIG_FTSDC010=y
+CONFIG_FTSDC010_SDIO=y
+CONFIG_MTD_NOR_FLASH=y
+CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_SYS_FLASH_CFI_WIDTH_16BIT=y
+CONFIG_FLASH_SHOW_PROGRESS=0
+CONFIG_SYS_CFI_FLASH_STATUS_POLL=y
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_CFI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_FTMAC100=y
+CONFIG_BAUDRATE=38400
+CONFIG_SYS_NS16550=y
+CONFIG_SPI=y
+CONFIG_ATCSPI200_SPI=y
+# CONFIG_BINMAN_FDT is not set
+CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT=y
\ No newline at end of file
diff --git a/configs/ae350_rv32_falcon_xip_defconfig b/configs/ae350_rv32_falcon_xip_defconfig
new file mode 100644
index 0000000000..e01dd6fc51
--- /dev/null
+++ b/configs/ae350_rv32_falcon_xip_defconfig
@@ -0,0 +1,61 @@
+CONFIG_RISCV=y
+CONFIG_TEXT_BASE=0x01800000
+CONFIG_SYS_MALLOC_LEN=0x80000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x10000000
+CONFIG_ENV_SECT_SIZE=0x1000
+CONFIG_DEFAULT_DEVICE_TREE="ae350_32"
+CONFIG_SPL_TEXT_BASE=0x80000000
+CONFIG_SYS_PROMPT="RISC-V # "
+CONFIG_SYS_MONITOR_LEN=786432
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000000
+CONFIG_SPL=y
+CONFIG_SYS_LOAD_ADDR=0x100000
+CONFIG_TARGET_ANDES_AE350=y
+CONFIG_RISCV_SMODE=y
+CONFIG_SPL_XIP=y
+CONFIG_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x80010000
+CONFIG_SYS_MONITOR_BASE=0x88000000
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTDELAY=3
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_MAX_SIZE=0x100000
+CONFIG_SPL_BSS_START_ADDR=0x400000
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_CACHE=y
+CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0
+CONFIG_SYS_PBSIZE=1050
+CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_IMLS=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF_TEST=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_PREFER_SERVERIP=y
+CONFIG_CMD_CACHE=y
+CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NET_RETRY_COUNT=50
+CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_MMC=y
+CONFIG_FTSDC010=y
+CONFIG_FTSDC010_SDIO=y
+CONFIG_MTD_NOR_FLASH=y
+CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_SYS_FLASH_CFI_WIDTH_16BIT=y
+CONFIG_FLASH_SHOW_PROGRESS=0
+CONFIG_SYS_CFI_FLASH_STATUS_POLL=y
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_CFI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_FTMAC100=y
+CONFIG_BAUDRATE=38400
+CONFIG_SYS_NS16550=y
+CONFIG_SPI=y
+CONFIG_ATCSPI200_SPI=y
+# CONFIG_BINMAN_FDT is not set
+CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT=y
\ No newline at end of file
diff --git a/configs/ae350_rv64_falcon_defconfig b/configs/ae350_rv64_falcon_defconfig
new file mode 100644
index 0000000000..d11be976de
--- /dev/null
+++ b/configs/ae350_rv64_falcon_defconfig
@@ -0,0 +1,60 @@
+CONFIG_RISCV=y
+CONFIG_TEXT_BASE=0x01800000
+CONFIG_SYS_MALLOC_LEN=0x80000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x10000000
+CONFIG_ENV_SECT_SIZE=0x1000
+CONFIG_DEFAULT_DEVICE_TREE="ae350_64"
+CONFIG_SYS_PROMPT="RISC-V # "
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000000
+CONFIG_SPL=y
+CONFIG_SYS_LOAD_ADDR=0x100000
+CONFIG_TARGET_ANDES_AE350=y
+CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_SMODE=y
+# CONFIG_AVAILABLE_HARTS is not set
+CONFIG_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x10000000
+CONFIG_SYS_MONITOR_BASE=0x88000000
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTDELAY=3
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_MAX_SIZE=0x100000
+CONFIG_SPL_BSS_START_ADDR=0x400000
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_CACHE=y
+CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0
+CONFIG_SYS_PBSIZE=1050
+CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_IMLS=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF_TEST=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_PREFER_SERVERIP=y
+CONFIG_CMD_CACHE=y
+CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NET_RETRY_COUNT=50
+CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_MMC=y
+CONFIG_FTSDC010=y
+CONFIG_FTSDC010_SDIO=y
+CONFIG_MTD_NOR_FLASH=y
+CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_SYS_FLASH_CFI_WIDTH_16BIT=y
+CONFIG_FLASH_SHOW_PROGRESS=0
+CONFIG_SYS_CFI_FLASH_STATUS_POLL=y
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_CFI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_FTMAC100=y
+CONFIG_BAUDRATE=38400
+CONFIG_SYS_NS16550=y
+CONFIG_SPI=y
+CONFIG_ATCSPI200_SPI=y
+# CONFIG_BINMAN_FDT is not set
+CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT=y
\ No newline at end of file
diff --git a/configs/ae350_rv64_falcon_xip_defconfig b/configs/ae350_rv64_falcon_xip_defconfig
new file mode 100644
index 0000000000..492451ecf1
--- /dev/null
+++ b/configs/ae350_rv64_falcon_xip_defconfig
@@ -0,0 +1,61 @@
+CONFIG_RISCV=y
+CONFIG_TEXT_BASE=0x01800000
+CONFIG_SYS_MALLOC_LEN=0x80000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x10000000
+CONFIG_ENV_SECT_SIZE=0x1000
+CONFIG_DEFAULT_DEVICE_TREE="ae350_64"
+CONFIG_SPL_TEXT_BASE=0x80000000
+CONFIG_SYS_PROMPT="RISC-V # "
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000000
+CONFIG_SPL=y
+CONFIG_SYS_LOAD_ADDR=0x100000
+CONFIG_TARGET_ANDES_AE350=y
+CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_SMODE=y
+CONFIG_SPL_XIP=y
+CONFIG_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x80010000
+CONFIG_SYS_MONITOR_BASE=0x88000000
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTDELAY=3
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_MAX_SIZE=0x100000
+CONFIG_SPL_BSS_START_ADDR=0x400000
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_CACHE=y
+CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS=0x0
+CONFIG_SYS_PBSIZE=1050
+CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_IMLS=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF_TEST=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_PREFER_SERVERIP=y
+CONFIG_CMD_CACHE=y
+CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_NET_RETRY_COUNT=50
+CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_MMC=y
+CONFIG_FTSDC010=y
+CONFIG_FTSDC010_SDIO=y
+CONFIG_MTD_NOR_FLASH=y
+CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_SYS_FLASH_CFI_WIDTH_16BIT=y
+CONFIG_FLASH_SHOW_PROGRESS=0
+CONFIG_SYS_CFI_FLASH_STATUS_POLL=y
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_CFI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_FTMAC100=y
+CONFIG_BAUDRATE=38400
+CONFIG_SYS_NS16550=y
+CONFIG_SPI=y
+CONFIG_ATCSPI200_SPI=y
+# CONFIG_BINMAN_FDT is not set
+CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT=y
\ No newline at end of file
-- 
2.34.1


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

* [PATCH RESEND 7/7] riscv: spl: andes: Move the DTB in front of kernel
  2023-10-06 11:23 [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode Randolph
                   ` (5 preceding siblings ...)
  2023-10-06 11:23 ` [PATCH RESEND 6/7] andes: config: add riscv falcon mode for ae350 platform Randolph
@ 2023-10-06 11:23 ` Randolph
  6 siblings, 0 replies; 13+ messages in thread
From: Randolph @ 2023-10-06 11:23 UTC (permalink / raw)
  To: u-boot; +Cc: randolph.sklin, dylan, tim609, peterlin, Randolph

Originally, u-boot SPL will place the DTB directly after the kernel,
but the size of the kernel does not include the BSS section, This
means that u-boot SPL places the DTB in the kernel BSS section causing
the DTB to be cleared by the kernel BSS initialisation.

Moving the DTB in front of the kernel can avoid this error.

Signed-off-by: Randolph <randolph@andestech.com>
---
 board/AndesTech/ae350/ae350.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/board/AndesTech/ae350/ae350.c b/board/AndesTech/ae350/ae350.c
index 1c2288b6ce..d78ee403e6 100644
--- a/board/AndesTech/ae350/ae350.c
+++ b/board/AndesTech/ae350/ae350.c
@@ -19,6 +19,8 @@
 #include <fdtdec.h>
 #include <dm.h>
 #include <spl.h>
+#include <mapmem.h>
+#include <hang.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -26,6 +28,29 @@ DECLARE_GLOBAL_DATA_PTR;
  * Miscellaneous platform dependent initializations
  */
 
+#if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
+#define ANDES_SPL_FDT_ADDR	(CONFIG_TEXT_BASE - 0x100000)
+void spl_perform_fixups(struct spl_image_info *spl_image)
+{
+	/*
+	 * Originally, u-boot-spl will place DTB directly after the kernel,
+	 * but the size of the kernel did not include the BSS section, which
+	 * means u-boot-spl will place the DTB in the kernel BSS section
+	 * causing the DTB to be cleared by kernel BSS initializtion.
+	 * Moving DTB in front of the kernel can avoid the error.
+	 */
+	if (ANDES_SPL_FDT_ADDR < 0) {
+		printf("%s: CONFIG_TEXT_BASE needs to be larger than 0x100000\n",
+		       __func__);
+		hang();
+	}
+
+	memcpy((void *)ANDES_SPL_FDT_ADDR, spl_image->fdt_addr,
+	       fdt_totalsize(spl_image->fdt_addr));
+	spl_image->fdt_addr = map_sysmem(ANDES_SPL_FDT_ADDR, 0);
+}
+#endif
+
 int board_init(void)
 {
 	gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
-- 
2.34.1


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

* Re: [PATCH RESEND 1/7] riscv: dts: Introduce SPL_LOAD_FIT_CONFIG symbol
  2023-10-06 11:23 ` [PATCH RESEND 1/7] riscv: dts: Introduce SPL_LOAD_FIT_CONFIG symbol Randolph
@ 2023-10-07 23:09   ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2023-10-07 23:09 UTC (permalink / raw)
  To: randolph; +Cc: u-boot, randolph.sklin, dylan, tim609, peterlin

Hi Randoph,

On Fri, 6 Oct 2023 at 05:26, Randolph <randolph@andestech.com> wrote:
>
> Introduce common Kconfig symbol for riscv architecture
> This symbol SPL_LOAD_FIT_CONFIG for binman itb layout selection
> Default is using binman.dtsi
>
> Signed-off-by: Randolph <randolph@andestech.com>
> ---
>  arch/riscv/Kconfig               | 7 +++++++
>  arch/riscv/dts/ae350-u-boot.dtsi | 1 +
>  arch/riscv/dts/ae350_32.dts      | 1 -
>  arch/riscv/dts/ae350_64.dts      | 1 -
>  4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index aff1f33665..ec1cfcaaa7 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -422,4 +422,11 @@ config TPL_USE_ARCH_MEMSET
>
>  endmenu
>
> +config SPL_LOAD_FIT_CONFIG
> +       string "Default FIT configuration for SPL"
> +       default "binman.dtsi"
> +       depends on SPL_LOAD_FIT
> +       help
> +         Specify corresponding FIT configuration for SPL modes.
> +
>  endmenu
> diff --git a/arch/riscv/dts/ae350-u-boot.dtsi b/arch/riscv/dts/ae350-u-boot.dtsi
> index aef9159b7a..ff5725501f 100644
> --- a/arch/riscv/dts/ae350-u-boot.dtsi
> +++ b/arch/riscv/dts/ae350-u-boot.dtsi
> @@ -1,4 +1,5 @@
>  // SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +#include CONFIG_SPL_LOAD_FIT_CONFIG

That doesn't seem great to me. I will check the next patch.

>  / {
>         cpus {
> diff --git a/arch/riscv/dts/ae350_32.dts b/arch/riscv/dts/ae350_32.dts
> index 61af6d5465..2caabad888 100644
> --- a/arch/riscv/dts/ae350_32.dts
> +++ b/arch/riscv/dts/ae350_32.dts
> @@ -2,7 +2,6 @@
>
>  /dts-v1/;
>
> -#include "binman.dtsi"
>  #include "ae350-u-boot.dtsi"
>
>  / {
> diff --git a/arch/riscv/dts/ae350_64.dts b/arch/riscv/dts/ae350_64.dts
> index 8c7db29b4f..9d5f6c743c 100644
> --- a/arch/riscv/dts/ae350_64.dts
> +++ b/arch/riscv/dts/ae350_64.dts
> @@ -2,7 +2,6 @@
>
>  /dts-v1/;
>
> -#include "binman.dtsi"
>  #include "ae350-u-boot.dtsi"
>
>  / {
> --
> 2.34.1
>

Regards,
Simon

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

* Re: [PATCH RESEND 2/7] riscv: dts: add binman_linux.dtsi for opensbi os boot mode
  2023-10-06 11:23 ` [PATCH RESEND 2/7] riscv: dts: add binman_linux.dtsi for opensbi os boot mode Randolph
@ 2023-10-07 23:09   ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2023-10-07 23:09 UTC (permalink / raw)
  To: randolph; +Cc: u-boot, randolph.sklin, dylan, tim609, peterlin

Hi Randoph,

On Fri, 6 Oct 2023 at 05:26, Randolph <randolph@andestech.com> wrote:
>
> The binman_linux.dtsi is a fork of binman.dtsi, just change the first
> section image from the "u-boot" to "linux". Note that the filename
> is also changed. In binman.dtsi, the filename of u-boot section filename
> is called "u-boot-nodtb.bin". In binman_linux.dtsi, the filename should
> be called "Image", which is located in linux/arch/riscv/boot.
>
> Signed-off-by: Randolph <randolph@andestech.com>
> ---
>  arch/riscv/dts/binman_linux.dtsi | 79 ++++++++++++++++++++++++++++++++
>  1 file changed, 79 insertions(+)
>  create mode 100644 arch/riscv/dts/binman_linux.dtsi
>
> diff --git a/arch/riscv/dts/binman_linux.dtsi b/arch/riscv/dts/binman_linux.dtsi
> new file mode 100644
> index 0000000000..334d64bc40
> --- /dev/null
> +++ b/arch/riscv/dts/binman_linux.dtsi
> @@ -0,0 +1,79 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
> + */
> +
> +#include <config.h>
> +
> +/ {
> +       binman: binman {
> +               multiple-images;
> +       };
> +};
> +
> +&binman {
> +       itb {
> +               filename = "linux.itb";
> +
> +               fit {
> +                       description = "Configuration to load OpenSBI before Linux";
> +                       #address-cells = <1>;
> +                       fit,fdt-list = "of-list";
> +
> +                       images {
> +                               linux {
> +                                       description = "Linux";
> +                                       type = "standalone";
> +                                       os = "Linux";
> +                                       arch = "riscv";
> +                                       compression = "none";
> +                                       load = <CONFIG_TEXT_BASE>;
> +
> +                                       linux_blob: blob-ext {
> +                                               filename = "Image";
> +                                       };
> +                               };
> +
> +                               opensbi {
> +                                       description = "OpenSBI fw_dynamic Firmware";
> +                                       type = "firmware";
> +                                       os = "opensbi";
> +                                       arch = "riscv";
> +                                       compression = "none";
> +                                       load = <CONFIG_SPL_OPENSBI_LOAD_ADDR>;
> +                                       entry = <CONFIG_SPL_OPENSBI_LOAD_ADDR>;
> +
> +                                       opensbi_blob: opensbi {
> +                                               filename = "fw_dynamic.bin";
> +                                               missing-msg = "opensbi";
> +                                       };
> +                               };
> +
> +#ifndef CONFIG_OF_BOARD
> +                               @fdt-SEQ {
> +                                       description = "NAME";
> +                                       type = "flat_dt";
> +                                       compression = "none";
> +                               };
> +#endif
> +                       };
> +
> +                       configurations {
> +                               default = "conf-1";
> +
> +#ifndef CONFIG_OF_BOARD
> +                               @conf-SEQ {
> +#else
> +                               conf-1 {
> +#endif
> +                                       description = "NAME";
> +                                       firmware = "opensbi";
> +                                       loadables = "linux";
> +#ifndef CONFIG_OF_BOARD
> +                                       fdt = "fdt-SEQ";
> +#endif
> +                               };
> +                       };
> +               };
> +       };
> +};
> --
> 2.34.1
>

Could you instead put an #ifdef to include the right file (or nodes)
in a single file?

i.e. always include binman.dtsi but have it do different things in either case?

Regards,
Simon

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

* Re: [PATCH RESEND 3/7] spl: riscv: opensbi: change the default os_type as varible
  2023-10-06 11:23 ` [PATCH RESEND 3/7] spl: riscv: opensbi: change the default os_type as varible Randolph
@ 2023-10-07 23:09   ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2023-10-07 23:09 UTC (permalink / raw)
  To: randolph; +Cc: u-boot, randolph.sklin, dylan, tim609, peterlin

On Fri, 6 Oct 2023 at 05:26, Randolph <randolph@andestech.com> wrote:
>
> In order to introduce the Opensbi OS boot mode, the next stage boot
> image of OpenSBI should be configurable.
>
> Signed-off-by: Randolph <randolph@andestech.com>
> ---
>  common/spl/spl_opensbi.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* Re: [PATCH RESEND 4/7] riscv: dts: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol
  2023-10-06 11:23 ` [PATCH RESEND 4/7] riscv: dts: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol Randolph
@ 2023-10-07 23:09   ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2023-10-07 23:09 UTC (permalink / raw)
  To: randolph; +Cc: u-boot, randolph.sklin, dylan, tim609, peterlin

Hi Randolph,

On Fri, 6 Oct 2023 at 05:27, Randolph <randolph@andestech.com> wrote:
>
> Introduce common Kconfig symbol for riscv architecture.
> This symbol SPL_LOAD_FIT_OPENSBI_OS_BOOT is like falcon mode on ARM,
> the Falcon boot is a shortcut boot method for SD/eMMC targets. It
> skips the loading the RAM version U-Boot. Instead, it will loads
> the FIT image and boots directly to Linux.
>
> When SPL_OPENSBI_OS_BOOT is enabled, linux.itb is created after
> compilation instead of the default u-boot.itb. It initialises memory
> with the U-Boot SPL at the first stage, just as a normal boot process
> does at the beginning. Instead of jumping to the U-Boot proper from
> OpenSBI before booting the Linux kernel, the RISC-V falcon mode
> process jumps directly to the Linux kernel to gain shorter booting time.
>
> When SPL_OPENSBI_OS_BOOT is enabled, it will change the default FIT
> configure file "binman.dtsi" to "binman_linux.dtsi"
> Default is not enabled.
>
> Signed-off-by: Randolph <randolph@andestech.com>
> ---
>  arch/riscv/Kconfig | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index ec1cfcaaa7..4f104789a7 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -422,8 +422,17 @@ config TPL_USE_ARCH_MEMSET
>
>  endmenu
>
> +config SPL_LOAD_FIT_OPENSBI_OS_BOOT
> +       bool "Enable SPL (OpenSBI OS boot mode) applying linux from FIT"
> +       depends on SPL_LOAD_FIT
> +       help
> +         Use fw_dynamic from the FIT image, and u-boot SPL will invoke it directly.
> +         This is a shortcut boot flow, from u-boot SPL -> OpenSBI -> u-boot proper
> +         -> linux to u-boot SPL -> OpenSBI -> linux.

This bit seems OK

> +
>  config SPL_LOAD_FIT_CONFIG
>         string "Default FIT configuration for SPL"
> +       default "binman_linux.dtsi" if SPL_LOAD_FIT_OPENSBI_OS_BOOT

But I'm hoping you can drop this and put the logic in binman.dtsi

>         default "binman.dtsi"
>         depends on SPL_LOAD_FIT
>         help
> --
> 2.34.1
>

Regards,
Simon

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

* Re: [PATCH RESEND 5/7] spl: riscv: add os type for next booting stage
  2023-10-06 11:23 ` [PATCH RESEND 5/7] spl: riscv: add os type for next booting stage Randolph
@ 2023-10-07 23:09   ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2023-10-07 23:09 UTC (permalink / raw)
  To: randolph; +Cc: u-boot, randolph.sklin, dylan, tim609, peterlin

Hi Randolph,

On Fri, 6 Oct 2023 at 05:27, Randolph <randolph@andestech.com> wrote:
>
> If SPL_LOAD_FIT_OPENSBI_OS_BOOT is enabled, the function
> spl_invoke_opensbi should change the target OS type to IH_OS_LINUX.
> OpenSBI will load the Linux image as the next boot stage.
> The os_takes_devicetree function returns a value of true or false
> depending on whether or not SPL_LOAD_FIT_OPENSBI_OS_BOOT is enabled.
>
> Signed-off-by: Randolph <randolph@andestech.com>
> ---
>  common/spl/spl_fit.c     | 4 ++++
>  common/spl/spl_opensbi.c | 7 ++++++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index 730639f756..750562721a 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -351,7 +351,11 @@ static bool os_takes_devicetree(uint8_t os)
>         case IH_OS_U_BOOT:
>                 return true;
>         case IH_OS_LINUX:
> +#ifdef CONFIG_RISCV

Can you not set CONFIG_SPL_OS_BOOT in this case, and avoid this extra
condition? We really don't want arch-specific code in a generic file.

> +               return IS_ENABLED(CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT);
> +#else
>                 return IS_ENABLED(CONFIG_SPL_OS_BOOT);
> +#endif
>         default:
>                 return false;
>         }
> diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
> index a0c5f35dab..708869ad48 100644
> --- a/common/spl/spl_opensbi.c
> +++ b/common/spl/spl_opensbi.c
> @@ -58,9 +58,14 @@ void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image)
>
>         /*
>          * Find next os image in /fit-images
> -        * The next os image default is u-boot proper
> +        * The next os image default is u-boot proper, once enable
> +        * OpenSBI OS boot mode, the OS image should be linux.
>          */
> +#if CONFIG_IS_ENABLED(LOAD_FIT_OPENSBI_OS_BOOT)
> +       os_type = IH_OS_LINUX;
> +#else
>         os_type = IH_OS_U_BOOT;
> +#endif

Please use if().

>         ret = spl_opensbi_find_os_node(spl_image->fdt_addr, &os_node, os_type);
>         if (ret) {
>                 pr_err("Can't find %s node for opensbi, %d\n",
> --
> 2.34.1
>

Regards,
Simon

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

end of thread, other threads:[~2023-10-07 23:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-06 11:23 [PATCH RESEND 0/7] riscv: spl: OpenSBI OS boot mode Randolph
2023-10-06 11:23 ` [PATCH RESEND 1/7] riscv: dts: Introduce SPL_LOAD_FIT_CONFIG symbol Randolph
2023-10-07 23:09   ` Simon Glass
2023-10-06 11:23 ` [PATCH RESEND 2/7] riscv: dts: add binman_linux.dtsi for opensbi os boot mode Randolph
2023-10-07 23:09   ` Simon Glass
2023-10-06 11:23 ` [PATCH RESEND 3/7] spl: riscv: opensbi: change the default os_type as varible Randolph
2023-10-07 23:09   ` Simon Glass
2023-10-06 11:23 ` [PATCH RESEND 4/7] riscv: dts: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol Randolph
2023-10-07 23:09   ` Simon Glass
2023-10-06 11:23 ` [PATCH RESEND 5/7] spl: riscv: add os type for next booting stage Randolph
2023-10-07 23:09   ` Simon Glass
2023-10-06 11:23 ` [PATCH RESEND 6/7] andes: config: add riscv falcon mode for ae350 platform Randolph
2023-10-06 11:23 ` [PATCH RESEND 7/7] riscv: spl: andes: Move the DTB in front of kernel Randolph

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).