Skip to contentSkip to conversation

boot/opensbi: Add support for including Linux payload

PATCH New Alistair Francis 4 participants 6 messages Jul 22, 2019 – Aug 6, 2019 SiFive drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 boot/opensbi: Add support for including Linux payload

---
 boot/opensbi/Config.in  | 10 ++++++++++
 boot/opensbi/opensbi.mk | 26 +++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 5 deletions(-)
boot/opensbi/Config.in +10 -0
index 5f3cc13312..686aac8798 100644
@@ -22,4 +22,14 @@ config BR2_TARGET_OPENSBI_PLAT
 	  library libsbi.a is built. If a platform is specified then
 	  the platform specific static library libplatsbi.a and firmware
 	  examples are built.
+
+if BR2_TARGET_OPENSBI_PLAT != ""
+config BR2_TARGET_OPENSBI_LINUX_PAYLOAD
+	bool "Include Linux as OpenSBI Payload"
+	depends on BR2_LINUX_KERNEL
+	depends on BR2_LINUX_KERNEL_IMAGE
+	depends on !BR2_TARGET_OPENSBI_LIBRARY_ONLY
+	help
+	  Build OpenSBI with the Linux kernel as a Payload.
+endif
 endif
boot/opensbi/opensbi.mk +21 -5
index 83552a5442..14657cac06 100644
@@ -19,19 +19,35 @@ ifneq ($(OPENSBI_PLAT),)
 OPENSBI_MAKE_ENV += PLATFORM=$(OPENSBI_PLAT)
 endif
 
+OPENSBI_LINUX_PAYLOAD = $(call qstrip,$(BR2_TARGET_OPENSBI_LINUX_PAYLOAD))
+ifeq ($(OPENSBI_LINUX_PAYLOAD), y)
+OPENSBI_DEPENDENCIES = linux
+OPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/Image"
+endif
+
 define OPENSBI_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(OPENSBI_MAKE_ENV) $(MAKE) -C $(@D)
 endef
 
 ifneq ($(OPENSBI_PLAT),)
 OPENSBI_INSTALL_IMAGES = YES
+OPENSBI_INSTALL_IMAGES_CMDS_PLAT = \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.bin $(BINARIES_DIR)/fw_dynamic.bin; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.elf $(BINARIES_DIR)/fw_dynamic.elf;
+endif
+
+ifeq ($(OPENSBI_LINUX_PAYLOAD), y)
+OPENSBI_INSTALL_IMAGES_CMDS_PAYLOAD = \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_payload.bin $(BINARIES_DIR)/fw_payload.bin; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_payload.elf $(BINARIES_DIR)/fw_payload.elf;
+endif
+
 define OPENSBI_INSTALL_IMAGES_CMDS
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.bin $(BINARIES_DIR)/fw_dynamic.bin
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.elf $(BINARIES_DIR)/fw_dynamic.elf
+	$(OPENSBI_INSTALL_IMAGES_CMDS_PLAT)
+	$(OPENSBI_INSTALL_IMAGES_CMDS_PAYLOAD)
 endef
-endif
 
 # libsbi.a is not a library meant to be linked in user-space code, but
 # with bare metal code, which is why we don't install it in
Signature · 1 line
2.22.0
#1 lore raw

PATCH v2 2/2 board/sifive: Add the HiFive Unleased

This patch adds support for the HiFive Unleashed board. This includes building the firmware, kernel and rootFS for the HiFive Unleased.

This patch includes a post-image.sh script and genimage.cfg file used to generate a sdcard image that can be dd-ed to an SD card.

The manual steps are useful even when genimage works as users won't always need to flash the entire SD card. For example a kernel update will only require one partition being updated manually via dd instead of a full reflash.

---
 DEVELOPERS                                    |   2 +
 board/sifive/hifive_unleased/genimage.cfg     |  17 +++
 .../hifive_unleased/linux.config.fragment     |  16 +++
 board/sifive/hifive_unleased/post-image.sh    |   9 ++
 board/sifive/hifive_unleased/readme.txt       | 103 ++++++++++++++++++
 configs/hifive_unleashed_defconfig            |  39 +++++++
 6 files changed, 186 insertions(+)
 create mode 100644 board/sifive/hifive_unleased/genimage.cfg
 create mode 100644 board/sifive/hifive_unleased/linux.config.fragment
 create mode 100755 board/sifive/hifive_unleased/post-image.sh
 create mode 100644 board/sifive/hifive_unleased/readme.txt
 create mode 100644 configs/hifive_unleashed_defconfig
DEVELOPERS +2 -0
index 4ab4e36593..dd15ea2cb7 100644
@@ -123,7 +123,9 @@ F:	package/kvazaar/
 F:	package/v4l2loopback/
 
 N:	Alistair Francis <[email protected]>
+F:	board/sifive/
 F:	boot/opensbi/
+F:	configs/hifive_unleashed_defconfig
 F:	package/xen/
 
 N:	Alvaro G. M <[email protected]>
board/sifive/hifive_unleased/genimage.cfg new file +17 -0
new file mode 100644
index 0000000000..8eebc52355
@@ -0,0 +1,17 @@
+image sdcard.img {
+	hdimage {
+		gpt = true
+	}
+
+	partition bootloader {
+		image = "fw_payload.bin"
+		offset = 1M
+		size = 32M
+		partition-type-uuid = 2E54B353-1271-4842-806F-E436D6AF6985
+	}
+
+	partition rootfs {
+		image = "rootfs.ext4"
+		partition-type-uuid = 0FC63DAF-8483-4772-8E79-3D69D8477DE4
+	}
+}
board/sifive/hifive_unleased/linux.config.fragment new file +16 -0
new file mode 100644
index 0000000000..f4f384088a
@@ -0,0 +1,16 @@
+CONFIG_HZ_100=y
+CONFIG_CMDLINE="earlycon=sbi root=/dev/mmcblk0p2 rootwait"
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_SERIAL_SIFIVE=y
+CONFIG_SERIAL_SIFIVE_CONSOLE=y
+CONFIG_SPI=y
+CONFIG_SPI_SIFIVE=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_SIFIVE=y
+CONFIG_MMC=y
+CONFIG_MMC_SPI=y
+CONFIG_CLK_U54_PRCI=y
+CONFIG_CLK_GEMGXL_MGMT=y
+CONFIG_PWM=y
+CONFIG_PWM_SIFIVE=y
board/sifive/hifive_unleased/post-image.sh new file +9 -0
new file mode 100755
index 0000000000..2051ee49cb
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Script to generate a SD card image for the HiFive Unleashed.
+
+# We need to make sure that this is updated
+make opensbi-rebuild
+
+support/scripts/genimage.sh -c board/sifive/hifive_unleased/genimage.cfg
+
board/sifive/hifive_unleased/readme.txt new file +103 -0

103 lines not on this page · raw message

configs/hifive_unleashed_defconfig new file +39 -0
new file mode 100644
index 0000000000..83cb33d3da
@@ -0,0 +1,39 @@
+# Architecture
+BR2_riscv=y
+BR2_riscv_custom=y
+BR2_RISCV_ISA_CUSTOM_RVM=y
+BR2_RISCV_ISA_CUSTOM_RVF=y
+BR2_RISCV_ISA_CUSTOM_RVD=y
+BR2_RISCV_ISA_CUSTOM_RVC=y
+BR2_RISCV_64=y
+BR2_RISCV_ABI_LP64D=y
+
+# System
+BR2_SYSTEM_DHCP="eth0"
+BR2_TARGET_GENERIC_GETTY=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttySIF0"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/sifive/hifive_unleased/post-image.sh"
+
+# Filesystem
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+
+# Linux headers same as kernel, a 5.1 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_1=y
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/alistair23/linux.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="hifive-unleashed-5.1"
+BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
+BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/sifive/hifive_unleased/linux.config.fragment"
+BR2_LINUX_KERNEL_IMAGE=y
+
+# Bootloader
+BR2_TARGET_OPENSBI=y
+BR2_TARGET_OPENSBI_PLAT="sifive/fu540"
+BR2_TARGET_OPENSBI_LINUX_PAYLOAD=y
+
+# Host tools
+BR2_PACKAGE_HOST_GENIMAGE=y
Signature · 1 line
2.22.0
#2 lore raw

PATCH v2 2/2 board/sifive: Add the HiFive Unleased

Hello Alistair,

The commit title should have been:

configs/hifive_unleashed: new defconfig

Quoted 10 lines · On Mon, 22 Jul 2019 13:44:47 -0700 Alistair Francis <[email protected]>…

This patch adds support for the HiFive Unleashed board. This includes building the firmware, kernel and rootFS for the HiFive Unleased.

This patch includes a post-image.sh script and genimage.cfg file used to generate a sdcard image that can be dd-ed to an SD card.

The manual steps are useful even when genimage works as users won't always need to flash the entire SD card. For example a kernel update will only require one partition being updated manually via dd instead of a full reflash.

Documenting such manual steps is not very useful in readme.txt. readme.txt is only meant as a very introductory document on how to use the image produced by Buildroot. More advanced use-cases cannot all be documented in readme.txt files, so I dropped that part from readme.txt.

board/sifive/hifive_unleased/genimage.cfg

Quoted 2 lines

N: Alvaro G. M <[email protected]>

board/sifive/hifive_unleased/genimage.cfg +0 -0

The folder board/sifive/hifive_unleased/ had a typo: unleased -> unleashed. This typo was also in the title of your commit.

board/sifive/hifive_unleased/post-image.sh line 6

Quoted 12 lines
board/sifive/hifive_unleased/post-image.sh new file +6 -0
new file mode 100755
index 0000000000..2051ee49cb
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Script to generate a SD card image for the HiFive Unleashed.
+
+# We need to make sure that this is updated
+make opensbi-rebuild

This is not necessary: at the end of a build, opensbi will have been built after linux, so it's updated. It's only if you later change the linux configuration again that you need to regenerate the opensbi package. Buildroot only guarantees that a build output is correct for completely clean builds, so I dropped this. This makes the post-image.sh script useless, because we can use support/scripts/genimage.sh.

I fixed those different aspects, and merged the patch. See the final commit at:

https://git.buildroot.org/buildroot/commit/?id=86531fae3e3c7ea59430cd0f86260d20fafa9b16

Thanks!

Thomas

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

PATCH v2 1/2 boot/opensbi: Add support for including Linux payload

In reply to Alistair Francis

Allistair, All,

On 2019-07-22 13:44 -0700, Alistair Francis spake thusly:

Quoted 1 line

[--SNIP--]

boot/opensbi/opensbi.mk ifneq ($(OPENSBI_PLAT),) · line 26

Quoted 13 lines
boot/opensbi/opensbi.mk +5 -0
index 83552a5442..14657cac06 100644
@@ -19,19 +19,35 @@ ifneq ($(OPENSBI_PLAT),)
 OPENSBI_MAKE_ENV += PLATFORM=$(OPENSBI_PLAT)
 endif
 
+OPENSBI_LINUX_PAYLOAD = $(call qstrip,$(BR2_TARGET_OPENSBI_LINUX_PAYLOAD))
+ifeq ($(OPENSBI_LINUX_PAYLOAD), y)
+OPENSBI_DEPENDENCIES = linux
+OPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/Image"
+endif

In Kconfig, OPENSBI_LINUX_PAYLOAD is conditional to OPENSBI_PLAT != "" so I would expect to see the same layout in the .mk (see below for what I mean).

Quoted 8 lines
boot/opensbi/opensbi.mk +2 -0
 define OPENSBI_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(OPENSBI_MAKE_ENV) $(MAKE) -C $(@D)
 endef
 
 ifneq ($(OPENSBI_PLAT),)
 OPENSBI_INSTALL_IMAGES = YES
+OPENSBI_INSTALL_IMAGES_CMDS_PLAT = \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin; \

boot/opensbi/opensbi.mk ifneq ($(OPENSBI_PLAT),) · line 45

Quoted 10 lines
boot/opensbi/opensbi.mk +10 -0
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.bin $(BINARIES_DIR)/fw_dynamic.bin; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.elf $(BINARIES_DIR)/fw_dynamic.elf;
+endif
+
+ifeq ($(OPENSBI_LINUX_PAYLOAD), y)
+OPENSBI_INSTALL_IMAGES_CMDS_PAYLOAD = \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_payload.bin $(BINARIES_DIR)/fw_payload.bin; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_payload.elf $(BINARIES_DIR)/fw_payload.elf;
+endif

Why can't we have something like (untested):

    OPENSBI_FW_DIR = $(@D)/build/platform/$(OPENSBI_PLAT)/firmware

    ifneq ($(OPENSBI_PLAT),)
    OPENSBI_FW_FILES = fw_jump.bin fw_jump.elf fw_dynamic.bin fw_dynamic.elf
    ifeq ($(OPENSBI_LINUX_PAYLOAD),y)
    OPENSBI_FW_FILES += fw_jump.bin fw_jump.elf fw_dynamic.bin fw_dynamic.elf
    endif
    endif

    define OPENSBI_INSTALL_IMAGES_CMDS
        $(foreach fw,$(OPENSBI_FW_FILES), \
            $(INSTALL) -m 0644 -D $(OPENSBI_FW_DIR)/$(fw) $(BINARIES_DIR)/$(fw)
        )
    endef

(notice also how OPENSBI_LINUX_PAYLOAD is inside the OPENSBI_PLAT != "" block, like it is in Config.in.)

Regards,
Yann E. MORIN.

Quoted 19 lines
boot/opensbi/opensbi.mk +2 -5
 define OPENSBI_INSTALL_IMAGES_CMDS
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.bin $(BINARIES_DIR)/fw_dynamic.bin
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.elf $(BINARIES_DIR)/fw_dynamic.elf
+	$(OPENSBI_INSTALL_IMAGES_CMDS_PLAT)
+	$(OPENSBI_INSTALL_IMAGES_CMDS_PAYLOAD)
 endef
-endif
 
 # libsbi.a is not a library meant to be linked in user-space code, but
 # with bare metal code, which is why we don't install it in
Signature · 6 lines
2.22.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH v2 1/2 boot/opensbi: Add support for including Linux payload

In reply to Alistair Francis

Hello,

Quoted 1 line · On Mon, 22 Jul 2019 13:44:46 -0700 Alistair Francis <[email protected]>…

+if BR2_TARGET_OPENSBI_PLAT != ""

I move this if to a simple "depends on" under the
BR2_TARGET_OPENSBI_LINUX_PAYLOAD optio.

boot/opensbi/Config.in config BR2_TARGET_OPENSBI_PLAT · line 31

Quoted 5 lines
boot/opensbi/Config.in +5 -0
+config BR2_TARGET_OPENSBI_LINUX_PAYLOAD
+	bool "Include Linux as OpenSBI Payload"
+	depends on BR2_LINUX_KERNEL
+	depends on BR2_LINUX_KERNEL_IMAGE
+	depends on !BR2_TARGET_OPENSBI_LIBRARY_ONLY

This option doesn't exist anywhere, so I dropped this depends on.

Quoted 1 line

+OPENSBI_LINUX_PAYLOAD = $(call qstrip,$(BR2_TARGET_OPENSBI_LINUX_PAYLOAD))

qstrip is only useful for string options. For boolean options, it's useless, so I dropped this and simply used BR2_TARGET_OPENSBI_LINUX_PAYLOAD everywhere.

Quoted 1 line

+ifeq ($(OPENSBI_LINUX_PAYLOAD), y)

No space before "y".

Quoted 1 line

+OPENSBI_DEPENDENCIES = linux

+= for this addition, so that we don't mistakenly overwrite any previous dependency that might have been added.

Quoted 19 lines
boot/opensbi/opensbi.mk +13 -0
+OPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/Image"
+endif
+
 define OPENSBI_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(OPENSBI_MAKE_ENV) $(MAKE) -C $(@D)
 endef
 
 ifneq ($(OPENSBI_PLAT),)
 OPENSBI_INSTALL_IMAGES = YES
+OPENSBI_INSTALL_IMAGES_CMDS_PLAT = \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.bin $(BINARIES_DIR)/fw_dynamic.bin; \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.elf $(BINARIES_DIR)/fw_dynamic.elf;
+endif
+
+ifeq ($(OPENSBI_LINUX_PAYLOAD), y)
+OPENSBI_INSTALL_IMAGES_CMDS_PAYLOAD = \
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_payload.bin $(BINARIES_DIR)/fw_payload.bin; \

boot/opensbi/opensbi.mk ifneq ($(OPENSBI_PLAT),) · line 49

Quoted 10 lines
boot/opensbi/opensbi.mk +5 -4
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_payload.elf $(BINARIES_DIR)/fw_payload.elf;
+endif
+
 define OPENSBI_INSTALL_IMAGES_CMDS
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.bin $(BINARIES_DIR)/fw_dynamic.bin
-	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.elf $(BINARIES_DIR)/fw_dynamic.elf
+	$(OPENSBI_INSTALL_IMAGES_CMDS_PLAT)
+	$(OPENSBI_INSTALL_IMAGES_CMDS_PAYLOAD)

As suggested by Yann, I've refactored all of that with a loop over a OPENSBI_FW_IMAGES variable that contains jump, dynamic and optionally payload.

I fixed up these different aspects, and merged the patch. See the final commit at:

https://git.buildroot.org/buildroot/commit/?id=9b5b7165deb91bad3cdb1ea0dd8f940eff75f3a9

Thanks!

Thomas

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

PATCH v2 1/2 boot/opensbi: Add support for including Linux payload

Quoted 68 lines · Thomas Petazzoni

Hello,

Quoted 1 line · On Mon, 22 Jul 2019 13:44:46 -0700 Alistair Francis <[email protected]>…

+if BR2_TARGET_OPENSBI_PLAT != ""

I move this if to a simple "depends on" under the
BR2_TARGET_OPENSBI_LINUX_PAYLOAD optio.

boot/opensbi/Config.in config BR2_TARGET_OPENSBI_PLAT · line 31

Quoted 5 lines
boot/opensbi/Config.in +5 -0
+config BR2_TARGET_OPENSBI_LINUX_PAYLOAD
+     bool "Include Linux as OpenSBI Payload"
+     depends on BR2_LINUX_KERNEL
+     depends on BR2_LINUX_KERNEL_IMAGE
+     depends on !BR2_TARGET_OPENSBI_LIBRARY_ONLY

This option doesn't exist anywhere, so I dropped this depends on.

Quoted 1 line

+OPENSBI_LINUX_PAYLOAD = $(call qstrip,$(BR2_TARGET_OPENSBI_LINUX_PAYLOAD))

qstrip is only useful for string options. For boolean options, it's useless, so I dropped this and simply used BR2_TARGET_OPENSBI_LINUX_PAYLOAD everywhere.

Quoted 1 line

+ifeq ($(OPENSBI_LINUX_PAYLOAD), y)

No space before "y".

Quoted 1 line

+OPENSBI_DEPENDENCIES = linux

+= for this addition, so that we don't mistakenly overwrite any previous dependency that might have been added.

Quoted 19 lines
boot/opensbi/opensbi.mk +13 -0
+OPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/Image"
+endif
+
 define OPENSBI_BUILD_CMDS
      $(TARGET_MAKE_ENV) $(OPENSBI_MAKE_ENV) $(MAKE) -C $(@D)
 endef
 
 ifneq ($(OPENSBI_PLAT),)
 OPENSBI_INSTALL_IMAGES = YES
+OPENSBI_INSTALL_IMAGES_CMDS_PLAT = \
+     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin; \
+     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf; \
+     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.bin $(BINARIES_DIR)/fw_dynamic.bin; \
+     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.elf $(BINARIES_DIR)/fw_dynamic.elf;
+endif
+
+ifeq ($(OPENSBI_LINUX_PAYLOAD), y)
+OPENSBI_INSTALL_IMAGES_CMDS_PAYLOAD = \
+     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_payload.bin $(BINARIES_DIR)/fw_payload.bin; \

boot/opensbi/opensbi.mk ifneq ($(OPENSBI_PLAT),) · line 49

Quoted 10 lines
boot/opensbi/opensbi.mk +5 -4
+     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_payload.elf $(BINARIES_DIR)/fw_payload.elf;
+endif
+
 define OPENSBI_INSTALL_IMAGES_CMDS
-     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin
-     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf
-     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.bin $(BINARIES_DIR)/fw_dynamic.bin
-     $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_dynamic.elf $(BINARIES_DIR)/fw_dynamic.elf
+     $(OPENSBI_INSTALL_IMAGES_CMDS_PLAT)
+     $(OPENSBI_INSTALL_IMAGES_CMDS_PAYLOAD)

As suggested by Yann, I've refactored all of that with a loop over a OPENSBI_FW_IMAGES variable that contains jump, dynamic and optionally payload.

Quoted 4 lines

I fixed up these different aspects, and merged the patch. See the final commit at:

https://git.buildroot.org/buildroot/commit/?id=9b5b7165deb91bad3cdb1ea0dd8f940eff75f3a9

Thanks for that Thomas. Sorry I didn't update it myself, I was travelling.

Alistair

Quoted 8 lines

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com