DistroKit Mailinglist
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: distrokit@pengutronix.de
Cc: Roland Hieber <rhi@pengutronix.de>
Subject: [DistroKit] [PATCH v2 5/6] images: remove qemu size hack
Date: Wed, 11 Oct 2023 12:50:37 +0200	[thread overview]
Message-ID: <20231011105038.1380620-5-rhi@pengutronix.de> (raw)
In-Reply-To: <20231011105038.1380620-1-rhi@pengutronix.de>

genimage knows about the 'size' option for images to fill the image to a
certain size, and since genimage v14 it supports the 'fill' option to
write all zeroes at the end of the image and not cut them off to
optimise the image size. Use this to blow up the images that are used
with qemu to the next power of two so qemu can work with them, and
remove our invisible-partition-at-the-end hack.

Since the first MiB (when using 1 MiB alignment) is occupied by the
partition table, and the first partition only starts at offset 1 MiB,
the data partition now no longer fits into the available space. Set it
to 'autoresize' so that genimage computes the size to fill the remaining
space in the image.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
PATCH v2:
 * use 'autoresize' for data partition instead of explicit size

PATCH v1: https://lore.distrokit.org/distrokit/20231010191631.31141-5-rhi@pengutronix.de
---
 .../platform-mips/config/images/ar9331.config   | 16 ++++------------
 .../platform-mips/config/images/malta.config    | 16 ++++------------
 .../platform-mipsel/config/images/malta.config  | 16 ++++------------
 .../config/images/vexpress-nor.config           | 10 +++-------
 .../platform-v7a/config/images/vexpress.config  | 17 ++++-------------
 .../config/images/vexpress-nor.config           | 10 +++-------
 .../config/images/vexpress.config               | 17 ++++-------------
 7 files changed, 26 insertions(+), 76 deletions(-)

diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
index 07125bea4c88..16122eb26a22 100644
--- a/configs/platform-mips/config/images/ar9331.config
+++ b/configs/platform-mips/config/images/ar9331.config
@@ -1,7 +1,10 @@
 image @IMAGE@ {
+	/* Note: qemu will complain if the SD card size is not a power of two */
+	size = 1G
 	hdimage {
 		align = 1M
 		disk-signature = 0x74823abf
+		fill = true
 	}
 	partition root-A {
 		image = root.ext2
@@ -10,18 +13,7 @@ image @IMAGE@ {
 	}
 	partition data {
 		partition-type = 0x83
-		size = 512M
-	}
-	/* genimage does not write zeros at the end of an image to save space,
-	 * but the kernel in qemu will complain if the image file is smaller
-	 * than the partition sizes. work around this by adding an empty
-	 * partition at the end.
-	 */
-	partition end {
-		image = /dev/null
-		size = 1M
-		offset = 1025M
-		in-partition-table = false
+		autoresize = true
 	}
 }
 
diff --git a/configs/platform-mips/config/images/malta.config b/configs/platform-mips/config/images/malta.config
index 07125bea4c88..16122eb26a22 100644
--- a/configs/platform-mips/config/images/malta.config
+++ b/configs/platform-mips/config/images/malta.config
@@ -1,7 +1,10 @@
 image @IMAGE@ {
+	/* Note: qemu will complain if the SD card size is not a power of two */
+	size = 1G
 	hdimage {
 		align = 1M
 		disk-signature = 0x74823abf
+		fill = true
 	}
 	partition root-A {
 		image = root.ext2
@@ -10,18 +13,7 @@ image @IMAGE@ {
 	}
 	partition data {
 		partition-type = 0x83
-		size = 512M
-	}
-	/* genimage does not write zeros at the end of an image to save space,
-	 * but the kernel in qemu will complain if the image file is smaller
-	 * than the partition sizes. work around this by adding an empty
-	 * partition at the end.
-	 */
-	partition end {
-		image = /dev/null
-		size = 1M
-		offset = 1025M
-		in-partition-table = false
+		autoresize = true
 	}
 }
 
diff --git a/configs/platform-mipsel/config/images/malta.config b/configs/platform-mipsel/config/images/malta.config
index 07125bea4c88..16122eb26a22 100644
--- a/configs/platform-mipsel/config/images/malta.config
+++ b/configs/platform-mipsel/config/images/malta.config
@@ -1,7 +1,10 @@
 image @IMAGE@ {
+	/* Note: qemu will complain if the SD card size is not a power of two */
+	size = 1G
 	hdimage {
 		align = 1M
 		disk-signature = 0x74823abf
+		fill = true
 	}
 	partition root-A {
 		image = root.ext2
@@ -10,18 +13,7 @@ image @IMAGE@ {
 	}
 	partition data {
 		partition-type = 0x83
-		size = 512M
-	}
-	/* genimage does not write zeros at the end of an image to save space,
-	 * but the kernel in qemu will complain if the image file is smaller
-	 * than the partition sizes. work around this by adding an empty
-	 * partition at the end.
-	 */
-	partition end {
-		image = /dev/null
-		size = 1M
-		offset = 1025M
-		in-partition-table = false
+		autoresize = true
 	}
 }
 
diff --git a/configs/platform-v7a/config/images/vexpress-nor.config b/configs/platform-v7a/config/images/vexpress-nor.config
index cc7edd28f628..58bbbfca404a 100644
--- a/configs/platform-v7a/config/images/vexpress-nor.config
+++ b/configs/platform-v7a/config/images/vexpress-nor.config
@@ -1,6 +1,9 @@
 image @IMAGE@ {
+	/* Note: qemu will complain if the SD card size is not a power of two */
+	size = 64M
 	hdimage {
 		partition-table-type = none
+		fill = true
 	}
 	partition barebox {
 		image = barebox-vexpress-ca9.img
@@ -19,13 +22,6 @@ image @IMAGE@ {
 		in-partition-table = false
 		size = 1M
 	}
-	/* expand image size to 64 MiB; dummy size, results in 0 bytes length */
-	partition end {
-		image = /dev/null
-		offset = 64M
-		size = 1M
-		in-partition-table = false
-	}
 }
 
 /* vim: set tabstop=8 noexpandtab : */
diff --git a/configs/platform-v7a/config/images/vexpress.config b/configs/platform-v7a/config/images/vexpress.config
index 3aa64a4299ce..5c523ae1707d 100644
--- a/configs/platform-v7a/config/images/vexpress.config
+++ b/configs/platform-v7a/config/images/vexpress.config
@@ -1,7 +1,10 @@
 image @IMAGE@ {
+	/* Note: qemu will complain if the SD card size is not a power of two */
+	size = 256M
 	hdimage {
 		align = 1M
 		disk-signature = 0x74823abf
+		fill = true
 	}
 	partition root-A {
 		image = root.ext2
@@ -15,19 +18,7 @@ image @IMAGE@ {
 	}
 	partition data {
 		partition-type = 0x83
-		size = 63M
-	}
-	/* genimage does not write zeros at the end of an image to save space,
-	 * but the kernel in qemu will complain if the image file is smaller
-	 * than the partition sizes, and qemu will complain if the SD card size
-	 * is not a power of 2. work around this issues by adding an empty
-	 * partition at the end.
-	 */
-	partition end {
-		image = /dev/null
-		size = 1M
-		offset = 256M
-		in-partition-table = false
+		autoresize = true
 	}
 }
 
diff --git a/configs/platform-v7a_noneon/config/images/vexpress-nor.config b/configs/platform-v7a_noneon/config/images/vexpress-nor.config
index cc7edd28f628..58bbbfca404a 100644
--- a/configs/platform-v7a_noneon/config/images/vexpress-nor.config
+++ b/configs/platform-v7a_noneon/config/images/vexpress-nor.config
@@ -1,6 +1,9 @@
 image @IMAGE@ {
+	/* Note: qemu will complain if the SD card size is not a power of two */
+	size = 64M
 	hdimage {
 		partition-table-type = none
+		fill = true
 	}
 	partition barebox {
 		image = barebox-vexpress-ca9.img
@@ -19,13 +22,6 @@ image @IMAGE@ {
 		in-partition-table = false
 		size = 1M
 	}
-	/* expand image size to 64 MiB; dummy size, results in 0 bytes length */
-	partition end {
-		image = /dev/null
-		offset = 64M
-		size = 1M
-		in-partition-table = false
-	}
 }
 
 /* vim: set tabstop=8 noexpandtab : */
diff --git a/configs/platform-v7a_noneon/config/images/vexpress.config b/configs/platform-v7a_noneon/config/images/vexpress.config
index d51a58be2893..54c47a42c8bf 100644
--- a/configs/platform-v7a_noneon/config/images/vexpress.config
+++ b/configs/platform-v7a_noneon/config/images/vexpress.config
@@ -1,7 +1,10 @@
 image @IMAGE@ {
+	/* Note: qemu will complain if the SD card size is not a power of two */
+	size = 256M
 	hdimage {
 		align = 1M
 		disk-signature = 0x74823abf
+		fill = true
 	}
 	partition root-A {
 		image = root.ext2
@@ -10,19 +13,7 @@ image @IMAGE@ {
 	}
 	partition data {
 		partition-type = 0x83
-		size = 63M
-	}
-	/* genimage does not write zeros at the end of an image to save space,
-	 * but the kernel in qemu will complain if the image file is smaller
-	 * than the partition sizes, and qemu will complain if the SD card size
-	 * is not a power of 2. work around this issues by adding an empty
-	 * partition at the end.
-	 */
-	partition end {
-		image = /dev/null
-		size = 1M
-		offset = 256M
-		in-partition-table = false
+		autoresize = true
 	}
 }
 
-- 
2.39.2




  parent reply	other threads:[~2023-10-11 10:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 10:50 [DistroKit] [PATCH v2 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt' Roland Hieber
2023-10-11 10:50 ` [DistroKit] [PATCH v2 2/6] images: use 'partition-table-type' option instead of 'partition-table' Roland Hieber
2023-10-11 10:50 ` [DistroKit] [PATCH v2 3/6] v7a: barebox: pass root=mmcblkXpN instead of root=PARTUUID=… to kernel Roland Hieber
2023-10-11 10:50 ` [DistroKit] [PATCH v2 4/6] v7a: barebox: enable GUID Partition Table support Roland Hieber
2023-10-11 10:50 ` Roland Hieber [this message]
2023-10-11 10:50 ` [DistroKit] [PATCH v2 6/6] images: convert to GPT format Roland Hieber
2023-10-18  9:17 ` [DistroKit] [PATCH v2 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt' Robert Schwebel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231011105038.1380620-5-rhi@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=distrokit@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox