From: Felix Moessbauer <felix.moessbauer@siemens.com>
To: cip-dev@lists.cip-project.org
Cc: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com,
Felix Moessbauer <felix.moessbauer@siemens.com>
Subject: [isar-cip-core][PATCH 2/2] generalize deployment of self compiled firmware
Date: Tue, 25 Apr 2023 11:32:46 +0800 [thread overview]
Message-ID: <20230425033246.1199444-2-felix.moessbauer@siemens.com> (raw)
In-Reply-To: <20230425033246.1199444-1-felix.moessbauer@siemens.com>
For some targets, dedicated firmware is compiled and copied into the
DEPLOY_DIR_IMAGE. Instead of implementing this logic for each firmware
individually, we move the common logic into a class and inherit.
This reduces the amount of code duplication and simplifies the maintenance.
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
classes/deploy-firmware.bbclass | 32 +++++++++++++++++++++++
recipes-bsp/opensbi/opensbi.inc | 16 ++----------
recipes-bsp/u-boot/u-boot-qemu-common.inc | 18 +++----------
3 files changed, 37 insertions(+), 29 deletions(-)
create mode 100644 classes/deploy-firmware.bbclass
diff --git a/classes/deploy-firmware.bbclass b/classes/deploy-firmware.bbclass
new file mode 100644
index 0000000..a4b754a
--- /dev/null
+++ b/classes/deploy-firmware.bbclass
@@ -0,0 +1,32 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2023
+#
+# Authors:
+# Felix Moessbauer <felix.moessbauer@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+# This class adds a mechanism to deploy files to the DEPLOY_DIR_IMAGE
+# directory. Simply overwrite the deploy_firmware task and copy the
+# to-be-deployed files into DEPLOYDIR_FIRMWARE.
+
+inherit dpkg-base
+
+DEPLOYDIR_FIRMWARE = "${WORKDIR}/deploy-fw"
+SSTATETASKS += "do_deploy_firmware"
+
+do_deploy_firmware[cleandirs] += "${DEPLOYDIR_FIRMWARE}"
+do_deploy_firmware[sstate-inputdirs] = "${DEPLOYDIR_FIRMWARE}"
+do_deploy_firmware[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
+do_deploy_firmware() {
+ die "This should never be called, overwrite it in your derived class"
+}
+
+python do_deploy_firmware_setscene () {
+ sstate_setscene(d)
+}
+addtask do_deploy_firmware_setscene
+
+addtask deploy_firmware after do_dpkg_build before do_deploy_deb
diff --git a/recipes-bsp/opensbi/opensbi.inc b/recipes-bsp/opensbi/opensbi.inc
index 0108231..6d84026 100644
--- a/recipes-bsp/opensbi/opensbi.inc
+++ b/recipes-bsp/opensbi/opensbi.inc
@@ -4,13 +4,11 @@
# SPDX-License-Identifier: MIT
inherit dpkg
+inherit deploy-firmware
U_BOOT_PACKAGE ?= "u-boot-${MACHINE}"
PLATFORM ?= "generic"
-DEPLOYDIR_FIRMWARE = "${WORKDIR}/deploy-fw"
-SSTATETASKS += "do_deploy"
-
SRC_URI = " \
https://github.com/riscv/opensbi/archive/v${PV}.tar.gz;downloadfilename=opensbi-${PV}.tar.gz;name=opensbi"
@@ -27,18 +25,8 @@ do_prepare_build() {
echo "build/platform/${PLATFORM}/firmware/fw_payload.bin /usr/lib/opensbi/${MACHINE}/" > ${S}/debian/install
}
-do_deploy[cleandirs] += "${DEPLOYDIR_FIRMWARE}"
-do_deploy[sstate-inputdirs] = "${DEPLOYDIR_FIRMWARE}"
-do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
-do_deploy() {
+do_deploy_firmware() {
dpkg --fsys-tarfile "${WORKDIR}/${PN}_${PV}_${DISTRO_ARCH}.deb" | \
tar xOf - "./usr/lib/opensbi/${MACHINE}/fw_payload.bin" \
> "${DEPLOYDIR_FIRMWARE}/fw_payload.bin"
}
-
-python do_deploy_setscene () {
- sstate_setscene(d)
-}
-addtask do_deploy_setscene
-
-addtask deploy after do_dpkg_build before do_deploy_deb
diff --git a/recipes-bsp/u-boot/u-boot-qemu-common.inc b/recipes-bsp/u-boot/u-boot-qemu-common.inc
index 4d8b240..b222155 100644
--- a/recipes-bsp/u-boot/u-boot-qemu-common.inc
+++ b/recipes-bsp/u-boot/u-boot-qemu-common.inc
@@ -9,25 +9,13 @@
# SPDX-License-Identifier: MIT
#
+inherit deploy-firmware
require recipes-bsp/u-boot/u-boot-common.inc
U_BOOT_BIN = "u-boot.bin"
-DEPLOYDIR_U_BOOT = "${WORKDIR}/deploy-u-boot"
-SSTATETASKS += "do_deploy"
-
-do_deploy[cleandirs] += "${DEPLOYDIR_U_BOOT}"
-do_deploy[sstate-inputdirs] = "${DEPLOYDIR_U_BOOT}"
-do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
-do_deploy() {
+do_deploy_firmware() {
dpkg --fsys-tarfile "${WORKDIR}/u-boot-${MACHINE}_${PV}_${DISTRO_ARCH}.deb" | \
tar xOf - "./usr/lib/u-boot/${MACHINE}/${U_BOOT_BIN}" \
- > "${DEPLOYDIR_U_BOOT}/firmware.bin"
-}
-
-python do_deploy_setscene () {
- sstate_setscene(d)
+ > "${DEPLOYDIR_FIRMWARE}/firmware.bin"
}
-addtask do_deploy_setscene
-
-addtask deploy after do_dpkg_build before do_deploy_deb
--
2.39.2
next prev parent reply other threads:[~2023-04-25 12:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 3:32 [isar-cip-core][PATCH 1/2] refactor deploy of OVMF binaries Felix Moessbauer
2023-04-25 3:32 ` Felix Moessbauer [this message]
2023-05-01 11:29 ` [isar-cip-core][PATCH 2/2] generalize deployment of self compiled firmware Jan Kiszka
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=20230425033246.1199444-2-felix.moessbauer@siemens.com \
--to=felix.moessbauer@siemens.com \
--cc=cip-dev@lists.cip-project.org \
--cc=jan.kiszka@siemens.com \
--cc=quirin.gylstorff@siemens.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.