From: Adrian Freihofer <[email protected]>

Generate a helper for NFS-enabled IDE SDK images that exports the rootfs
with runqemu-export-rootfs and serves the deploy directory over HTTP. This
allows real hardware targets to boot the generated rootfs and retrieve the
kernel from the deploy directory over HTTP.

For some use cases like u-boot with wget command built-in this helper
is expected to cover the typical scenario. For other use cases the
generated script at least provides a starting point and can be adapted
as needed for other scenarios.

Signed-off-by: Adrian Freihofer <[email protected]>
---
 scripts/lib/devtool/ide_sdk.py | 35 ++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index 20b03b2d40..a2b15ce440 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -360,6 +360,33 @@ class RecipeImage:
         os.chmod(helper, os.stat(helper).st_mode | stat.S_IEXEC)
         return helper
 
+    def nfs_hw_helper(self, nfs_export_base_dir, nfs):
+        """Create a helper that exports the selected rootfs and the kernel to 
a target.
+
+        The rootfs is exported over NFS with runqemu-export-rootfs
+        The deploy directory (fitImage/kernel) is served over plain
+        HTTP, e.g. for a U-Boot 'wget' in recovery/netboot mode.
+        """
+        export_dir = os.path.join(nfs_export_base_dir, self.pn)
+        rootfs_dir = self.nfs_rootfs_dir(nfs_export_base_dir, nfs)
+
+        helper = os.path.join(export_dir, 'export-hw-' + nfs)
+        with open(helper, 'w') as helper_file:
+            helper_file.write('#!/bin/sh\n')
+            helper_file.write('set -e\n')
+            helper_file.write(
+                'runqemu-export-rootfs start %s\n' % shlex.quote(rootfs_dir))
+            helper_file.write(
+                'trap \'runqemu-export-rootfs stop %s\' EXIT INT TERM\n' %
+                shlex.quote(rootfs_dir))
+            helper_file.write('cd %s\n' % shlex.quote(self.deploy_dir_image))
+            helper_file.write(
+                'echo "Serving %s over HTTP on port ${PORT:-8080}"\n' %
+                self.deploy_dir_image)
+            helper_file.write('python3 -m http.server "${PORT:-8080}"\n')
+        os.chmod(helper, os.stat(helper).st_mode | stat.S_IEXEC)
+        return helper
+
     def update_image_bbappend(self, recipes_modified, nfs=None):
         """Write debug settings for modified-mode recipes into the image 
bbappend.
 
@@ -489,6 +516,14 @@ class RecipeImage:
                 'Pass any additional runqemu options to this helper.',
                 helper, opts)
 
+        hw_helper = self.nfs_hw_helper(nfs_export_base_dir, nfs)
+        logger.info(
+            'With the build environment sourced, export the rootfs (NFS) and '
+            'the kernel (HTTP) for a real hardware target instead of QEMU:\n'
+            '  %s\n'
+            'Set PORT to override the HTTP port (default: 8080).',
+            hw_helper)
+
     def update_qb_slirp_opt(self):
         """Update QB_SLIRP_OPT in the image bbappend
 
-- 
2.55.0

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

Reply via email to