Hello,
attached is a proof of concept. Using a ./waf bootimages command didn't
work since you don't have a build context in this case. I added a new
option:
# If this option is enabled, then boot images for the test programs
# are built.
BUILD_BOOT_IMAGES = False
If this option is enabled, then a BSP-specific method is used to build a
boot image. This method is optional. BSPs can provide it through a new
build item with type "mkimage", see the powerpc/qoriq example of the
attached patches.
--
embedded brains GmbH & Co. KG
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
From 74303e5fefc1104415ba7c86f5738855dd27610e Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.hu...@embedded-brains.de>
Date: Wed, 17 Jan 2024 12:30:37 +0100
Subject: [PATCH 1/2] build: Add support to make bootloader images
---
spec/build/cpukit/cpuopts.yml | 4 ++++
spec/build/cpukit/optbootimageext.yml | 17 ++++++++++++++
spec/build/cpukit/optbuildbootimages.yml | 16 +++++++++++++
wscript | 30 ++++++++++++++++++++++++
4 files changed, 67 insertions(+)
create mode 100644 spec/build/cpukit/optbootimageext.yml
create mode 100644 spec/build/cpukit/optbuildbootimages.yml
diff --git a/spec/build/cpukit/cpuopts.yml b/spec/build/cpukit/cpuopts.yml
index 1d28ace552..bdf8fc2f66 100644
--- a/spec/build/cpukit/cpuopts.yml
+++ b/spec/build/cpukit/cpuopts.yml
@@ -75,6 +75,10 @@ links:
uid: optcoverageldflags
- role: build-dependency
uid: optnocoverageldflags
+- role: build-dependency
+ uid: optbootimageext
+- role: build-dependency
+ uid: optbuildbootimages
- role: build-dependency
uid: optversion
target: cpukit/include/rtems/score/cpuopts.h
diff --git a/spec/build/cpukit/optbootimageext.yml b/spec/build/cpukit/optbootimageext.yml
new file mode 100644
index 0000000000..c9347ffba8
--- /dev/null
+++ b/spec/build/cpukit/optbootimageext.yml
@@ -0,0 +1,17 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-string: null
+- env-assign: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by: true
+ value: .img
+description: |
+ Defines the file extension of boot images.
+enabled-by: true
+format: '{}'
+links: []
+name: BOOT_IMAGE_EXTENSION
+type: build
diff --git a/spec/build/cpukit/optbuildbootimages.yml b/spec/build/cpukit/optbuildbootimages.yml
new file mode 100644
index 0000000000..12328b006d
--- /dev/null
+++ b/spec/build/cpukit/optbuildbootimages.yml
@@ -0,0 +1,16 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-boolean: null
+- env-enable: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by: true
+ value: false
+description: |
+ If this option is enabled, then boot images for the test programs are built.
+enabled-by: true
+links: []
+name: BUILD_BOOT_IMAGES
+type: build
diff --git a/wscript b/wscript
index 6c81083b2c..34a9789bed 100755
--- a/wscript
+++ b/wscript
@@ -590,6 +590,29 @@ class ConfigFileItem(Item):
self.install_target(bld)
+class MakeImageItem(Item):
+
+ def __init__(self, uid, data):
+ super(MakeImageItem, self).__init__(uid, data)
+
+ def do_configure(self, conf, cic):
+ content = self.substitute(conf, self.data["content"])
+ f = conf.bldnode.make_node(conf.env.VARIANT + "/bin/mkimage.py")
+ f.parent.mkdir()
+ f.write(content)
+ # 493 == 0755
+ f.chmod(493)
+ file_path = f.abspath()
+ conf.env.BUILD_TOOL_MKIMAGE = file_path
+ conf.env.append_value("cfg_files", file_path)
+
+ def do_build(self, bld, bic):
+ bld.install_as("${PREFIX}/bin/rtems-mkimage-" + bld.env.ARCH + "-" +
+ bld.env.BSP_NAME + ".py",
+ "bin/mkimage.py",
+ chmod=493)
+
+
class ConfigHeaderItem(Item):
def __init__(self, uid, data):
@@ -760,6 +783,12 @@ class TestProgramItem(Item):
use=bic.objects + bic.use,
)
+ if bld.env.BUILD_TOOL_MKIMAGE:
+ bld(rule="${BUILD_TOOL_MKIMAGE} ${SRC} ${TGT}",
+ source=target,
+ target=os.path.splitext(target)[0] +
+ bld.env.BOOT_IMAGE_EXTENSION)
+
class AdaTestProgramItem(TestProgramItem):
@@ -1272,6 +1301,7 @@ def load_items(ctx, specs):
"test-program": TestProgramItem,
"group": GroupItem,
"library": LibraryItem,
+ "mkimage": MakeImageItem,
"objects": ObjectsItem,
"option": OptionItem,
"script": ScriptItem,
--
2.35.3
From ae532b560719566f15718a86abdcb657c4a3d45f Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.hu...@embedded-brains.de>
Date: Wed, 17 Jan 2024 12:31:10 +0100
Subject: [PATCH 2/2] build: Add mkimage support for powerpc/qoriq
---
spec/build/bsps/optpython.yml | 14 ++++++++
spec/build/bsps/optubootmkimage.yml | 14 ++++++++
spec/build/bsps/powerpc/qoriq/grp.yml | 2 ++
spec/build/bsps/powerpc/qoriq/mkimage.yml | 40 +++++++++++++++++++++++
4 files changed, 70 insertions(+)
create mode 100644 spec/build/bsps/optpython.yml
create mode 100644 spec/build/bsps/optubootmkimage.yml
create mode 100644 spec/build/bsps/powerpc/qoriq/mkimage.yml
diff --git a/spec/build/bsps/optpython.yml b/spec/build/bsps/optpython.yml
new file mode 100644
index 0000000000..15e0e500e6
--- /dev/null
+++ b/spec/build/bsps/optpython.yml
@@ -0,0 +1,14 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- script: |
+ value = sys.executable
+- env-assign: PYTHON
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default: []
+description: ''
+enabled-by: true
+links: []
+name: PYTHON
+type: build
diff --git a/spec/build/bsps/optubootmkimage.yml b/spec/build/bsps/optubootmkimage.yml
new file mode 100644
index 0000000000..570ee722c0
--- /dev/null
+++ b/spec/build/bsps/optubootmkimage.yml
@@ -0,0 +1,14 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- set-value: mkimage
+- substitute: null
+- find-program: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default: []
+description: ''
+enabled-by: true
+links: []
+name: MKIMAGE
+type: build
diff --git a/spec/build/bsps/powerpc/qoriq/grp.yml b/spec/build/bsps/powerpc/qoriq/grp.yml
index 2acb506c89..7ba85e8f68 100644
--- a/spec/build/bsps/powerpc/qoriq/grp.yml
+++ b/spec/build/bsps/powerpc/qoriq/grp.yml
@@ -112,6 +112,8 @@ links:
uid: optuartirq
- role: build-dependency
uid: start
+- role: build-dependency
+ uid: mkimage
- role: build-dependency
uid: ../../bspopts
type: build
diff --git a/spec/build/bsps/powerpc/qoriq/mkimage.yml b/spec/build/bsps/powerpc/qoriq/mkimage.yml
new file mode 100644
index 0000000000..2d3891cdad
--- /dev/null
+++ b/spec/build/bsps/powerpc/qoriq/mkimage.yml
@@ -0,0 +1,40 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: mkimage
+content: |
+ #!${PYTHON}
+
+ import gzip
+ import os
+ import shutil
+ import subprocess
+ import sys
+ import tempfile
+
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ bin_path = os.path.join(tmp_dir, "bin")
+ gz_path = os.path.join(tmp_dir, "gz")
+ subprocess.run([
+ "${OBJCOPY}",
+ "-O", "binary", sys.argv[1], bin_path
+ ],
+ check=True)
+ with open(bin_path, "rb") as f_bin:
+ with gzip.open(gz_path, "wb") as f_gz:
+ shutil.copyfileobj(f_bin, f_gz)
+ subprocess.run([
+ "${MKIMAGE}",
+ "-A", "ppc", "-O", "linux", "-T", "kernel", "-a", "0x4000", "-e",
+ "0x4000", "-n", "RTEMS", "-d", bin_path, sys.argv[2]
+ ],
+ check=True)
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+enabled-by: BUILD_BOOT_IMAGES
+links:
+- role: build-dependency
+ uid: ../../optobjcopy
+- role: build-dependency
+ uid: ../../optpython
+- role: build-dependency
+ uid: ../../optubootmkimage
+type: build
--
2.35.3
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel