* [RESEND PATCH 1/2] runqemu: remove setting of mem on kernel command line for certain systems
@ 2025-10-01 17:57 Jon Mason
2025-10-01 17:57 ` [RESEND PATCH 2/2] runqemu: resize rootfs image to power of 2 for SD or pflash Jon Mason
0 siblings, 1 reply; 4+ messages in thread
From: Jon Mason @ 2025-10-01 17:57 UTC (permalink / raw)
To: openembedded-core
Some emulated hardware will not boot if mem is set on the kernel command
line (all of the Raspberry Pi machines seemed to fail with this set,
possibly many others). Also, it is not necessary if the device tree
file is present, as that _should_ have the memory size specified in it.
Add a check for QB_DTB and don't set mem in the kernel command line if
present.
Signed-off-by: Jon Mason <jon.mason@arm.com>
---
scripts/runqemu | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index 32c7a2aab3b5..a8144aa68c3d 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -884,7 +884,7 @@ to your build configuration.
self.set('QB_MEM', qb_mem)
mach = self.get('MACHINE')
- if not mach.startswith(('qemumips', 'qemux86', 'qemuloongarch64')):
+ if not mach.startswith(('qemumips', 'qemux86', 'qemuloongarch64')) and self.get('QB_DTB') == "":
self.kernel_cmdline_script += ' mem=%s' % self.get('QB_MEM').replace('-m','').strip() + 'M'
self.qemu_opt_script += ' %s' % self.get('QB_MEM')
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 4+ messages in thread* [RESEND PATCH 2/2] runqemu: resize rootfs image to power of 2 for SD or pflash
2025-10-01 17:57 [RESEND PATCH 1/2] runqemu: remove setting of mem on kernel command line for certain systems Jon Mason
@ 2025-10-01 17:57 ` Jon Mason
2025-10-02 17:29 ` [OE-core] " Gyorgy Sarvari
0 siblings, 1 reply; 4+ messages in thread
From: Jon Mason @ 2025-10-01 17:57 UTC (permalink / raw)
To: openembedded-core
QEMU requires that SD and pflash images are sized to be a power of 2
(e.g., 32M, 64M, etc). So, if the image being used is not a power of 2
and it's being used for SD or pflash, increase it to the next power of 2
size via the truncate command.
This might not be an actual spec requirement, and is being investigated
in https://gitlab.com/qemu-project/qemu/-/issues/1754
Signed-off-by: Jon Mason <jon.mason@arm.com>
---
scripts/runqemu | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index a8144aa68c3d..cd2ded69916a 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -421,7 +421,27 @@ class BaseConfig(object):
else:
raise RunQemuError("Unknown path arg %s" % p)
- def uncompress_rootfs(self):
+ def rootfs_fixups(self):
+
+ """Resize rootfs image if needed"""
+ qb_rootfs_opt = self.get('QB_ROOTFS_OPT')
+
+ # Check if sdcard size is a power of 2, as that is currently a requirement for qemu
+ # See https://gitlab.com/qemu-project/qemu/-/issues/1754
+ rootfs_size = os.path.getsize(self.rootfs)
+ rootfs_size_pwr2 = 1 << (rootfs_size - 1).bit_length()
+ if ("if=sd" in qb_rootfs_opt or "if=pflash" in qb_rootfs_opt) and rootfs_size != rootfs_size_pwr2:
+ logger.info("Using sd-card or pflash and is not power of 2. File size %d, power of 2 size %d" %(rootfs_size, rootfs_size_pwr2))
+ logger.info("Attempting to use truncate to correct this.")
+
+ # Ensure the 'truncate' tool is installed before attempting to make a power of 2.
+ if not shutil.which('truncate'):
+ raise RunQemuError(f"'truncate' is required to make {self.rootfs} a power of 2 in size but was not found in PATH")
+ try:
+ subprocess.check_call(['truncate', '-s', str(rootfs_size_pwr2), self.rootfs])
+ except subprocess.CalledProcessError as e:
+ raise RunQemuError(f"Failed to make {self.rootfs} power of 2 in size: {e}")
+
"""Decompress ZST rootfs image if needed"""
if not self.rootfs or not self.fstype.endswith('.zst'):
return
@@ -1808,7 +1828,7 @@ def main():
config.check_args()
config.read_qemuboot()
config.check_and_set()
- config.uncompress_rootfs()
+ config.rootfs_fixups()
# Check whether the combos is valid or not
config.validate_combos()
config.print_config()
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [OE-core] [RESEND PATCH 2/2] runqemu: resize rootfs image to power of 2 for SD or pflash
2025-10-01 17:57 ` [RESEND PATCH 2/2] runqemu: resize rootfs image to power of 2 for SD or pflash Jon Mason
@ 2025-10-02 17:29 ` Gyorgy Sarvari
2025-10-03 14:42 ` Jon Mason
0 siblings, 1 reply; 4+ messages in thread
From: Gyorgy Sarvari @ 2025-10-02 17:29 UTC (permalink / raw)
To: jon.mason, openembedded-core
On 10/1/25 19:57, Jon Mason via lists.openembedded.org wrote:
> QEMU requires that SD and pflash images are sized to be a power of 2
> (e.g., 32M, 64M, etc). So, if the image being used is not a power of 2
> and it's being used for SD or pflash, increase it to the next power of 2
> size via the truncate command.
>
> This might not be an actual spec requirement, and is being investigated
> in https://gitlab.com/qemu-project/qemu/-/issues/1754
>
> Signed-off-by: Jon Mason <jon.mason@arm.com>
> ---
> scripts/runqemu | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/runqemu b/scripts/runqemu
> index a8144aa68c3d..cd2ded69916a 100755
> --- a/scripts/runqemu
> +++ b/scripts/runqemu
> @@ -421,7 +421,27 @@ class BaseConfig(object):
> else:
> raise RunQemuError("Unknown path arg %s" % p)
>
> - def uncompress_rootfs(self):
> + def rootfs_fixups(self):
> +
> + """Resize rootfs image if needed"""
Nit: the docstring now only describes the newly added behavior, but not
the original. The original docstring is also present, but it is now in
the middle of the method.
> + qb_rootfs_opt = self.get('QB_ROOTFS_OPT')
> +
> + # Check if sdcard size is a power of 2, as that is currently a requirement for qemu
> + # See https://gitlab.com/qemu-project/qemu/-/issues/1754
> + rootfs_size = os.path.getsize(self.rootfs)
> + rootfs_size_pwr2 = 1 << (rootfs_size - 1).bit_length()
> + if ("if=sd" in qb_rootfs_opt or "if=pflash" in qb_rootfs_opt) and rootfs_size != rootfs_size_pwr2:
> + logger.info("Using sd-card or pflash and is not power of 2. File size %d, power of 2 size %d" %(rootfs_size, rootfs_size_pwr2))
> + logger.info("Attempting to use truncate to correct this.")
> +
> + # Ensure the 'truncate' tool is installed before attempting to make a power of 2.
> + if not shutil.which('truncate'):
> + raise RunQemuError(f"'truncate' is required to make {self.rootfs} a power of 2 in size but was not found in PATH")
> + try:
> + subprocess.check_call(['truncate', '-s', str(rootfs_size_pwr2), self.rootfs])
> + except subprocess.CalledProcessError as e:
> + raise RunQemuError(f"Failed to make {self.rootfs} power of 2 in size: {e}")
> +
> """Decompress ZST rootfs image if needed"""
> if not self.rootfs or not self.fstype.endswith('.zst'):
> return
> @@ -1808,7 +1828,7 @@ def main():
> config.check_args()
> config.read_qemuboot()
> config.check_and_set()
> - config.uncompress_rootfs()
> + config.rootfs_fixups()
> # Check whether the combos is valid or not
> config.validate_combos()
> config.print_config()
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#224315): https://lists.openembedded.org/g/openembedded-core/message/224315
> Mute This Topic: https://lists.openembedded.org/mt/115538558/6084445
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [OE-core] [RESEND PATCH 2/2] runqemu: resize rootfs image to power of 2 for SD or pflash
2025-10-02 17:29 ` [OE-core] " Gyorgy Sarvari
@ 2025-10-03 14:42 ` Jon Mason
0 siblings, 0 replies; 4+ messages in thread
From: Jon Mason @ 2025-10-03 14:42 UTC (permalink / raw)
To: skandigraun; +Cc: jon.mason, openembedded-core
On Thu, Oct 2, 2025 at 1:29 PM Gyorgy Sarvari via
lists.openembedded.org <skandigraun=gmail.com@lists.openembedded.org>
wrote:
>
> On 10/1/25 19:57, Jon Mason via lists.openembedded.org wrote:
> > QEMU requires that SD and pflash images are sized to be a power of 2
> > (e.g., 32M, 64M, etc). So, if the image being used is not a power of 2
> > and it's being used for SD or pflash, increase it to the next power of 2
> > size via the truncate command.
> >
> > This might not be an actual spec requirement, and is being investigated
> > in https://gitlab.com/qemu-project/qemu/-/issues/1754
> >
> > Signed-off-by: Jon Mason <jon.mason@arm.com>
> > ---
> > scripts/runqemu | 24 ++++++++++++++++++++++--
> > 1 file changed, 22 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/runqemu b/scripts/runqemu
> > index a8144aa68c3d..cd2ded69916a 100755
> > --- a/scripts/runqemu
> > +++ b/scripts/runqemu
> > @@ -421,7 +421,27 @@ class BaseConfig(object):
> > else:
> > raise RunQemuError("Unknown path arg %s" % p)
> >
> > - def uncompress_rootfs(self):
> > + def rootfs_fixups(self):
> > +
> > + """Resize rootfs image if needed"""
>
> Nit: the docstring now only describes the newly added behavior, but not
> the original. The original docstring is also present, but it is now in
> the middle of the method.
Thanks for the review, I'll fix this up and send out a v2
>
> > + qb_rootfs_opt = self.get('QB_ROOTFS_OPT')
> > +
> > + # Check if sdcard size is a power of 2, as that is currently a requirement for qemu
> > + # See https://gitlab.com/qemu-project/qemu/-/issues/1754
> > + rootfs_size = os.path.getsize(self.rootfs)
> > + rootfs_size_pwr2 = 1 << (rootfs_size - 1).bit_length()
> > + if ("if=sd" in qb_rootfs_opt or "if=pflash" in qb_rootfs_opt) and rootfs_size != rootfs_size_pwr2:
> > + logger.info("Using sd-card or pflash and is not power of 2. File size %d, power of 2 size %d" %(rootfs_size, rootfs_size_pwr2))
> > + logger.info("Attempting to use truncate to correct this.")
> > +
> > + # Ensure the 'truncate' tool is installed before attempting to make a power of 2.
> > + if not shutil.which('truncate'):
> > + raise RunQemuError(f"'truncate' is required to make {self.rootfs} a power of 2 in size but was not found in PATH")
> > + try:
> > + subprocess.check_call(['truncate', '-s', str(rootfs_size_pwr2), self.rootfs])
> > + except subprocess.CalledProcessError as e:
> > + raise RunQemuError(f"Failed to make {self.rootfs} power of 2 in size: {e}")
> > +
> > """Decompress ZST rootfs image if needed"""
> > if not self.rootfs or not self.fstype.endswith('.zst'):
> > return
> > @@ -1808,7 +1828,7 @@ def main():
> > config.check_args()
> > config.read_qemuboot()
> > config.check_and_set()
> > - config.uncompress_rootfs()
> > + config.rootfs_fixups()
> > # Check whether the combos is valid or not
> > config.validate_combos()
> > config.print_config()
> >
> >
> >
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#224377): https://lists.openembedded.org/g/openembedded-core/message/224377
> Mute This Topic: https://lists.openembedded.org/mt/115538558/3616920
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [jdmason@kudzu.us]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-03 14:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-01 17:57 [RESEND PATCH 1/2] runqemu: remove setting of mem on kernel command line for certain systems Jon Mason
2025-10-01 17:57 ` [RESEND PATCH 2/2] runqemu: resize rootfs image to power of 2 for SD or pflash Jon Mason
2025-10-02 17:29 ` [OE-core] " Gyorgy Sarvari
2025-10-03 14:42 ` Jon Mason
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox