u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Randolph <randolph@andestech.com>
To: <u-boot@lists.denx.de>
Cc: <randolph.sklin@gmail.com>, <dylan@andestech.com>,
	<tim609@andestech.com>,  <peterlin@andestech.com>,
	Randolph <randolph@andestech.com>
Subject: [PATCH RESEND 7/7] riscv: spl: andes: Move the DTB in front of kernel
Date: Fri, 6 Oct 2023 19:23:51 +0800	[thread overview]
Message-ID: <20231006112351.2275090-8-randolph@andestech.com> (raw)
In-Reply-To: <20231006112351.2275090-1-randolph@andestech.com>

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


      parent reply	other threads:[~2023-10-06 11:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Randolph [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231006112351.2275090-8-randolph@andestech.com \
    --to=randolph@andestech.com \
    --cc=dylan@andestech.com \
    --cc=peterlin@andestech.com \
    --cc=randolph.sklin@gmail.com \
    --cc=tim609@andestech.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).