Skip to contentSkip to conversation

board: visionfive2: Select fdtfile based on revision

RFC PATCH In review Jami Kettunen 3 participants 7 messages Sep 11, 2023 – Sep 14, 2023

lore
Share & tools
lore
#0 lore raw

cover board: visionfive2: Select fdtfile based on revision

From: Jami Kettunen <[email protected]>

Currently booting a mainline Linux kernel via extlinux with fdtdir set doesn't load a proper DTB but passes on the U-Boot one to the kernel which as far as I know is very incorrect and prevents user (normally distro) provided DTB usage in a sensible/generic way.

A uEnv.txt or similar manual environment changes were not used and should not be required to boot the board as per:
https://u-boot.readthedocs.io/en/latest/develop/distro.html

This also currently needs a kernel patch[1] for my board to have the full 8GB of memory available to Linux instead of just 4GB it shows with these patches alone.

[1] https://gitlab.alpinelinux.org/nmeum/alpine-visionfive/-/blob/main/starfive/linux-starfive/set-8GB-RAM.patch

Jami Kettunen (2):
board: visionfive2: Select fdtfile based on revision
configs: visionfive2: Enable MISC_INIT_R

 .../visionfive2/starfive_visionfive2.c        | 25 +++++++++++++++++++
 configs/starfive_visionfive2_defconfig        |  1 +
 2 files changed, 26 insertions(+)
Signature · 1 line
2.42.0
#1 lore raw

RFC PATCH 1/2 board: visionfive2: Select fdtfile based on revision

From: Jami Kettunen <[email protected]>

Linux mainline kernel device tree files[1] are named:
- jh7110-starfive-visionfive-2-v1.2a
- jh7110-starfive-visionfive-2-v1.3b

which should be selected accordingly by U-Boot to have a proper extlinux experience with fdtdir set by the distribution.

[1] https://github.com/torvalds/linux/tree/master/arch/riscv/boot/dts/starfive

---
 .../visionfive2/starfive_visionfive2.c        | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
board/starfive/visionfive2/starfive_visionfive2.c +25 -0
index d609262b67..9244d4654b 100644
@@ -10,6 +10,8 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <linux/bitops.h>
+#include <asm/arch-jh7110/eeprom.h>
+#include <env.h>
 
 #define JH7110_L2_PREFETCHER_BASE_ADDR		0x2030000
 #define JH7110_L2_PREFETCHER_HART_OFFSET	0x2000
@@ -41,6 +43,29 @@ int board_init(void)
 	return 0;
 }
 
+int misc_init_r(void)
+{
+	u8 rev;
+	const char *linux_dtb_file;
+
+	rev = get_pcb_revision_from_eeprom();
+	switch (rev) {
+	case 'a':
+	case 'A':
+		linux_dtb_file = "starfive/jh7110-starfive-visionfive-2-v1.2a.dtb";
+		break;
+
+	case 'b':
+	case 'B':
+	default:
+		linux_dtb_file = "starfive/jh7110-starfive-visionfive-2-v1.3b.dtb";
+		break;
+	};
+
+	env_set("fdtfile", linux_dtb_file);
+	return 0;
+}
+
 void *board_fdt_blob_setup(int *err)
 {
 	*err = 0;
Signature · 1 line
2.42.0
Tested-by on v1 1/2
#2 lore raw
Quoted 6 lines · Jami Kettunen

From: Jami Kettunen <[email protected]>

Linux mainline kernel device tree files[1] are named:
- jh7110-starfive-visionfive-2-v1.2a
- jh7110-starfive-visionfive-2-v1.3b

Quoted 6 lines

which should be selected accordingly by U-Boot to have a proper extlinux experience with fdtdir set by the distribution.

[1] https://github.com/torvalds/linux/tree/master/arch/riscv/boot/dts/starfive

Quoted 47 lines
---
 .../visionfive2/starfive_visionfive2.c        | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
board/starfive/visionfive2/starfive_visionfive2.c +25 -0
index d609262b67..9244d4654b 100644
@@ -10,6 +10,8 @@
 #include <cpu_func.h>
 #include <dm.h>
 #include <linux/bitops.h>
+#include <asm/arch-jh7110/eeprom.h>
+#include <env.h>
 
 #define JH7110_L2_PREFETCHER_BASE_ADDR		0x2030000
 #define JH7110_L2_PREFETCHER_HART_OFFSET	0x2000
@@ -41,6 +43,29 @@ int board_init(void)
 	return 0;
 }
 
+int misc_init_r(void)
+{
+	u8 rev;
+	const char *linux_dtb_file;
+
+	rev = get_pcb_revision_from_eeprom();
+	switch (rev) {
+	case 'a':
+	case 'A':
+		linux_dtb_file = "starfive/jh7110-starfive-visionfive-2-v1.2a.dtb";
+		break;
+
+	case 'b':
+	case 'B':
+	default:
+		linux_dtb_file = "starfive/jh7110-starfive-visionfive-2-v1.3b.dtb";
+		break;
+	};
+
+	env_set("fdtfile", linux_dtb_file);
+	return 0;
+}
+
 void *board_fdt_blob_setup(int *err)
 {
 	*err = 0;
#3 lore raw

RFC PATCH 2/2 configs: visionfive2: Enable MISC_INIT_R

In reply to Jami Kettunen

From: Jami Kettunen <[email protected]>

Used to select mainline kernel fdtfile based on board revision.

---
 configs/starfive_visionfive2_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/starfive_visionfive2_defconfig +1 -0
index e9b63e5b84..33f9ec8ad6 100644
@@ -125,3 +125,4 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_PCI=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_MISC_INIT_R=y
Signature · 1 line
2.42.0
Tested-by on v1 2/2
#4 lore raw

Re: [PATCH RFC 2/2] configs: visionfive2: Enable MISC_INIT_R

Quoted 5 lines · Jami Kettunen

From: Jami Kettunen <[email protected]>

Used to select mainline kernel fdtfile based on board revision.

Quoted 13 lines
---
 configs/starfive_visionfive2_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/starfive_visionfive2_defconfig +1 -0
index e9b63e5b84..33f9ec8ad6 100644
@@ -125,3 +125,4 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_PCI=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_MISC_INIT_R=y
#5 lore raw
In reply to Jami Kettunen

Hello Jami,
For DDR size problem, I think we could enable CONFIG_OF_BOARD_SETUP, then use ft_board_setup() to apply fdt_fixup_memory()? Just like what they did in spl.c: https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Best regards,
Shengyu
(This mail is sent twice because the first one didn't use reply all)

Quoted 25 lines

From: Jami Kettunen <[email protected]>

Currently booting a mainline Linux kernel via extlinux with fdtdir set doesn't load a proper DTB but passes on the U-Boot one to the kernel which as far as I know is very incorrect and prevents user (normally distro) provided DTB usage in a sensible/generic way.

A uEnv.txt or similar manual environment changes were not used and should not be required to boot the board as per:
https://u-boot.readthedocs.io/en/latest/develop/distro.html

This also currently needs a kernel patch[1] for my board to have the full 8GB of memory available to Linux instead of just 4GB it shows with these patches alone.

[1] https://gitlab.alpinelinux.org/nmeum/alpine-visionfive/-/blob/main/starfive/linux-starfive/set-8GB-RAM.patch

Jami Kettunen (2):
board: visionfive2: Select fdtfile based on revision
configs: visionfive2: Enable MISC_INIT_R

.../visionfive2/starfive_visionfive2.c | 25 +++++++++++++++++++
configs/starfive_visionfive2_defconfig | 1 +

2 files changed, 26 insertions(+)
#6 lore raw
In reply to Jami Kettunen

Hello Jami,

I made a fix for memory size problem based on your series, but I can't try

that because I'm using 4GB version. Could you test this?

https://github.com/Headcrabed/u-boot/tree/ddr_fix_v1

Best regards,

Shengyu

Quoted 25 lines

From: Jami Kettunen <[email protected]>

Currently booting a mainline Linux kernel via extlinux with fdtdir set doesn't load a proper DTB but passes on the U-Boot one to the kernel which as far as I know is very incorrect and prevents user (normally distro) provided DTB usage in a sensible/generic way.

A uEnv.txt or similar manual environment changes were not used and should not be required to boot the board as per:
https://u-boot.readthedocs.io/en/latest/develop/distro.html

This also currently needs a kernel patch[1] for my board to have the full 8GB of memory available to Linux instead of just 4GB it shows with these patches alone.

[1] https://gitlab.alpinelinux.org/nmeum/alpine-visionfive/-/blob/main/starfive/linux-starfive/set-8GB-RAM.patch

Jami Kettunen (2):
board: visionfive2: Select fdtfile based on revision
configs: visionfive2: Enable MISC_INIT_R

  .../visionfive2/starfive_visionfive2.c        | 25 +++++++++++++++++++
  configs/starfive_visionfive2_defconfig        |  1 +
  2 files changed, 26 insertions(+)