Skip to contentSkip to conversation

beaglev: enable opensbi generic platform

PATCH New Drew Fustini 2 participants 9 messages Jun 16, 2021 – Jul 18, 2021

lore
Share & tools
lore
#0 lore raw

v2 cover beaglev: enable opensbi generic platform

Introduce BR2_TARGET_UBOOT_FORMAT_DTB to copy u-boot.dtb [1] to BINARIES_DIR. This file can be used for FW_FDT_PATH [2] in OpenSBI build when BR2_TARGET_OPENSBI_FW_FDT_PATH is enabled.

Update U-Boot in beaglev_defconfig to new commit in starfive-tech repo which enables CONFIG_OF_SEPARATE to build u-boot.dtb [3]. Finally switch to upstream OpenSBI repo and use generic platform now that it supports the console UART [4] on the BeagleV Starlight JH7100 board.

[1] https://github.com/lentinj/u-boot/blob/master/doc/README.fdt-control
[2] https://github.com/riscv/opensbi/blob/master/docs/firmware/fw.md
[3] https://github.com/u-boot/u-boot/blob/master/doc/README.fdt-control
[4] https://github.com/riscv/opensbi/commit/e822b7504df0583a6a227d51cb7da8ea9fc79c0a

v2 fixes:
- correct spelling to "U-Boot"
- correct URL for README.fdt-control to U-Boot repo instead of fork
- added Reviewed-by: for Bin Meng and Alistair Francis

Drew Fustini (4):
boot/uboot: introduce BR2_TARGET_UBOOT_FORMAT_DTB boot/opensbi: introduce BR2_TARGET_OPENSBI_FW_FDT_PATH configs/beaglev: update U-Boot to enable OF_SEPARATE configs/beaglev: switch to upstream opensbi generic platform

 boot/opensbi/Config.in    | 10 ++++++++++
 boot/opensbi/opensbi.mk   |  3 +++
 boot/uboot/Config.in      |  3 +++
 boot/uboot/uboot.mk       |  4 ++++
 configs/beaglev_defconfig | 10 ++++++----
 5 files changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH v2 1/4 boot/uboot: introduce BR2_TARGET_UBOOT_FORMAT_DTB

If U-Boot CONFIG_OF_SEPARATE is defined [1], then the device tree will be built and placed in a u-boot.dtb file alongside u-boot.bin.

When BR2_TARGET_UBOOT_FORMAT_DTB is enabled, buildroot will copy u-boot.dtb to $(BINARIES_DIR).

This is useful for RISC-V platforms that want to build OpenSBI with an external DTB by using FW_FDT_PATH [2].

[1] https://github.com/u-boot/u-boot/blob/master/doc/README.fdt-control
[2] https://github.com/riscv/opensbi/blob/master/docs/firmware/fw.md

---
 boot/uboot/Config.in | 3 +++
 boot/uboot/uboot.mk  | 4 ++++
 2 files changed, 7 insertions(+)
boot/uboot/Config.in +3 -0
index 00c667412006..44a16d892a60 100644
@@ -252,6 +252,9 @@ config BR2_TARGET_UBOOT_FORMAT_BIN
 	bool "u-boot.bin"
 	default y
 
+config BR2_TARGET_UBOOT_FORMAT_DTB
+	bool "u-boot.dtb"
+
 config BR2_TARGET_UBOOT_FORMAT_DTB_BIN
 	bool "u-boot-dtb.bin"
 
boot/uboot/uboot.mk +4 -0
index dbe82e65b17e..923fd0c1d46c 100644
@@ -48,6 +48,10 @@ ifeq ($(BR2_TARGET_UBOOT_FORMAT_BIN),y)
 UBOOT_BINS += u-boot.bin
 endif
 
+ifeq ($(BR2_TARGET_UBOOT_FORMAT_DTB),y)
+UBOOT_BINS += u-boot.dtb
+endif
+
 ifeq ($(BR2_TARGET_UBOOT_FORMAT_ELF),y)
 UBOOT_BINS += u-boot
 # To make elf usable for debuging on ARC use special target
Signature · 1 line
2.27.0
#2 lore raw

PATCH v2 1/4 boot/uboot: introduce BR2_TARGET_UBOOT_FORMAT_DTB

Quoted 12 lines · On Tue, 15 Jun 2021 22:03:39 -0700 Drew Fustini <[email protected]> wrote:

If U-Boot CONFIG_OF_SEPARATE is defined [1], then the device tree will be built and placed in a u-boot.dtb file alongside u-boot.bin.

When BR2_TARGET_UBOOT_FORMAT_DTB is enabled, buildroot will copy u-boot.dtb to $(BINARIES_DIR).

This is useful for RISC-V platforms that want to build OpenSBI with an external DTB by using FW_FDT_PATH [2].

[1] https://github.com/u-boot/u-boot/blob/master/doc/README.fdt-control
[2] https://github.com/riscv/opensbi/blob/master/docs/firmware/fw.md

Quoted 7 lines
---
 boot/uboot/Config.in | 3 +++
 boot/uboot/uboot.mk  | 4 ++++
 2 files changed, 7 insertions(+)

This new option is not exactly another U-Boot format, u-boot.dtb does not include the U-Boot code itself. But oh well, your solution is very simple, and fits well with what already exists, so I've applied.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH v2 2/4 boot/opensbi: introduce BR2_TARGET_OPENSBI_FW_FDT_PATH

In reply to Drew Fustini

If U-Boot CONFIG_OF_SEPARATE is defined [1], then the device tree will be built and placed in a u-boot.dtb file alongside u-boot.bin.

When BR2_TARGET_UBOOT_FORMAT_DTB is enabled, buildroot will copy u-boot.dtb to $(BINARIES_DIR).

This is useful for RISC-V platforms that want to build OpenSBI with an external DTB by using FW_FDT_PATH [2].

[1] https://github.com/u-boot/u-boot/blob/master/doc/README.fdt-control
[2] https://github.com/riscv/opensbi/blob/master/docs/firmware/fw.md

---
 boot/opensbi/Config.in  | 10 ++++++++++
 boot/opensbi/opensbi.mk |  3 +++
 2 files changed, 13 insertions(+)
boot/opensbi/Config.in +10 -0
index 632eeec88d77..bd4bd5ee6175 100644
@@ -109,4 +109,14 @@ config BR2_TARGET_OPENSBI_UBOOT_PAYLOAD
 	help
 	  Build OpenSBI with the U-Boot as a Payload.
 
+config BR2_TARGET_OPENSBI_FW_FDT_PATH
+	bool "Include U-Boot DTB in OpenSBI Payload"
+	depends on BR2_TARGET_OPENSBI_PLAT != ""
+	depends on BR2_TARGET_UBOOT
+	depends on BR2_TARGET_OPENSBI_UBOOT_PAYLOAD
+	select BR2_TARGET_OPENSBI_INSTALL_PAYLOAD_IMG
+	help
+	  Build OpenSBI with FW_FDT_PATH set to $(BINARIES_DIR)/u-boot.dtb
+	  Note that CONFIG_OF_SEPARATE must be set in the u-boot kconfig.
+
 endif
boot/opensbi/opensbi.mk +3 -0
index a525b8aea348..8e055633a82d 100644
@@ -46,6 +46,9 @@ endif
 ifeq ($(BR2_TARGET_OPENSBI_UBOOT_PAYLOAD),y)
 OPENSBI_DEPENDENCIES += uboot
 OPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/u-boot.bin"
+ifeq ($(BR2_TARGET_OPENSBI_FW_FDT_PATH),y)
+OPENSBI_MAKE_ENV += FW_FDT_PATH="$(BINARIES_DIR)/u-boot.dtb"
+endif
 endif
 
 define OPENSBI_BUILD_CMDS
Signature · 1 line
2.27.0
#4 lore raw

PATCH v2 2/4 boot/opensbi: introduce BR2_TARGET_OPENSBI_FW_FDT_PATH

Hello,

boot/opensbi/Config.in config BR2_TARGET_OPENSBI_UBOOT_PAYLOAD · line 115

Quoted 4 lines · On Tue, 15 Jun 2021 22:03:41 -0700 Drew Fustini <[email protected]> wrote:
boot/opensbi/Config.in +4 -0
+config BR2_TARGET_OPENSBI_FW_FDT_PATH
+	bool "Include U-Boot DTB in OpenSBI Payload"
+	depends on BR2_TARGET_OPENSBI_PLAT != ""
+	depends on BR2_TARGET_UBOOT

Both of these were not needed, as they are already part of BR2_TARGET_OPENSBI_UBOOT_PAYLOAD, which you depend on.

boot/opensbi/Config.in config BR2_TARGET_OPENSBI_UBOOT_PAYLOAD · line 117

Quoted 2 lines
boot/opensbi/Config.in +2 -0
+	depends on BR2_TARGET_OPENSBI_UBOOT_PAYLOAD
+	select BR2_TARGET_OPENSBI_INSTALL_PAYLOAD_IMG

This select was not needed, as it's already done by BR2_TARGET_OPENSBI_UBOOT_PAYLOAD, which you depend on.

However, I've added a "select BR2_TARGET_UBOOT_FORMAT_DTB" to make sure u-boot.dtb gets installed in BINARIES_DIR.

Applied with those changes.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH v2 3/4 configs/beaglev: update U-Boot to enable OF_SEPARATE

In reply to Drew Fustini

Update commit ID of U-Boot to latest commit in starfive-tech repo [1] which enables OF_SEPARATE [2].

[1] https://github.com/starfive-tech/u-boot/tree/Fedora_VIC_7100_2021.04
[2] https://github.com/starfive-tech/u-boot/commit/64ead5b83959da8eb87b6963843addf5942e6ed4

---
 configs/beaglev_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/beaglev_defconfig +1 -1
index 895902a11a7c..fcbea2cdec86 100644
@@ -33,7 +33,7 @@ BR2_TARGET_UBOOT=y
 BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
 BR2_TARGET_UBOOT_CUSTOM_TARBALL=y
 # HEAD of the starfive-tech:Fedora_VIC_7100_2021.04 branch
-BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION="$(call github,starfive-tech,u-boot,494e5ef7b8071d0b2fba50616d97771e44cbcb7c)/uboot-494e5ef7b8071d0b2fba50616d97771e44cbcb7c.tar.gz"
+BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION="$(call github,starfive-tech,u-boot,64ead5b83959da8eb87b6963843addf5942e6ed4)/uboot-64ead5b83959da8eb87b6963843addf5942e6ed4.tar.gz"
 BR2_TARGET_UBOOT_BOARD_DEFCONFIG="starfive_vic7100_beagle_v_smode"
 BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_JH71XX_TOOLS=y
Signature · 1 line
2.27.0
#6 lore raw

PATCH v2 3/4 configs/beaglev: update U-Boot to enable OF_SEPARATE

Quoted 6 lines · On Tue, 15 Jun 2021 22:03:43 -0700 Drew Fustini <[email protected]> wrote:

Update commit ID of U-Boot to latest commit in starfive-tech repo [1] which enables OF_SEPARATE [2].

[1] https://github.com/starfive-tech/u-boot/tree/Fedora_VIC_7100_2021.04
[2] https://github.com/starfive-tech/u-boot/commit/64ead5b83959da8eb87b6963843addf5942e6ed4

Quoted 6 lines
---
 configs/beaglev_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw

PATCH v2 4/4 configs/beaglev: switch to upstream opensbi generic platform

In reply to Drew Fustini

Switch from the starfive-tech opensbi to upstream repo and use generic platform now that it supports the console uart [1]. This landed after the 0.9 release [2], so the current head of master branch is used [3].

FW_FDT_PATH is set to u-boot.dtb so that the device tree from U-Boot will be included in the OpenSBI build [4]. Note that U-Boot must have CONFIG_OF_SEPARATE enabled for U-Boot to build u-boot.dtb [5].

[1] https://github.com/riscv/opensbi/commit/e822b7504df0583a6a227d51cb7da8ea9fc79c0a
[2] https://github.com/riscv/opensbi/commit/234ed8e427f4d92903123199f6590d144e0d9351
[3] https://github.com/riscv/opensbi/commit/79f9b4220ffa7f74356054be25d450d7958bf16c
[4] https://github.com/riscv/opensbi/blob/master/docs/firmware/fw.md
[5] https://github.com/u-boot/u-boot/blob/master/doc/README.fdt-control

---
 configs/beaglev_defconfig | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
configs/beaglev_defconfig +5 -3
index fcbea2cdec86..29e3a52be36c 100644
@@ -23,17 +23,19 @@ BR2_TARGET_BEAGLEV_DDRINIT=y
 BR2_TARGET_BEAGLEV_SECONDBOOT=y
 BR2_TARGET_OPENSBI=y
 BR2_TARGET_OPENSBI_CUSTOM_TARBALL=y
-# HEAD of the Fedora branch
-BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION="$(call github,starfive-tech,opensbi,2524b0ecd8684b42bc7a4c69794f40f11cbbe2a5)/opensbi-2524b0ecd8684b42bc7a4c69794f40f11cbbe2a5.tar.gz"
-BR2_TARGET_OPENSBI_PLAT="starfive/vic7100"
+# upstream opensbi master branch
+BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION="$(call github,riscv,opensbi,79f9b4220ffa7f74356054be25d450d7958bf16c)/opensbi-79f9b4220ffa7f74356054be25d450d7958bf16c.tar.gz"
+BR2_TARGET_OPENSBI_PLAT="generic"
 # BR2_TARGET_OPENSBI_INSTALL_DYNAMIC_IMG is not set
 # BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set
 BR2_TARGET_OPENSBI_UBOOT_PAYLOAD=y
+BR2_TARGET_OPENSBI_FW_FDT_PATH=y
 BR2_TARGET_UBOOT=y
 BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
 BR2_TARGET_UBOOT_CUSTOM_TARBALL=y
 # HEAD of the starfive-tech:Fedora_VIC_7100_2021.04 branch
 BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION="$(call github,starfive-tech,u-boot,64ead5b83959da8eb87b6963843addf5942e6ed4)/uboot-64ead5b83959da8eb87b6963843addf5942e6ed4.tar.gz"
 BR2_TARGET_UBOOT_BOARD_DEFCONFIG="starfive_vic7100_beagle_v_smode"
+BR2_TARGET_UBOOT_FORMAT_DTB=y
 BR2_PACKAGE_HOST_GENIMAGE=y
 BR2_PACKAGE_HOST_JH71XX_TOOLS=y
Signature · 1 line
2.27.0
#8 lore raw

PATCH v2 4/4 configs/beaglev: switch to upstream opensbi generic platform

Quoted 4 lines · On Tue, 15 Jun 2021 22:03:45 -0700 Drew Fustini <[email protected]> wrote:
configs/beaglev_defconfig +3 -0
+# upstream opensbi master branch
+BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION="$(call github,riscv,opensbi,79f9b4220ffa7f74356054be25d450d7958bf16c)/opensbi-79f9b4220ffa7f74356054be25d450d7958bf16c.tar.gz"
+BR2_TARGET_OPENSBI_PLAT="generic"
 # BR2_TARGET_OPENSBI_INSTALL_DYNAMIC_IMG is not set

configs/beaglev_defconfig BR2_TARGET_BEAGLEV_DDRINIT=y · line 39

Quoted 10 lines
configs/beaglev_defconfig +2 -0
 # BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set
 BR2_TARGET_OPENSBI_UBOOT_PAYLOAD=y
+BR2_TARGET_OPENSBI_FW_FDT_PATH=y
 BR2_TARGET_UBOOT=y
 BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
 BR2_TARGET_UBOOT_CUSTOM_TARBALL=y
 # HEAD of the starfive-tech:Fedora_VIC_7100_2021.04 branch
 BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION="$(call github,starfive-tech,u-boot,64ead5b83959da8eb87b6963843addf5942e6ed4)/uboot-64ead5b83959da8eb87b6963843addf5942e6ed4.tar.gz"
 BR2_TARGET_UBOOT_BOARD_DEFCONFIG="starfive_vic7100_beagle_v_smode"
+BR2_TARGET_UBOOT_FORMAT_DTB=y

This was no longer needed in the defconfig, as it is now implied by BR2_TARGET_OPENSBI_FW_FDT_PATH=y.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com