[v3] wic/rootfs-u-boot: Allow to set root with source_params

Message ID 20210924114058.1056129-1-Quirin.Gylstorff@siemens.com
State Accepted, archived
Headers show
Series [v3] wic/rootfs-u-boot: Allow to set root with source_params | expand

Commit Message

Quirin Gylstorff Sept. 24, 2021, 3:40 a.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

If the root device needs to be modified during boot it needs
to be set as source parameter in the wic file similar to efi
boot.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---

Changes V2:
 - remove autoformatted code
Changes V3:
 - add example usage to bananapi.wks

 meta-isar/scripts/lib/wic/canned-wks/bananapi.wks    | 2 +-
 meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

Comments

Anton Mikanovich Oct. 4, 2021, 5:30 a.m. UTC | #1
On 24.09.21 14:40, Q. Gylstorff wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>
> If the root device needs to be modified during boot it needs
> to be set as source parameter in the wic file similar to efi
> boot.
>
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>

Applied to next, thanks.

Patch

diff --git a/meta-isar/scripts/lib/wic/canned-wks/bananapi.wks b/meta-isar/scripts/lib/wic/canned-wks/bananapi.wks
index 1ba71b9..e0badcd 100644
--- a/meta-isar/scripts/lib/wic/canned-wks/bananapi.wks
+++ b/meta-isar/scripts/lib/wic/canned-wks/bananapi.wks
@@ -1,5 +1,5 @@ 
 part u-boot --source rawcopy --sourceparams "file=/usr/lib/u-boot/Bananapi/u-boot-sunxi-with-spl.bin" --no-table --align 8
 
-part / --source rootfs-u-boot --ondisk mmcblk0 --fstype ext4 --mkfs-extraopts "-T default" --label platform --align 1024
+part --source rootfs-u-boot --ondisk mmcblk0 --sourceparams="root=/dev/mmcblk0p1" --fstype ext4 --mkfs-extraopts "-T default" --label platform --align 1024
 
 bootloader --append "rootwait"
diff --git a/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py b/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py
index 15acb57..0b4f9ee 100644
--- a/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py
+++ b/meta/scripts/lib/wic/plugins/source/rootfs-u-boot.py
@@ -60,6 +60,13 @@  class RootfsUBootPlugin(RootfsPlugin):
                                (rootfs_dir, image_rootfs_dir))
             real_rootfs_dir = image_rootfs_dir
 
+        root_dev = cr.rootdev
+        if not root_dev:
+            root_dev = source_params.get("root", None)
+            if not root_dev:
+                raise WicError("root not defined, exiting.")
+            root_dev = root_dev.replace(":", "=")
+
         u_boot_script = os.path.join(real_rootfs_dir,
                                      "etc/default/u-boot-script")
         if not os.path.exists(u_boot_script):
@@ -70,7 +77,7 @@  class RootfsUBootPlugin(RootfsPlugin):
             cfg.write('# Generated by wic, rootfs-u-boot plugin\n')
             cfg.write('ROOT_PARTITION="%d"\n' % part.realnum)
             cfg.write('KERNEL_ARGS="root=%s %s"\n' % \
-                (cr.rootdev, cr.ks.bootloader.append or ""))
+                (root_dev, cr.ks.bootloader.append or ""))
             no_initrd = source_params.get('no_initrd') or ''
             cfg.write('NO_INITRD="%s"\n' % no_initrd)
             overlays = source_params.get('overlays') or ''