From: [email protected]

When specifying a custom .dtb with the --sourceparams="dtb=<path>" parameter,
the custom file is looked for in ${DEPLOY_DIR_IMAGE}/<path>, and the resulting
grub config file is set to look for the .dtb under /<path> inside the boot
partition. However, the file is not currently being copied there.

Change the behaviour of the --sourceparams="dtb=<path>" parameter so that
the custom .dtb file is copied under /<path> in the boot partition.

Include oe-selftest to validate the functionality.

Signed-off-by: Tomás González <[email protected]>
---
 .../recipes-test/dtb/devicetree-sample.bb     |  8 +++
 .../dtb/files/sample-devicetree.dts           | 69 +++++++++++++++++++
 meta-selftest/wic/test_dtb_efi.wks            |  3 +
 meta/lib/oeqa/selftest/cases/wic.py           | 16 +++++
 scripts/lib/wic/plugins/source/bootimg-efi.py |  2 +-
 5 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 meta-selftest/recipes-test/dtb/devicetree-sample.bb
 create mode 100644 meta-selftest/recipes-test/dtb/files/sample-devicetree.dts
 create mode 100644 meta-selftest/wic/test_dtb_efi.wks

diff --git a/meta-selftest/recipes-test/dtb/devicetree-sample.bb 
b/meta-selftest/recipes-test/dtb/devicetree-sample.bb
new file mode 100644
index 0000000000..8be977a821
--- /dev/null
+++ b/meta-selftest/recipes-test/dtb/devicetree-sample.bb
@@ -0,0 +1,8 @@
+SUMMARY = "Device tree"
+DESCRIPTION = "Contains a Device Tree recipe to be used to for testing."
+
+inherit devicetree
+
+SRC_URI += "file://sample-devicetree.dts"
+
+COMPATIBLE_MACHINE = ""
diff --git a/meta-selftest/recipes-test/dtb/files/sample-devicetree.dts 
b/meta-selftest/recipes-test/dtb/files/sample-devicetree.dts
new file mode 100644
index 0000000000..71af0e117b
--- /dev/null
+++ b/meta-selftest/recipes-test/dtb/files/sample-devicetree.dts
@@ -0,0 +1,69 @@
+/dts-v1/;
+/ {
+       compatible = "opencores,or1ksim";
+       #address-cells = <1>;
+       #size-cells = <1>;
+       interrupt-parent = <&pic>;
+
+       aliases {
+               uart0 = &serial0;
+       };
+
+       chosen {
+               bootargs = "earlycon";
+               stdout-path = "uart0:115200";
+       };
+
+       memory@0 {
+               device_type = "memory";
+               reg = <0x00000000 0x02000000>;
+       };
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               cpu@0 {
+                       compatible = "opencores,or1200-rtlsvn481";
+                       reg = <0>;
+                       clock-frequency = <20000000>;
+               };
+               cpu@1 {
+                       compatible = "opencores,or1200-rtlsvn481";
+                       reg = <1>;
+                       clock-frequency = <20000000>;
+               };
+       };
+
+       ompic: ompic@98000000 {
+               compatible = "openrisc,ompic";
+               reg = <0x98000000 16>;
+               interrupt-controller;
+               #interrupt-cells = <0>;
+               interrupts = <1>;
+       };
+
+       /*
+        * OR1K PIC is built into CPU and accessed via special purpose
+        * registers.  It is not addressable and, hence, has no 'reg'
+        * property.
+        */
+       pic: pic {
+               compatible = "opencores,or1k-pic-level";
+               #interrupt-cells = <1>;
+               interrupt-controller;
+       };
+
+       serial0: serial@90000000 {
+               compatible = "opencores,uart16550-rtlsvn105", "ns16550a";
+               reg = <0x90000000 0x100>;
+               interrupts = <2>;
+               clock-frequency = <20000000>;
+       };
+
+       enet0: ethoc@92000000 {
+               compatible = "opencores,ethoc";
+               reg = <0x92000000 0x800>;
+               interrupts = <4>;
+               big-endian;
+       };
+};
diff --git a/meta-selftest/wic/test_dtb_efi.wks 
b/meta-selftest/wic/test_dtb_efi.wks
new file mode 100644
index 0000000000..61a7b1c9b4
--- /dev/null
+++ b/meta-selftest/wic/test_dtb_efi.wks
@@ -0,0 +1,3 @@
+part /boot --active --source bootimg-efi 
--sourceparams="loader=grub-efi,dtb=devicetree/sample-devicetree.dtb" --active 
--align 1024 --use-uuid --part-type EF00
+part / --source rootfs --fstype=ext4 --align 1024 --use-uuid
+bootloader --ptable gpt --timeout=1 --append="rootwait rootfstype=ext4 
console=ttyS0,115200n8"
diff --git a/meta/lib/oeqa/selftest/cases/wic.py 
b/meta/lib/oeqa/selftest/cases/wic.py
index 0d664d7c39..d702c57679 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1512,3 +1512,19 @@ class ModifyTests(WicTestCase):
         # check if it's removed
         result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot))
         self.assertTrue('etc' not in [line.split()[-1] for line in 
result.output.split('\n') if line])
+
+    def test_dtb_efi(self):
+        """Test custom dtb"""
+        config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = 
"test_dtb_efi.wks"\nMACHINE_FEATURES:append = " efi"\n'
+        config += 'EXTRA_IMAGEDEPENDS = "devicetree-sample"\n'
+        self.append_config(config)
+        bitbake('core-image-minimal')
+
+        deploy_dir = get_bb_var('DEPLOY_DIR_IMAGE')
+        machine = self.td['MACHINE']
+        image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % 
machine)
+
+        self.assertTrue(os.path.exists(image_path))
+
+        result = runCmd("wic ls %s:1/devicetree" % (image_path))
+        self.assertTrue('sample-devicetree.dtb' in [line.split()[-1] for line 
in result.output.split('\n') if line])
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py 
b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 4b00913a70..69c427e01d 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -51,7 +51,7 @@ class BootimgEFIPlugin(SourcePlugin):
         if dtb:
             if ';' in dtb:
                 raise WicError("Only one DTB supported, exiting")
-            cp_cmd = "cp %s/%s %s" % (bootimg_dir, dtb, hdddir)
+            cp_cmd = "install -D %s/%s %s/%s" % (bootimg_dir, dtb, hdddir, dtb)
             exec_cmd(cp_cmd, True)
 
     @classmethod
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#177885): 
https://lists.openembedded.org/g/openembedded-core/message/177885
Mute This Topic: https://lists.openembedded.org/mt/97312887/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to