DistroKit Mailinglist
 help / color / mirror / Atom feed
* [DistroKit] [PATCH 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt'
@ 2023-10-10 19:16 Roland Hieber
  2023-10-10 19:16 ` [DistroKit] [PATCH 2/6] v7a: images: use 'partition-table-type' option instead of 'partition-table' Roland Hieber
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Roland Hieber @ 2023-10-10 19:16 UTC (permalink / raw)
  To: distrokit; +Cc: Roland Hieber

The 'gpt' option in genimage has been deprecated in favour of
'partition-table-type = gpt'.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 configs/platform-v7a/config/images/stm32mp.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/platform-v7a/config/images/stm32mp.config b/configs/platform-v7a/config/images/stm32mp.config
index 908ed44ce78c..805c50ded520 100644
--- a/configs/platform-v7a/config/images/stm32mp.config
+++ b/configs/platform-v7a/config/images/stm32mp.config
@@ -1,7 +1,7 @@
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		gpt = true
+		partition-table-type = gpt
 		gpt-no-backup = true
 	}
 	partition fsbl1 {
-- 
2.39.2




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [DistroKit] [PATCH 2/6] v7a: images: use 'partition-table-type' option instead of 'partition-table'
  2023-10-10 19:16 [DistroKit] [PATCH 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt' Roland Hieber
@ 2023-10-10 19:16 ` Roland Hieber
  2023-10-10 19:16 ` [DistroKit] [PATCH 3/6] v7a: barebox: pass root=mmcblkXpN instead of root=PARTUUID=… to kernel Roland Hieber
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Roland Hieber @ 2023-10-10 19:16 UTC (permalink / raw)
  To: distrokit; +Cc: Roland Hieber

genimage v16 complains that 'partition-table = false' is deprecated in
favour of 'partition-table-type = none'.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 configs/platform-v7a/config/images/vexpress-nor.config        | 2 +-
 configs/platform-v7a_noneon/config/images/vexpress-nor.config | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/platform-v7a/config/images/vexpress-nor.config b/configs/platform-v7a/config/images/vexpress-nor.config
index 790ee5fac1dd..cc7edd28f628 100644
--- a/configs/platform-v7a/config/images/vexpress-nor.config
+++ b/configs/platform-v7a/config/images/vexpress-nor.config
@@ -1,6 +1,6 @@
 image @IMAGE@ {
 	hdimage {
-		partition-table = false
+		partition-table-type = none
 	}
 	partition barebox {
 		image = barebox-vexpress-ca9.img
diff --git a/configs/platform-v7a_noneon/config/images/vexpress-nor.config b/configs/platform-v7a_noneon/config/images/vexpress-nor.config
index 790ee5fac1dd..cc7edd28f628 100644
--- a/configs/platform-v7a_noneon/config/images/vexpress-nor.config
+++ b/configs/platform-v7a_noneon/config/images/vexpress-nor.config
@@ -1,6 +1,6 @@
 image @IMAGE@ {
 	hdimage {
-		partition-table = false
+		partition-table-type = none
 	}
 	partition barebox {
 		image = barebox-vexpress-ca9.img
-- 
2.39.2




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [DistroKit] [PATCH 3/6] v7a: barebox: pass root=mmcblkXpN instead of root=PARTUUID=… to kernel
  2023-10-10 19:16 [DistroKit] [PATCH 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt' Roland Hieber
  2023-10-10 19:16 ` [DistroKit] [PATCH 2/6] v7a: images: use 'partition-table-type' option instead of 'partition-table' Roland Hieber
@ 2023-10-10 19:16 ` Roland Hieber
  2023-10-10 19:16 ` [DistroKit] [PATCH 4/6] v7a: barebox: enable GUID Partition Table support Roland Hieber
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Roland Hieber @ 2023-10-10 19:16 UTC (permalink / raw)
  To: distrokit; +Cc: Roland Hieber

Kernels prior to v5.10-rc1 could not ensure deterministic ordering for
MMC devices. For this reason, the default 'append-root' behaviour of
barebox for MMC block devices is to append a 'root=PARTUUID=XYZ' option
to the kernel command line. The PARTUUID is derived from the partition
table and is expected to be unique system-wide. This is however
susceptible to breakage if the exact same image is written to different
boot media in the system, e.g. SD and eMMC, so the PARTUUID will no
longer uniquely refer to a single partition.

Newer kernel versions honor the numbering used for 'mmc' aliases,
which makes 'root=mmcblkXpN' deterministic as long as barebox and
kernel aliases are identical. Since we're using kernel 6.4, enable this
option in barebox.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 configs/platform-v7a/barebox-am335x.config               | 2 +-
 configs/platform-v7a/barebox-am335x.config.diff          | 2 +-
 configs/platform-v7a/barebox-at91.config                 | 2 +-
 configs/platform-v7a/barebox-at91.config.diff            | 2 +-
 configs/platform-v7a/barebox-mx6.config                  | 2 +-
 configs/platform-v7a/barebox-mx6.config.diff             | 2 +-
 configs/platform-v7a/barebox-rpi2.config                 | 2 +-
 configs/platform-v7a/barebox-rpi2.config.diff            | 2 +-
 configs/platform-v7a/barebox-stm32mp.config              | 2 +-
 configs/platform-v7a/barebox-stm32mp.config.diff         | 2 +-
 configs/platform-v7a/barebox-vexpress.config             | 2 +-
 configs/platform-v7a/barebox-vexpress.config.diff        | 2 +-
 configs/platform-v7a/barebox.config                      | 2 +-
 configs/platform-v7a_noneon/barebox-at91.config          | 2 +-
 configs/platform-v7a_noneon/barebox-at91.config.diff     | 2 +-
 configs/platform-v7a_noneon/barebox-vexpress.config      | 2 +-
 configs/platform-v7a_noneon/barebox-vexpress.config.diff | 2 +-
 configs/platform-v7a_noneon/barebox.config               | 2 +-
 18 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/configs/platform-v7a/barebox-am335x.config b/configs/platform-v7a/barebox-am335x.config
index 30a58497bc95..90e7756dabae 100644
--- a/configs/platform-v7a/barebox-am335x.config
+++ b/configs/platform-v7a/barebox-am335x.config
@@ -180,7 +180,7 @@ CONFIG_BOOTM_OFTREE_UIMAGE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 CONFIG_SYSTEM_PARTITIONS=y
 CONFIG_IMD=y
diff --git a/configs/platform-v7a/barebox-am335x.config.diff b/configs/platform-v7a/barebox-am335x.config.diff
index 81e857d116e0..eeb39d3ffc0f 100644
--- a/configs/platform-v7a/barebox-am335x.config.diff
+++ b/configs/platform-v7a/barebox-am335x.config.diff
@@ -1,4 +1,4 @@
-e1ec3277facf26f7ecc5fc49c9c31515
+767c9d2f029195d89d541b1de6347271
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 # CONFIG_AM33XX_NET_BOOT is not set
diff --git a/configs/platform-v7a/barebox-at91.config b/configs/platform-v7a/barebox-at91.config
index 5dc6ec9dc51d..a9758bee288f 100644
--- a/configs/platform-v7a/barebox-at91.config
+++ b/configs/platform-v7a/barebox-at91.config
@@ -191,7 +191,7 @@ CONFIG_BOOTM_OFTREE_UIMAGE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 CONFIG_SYSTEM_PARTITIONS=y
 CONFIG_IMD=y
diff --git a/configs/platform-v7a/barebox-at91.config.diff b/configs/platform-v7a/barebox-at91.config.diff
index 937c41987be2..e90f18cb58e0 100644
--- a/configs/platform-v7a/barebox-at91.config.diff
+++ b/configs/platform-v7a/barebox-at91.config.diff
@@ -1,4 +1,4 @@
-e1ec3277facf26f7ecc5fc49c9c31515
+767c9d2f029195d89d541b1de6347271
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 CONFIG_ARCH_AT91=y
diff --git a/configs/platform-v7a/barebox-mx6.config b/configs/platform-v7a/barebox-mx6.config
index 0484d35e5087..8e8f0d78cef0 100644
--- a/configs/platform-v7a/barebox-mx6.config
+++ b/configs/platform-v7a/barebox-mx6.config
@@ -251,7 +251,7 @@ CONFIG_BOOTM_OFTREE_UIMAGE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 CONFIG_SYSTEM_PARTITIONS=y
 CONFIG_IMD=y
diff --git a/configs/platform-v7a/barebox-mx6.config.diff b/configs/platform-v7a/barebox-mx6.config.diff
index 93775f6509cf..f1308c66847c 100644
--- a/configs/platform-v7a/barebox-mx6.config.diff
+++ b/configs/platform-v7a/barebox-mx6.config.diff
@@ -1,4 +1,4 @@
-e1ec3277facf26f7ecc5fc49c9c31515
+767c9d2f029195d89d541b1de6347271
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 # CONFIG_ARCH_BCM283X is not set
diff --git a/configs/platform-v7a/barebox-rpi2.config b/configs/platform-v7a/barebox-rpi2.config
index 95de61f1c6b8..57250e40b6b6 100644
--- a/configs/platform-v7a/barebox-rpi2.config
+++ b/configs/platform-v7a/barebox-rpi2.config
@@ -179,7 +179,7 @@ CONFIG_BOOTM_OFTREE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 CONFIG_SYSTEM_PARTITIONS=y
 CONFIG_IMD=y
diff --git a/configs/platform-v7a/barebox-rpi2.config.diff b/configs/platform-v7a/barebox-rpi2.config.diff
index 058f595cc787..6f8705a94859 100644
--- a/configs/platform-v7a/barebox-rpi2.config.diff
+++ b/configs/platform-v7a/barebox-rpi2.config.diff
@@ -1,4 +1,4 @@
-e1ec3277facf26f7ecc5fc49c9c31515
+767c9d2f029195d89d541b1de6347271
 CONFIG_ARM_ASM_UNIFIED=y
 CONFIG_BOOTCHOOSER=y
 CONFIG_CMD_BOOTCHOOSER=y
diff --git a/configs/platform-v7a/barebox-stm32mp.config b/configs/platform-v7a/barebox-stm32mp.config
index 08a21f50c00e..af3552c4344b 100644
--- a/configs/platform-v7a/barebox-stm32mp.config
+++ b/configs/platform-v7a/barebox-stm32mp.config
@@ -170,7 +170,7 @@ CONFIG_BOOTM_OFTREE_UIMAGE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 CONFIG_SYSTEM_PARTITIONS=y
 CONFIG_IMD=y
diff --git a/configs/platform-v7a/barebox-stm32mp.config.diff b/configs/platform-v7a/barebox-stm32mp.config.diff
index e951f3824fd3..034c89223848 100644
--- a/configs/platform-v7a/barebox-stm32mp.config.diff
+++ b/configs/platform-v7a/barebox-stm32mp.config.diff
@@ -1,4 +1,4 @@
-e1ec3277facf26f7ecc5fc49c9c31515
+767c9d2f029195d89d541b1de6347271
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 # CONFIG_ARCH_BCM283X is not set
diff --git a/configs/platform-v7a/barebox-vexpress.config b/configs/platform-v7a/barebox-vexpress.config
index 433c73be691c..1024c9d5f2bf 100644
--- a/configs/platform-v7a/barebox-vexpress.config
+++ b/configs/platform-v7a/barebox-vexpress.config
@@ -157,7 +157,7 @@ CONFIG_BOOTM_OFTREE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 CONFIG_SYSTEM_PARTITIONS=y
 CONFIG_IMD=y
diff --git a/configs/platform-v7a/barebox-vexpress.config.diff b/configs/platform-v7a/barebox-vexpress.config.diff
index ff170d222b86..1fce564357f0 100644
--- a/configs/platform-v7a/barebox-vexpress.config.diff
+++ b/configs/platform-v7a/barebox-vexpress.config.diff
@@ -1,4 +1,4 @@
-e1ec3277facf26f7ecc5fc49c9c31515
+767c9d2f029195d89d541b1de6347271
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 CONFIG_AMBA_SP804=y
diff --git a/configs/platform-v7a/barebox.config b/configs/platform-v7a/barebox.config
index 27a6373837b0..f4d9cd21b11c 100644
--- a/configs/platform-v7a/barebox.config
+++ b/configs/platform-v7a/barebox.config
@@ -178,7 +178,7 @@ CONFIG_BOOTM_OFTREE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 CONFIG_SYSTEM_PARTITIONS=y
 CONFIG_IMD=y
diff --git a/configs/platform-v7a_noneon/barebox-at91.config b/configs/platform-v7a_noneon/barebox-at91.config
index d66e099ecada..600417a314df 100644
--- a/configs/platform-v7a_noneon/barebox-at91.config
+++ b/configs/platform-v7a_noneon/barebox-at91.config
@@ -180,7 +180,7 @@ CONFIG_BOOTM_OFTREE_UIMAGE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 CONFIG_SYSTEM_PARTITIONS=y
 CONFIG_IMD=y
diff --git a/configs/platform-v7a_noneon/barebox-at91.config.diff b/configs/platform-v7a_noneon/barebox-at91.config.diff
index 29584321f023..9a5ff84cf648 100644
--- a/configs/platform-v7a_noneon/barebox-at91.config.diff
+++ b/configs/platform-v7a_noneon/barebox-at91.config.diff
@@ -1,4 +1,4 @@
-1dedd85e90c7b6ae44712caf6c69913b
+4843d0dbea5da5cc603015348ad891de
 CONFIG_ARCH_AT91=y
 # CONFIG_ARCH_BCM283X is not set
 # CONFIG_ARCH_IMX is undefined
diff --git a/configs/platform-v7a_noneon/barebox-vexpress.config b/configs/platform-v7a_noneon/barebox-vexpress.config
index d2b7aa6c0073..cf504a6c606c 100644
--- a/configs/platform-v7a_noneon/barebox-vexpress.config
+++ b/configs/platform-v7a_noneon/barebox-vexpress.config
@@ -158,7 +158,7 @@ CONFIG_BOOTM_OFTREE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 # CONFIG_SYSTEM_PARTITIONS is not set
 CONFIG_IMD=y
diff --git a/configs/platform-v7a_noneon/barebox-vexpress.config.diff b/configs/platform-v7a_noneon/barebox-vexpress.config.diff
index fff891e02b70..2215ceb876cc 100644
--- a/configs/platform-v7a_noneon/barebox-vexpress.config.diff
+++ b/configs/platform-v7a_noneon/barebox-vexpress.config.diff
@@ -1,4 +1,4 @@
-1dedd85e90c7b6ae44712caf6c69913b
+4843d0dbea5da5cc603015348ad891de
 CONFIG_AMBA_SP804=y
 # CONFIG_ARCH_BCM283X is not set
 CONFIG_ARCH_VEXPRESS=y
diff --git a/configs/platform-v7a_noneon/barebox.config b/configs/platform-v7a_noneon/barebox.config
index bbedcdb2d650..908bf1fe8d3f 100644
--- a/configs/platform-v7a_noneon/barebox.config
+++ b/configs/platform-v7a_noneon/barebox.config
@@ -174,7 +174,7 @@ CONFIG_BOOTM_OFTREE=y
 # CONFIG_BOOTM_FITIMAGE is not set
 CONFIG_BLSPEC=y
 CONFIG_FLEXIBLE_BOOTARGS=y
-# CONFIG_MMCBLKDEV_ROOTARG is not set
+CONFIG_MMCBLKDEV_ROOTARG=y
 CONFIG_BAREBOX_UPDATE=y
 # CONFIG_SYSTEM_PARTITIONS is not set
 CONFIG_IMD=y
-- 
2.39.2




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [DistroKit] [PATCH 4/6] v7a: barebox: enable GUID Partition Table support
  2023-10-10 19:16 [DistroKit] [PATCH 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt' Roland Hieber
  2023-10-10 19:16 ` [DistroKit] [PATCH 2/6] v7a: images: use 'partition-table-type' option instead of 'partition-table' Roland Hieber
  2023-10-10 19:16 ` [DistroKit] [PATCH 3/6] v7a: barebox: pass root=mmcblkXpN instead of root=PARTUUID=… to kernel Roland Hieber
@ 2023-10-10 19:16 ` Roland Hieber
  2023-10-10 19:16 ` [DistroKit] [PATCH 5/6] images: remove qemu size hack Roland Hieber
  2023-10-10 19:16 ` [DistroKit] [PATCH 6/6] images: convert to GPT format Roland Hieber
  4 siblings, 0 replies; 12+ messages in thread
From: Roland Hieber @ 2023-10-10 19:16 UTC (permalink / raw)
  To: distrokit; +Cc: Roland Hieber

We want to be able to boot from devices formatted with GPT, enable this
on the platforms that don't have it yet.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 configs/platform-v7a/barebox-am335x.config               | 5 ++++-
 configs/platform-v7a/barebox-am335x.config.diff          | 2 +-
 configs/platform-v7a/barebox-at91.config                 | 5 ++++-
 configs/platform-v7a/barebox-at91.config.diff            | 2 +-
 configs/platform-v7a/barebox-mx6.config.diff             | 6 +-----
 configs/platform-v7a/barebox-rpi2.config                 | 5 ++++-
 configs/platform-v7a/barebox-rpi2.config.diff            | 2 +-
 configs/platform-v7a/barebox-stm32mp.config.diff         | 4 +---
 configs/platform-v7a/barebox-vexpress.config             | 5 ++++-
 configs/platform-v7a/barebox-vexpress.config.diff        | 2 +-
 configs/platform-v7a/barebox.config                      | 5 ++++-
 configs/platform-v7a_noneon/barebox-at91.config          | 5 ++++-
 configs/platform-v7a_noneon/barebox-at91.config.diff     | 2 +-
 configs/platform-v7a_noneon/barebox-vexpress.config      | 5 ++++-
 configs/platform-v7a_noneon/barebox-vexpress.config.diff | 2 +-
 configs/platform-v7a_noneon/barebox.config               | 5 ++++-
 16 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/configs/platform-v7a/barebox-am335x.config b/configs/platform-v7a/barebox-am335x.config
index 90e7756dabae..875d935b1755 100644
--- a/configs/platform-v7a/barebox-am335x.config
+++ b/configs/platform-v7a/barebox-am335x.config
@@ -197,7 +197,9 @@ CONFIG_CONSOLE_ALLOW_COLOR=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
 CONFIG_PARTITION_DISK_DOS=y
-# CONFIG_PARTITION_DISK_EFI is not set
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
+CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
 CONFIG_ENV_HANDLING=y
 CONFIG_DEFAULT_ENVIRONMENT=y
 CONFIG_DEFAULT_COMPRESSION_NONE=y
@@ -928,6 +930,7 @@ CONFIG_LIBFDT=y
 #
 # end of Library gui routines
 
+CONFIG_PRINTF_UUID=y
 # CONFIG_NLS is not set
 # CONFIG_BLOBGEN is not set
 CONFIG_ARCH_HAS_STACK_DUMP=y
diff --git a/configs/platform-v7a/barebox-am335x.config.diff b/configs/platform-v7a/barebox-am335x.config.diff
index eeb39d3ffc0f..aa31220c8dab 100644
--- a/configs/platform-v7a/barebox-am335x.config.diff
+++ b/configs/platform-v7a/barebox-am335x.config.diff
@@ -1,4 +1,4 @@
-767c9d2f029195d89d541b1de6347271
+a8029702e337f16bb6355beda6d149d7
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 # CONFIG_AM33XX_NET_BOOT is not set
diff --git a/configs/platform-v7a/barebox-at91.config b/configs/platform-v7a/barebox-at91.config
index a9758bee288f..36925a447cfa 100644
--- a/configs/platform-v7a/barebox-at91.config
+++ b/configs/platform-v7a/barebox-at91.config
@@ -208,7 +208,9 @@ CONFIG_PBL_CONSOLE=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
 CONFIG_PARTITION_DISK_DOS=y
-# CONFIG_PARTITION_DISK_EFI is not set
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
+CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
 CONFIG_ENV_HANDLING=y
 CONFIG_DEFAULT_ENVIRONMENT=y
 CONFIG_DEFAULT_COMPRESSION_NONE=y
@@ -937,6 +939,7 @@ CONFIG_IMAGE_SPARSE=y
 #
 # end of Library gui routines
 
+CONFIG_PRINTF_UUID=y
 # CONFIG_NLS is not set
 # CONFIG_BLOBGEN is not set
 CONFIG_ARCH_HAS_STACK_DUMP=y
diff --git a/configs/platform-v7a/barebox-at91.config.diff b/configs/platform-v7a/barebox-at91.config.diff
index e90f18cb58e0..913695684ecb 100644
--- a/configs/platform-v7a/barebox-at91.config.diff
+++ b/configs/platform-v7a/barebox-at91.config.diff
@@ -1,4 +1,4 @@
-767c9d2f029195d89d541b1de6347271
+a8029702e337f16bb6355beda6d149d7
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 CONFIG_ARCH_AT91=y
diff --git a/configs/platform-v7a/barebox-mx6.config.diff b/configs/platform-v7a/barebox-mx6.config.diff
index f1308c66847c..b15528a71ae4 100644
--- a/configs/platform-v7a/barebox-mx6.config.diff
+++ b/configs/platform-v7a/barebox-mx6.config.diff
@@ -1,4 +1,4 @@
-767c9d2f029195d89d541b1de6347271
+a8029702e337f16bb6355beda6d149d7
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 # CONFIG_ARCH_BCM283X is not set
@@ -210,9 +210,6 @@ CONFIG_NVMEM=y
 # CONFIG_NVMEM_REBOOT_MODE is not set
 # CONFIG_NVMEM_RMEM is not set
 # CONFIG_NVMEM_SNVS_LPGPR is not set
-CONFIG_PARTITION_DISK_EFI=y
-CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
-CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
 # CONFIG_PBL_OPTEE is undefined
 # CONFIG_PCI is not set
 # CONFIG_PCI_ECAM_GENERIC is not set
@@ -222,7 +219,6 @@ CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
 # CONFIG_PINCTRL_BCM283X is undefined
 CONFIG_PINCTRL_IMX_IOMUX_V3=y
 CONFIG_PNG=y
-CONFIG_PRINTF_UUID=y
 CONFIG_PROMPT="barebox:"
 CONFIG_PWM=y
 CONFIG_PWM_IMX=y
diff --git a/configs/platform-v7a/barebox-rpi2.config b/configs/platform-v7a/barebox-rpi2.config
index 57250e40b6b6..1789d9c8faa1 100644
--- a/configs/platform-v7a/barebox-rpi2.config
+++ b/configs/platform-v7a/barebox-rpi2.config
@@ -196,7 +196,9 @@ CONFIG_CONSOLE_ALLOW_COLOR=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
 CONFIG_PARTITION_DISK_DOS=y
-# CONFIG_PARTITION_DISK_EFI is not set
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
+CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
 CONFIG_ENV_HANDLING=y
 CONFIG_DEFAULT_ENVIRONMENT=y
 CONFIG_DEFAULT_COMPRESSION_NONE=y
@@ -917,6 +919,7 @@ CONFIG_LIBFDT=y
 #
 # end of Library gui routines
 
+CONFIG_PRINTF_UUID=y
 # CONFIG_NLS is not set
 # CONFIG_BLOBGEN is not set
 CONFIG_ARCH_HAS_STACK_DUMP=y
diff --git a/configs/platform-v7a/barebox-rpi2.config.diff b/configs/platform-v7a/barebox-rpi2.config.diff
index 6f8705a94859..7dceb530ed66 100644
--- a/configs/platform-v7a/barebox-rpi2.config.diff
+++ b/configs/platform-v7a/barebox-rpi2.config.diff
@@ -1,4 +1,4 @@
-767c9d2f029195d89d541b1de6347271
+a8029702e337f16bb6355beda6d149d7
 CONFIG_ARM_ASM_UNIFIED=y
 CONFIG_BOOTCHOOSER=y
 CONFIG_CMD_BOOTCHOOSER=y
diff --git a/configs/platform-v7a/barebox-stm32mp.config.diff b/configs/platform-v7a/barebox-stm32mp.config.diff
index 034c89223848..f0c4045194df 100644
--- a/configs/platform-v7a/barebox-stm32mp.config.diff
+++ b/configs/platform-v7a/barebox-stm32mp.config.diff
@@ -1,4 +1,4 @@
-767c9d2f029195d89d541b1de6347271
+a8029702e337f16bb6355beda6d149d7
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 # CONFIG_ARCH_BCM283X is not set
@@ -109,7 +109,6 @@ CONFIG_NVMEM=y
 # CONFIG_NVMEM_REBOOT_MODE is not set
 # CONFIG_NVMEM_RMEM is not set
 # CONFIG_NVMEM_SNVS_LPGPR is not set
-CONFIG_PARTITION_DISK_EFI=y
 # CONFIG_PARTITION_DISK_EFI_GPT_COMPARE is not set
 # CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE is not set
 CONFIG_PBL_CONSOLE=y
@@ -118,7 +117,6 @@ CONFIG_PBL_CONSOLE=y
 CONFIG_PHY_STM32_USBPHYC=y
 # CONFIG_PINCTRL_BCM283X is undefined
 CONFIG_PINCTRL_STM32=y
-CONFIG_PRINTF_UUID=y
 CONFIG_PROMPT="barebox:"
 CONFIG_PWM=y
 CONFIG_PWM_STM32=y
diff --git a/configs/platform-v7a/barebox-vexpress.config b/configs/platform-v7a/barebox-vexpress.config
index 1024c9d5f2bf..0d3ab3bde546 100644
--- a/configs/platform-v7a/barebox-vexpress.config
+++ b/configs/platform-v7a/barebox-vexpress.config
@@ -174,7 +174,9 @@ CONFIG_PBL_CONSOLE=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
 CONFIG_PARTITION_DISK_DOS=y
-# CONFIG_PARTITION_DISK_EFI is not set
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
+CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
 CONFIG_ENV_HANDLING=y
 CONFIG_DEFAULT_ENVIRONMENT=y
 CONFIG_DEFAULT_COMPRESSION_NONE=y
@@ -850,6 +852,7 @@ CONFIG_LIBFDT=y
 #
 # end of Library gui routines
 
+CONFIG_PRINTF_UUID=y
 # CONFIG_NLS is not set
 # CONFIG_BLOBGEN is not set
 CONFIG_ARCH_HAS_STACK_DUMP=y
diff --git a/configs/platform-v7a/barebox-vexpress.config.diff b/configs/platform-v7a/barebox-vexpress.config.diff
index 1fce564357f0..f47f7b66f9e2 100644
--- a/configs/platform-v7a/barebox-vexpress.config.diff
+++ b/configs/platform-v7a/barebox-vexpress.config.diff
@@ -1,4 +1,4 @@
-767c9d2f029195d89d541b1de6347271
+a8029702e337f16bb6355beda6d149d7
 # CONFIG_32BIT is undefined
 # CONFIG_64BIT is undefined
 CONFIG_AMBA_SP804=y
diff --git a/configs/platform-v7a/barebox.config b/configs/platform-v7a/barebox.config
index f4d9cd21b11c..b0b3d64c5a0e 100644
--- a/configs/platform-v7a/barebox.config
+++ b/configs/platform-v7a/barebox.config
@@ -195,7 +195,9 @@ CONFIG_CONSOLE_ALLOW_COLOR=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
 CONFIG_PARTITION_DISK_DOS=y
-# CONFIG_PARTITION_DISK_EFI is not set
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
+CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
 CONFIG_ENV_HANDLING=y
 CONFIG_DEFAULT_ENVIRONMENT=y
 CONFIG_DEFAULT_COMPRESSION_NONE=y
@@ -907,6 +909,7 @@ CONFIG_LIBFDT=y
 #
 # end of Library gui routines
 
+CONFIG_PRINTF_UUID=y
 # CONFIG_NLS is not set
 # CONFIG_BLOBGEN is not set
 CONFIG_ARCH_HAS_STACK_DUMP=y
diff --git a/configs/platform-v7a_noneon/barebox-at91.config b/configs/platform-v7a_noneon/barebox-at91.config
index 600417a314df..c24b5d36b79d 100644
--- a/configs/platform-v7a_noneon/barebox-at91.config
+++ b/configs/platform-v7a_noneon/barebox-at91.config
@@ -197,7 +197,9 @@ CONFIG_PBL_CONSOLE=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
 CONFIG_PARTITION_DISK_DOS=y
-# CONFIG_PARTITION_DISK_EFI is not set
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
+CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
 CONFIG_ENV_HANDLING=y
 CONFIG_DEFAULT_ENVIRONMENT=y
 CONFIG_DEFAULT_COMPRESSION_NONE=y
@@ -966,6 +968,7 @@ CONFIG_IMAGE_SPARSE=y
 #
 # end of Library gui routines
 
+CONFIG_PRINTF_UUID=y
 CONFIG_NLS=y
 # CONFIG_BLOBGEN is not set
 CONFIG_ARCH_HAS_STACK_DUMP=y
diff --git a/configs/platform-v7a_noneon/barebox-at91.config.diff b/configs/platform-v7a_noneon/barebox-at91.config.diff
index 9a5ff84cf648..e2cdc16d00ff 100644
--- a/configs/platform-v7a_noneon/barebox-at91.config.diff
+++ b/configs/platform-v7a_noneon/barebox-at91.config.diff
@@ -1,4 +1,4 @@
-4843d0dbea5da5cc603015348ad891de
+71b0583d9737e188a32240ae7d29a558
 CONFIG_ARCH_AT91=y
 # CONFIG_ARCH_BCM283X is not set
 # CONFIG_ARCH_IMX is undefined
diff --git a/configs/platform-v7a_noneon/barebox-vexpress.config b/configs/platform-v7a_noneon/barebox-vexpress.config
index cf504a6c606c..09f112d397e1 100644
--- a/configs/platform-v7a_noneon/barebox-vexpress.config
+++ b/configs/platform-v7a_noneon/barebox-vexpress.config
@@ -175,7 +175,9 @@ CONFIG_PBL_CONSOLE=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
 CONFIG_PARTITION_DISK_DOS=y
-# CONFIG_PARTITION_DISK_EFI is not set
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
+CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
 CONFIG_ENV_HANDLING=y
 CONFIG_DEFAULT_ENVIRONMENT=y
 CONFIG_DEFAULT_COMPRESSION_NONE=y
@@ -864,6 +866,7 @@ CONFIG_LIBFDT=y
 #
 # end of Library gui routines
 
+CONFIG_PRINTF_UUID=y
 CONFIG_NLS=y
 # CONFIG_BLOBGEN is not set
 CONFIG_ARCH_HAS_STACK_DUMP=y
diff --git a/configs/platform-v7a_noneon/barebox-vexpress.config.diff b/configs/platform-v7a_noneon/barebox-vexpress.config.diff
index 2215ceb876cc..36ab78e8ebc3 100644
--- a/configs/platform-v7a_noneon/barebox-vexpress.config.diff
+++ b/configs/platform-v7a_noneon/barebox-vexpress.config.diff
@@ -1,4 +1,4 @@
-4843d0dbea5da5cc603015348ad891de
+71b0583d9737e188a32240ae7d29a558
 CONFIG_AMBA_SP804=y
 # CONFIG_ARCH_BCM283X is not set
 CONFIG_ARCH_VEXPRESS=y
diff --git a/configs/platform-v7a_noneon/barebox.config b/configs/platform-v7a_noneon/barebox.config
index 908bf1fe8d3f..9bbc3745d184 100644
--- a/configs/platform-v7a_noneon/barebox.config
+++ b/configs/platform-v7a_noneon/barebox.config
@@ -191,7 +191,9 @@ CONFIG_CONSOLE_ALLOW_COLOR=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
 CONFIG_PARTITION_DISK_DOS=y
-# CONFIG_PARTITION_DISK_EFI is not set
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE=y
+CONFIG_PARTITION_DISK_EFI_GPT_COMPARE=y
 CONFIG_ENV_HANDLING=y
 CONFIG_DEFAULT_ENVIRONMENT=y
 CONFIG_DEFAULT_COMPRESSION_NONE=y
@@ -916,6 +918,7 @@ CONFIG_LIBFDT=y
 #
 # end of Library gui routines
 
+CONFIG_PRINTF_UUID=y
 CONFIG_NLS=y
 # CONFIG_BLOBGEN is not set
 CONFIG_ARCH_HAS_STACK_DUMP=y
-- 
2.39.2




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [DistroKit] [PATCH 5/6] images: remove qemu size hack
  2023-10-10 19:16 [DistroKit] [PATCH 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt' Roland Hieber
                   ` (2 preceding siblings ...)
  2023-10-10 19:16 ` [DistroKit] [PATCH 4/6] v7a: barebox: enable GUID Partition Table support Roland Hieber
@ 2023-10-10 19:16 ` Roland Hieber
  2023-10-11  6:51   ` Michael Olbrich
  2023-10-10 19:16 ` [DistroKit] [PATCH 6/6] images: convert to GPT format Roland Hieber
  4 siblings, 1 reply; 12+ messages in thread
From: Roland Hieber @ 2023-10-10 19:16 UTC (permalink / raw)
  To: distrokit; +Cc: Roland Hieber

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.

On MIPS, we also need to decrease the size of the last partition so that
it still fits inside the specified image size, because the first MiB
(when using 1 MiB alignment) is occupied by the partition table, so the
first partition only starts at offset 1 MiB.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 .../platform-mips/config/images/ar9331.config    | 16 ++++------------
 configs/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   | 15 +++------------
 .../config/images/vexpress-nor.config            | 10 +++-------
 .../config/images/vexpress.config                | 15 +++------------
 7 files changed, 24 insertions(+), 74 deletions(-)

diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
index 07125bea4c88..8012cf0f839d 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
+		size = 511M
 	}
 }
 
diff --git a/configs/platform-mips/config/images/malta.config b/configs/platform-mips/config/images/malta.config
index 07125bea4c88..8012cf0f839d 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
+		size = 511M
 	}
 }
 
diff --git a/configs/platform-mipsel/config/images/malta.config b/configs/platform-mipsel/config/images/malta.config
index 07125bea4c88..8012cf0f839d 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
+		size = 511M
 	}
 }
 
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..ba677fc3c946 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
@@ -17,18 +20,6 @@ image @IMAGE@ {
 		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
-	}
 }
 
 /* vim: set tabstop=8 noexpandtab : */
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..5291cb31e385 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
@@ -12,18 +15,6 @@ image @IMAGE@ {
 		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
-	}
 }
 
 /* vim: set tabstop=8 noexpandtab : */
-- 
2.39.2




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [DistroKit] [PATCH 6/6] images: convert to GPT format
  2023-10-10 19:16 [DistroKit] [PATCH 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt' Roland Hieber
                   ` (3 preceding siblings ...)
  2023-10-10 19:16 ` [DistroKit] [PATCH 5/6] images: remove qemu size hack Roland Hieber
@ 2023-10-10 19:16 ` Roland Hieber
  2023-10-11  6:58   ` Michael Olbrich
  4 siblings, 1 reply; 12+ messages in thread
From: Roland Hieber @ 2023-10-10 19:16 UTC (permalink / raw)
  To: distrokit; +Cc: Roland Hieber

The GUID Partition Table format has several advantages over the legacy
MBR format. Especially when we want to make use of systemd-repart
functionality later, the GPT format is a necessity. Therefore, migrate
all images to the GPT format.

For some platforms (Raspberry Pi, AM355x, AT91), we still need a legacy
MBR partition table so that the ROM code can find a bootable partition
(which contains our barebox image). For those cases, transform the image
into a hybrid format containing an MBR at offset 0, which contains the
VFAT boot partition for the ROM loader, and a protective GPT partition
of partition type 0xEE after it to claim the remaining space on the
storage medium for GPT porpuses. Then a GPT header is added at the
default GPT offset of 0x200, which defines the boot partition as well as
the root partition, and which is read by Barebox and Linux to boot the
system.

For images that contain a raw barebox image at a fixed offset outside of
a GPT partition, make sure that the GPT does not conflict with the
barebox image, and write only the primary GPT header into the hole
specified by the barebox image (offset 440 to 1K), but move the GPT
partition array to an offset behind the barebox image. (genimage will
then also offset the following partitions accordingly.)

Remove any 'disk-signature' options, which are not compatible with GPT;
genimage will generate a random Disk UUID instead. Also remove any
partition type options which specify a 0x83 or 'Linux'/'L' partition
type, which is the default assumed by genimage.

For the rpi1 image-hdimg, overwrite the upstream hd.config with a
hardcoded genimage config file since it is not possible to build a
hybrid MBR/GPT image with the image recipe from upstream PTXdist.

For the v7a image-hdimg, enable GPT support in the platformconfig menu,
and re-add the respective config lines from the upstream version of the
config file in order to make GPT work.

The images with fixed partition sizes for qemu need to stay below the
size specified in the 'size' option, so decrease the size of the last
partition further to make space for the secondary GPT header, which will
reside in the last block of the image.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 configs/platform-mips/config/images/ar9331.config |  6 ++----
 configs/platform-mips/config/images/malta.config  |  6 ++----
 .../platform-mipsel/config/images/malta.config    |  6 ++----
 configs/platform-rpi1/config/images/hd.config     | 15 +++++++++++++++
 configs/platform-rpi1/platformconfig              |  4 ----
 configs/platform-rpi1/platforms/image-hdimg.in    | 11 +++++++++++
 configs/platform-v7a/config/images/at91-sd.config |  5 ++---
 .../platform-v7a/config/images/beaglebone.config  |  6 ++----
 configs/platform-v7a/config/images/gf.config      |  5 ++---
 configs/platform-v7a/config/images/hd.config      |  4 ++--
 .../platform-v7a/config/images/riotboard.config   |  6 ++----
 configs/platform-v7a/config/images/rpi2.config    |  6 ++----
 .../platform-v7a/config/images/sabrelite.config   |  5 ++---
 .../platform-v7a/config/images/udoo-neo.config    |  5 ++---
 .../platform-v7a/config/images/vexpress.config    |  7 ++-----
 configs/platform-v7a/platformconfig               |  2 +-
 .../config/images/at91-sd.config                  |  5 ++---
 .../config/images/vexpress.config                 |  6 ++----
 .../platform-v8a/config/images/espressobin.config |  3 +--
 configs/platform-v8a/config/images/rock3a.config  |  4 +---
 20 files changed, 57 insertions(+), 60 deletions(-)
 create mode 100644 configs/platform-rpi1/config/images/hd.config
 create mode 100644 configs/platform-rpi1/platforms/image-hdimg.in

diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
index 8012cf0f839d..f3aa28c78e53 100644
--- a/configs/platform-mips/config/images/ar9331.config
+++ b/configs/platform-mips/config/images/ar9331.config
@@ -3,17 +3,15 @@ image @IMAGE@ {
 	size = 1G
 	hdimage {
 		align = 1M
-		disk-signature = 0x74823abf
 		fill = true
+		partition-table-type = gpt
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 		size = 512M
 	}
 	partition data {
-		partition-type = 0x83
-		size = 511M
+		size = 510M
 	}
 }
 
diff --git a/configs/platform-mips/config/images/malta.config b/configs/platform-mips/config/images/malta.config
index 8012cf0f839d..f3aa28c78e53 100644
--- a/configs/platform-mips/config/images/malta.config
+++ b/configs/platform-mips/config/images/malta.config
@@ -3,17 +3,15 @@ image @IMAGE@ {
 	size = 1G
 	hdimage {
 		align = 1M
-		disk-signature = 0x74823abf
 		fill = true
+		partition-table-type = gpt
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 		size = 512M
 	}
 	partition data {
-		partition-type = 0x83
-		size = 511M
+		size = 510M
 	}
 }
 
diff --git a/configs/platform-mipsel/config/images/malta.config b/configs/platform-mipsel/config/images/malta.config
index 8012cf0f839d..f3aa28c78e53 100644
--- a/configs/platform-mipsel/config/images/malta.config
+++ b/configs/platform-mipsel/config/images/malta.config
@@ -3,17 +3,15 @@ image @IMAGE@ {
 	size = 1G
 	hdimage {
 		align = 1M
-		disk-signature = 0x74823abf
 		fill = true
+		partition-table-type = gpt
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 		size = 512M
 	}
 	partition data {
-		partition-type = 0x83
-		size = 511M
+		size = 510M
 	}
 }
 
diff --git a/configs/platform-rpi1/config/images/hd.config b/configs/platform-rpi1/config/images/hd.config
new file mode 100644
index 000000000000..b67369d2c0c7
--- /dev/null
+++ b/configs/platform-rpi1/config/images/hd.config
@@ -0,0 +1,15 @@
+image @IMAGE@ {
+	hdimage {
+		align = 1M
+		partition-table-type = hybrid
+	}
+	partition boot-vfat {
+		image = boot.vfat
+		partition-type-uuid = F
+		partition-type = 0xc
+		bootable = true
+	}
+	partition root {
+		image = root.ext2
+	}
+}
diff --git a/configs/platform-rpi1/platformconfig b/configs/platform-rpi1/platformconfig
index 67e5f161cd78..8fd1b1983015 100644
--- a/configs/platform-rpi1/platformconfig
+++ b/configs/platform-rpi1/platformconfig
@@ -230,10 +230,6 @@ PTXCONF_IMAGE_BOOT_VFAT=y
 PTXCONF_IMAGE_BOOT_VFAT_GPU_MEM=16
 # PTXCONF_IMAGE_HD_VDI is not set
 PTXCONF_IMAGE_HDIMG=y
-# PTXCONF_IMAGE_HDIMG_GPT is not set
-# PTXCONF_IMAGE_HDIMG_NONE is not set
-# PTXCONF_IMAGE_HDIMG_BAREBOX is not set
-PTXCONF_IMAGE_HDIMG_VFAT=y
 PTXCONF_IMAGE_KERNEL=y
 
 #
diff --git a/configs/platform-rpi1/platforms/image-hdimg.in b/configs/platform-rpi1/platforms/image-hdimg.in
new file mode 100644
index 000000000000..052e7e71df38
--- /dev/null
+++ b/configs/platform-rpi1/platforms/image-hdimg.in
@@ -0,0 +1,11 @@
+## SECTION=image
+
+config IMAGE_HDIMG
+	bool
+	select HOST_GENIMAGE
+	select IMAGE_BOOT_VFAT
+	select IMAGE_ROOT_EXT
+	prompt "Generate images/hd.img"
+        help
+	  Build a harddisk root image. The image will contain one partition
+	  containing the root.ext2 and a corresponding partition table.
diff --git a/configs/platform-v7a/config/images/at91-sd.config b/configs/platform-v7a/config/images/at91-sd.config
index 641db071224f..e1522462815c 100644
--- a/configs/platform-v7a/config/images/at91-sd.config
+++ b/configs/platform-v7a/config/images/at91-sd.config
@@ -9,19 +9,18 @@ image @IMAGE@-boot.vfat {
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0x67823abf
+		partition-table-type = hybrid
 	}
 	partition boot {
 		image = @IMAGE@-boot.vfat
 		partition-type = 0xc
+		partition-type-uuid = F
 		bootable = true
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v7a/config/images/beaglebone.config b/configs/platform-v7a/config/images/beaglebone.config
index 07d251bfbe69..135a49b3908b 100644
--- a/configs/platform-v7a/config/images/beaglebone.config
+++ b/configs/platform-v7a/config/images/beaglebone.config
@@ -9,23 +9,21 @@ image beaglebone-boot.vfat {
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0xabe26147
+		partition-table-type = hybrid
 	}
 	partition boot {
 		image = beaglebone-boot.vfat
 		partition-type = 0xc
+		partition-type-uuid = F
 		bootable = true
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition root-B {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v7a/config/images/gf.config b/configs/platform-v7a/config/images/gf.config
index fbaddf15f527..ed6fd3ba2bbb 100644
--- a/configs/platform-v7a/config/images/gf.config
+++ b/configs/platform-v7a/config/images/gf.config
@@ -9,19 +9,18 @@ image gf-boot.vfat {
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0x74823abf
+		partition-table-type = hybrid
 	}
 	partition boot {
 		image = gf-boot.vfat
 		partition-type = 0xc
+		partition-type-uuid = F
 		bootable = true
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v7a/config/images/hd.config b/configs/platform-v7a/config/images/hd.config
index 03cf37a0dbcf..d33ddc43490a 100644
--- a/configs/platform-v7a/config/images/hd.config
+++ b/configs/platform-v7a/config/images/hd.config
@@ -4,11 +4,11 @@
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0xdfb978e3
+		partition-table-type = "@PARTITION_TABLE_TYPE@"
 	}
 	@BOOTLOADER_PARTITIONS@
 	partition root {
 		image = root.ext2
-		partition-type = 0x83
+		partition-type@PARTITION_TYPE_SUFFIX@ = @ROOT_PARTITION_TYPE@
 	}
 }
diff --git a/configs/platform-v7a/config/images/riotboard.config b/configs/platform-v7a/config/images/riotboard.config
index f311fd5e41b0..f10858cbb0bd 100644
--- a/configs/platform-v7a/config/images/riotboard.config
+++ b/configs/platform-v7a/config/images/riotboard.config
@@ -1,7 +1,8 @@
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0x67bac764
+		partition-table-type = gpt
+		gpt-location = 2M
 	}
 
 	partition barebox {
@@ -13,16 +14,13 @@ image @IMAGE@ {
 
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 	}
 
 	partition root-B {
 		image = root.ext2
-		partition-type = 0x83
 	}
 
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v7a/config/images/rpi2.config b/configs/platform-v7a/config/images/rpi2.config
index eebf7052713f..78b46b92ffa5 100644
--- a/configs/platform-v7a/config/images/rpi2.config
+++ b/configs/platform-v7a/config/images/rpi2.config
@@ -10,24 +10,22 @@ image rpi2-boot.vfat {
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0xbedf7893
+		partition-table-type = hybrid
 	}
 	partition boot {
 		offset = 4M
 		image = rpi2-boot.vfat
 		partition-type = 0xc
+		partition-type-uuid = F
 		bootable = true
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition root-B {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v7a/config/images/sabrelite.config b/configs/platform-v7a/config/images/sabrelite.config
index 29e6b5f5a44a..b362534c4346 100644
--- a/configs/platform-v7a/config/images/sabrelite.config
+++ b/configs/platform-v7a/config/images/sabrelite.config
@@ -1,7 +1,8 @@
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0x67bac764
+		partition-table-type = gpt
+		gpt-location = 2M
 	}
 
 	partition barebox {
@@ -13,10 +14,8 @@ image @IMAGE@ {
 
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v7a/config/images/udoo-neo.config b/configs/platform-v7a/config/images/udoo-neo.config
index da677757804d..0dbed62e9441 100644
--- a/configs/platform-v7a/config/images/udoo-neo.config
+++ b/configs/platform-v7a/config/images/udoo-neo.config
@@ -1,7 +1,8 @@
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0x374ac764
+		partition-table-type = gpt
+		gpt-location = 2M
 	}
 
 	partition barebox {
@@ -13,10 +14,8 @@ image @IMAGE@ {
 
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v7a/config/images/vexpress.config b/configs/platform-v7a/config/images/vexpress.config
index ba677fc3c946..41424f79724c 100644
--- a/configs/platform-v7a/config/images/vexpress.config
+++ b/configs/platform-v7a/config/images/vexpress.config
@@ -3,22 +3,19 @@ image @IMAGE@ {
 	size = 256M
 	hdimage {
 		align = 1M
-		disk-signature = 0x74823abf
 		fill = true
+		partition-table-type = gpt
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 		size = 96M
 	}
 	partition root-B {
 		image = root.ext2
-		partition-type = 0x83
 		size = 96M
 	}
 	partition data {
-		partition-type = 0x83
-		size = 63M
+		size = 62M
 	}
 }
 
diff --git a/configs/platform-v7a/platformconfig b/configs/platform-v7a/platformconfig
index 1e83fb3620cd..63e98e7ff4af 100644
--- a/configs/platform-v7a/platformconfig
+++ b/configs/platform-v7a/platformconfig
@@ -242,7 +242,7 @@ PTXCONF_IMAGE_BEAGLEBONE=y
 PTXCONF_IMAGE_GF=y
 # PTXCONF_IMAGE_HD_VDI is not set
 PTXCONF_IMAGE_HDIMG=y
-# PTXCONF_IMAGE_HDIMG_GPT is not set
+PTXCONF_IMAGE_HDIMG_GPT=y
 PTXCONF_IMAGE_HDIMG_NONE=y
 # PTXCONF_IMAGE_HDIMG_BAREBOX is not set
 # PTXCONF_IMAGE_HDIMG_VFAT is not set
diff --git a/configs/platform-v7a_noneon/config/images/at91-sd.config b/configs/platform-v7a_noneon/config/images/at91-sd.config
index caecd247065a..e8a4592b5c05 100644
--- a/configs/platform-v7a_noneon/config/images/at91-sd.config
+++ b/configs/platform-v7a_noneon/config/images/at91-sd.config
@@ -9,19 +9,18 @@ image @IMAGE@-boot.vfat {
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0x67823abf
+		partition-table-type = hybrid
 	}
 	partition boot {
 		image = @IMAGE@-boot.vfat
 		partition-type = 0xc
+		partition-type-uuid = F
 		bootable = true
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v7a_noneon/config/images/vexpress.config b/configs/platform-v7a_noneon/config/images/vexpress.config
index 5291cb31e385..bd82e3b8a4f6 100644
--- a/configs/platform-v7a_noneon/config/images/vexpress.config
+++ b/configs/platform-v7a_noneon/config/images/vexpress.config
@@ -3,17 +3,15 @@ image @IMAGE@ {
 	size = 256M
 	hdimage {
 		align = 1M
-		disk-signature = 0x74823abf
 		fill = true
+		partition-table-type = gpt
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 		size = 192M
 	}
 	partition data {
-		partition-type = 0x83
-		size = 63M
+		size = 62M
 	}
 }
 
diff --git a/configs/platform-v8a/config/images/espressobin.config b/configs/platform-v8a/config/images/espressobin.config
index c4ab201691a9..ec6fac6b19ec 100644
--- a/configs/platform-v8a/config/images/espressobin.config
+++ b/configs/platform-v8a/config/images/espressobin.config
@@ -1,14 +1,13 @@
 image @IMAGE@ {
 	hdimage {
 		align = 1M
+		partition-table-type = gpt
 	}
 	partition root-A {
 		image = root.ext2
-		partition-type = 0x83
 		size = 512M
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
diff --git a/configs/platform-v8a/config/images/rock3a.config b/configs/platform-v8a/config/images/rock3a.config
index 522d82cdc9c9..c3edc9617c86 100644
--- a/configs/platform-v8a/config/images/rock3a.config
+++ b/configs/platform-v8a/config/images/rock3a.config
@@ -1,7 +1,7 @@
 image @IMAGE@ {
 	hdimage {
 		align = 1M
-		disk-signature = 0xf5feaddc
+		partition-table-type = gpt
 	}
 	partition boot1 {
 		offset = 32k
@@ -24,10 +24,8 @@ image @IMAGE@ {
 	partition root-A {
 		offset = 5M
 		image = "root.ext2"
-		partition-type = 0x83
 	}
 	partition data {
-		partition-type = 0x83
 		size = 512M
 	}
 }
-- 
2.39.2




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [DistroKit] [PATCH 5/6] images: remove qemu size hack
  2023-10-10 19:16 ` [DistroKit] [PATCH 5/6] images: remove qemu size hack Roland Hieber
@ 2023-10-11  6:51   ` Michael Olbrich
  2023-10-11  9:40     ` Roland Hieber
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Olbrich @ 2023-10-11  6:51 UTC (permalink / raw)
  To: Roland Hieber; +Cc: distrokit

On Tue, Oct 10, 2023 at 09:16:30PM +0200, Roland Hieber wrote:
> 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.
> 
> On MIPS, we also need to decrease the size of the last partition so that
> it still fits inside the specified image size, because the first MiB
> (when using 1 MiB alignment) is occupied by the partition table, so the
> first partition only starts at offset 1 MiB.
> 
> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
>  .../platform-mips/config/images/ar9331.config    | 16 ++++------------
>  configs/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   | 15 +++------------
>  .../config/images/vexpress-nor.config            | 10 +++-------
>  .../config/images/vexpress.config                | 15 +++------------
>  7 files changed, 24 insertions(+), 74 deletions(-)
> 
> diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
> index 07125bea4c88..8012cf0f839d 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
> +		size = 511M

The last partition can have a 'fill = true' property if the image size is
explicitly specified. That's better than calculating it manually.

Michael

>  	}
>  }
>  
> diff --git a/configs/platform-mips/config/images/malta.config b/configs/platform-mips/config/images/malta.config
> index 07125bea4c88..8012cf0f839d 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
> +		size = 511M
>  	}
>  }
>  
> diff --git a/configs/platform-mipsel/config/images/malta.config b/configs/platform-mipsel/config/images/malta.config
> index 07125bea4c88..8012cf0f839d 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
> +		size = 511M
>  	}
>  }
>  
> 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..ba677fc3c946 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
> @@ -17,18 +20,6 @@ image @IMAGE@ {
>  		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
> -	}
>  }
>  
>  /* vim: set tabstop=8 noexpandtab : */
> 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..5291cb31e385 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
> @@ -12,18 +15,6 @@ image @IMAGE@ {
>  		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
> -	}
>  }
>  
>  /* vim: set tabstop=8 noexpandtab : */
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [DistroKit] [PATCH 6/6] images: convert to GPT format
  2023-10-10 19:16 ` [DistroKit] [PATCH 6/6] images: convert to GPT format Roland Hieber
@ 2023-10-11  6:58   ` Michael Olbrich
  2023-10-11  9:34     ` Roland Hieber
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Olbrich @ 2023-10-11  6:58 UTC (permalink / raw)
  To: Roland Hieber; +Cc: distrokit

On Tue, Oct 10, 2023 at 09:16:31PM +0200, Roland Hieber wrote:
> The GUID Partition Table format has several advantages over the legacy
> MBR format. Especially when we want to make use of systemd-repart
> functionality later, the GPT format is a necessity. Therefore, migrate
> all images to the GPT format.
> 
> For some platforms (Raspberry Pi, AM355x, AT91), we still need a legacy
> MBR partition table so that the ROM code can find a bootable partition
> (which contains our barebox image). For those cases, transform the image
> into a hybrid format containing an MBR at offset 0, which contains the
> VFAT boot partition for the ROM loader, and a protective GPT partition
> of partition type 0xEE after it to claim the remaining space on the
> storage medium for GPT porpuses. Then a GPT header is added at the

s/porpuses/purposes/

> default GPT offset of 0x200, which defines the boot partition as well as
> the root partition, and which is read by Barebox and Linux to boot the
> system.
> 
> For images that contain a raw barebox image at a fixed offset outside of
> a GPT partition, make sure that the GPT does not conflict with the
> barebox image, and write only the primary GPT header into the hole
> specified by the barebox image (offset 440 to 1K), but move the GPT
> partition array to an offset behind the barebox image. (genimage will
> then also offset the following partitions accordingly.)
> 
> Remove any 'disk-signature' options, which are not compatible with GPT;
> genimage will generate a random Disk UUID instead. Also remove any
> partition type options which specify a 0x83 or 'Linux'/'L' partition
> type, which is the default assumed by genimage.

GPT has a special types for rootfs. I think that should be used for the
root partitions.

Michael

> For the rpi1 image-hdimg, overwrite the upstream hd.config with a
> hardcoded genimage config file since it is not possible to build a
> hybrid MBR/GPT image with the image recipe from upstream PTXdist.
> 
> For the v7a image-hdimg, enable GPT support in the platformconfig menu,
> and re-add the respective config lines from the upstream version of the
> config file in order to make GPT work.
> 
> The images with fixed partition sizes for qemu need to stay below the
> size specified in the 'size' option, so decrease the size of the last
> partition further to make space for the secondary GPT header, which will
> reside in the last block of the image.
> 
> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
>  configs/platform-mips/config/images/ar9331.config |  6 ++----
>  configs/platform-mips/config/images/malta.config  |  6 ++----
>  .../platform-mipsel/config/images/malta.config    |  6 ++----
>  configs/platform-rpi1/config/images/hd.config     | 15 +++++++++++++++
>  configs/platform-rpi1/platformconfig              |  4 ----
>  configs/platform-rpi1/platforms/image-hdimg.in    | 11 +++++++++++
>  configs/platform-v7a/config/images/at91-sd.config |  5 ++---
>  .../platform-v7a/config/images/beaglebone.config  |  6 ++----
>  configs/platform-v7a/config/images/gf.config      |  5 ++---
>  configs/platform-v7a/config/images/hd.config      |  4 ++--
>  .../platform-v7a/config/images/riotboard.config   |  6 ++----
>  configs/platform-v7a/config/images/rpi2.config    |  6 ++----
>  .../platform-v7a/config/images/sabrelite.config   |  5 ++---
>  .../platform-v7a/config/images/udoo-neo.config    |  5 ++---
>  .../platform-v7a/config/images/vexpress.config    |  7 ++-----
>  configs/platform-v7a/platformconfig               |  2 +-
>  .../config/images/at91-sd.config                  |  5 ++---
>  .../config/images/vexpress.config                 |  6 ++----
>  .../platform-v8a/config/images/espressobin.config |  3 +--
>  configs/platform-v8a/config/images/rock3a.config  |  4 +---
>  20 files changed, 57 insertions(+), 60 deletions(-)
>  create mode 100644 configs/platform-rpi1/config/images/hd.config
>  create mode 100644 configs/platform-rpi1/platforms/image-hdimg.in
> 
> diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
> index 8012cf0f839d..f3aa28c78e53 100644
> --- a/configs/platform-mips/config/images/ar9331.config
> +++ b/configs/platform-mips/config/images/ar9331.config
> @@ -3,17 +3,15 @@ image @IMAGE@ {
>  	size = 1G
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x74823abf
>  		fill = true
> +		partition-table-type = gpt
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  	partition data {
> -		partition-type = 0x83
> -		size = 511M
> +		size = 510M
>  	}
>  }
>  
> diff --git a/configs/platform-mips/config/images/malta.config b/configs/platform-mips/config/images/malta.config
> index 8012cf0f839d..f3aa28c78e53 100644
> --- a/configs/platform-mips/config/images/malta.config
> +++ b/configs/platform-mips/config/images/malta.config
> @@ -3,17 +3,15 @@ image @IMAGE@ {
>  	size = 1G
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x74823abf
>  		fill = true
> +		partition-table-type = gpt
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  	partition data {
> -		partition-type = 0x83
> -		size = 511M
> +		size = 510M
>  	}
>  }
>  
> diff --git a/configs/platform-mipsel/config/images/malta.config b/configs/platform-mipsel/config/images/malta.config
> index 8012cf0f839d..f3aa28c78e53 100644
> --- a/configs/platform-mipsel/config/images/malta.config
> +++ b/configs/platform-mipsel/config/images/malta.config
> @@ -3,17 +3,15 @@ image @IMAGE@ {
>  	size = 1G
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x74823abf
>  		fill = true
> +		partition-table-type = gpt
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  	partition data {
> -		partition-type = 0x83
> -		size = 511M
> +		size = 510M
>  	}
>  }
>  
> diff --git a/configs/platform-rpi1/config/images/hd.config b/configs/platform-rpi1/config/images/hd.config
> new file mode 100644
> index 000000000000..b67369d2c0c7
> --- /dev/null
> +++ b/configs/platform-rpi1/config/images/hd.config
> @@ -0,0 +1,15 @@
> +image @IMAGE@ {
> +	hdimage {
> +		align = 1M
> +		partition-table-type = hybrid
> +	}
> +	partition boot-vfat {
> +		image = boot.vfat
> +		partition-type-uuid = F
> +		partition-type = 0xc
> +		bootable = true
> +	}
> +	partition root {
> +		image = root.ext2
> +	}
> +}
> diff --git a/configs/platform-rpi1/platformconfig b/configs/platform-rpi1/platformconfig
> index 67e5f161cd78..8fd1b1983015 100644
> --- a/configs/platform-rpi1/platformconfig
> +++ b/configs/platform-rpi1/platformconfig
> @@ -230,10 +230,6 @@ PTXCONF_IMAGE_BOOT_VFAT=y
>  PTXCONF_IMAGE_BOOT_VFAT_GPU_MEM=16
>  # PTXCONF_IMAGE_HD_VDI is not set
>  PTXCONF_IMAGE_HDIMG=y
> -# PTXCONF_IMAGE_HDIMG_GPT is not set
> -# PTXCONF_IMAGE_HDIMG_NONE is not set
> -# PTXCONF_IMAGE_HDIMG_BAREBOX is not set
> -PTXCONF_IMAGE_HDIMG_VFAT=y
>  PTXCONF_IMAGE_KERNEL=y
>  
>  #
> diff --git a/configs/platform-rpi1/platforms/image-hdimg.in b/configs/platform-rpi1/platforms/image-hdimg.in
> new file mode 100644
> index 000000000000..052e7e71df38
> --- /dev/null
> +++ b/configs/platform-rpi1/platforms/image-hdimg.in
> @@ -0,0 +1,11 @@
> +## SECTION=image
> +
> +config IMAGE_HDIMG
> +	bool
> +	select HOST_GENIMAGE
> +	select IMAGE_BOOT_VFAT
> +	select IMAGE_ROOT_EXT
> +	prompt "Generate images/hd.img"
> +        help
> +	  Build a harddisk root image. The image will contain one partition
> +	  containing the root.ext2 and a corresponding partition table.
> diff --git a/configs/platform-v7a/config/images/at91-sd.config b/configs/platform-v7a/config/images/at91-sd.config
> index 641db071224f..e1522462815c 100644
> --- a/configs/platform-v7a/config/images/at91-sd.config
> +++ b/configs/platform-v7a/config/images/at91-sd.config
> @@ -9,19 +9,18 @@ image @IMAGE@-boot.vfat {
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x67823abf
> +		partition-table-type = hybrid
>  	}
>  	partition boot {
>  		image = @IMAGE@-boot.vfat
>  		partition-type = 0xc
> +		partition-type-uuid = F
>  		bootable = true
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v7a/config/images/beaglebone.config b/configs/platform-v7a/config/images/beaglebone.config
> index 07d251bfbe69..135a49b3908b 100644
> --- a/configs/platform-v7a/config/images/beaglebone.config
> +++ b/configs/platform-v7a/config/images/beaglebone.config
> @@ -9,23 +9,21 @@ image beaglebone-boot.vfat {
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0xabe26147
> +		partition-table-type = hybrid
>  	}
>  	partition boot {
>  		image = beaglebone-boot.vfat
>  		partition-type = 0xc
> +		partition-type-uuid = F
>  		bootable = true
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition root-B {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v7a/config/images/gf.config b/configs/platform-v7a/config/images/gf.config
> index fbaddf15f527..ed6fd3ba2bbb 100644
> --- a/configs/platform-v7a/config/images/gf.config
> +++ b/configs/platform-v7a/config/images/gf.config
> @@ -9,19 +9,18 @@ image gf-boot.vfat {
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x74823abf
> +		partition-table-type = hybrid
>  	}
>  	partition boot {
>  		image = gf-boot.vfat
>  		partition-type = 0xc
> +		partition-type-uuid = F
>  		bootable = true
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v7a/config/images/hd.config b/configs/platform-v7a/config/images/hd.config
> index 03cf37a0dbcf..d33ddc43490a 100644
> --- a/configs/platform-v7a/config/images/hd.config
> +++ b/configs/platform-v7a/config/images/hd.config
> @@ -4,11 +4,11 @@
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0xdfb978e3
> +		partition-table-type = "@PARTITION_TABLE_TYPE@"
>  	}
>  	@BOOTLOADER_PARTITIONS@
>  	partition root {
>  		image = root.ext2
> -		partition-type = 0x83
> +		partition-type@PARTITION_TYPE_SUFFIX@ = @ROOT_PARTITION_TYPE@
>  	}
>  }
> diff --git a/configs/platform-v7a/config/images/riotboard.config b/configs/platform-v7a/config/images/riotboard.config
> index f311fd5e41b0..f10858cbb0bd 100644
> --- a/configs/platform-v7a/config/images/riotboard.config
> +++ b/configs/platform-v7a/config/images/riotboard.config
> @@ -1,7 +1,8 @@
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x67bac764
> +		partition-table-type = gpt
> +		gpt-location = 2M
>  	}
>  
>  	partition barebox {
> @@ -13,16 +14,13 @@ image @IMAGE@ {
>  
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  
>  	partition root-B {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v7a/config/images/rpi2.config b/configs/platform-v7a/config/images/rpi2.config
> index eebf7052713f..78b46b92ffa5 100644
> --- a/configs/platform-v7a/config/images/rpi2.config
> +++ b/configs/platform-v7a/config/images/rpi2.config
> @@ -10,24 +10,22 @@ image rpi2-boot.vfat {
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0xbedf7893
> +		partition-table-type = hybrid
>  	}
>  	partition boot {
>  		offset = 4M
>  		image = rpi2-boot.vfat
>  		partition-type = 0xc
> +		partition-type-uuid = F
>  		bootable = true
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition root-B {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v7a/config/images/sabrelite.config b/configs/platform-v7a/config/images/sabrelite.config
> index 29e6b5f5a44a..b362534c4346 100644
> --- a/configs/platform-v7a/config/images/sabrelite.config
> +++ b/configs/platform-v7a/config/images/sabrelite.config
> @@ -1,7 +1,8 @@
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x67bac764
> +		partition-table-type = gpt
> +		gpt-location = 2M
>  	}
>  
>  	partition barebox {
> @@ -13,10 +14,8 @@ image @IMAGE@ {
>  
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v7a/config/images/udoo-neo.config b/configs/platform-v7a/config/images/udoo-neo.config
> index da677757804d..0dbed62e9441 100644
> --- a/configs/platform-v7a/config/images/udoo-neo.config
> +++ b/configs/platform-v7a/config/images/udoo-neo.config
> @@ -1,7 +1,8 @@
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x374ac764
> +		partition-table-type = gpt
> +		gpt-location = 2M
>  	}
>  
>  	partition barebox {
> @@ -13,10 +14,8 @@ image @IMAGE@ {
>  
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v7a/config/images/vexpress.config b/configs/platform-v7a/config/images/vexpress.config
> index ba677fc3c946..41424f79724c 100644
> --- a/configs/platform-v7a/config/images/vexpress.config
> +++ b/configs/platform-v7a/config/images/vexpress.config
> @@ -3,22 +3,19 @@ image @IMAGE@ {
>  	size = 256M
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x74823abf
>  		fill = true
> +		partition-table-type = gpt
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  		size = 96M
>  	}
>  	partition root-B {
>  		image = root.ext2
> -		partition-type = 0x83
>  		size = 96M
>  	}
>  	partition data {
> -		partition-type = 0x83
> -		size = 63M
> +		size = 62M
>  	}
>  }
>  
> diff --git a/configs/platform-v7a/platformconfig b/configs/platform-v7a/platformconfig
> index 1e83fb3620cd..63e98e7ff4af 100644
> --- a/configs/platform-v7a/platformconfig
> +++ b/configs/platform-v7a/platformconfig
> @@ -242,7 +242,7 @@ PTXCONF_IMAGE_BEAGLEBONE=y
>  PTXCONF_IMAGE_GF=y
>  # PTXCONF_IMAGE_HD_VDI is not set
>  PTXCONF_IMAGE_HDIMG=y
> -# PTXCONF_IMAGE_HDIMG_GPT is not set
> +PTXCONF_IMAGE_HDIMG_GPT=y
>  PTXCONF_IMAGE_HDIMG_NONE=y
>  # PTXCONF_IMAGE_HDIMG_BAREBOX is not set
>  # PTXCONF_IMAGE_HDIMG_VFAT is not set
> diff --git a/configs/platform-v7a_noneon/config/images/at91-sd.config b/configs/platform-v7a_noneon/config/images/at91-sd.config
> index caecd247065a..e8a4592b5c05 100644
> --- a/configs/platform-v7a_noneon/config/images/at91-sd.config
> +++ b/configs/platform-v7a_noneon/config/images/at91-sd.config
> @@ -9,19 +9,18 @@ image @IMAGE@-boot.vfat {
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x67823abf
> +		partition-table-type = hybrid
>  	}
>  	partition boot {
>  		image = @IMAGE@-boot.vfat
>  		partition-type = 0xc
> +		partition-type-uuid = F
>  		bootable = true
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v7a_noneon/config/images/vexpress.config b/configs/platform-v7a_noneon/config/images/vexpress.config
> index 5291cb31e385..bd82e3b8a4f6 100644
> --- a/configs/platform-v7a_noneon/config/images/vexpress.config
> +++ b/configs/platform-v7a_noneon/config/images/vexpress.config
> @@ -3,17 +3,15 @@ image @IMAGE@ {
>  	size = 256M
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0x74823abf
>  		fill = true
> +		partition-table-type = gpt
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  		size = 192M
>  	}
>  	partition data {
> -		partition-type = 0x83
> -		size = 63M
> +		size = 62M
>  	}
>  }
>  
> diff --git a/configs/platform-v8a/config/images/espressobin.config b/configs/platform-v8a/config/images/espressobin.config
> index c4ab201691a9..ec6fac6b19ec 100644
> --- a/configs/platform-v8a/config/images/espressobin.config
> +++ b/configs/platform-v8a/config/images/espressobin.config
> @@ -1,14 +1,13 @@
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> +		partition-table-type = gpt
>  	}
>  	partition root-A {
>  		image = root.ext2
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> diff --git a/configs/platform-v8a/config/images/rock3a.config b/configs/platform-v8a/config/images/rock3a.config
> index 522d82cdc9c9..c3edc9617c86 100644
> --- a/configs/platform-v8a/config/images/rock3a.config
> +++ b/configs/platform-v8a/config/images/rock3a.config
> @@ -1,7 +1,7 @@
>  image @IMAGE@ {
>  	hdimage {
>  		align = 1M
> -		disk-signature = 0xf5feaddc
> +		partition-table-type = gpt
>  	}
>  	partition boot1 {
>  		offset = 32k
> @@ -24,10 +24,8 @@ image @IMAGE@ {
>  	partition root-A {
>  		offset = 5M
>  		image = "root.ext2"
> -		partition-type = 0x83
>  	}
>  	partition data {
> -		partition-type = 0x83
>  		size = 512M
>  	}
>  }
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [DistroKit] [PATCH 6/6] images: convert to GPT format
  2023-10-11  6:58   ` Michael Olbrich
@ 2023-10-11  9:34     ` Roland Hieber
  0 siblings, 0 replies; 12+ messages in thread
From: Roland Hieber @ 2023-10-11  9:34 UTC (permalink / raw)
  To: distrokit

On Wed, Oct 11, 2023 at 08:58:31AM +0200, Michael Olbrich wrote:
> On Tue, Oct 10, 2023 at 09:16:31PM +0200, Roland Hieber wrote:
> > The GUID Partition Table format has several advantages over the legacy
> > MBR format. Especially when we want to make use of systemd-repart
> > functionality later, the GPT format is a necessity. Therefore, migrate
> > all images to the GPT format.
> > 
> > For some platforms (Raspberry Pi, AM355x, AT91), we still need a legacy
> > MBR partition table so that the ROM code can find a bootable partition
> > (which contains our barebox image). For those cases, transform the image
> > into a hybrid format containing an MBR at offset 0, which contains the
> > VFAT boot partition for the ROM loader, and a protective GPT partition
> > of partition type 0xEE after it to claim the remaining space on the
> > storage medium for GPT porpuses. Then a GPT header is added at the
> 
> s/porpuses/purposes/
> 
> > default GPT offset of 0x200, which defines the boot partition as well as
> > the root partition, and which is read by Barebox and Linux to boot the
> > system.
> > 
> > For images that contain a raw barebox image at a fixed offset outside of
> > a GPT partition, make sure that the GPT does not conflict with the
> > barebox image, and write only the primary GPT header into the hole
> > specified by the barebox image (offset 440 to 1K), but move the GPT
> > partition array to an offset behind the barebox image. (genimage will
> > then also offset the following partitions accordingly.)
> > 
> > Remove any 'disk-signature' options, which are not compatible with GPT;
> > genimage will generate a random Disk UUID instead. Also remove any
> > partition type options which specify a 0x83 or 'Linux'/'L' partition
> > type, which is the default assumed by genimage.
> 
> GPT has a special types for rootfs. I think that should be used for the
> root partitions.

Yes, but until yesterday [1], there wasn't a GUID for big-endian MIPS,
so I opted for the default 'linux-generic' instead. Will update this in
v2.

[1]: https://github.com/uapi-group/specifications/pull/86

 - Roland

> 
> Michael
> 
> > For the rpi1 image-hdimg, overwrite the upstream hd.config with a
> > hardcoded genimage config file since it is not possible to build a
> > hybrid MBR/GPT image with the image recipe from upstream PTXdist.
> > 
> > For the v7a image-hdimg, enable GPT support in the platformconfig menu,
> > and re-add the respective config lines from the upstream version of the
> > config file in order to make GPT work.
> > 
> > The images with fixed partition sizes for qemu need to stay below the
> > size specified in the 'size' option, so decrease the size of the last
> > partition further to make space for the secondary GPT header, which will
> > reside in the last block of the image.
> > 
> > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > ---
> >  configs/platform-mips/config/images/ar9331.config |  6 ++----
> >  configs/platform-mips/config/images/malta.config  |  6 ++----
> >  .../platform-mipsel/config/images/malta.config    |  6 ++----
> >  configs/platform-rpi1/config/images/hd.config     | 15 +++++++++++++++
> >  configs/platform-rpi1/platformconfig              |  4 ----
> >  configs/platform-rpi1/platforms/image-hdimg.in    | 11 +++++++++++
> >  configs/platform-v7a/config/images/at91-sd.config |  5 ++---
> >  .../platform-v7a/config/images/beaglebone.config  |  6 ++----
> >  configs/platform-v7a/config/images/gf.config      |  5 ++---
> >  configs/platform-v7a/config/images/hd.config      |  4 ++--
> >  .../platform-v7a/config/images/riotboard.config   |  6 ++----
> >  configs/platform-v7a/config/images/rpi2.config    |  6 ++----
> >  .../platform-v7a/config/images/sabrelite.config   |  5 ++---
> >  .../platform-v7a/config/images/udoo-neo.config    |  5 ++---
> >  .../platform-v7a/config/images/vexpress.config    |  7 ++-----
> >  configs/platform-v7a/platformconfig               |  2 +-
> >  .../config/images/at91-sd.config                  |  5 ++---
> >  .../config/images/vexpress.config                 |  6 ++----
> >  .../platform-v8a/config/images/espressobin.config |  3 +--
> >  configs/platform-v8a/config/images/rock3a.config  |  4 +---
> >  20 files changed, 57 insertions(+), 60 deletions(-)
> >  create mode 100644 configs/platform-rpi1/config/images/hd.config
> >  create mode 100644 configs/platform-rpi1/platforms/image-hdimg.in
> > 
> > diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
> > index 8012cf0f839d..f3aa28c78e53 100644
> > --- a/configs/platform-mips/config/images/ar9331.config
> > +++ b/configs/platform-mips/config/images/ar9331.config
> > @@ -3,17 +3,15 @@ image @IMAGE@ {
> >  	size = 1G
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x74823abf
> >  		fill = true
> > +		partition-table-type = gpt
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> > -		size = 511M
> > +		size = 510M
> >  	}
> >  }
> >  
> > diff --git a/configs/platform-mips/config/images/malta.config b/configs/platform-mips/config/images/malta.config
> > index 8012cf0f839d..f3aa28c78e53 100644
> > --- a/configs/platform-mips/config/images/malta.config
> > +++ b/configs/platform-mips/config/images/malta.config
> > @@ -3,17 +3,15 @@ image @IMAGE@ {
> >  	size = 1G
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x74823abf
> >  		fill = true
> > +		partition-table-type = gpt
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> > -		size = 511M
> > +		size = 510M
> >  	}
> >  }
> >  
> > diff --git a/configs/platform-mipsel/config/images/malta.config b/configs/platform-mipsel/config/images/malta.config
> > index 8012cf0f839d..f3aa28c78e53 100644
> > --- a/configs/platform-mipsel/config/images/malta.config
> > +++ b/configs/platform-mipsel/config/images/malta.config
> > @@ -3,17 +3,15 @@ image @IMAGE@ {
> >  	size = 1G
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x74823abf
> >  		fill = true
> > +		partition-table-type = gpt
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> > -		size = 511M
> > +		size = 510M
> >  	}
> >  }
> >  
> > diff --git a/configs/platform-rpi1/config/images/hd.config b/configs/platform-rpi1/config/images/hd.config
> > new file mode 100644
> > index 000000000000..b67369d2c0c7
> > --- /dev/null
> > +++ b/configs/platform-rpi1/config/images/hd.config
> > @@ -0,0 +1,15 @@
> > +image @IMAGE@ {
> > +	hdimage {
> > +		align = 1M
> > +		partition-table-type = hybrid
> > +	}
> > +	partition boot-vfat {
> > +		image = boot.vfat
> > +		partition-type-uuid = F
> > +		partition-type = 0xc
> > +		bootable = true
> > +	}
> > +	partition root {
> > +		image = root.ext2
> > +	}
> > +}
> > diff --git a/configs/platform-rpi1/platformconfig b/configs/platform-rpi1/platformconfig
> > index 67e5f161cd78..8fd1b1983015 100644
> > --- a/configs/platform-rpi1/platformconfig
> > +++ b/configs/platform-rpi1/platformconfig
> > @@ -230,10 +230,6 @@ PTXCONF_IMAGE_BOOT_VFAT=y
> >  PTXCONF_IMAGE_BOOT_VFAT_GPU_MEM=16
> >  # PTXCONF_IMAGE_HD_VDI is not set
> >  PTXCONF_IMAGE_HDIMG=y
> > -# PTXCONF_IMAGE_HDIMG_GPT is not set
> > -# PTXCONF_IMAGE_HDIMG_NONE is not set
> > -# PTXCONF_IMAGE_HDIMG_BAREBOX is not set
> > -PTXCONF_IMAGE_HDIMG_VFAT=y
> >  PTXCONF_IMAGE_KERNEL=y
> >  
> >  #
> > diff --git a/configs/platform-rpi1/platforms/image-hdimg.in b/configs/platform-rpi1/platforms/image-hdimg.in
> > new file mode 100644
> > index 000000000000..052e7e71df38
> > --- /dev/null
> > +++ b/configs/platform-rpi1/platforms/image-hdimg.in
> > @@ -0,0 +1,11 @@
> > +## SECTION=image
> > +
> > +config IMAGE_HDIMG
> > +	bool
> > +	select HOST_GENIMAGE
> > +	select IMAGE_BOOT_VFAT
> > +	select IMAGE_ROOT_EXT
> > +	prompt "Generate images/hd.img"
> > +        help
> > +	  Build a harddisk root image. The image will contain one partition
> > +	  containing the root.ext2 and a corresponding partition table.
> > diff --git a/configs/platform-v7a/config/images/at91-sd.config b/configs/platform-v7a/config/images/at91-sd.config
> > index 641db071224f..e1522462815c 100644
> > --- a/configs/platform-v7a/config/images/at91-sd.config
> > +++ b/configs/platform-v7a/config/images/at91-sd.config
> > @@ -9,19 +9,18 @@ image @IMAGE@-boot.vfat {
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x67823abf
> > +		partition-table-type = hybrid
> >  	}
> >  	partition boot {
> >  		image = @IMAGE@-boot.vfat
> >  		partition-type = 0xc
> > +		partition-type-uuid = F
> >  		bootable = true
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v7a/config/images/beaglebone.config b/configs/platform-v7a/config/images/beaglebone.config
> > index 07d251bfbe69..135a49b3908b 100644
> > --- a/configs/platform-v7a/config/images/beaglebone.config
> > +++ b/configs/platform-v7a/config/images/beaglebone.config
> > @@ -9,23 +9,21 @@ image beaglebone-boot.vfat {
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0xabe26147
> > +		partition-table-type = hybrid
> >  	}
> >  	partition boot {
> >  		image = beaglebone-boot.vfat
> >  		partition-type = 0xc
> > +		partition-type-uuid = F
> >  		bootable = true
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition root-B {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v7a/config/images/gf.config b/configs/platform-v7a/config/images/gf.config
> > index fbaddf15f527..ed6fd3ba2bbb 100644
> > --- a/configs/platform-v7a/config/images/gf.config
> > +++ b/configs/platform-v7a/config/images/gf.config
> > @@ -9,19 +9,18 @@ image gf-boot.vfat {
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x74823abf
> > +		partition-table-type = hybrid
> >  	}
> >  	partition boot {
> >  		image = gf-boot.vfat
> >  		partition-type = 0xc
> > +		partition-type-uuid = F
> >  		bootable = true
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v7a/config/images/hd.config b/configs/platform-v7a/config/images/hd.config
> > index 03cf37a0dbcf..d33ddc43490a 100644
> > --- a/configs/platform-v7a/config/images/hd.config
> > +++ b/configs/platform-v7a/config/images/hd.config
> > @@ -4,11 +4,11 @@
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0xdfb978e3
> > +		partition-table-type = "@PARTITION_TABLE_TYPE@"
> >  	}
> >  	@BOOTLOADER_PARTITIONS@
> >  	partition root {
> >  		image = root.ext2
> > -		partition-type = 0x83
> > +		partition-type@PARTITION_TYPE_SUFFIX@ = @ROOT_PARTITION_TYPE@
> >  	}
> >  }
> > diff --git a/configs/platform-v7a/config/images/riotboard.config b/configs/platform-v7a/config/images/riotboard.config
> > index f311fd5e41b0..f10858cbb0bd 100644
> > --- a/configs/platform-v7a/config/images/riotboard.config
> > +++ b/configs/platform-v7a/config/images/riotboard.config
> > @@ -1,7 +1,8 @@
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x67bac764
> > +		partition-table-type = gpt
> > +		gpt-location = 2M
> >  	}
> >  
> >  	partition barebox {
> > @@ -13,16 +14,13 @@ image @IMAGE@ {
> >  
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  
> >  	partition root-B {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v7a/config/images/rpi2.config b/configs/platform-v7a/config/images/rpi2.config
> > index eebf7052713f..78b46b92ffa5 100644
> > --- a/configs/platform-v7a/config/images/rpi2.config
> > +++ b/configs/platform-v7a/config/images/rpi2.config
> > @@ -10,24 +10,22 @@ image rpi2-boot.vfat {
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0xbedf7893
> > +		partition-table-type = hybrid
> >  	}
> >  	partition boot {
> >  		offset = 4M
> >  		image = rpi2-boot.vfat
> >  		partition-type = 0xc
> > +		partition-type-uuid = F
> >  		bootable = true
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition root-B {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v7a/config/images/sabrelite.config b/configs/platform-v7a/config/images/sabrelite.config
> > index 29e6b5f5a44a..b362534c4346 100644
> > --- a/configs/platform-v7a/config/images/sabrelite.config
> > +++ b/configs/platform-v7a/config/images/sabrelite.config
> > @@ -1,7 +1,8 @@
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x67bac764
> > +		partition-table-type = gpt
> > +		gpt-location = 2M
> >  	}
> >  
> >  	partition barebox {
> > @@ -13,10 +14,8 @@ image @IMAGE@ {
> >  
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v7a/config/images/udoo-neo.config b/configs/platform-v7a/config/images/udoo-neo.config
> > index da677757804d..0dbed62e9441 100644
> > --- a/configs/platform-v7a/config/images/udoo-neo.config
> > +++ b/configs/platform-v7a/config/images/udoo-neo.config
> > @@ -1,7 +1,8 @@
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x374ac764
> > +		partition-table-type = gpt
> > +		gpt-location = 2M
> >  	}
> >  
> >  	partition barebox {
> > @@ -13,10 +14,8 @@ image @IMAGE@ {
> >  
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v7a/config/images/vexpress.config b/configs/platform-v7a/config/images/vexpress.config
> > index ba677fc3c946..41424f79724c 100644
> > --- a/configs/platform-v7a/config/images/vexpress.config
> > +++ b/configs/platform-v7a/config/images/vexpress.config
> > @@ -3,22 +3,19 @@ image @IMAGE@ {
> >  	size = 256M
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x74823abf
> >  		fill = true
> > +		partition-table-type = gpt
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  		size = 96M
> >  	}
> >  	partition root-B {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  		size = 96M
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> > -		size = 63M
> > +		size = 62M
> >  	}
> >  }
> >  
> > diff --git a/configs/platform-v7a/platformconfig b/configs/platform-v7a/platformconfig
> > index 1e83fb3620cd..63e98e7ff4af 100644
> > --- a/configs/platform-v7a/platformconfig
> > +++ b/configs/platform-v7a/platformconfig
> > @@ -242,7 +242,7 @@ PTXCONF_IMAGE_BEAGLEBONE=y
> >  PTXCONF_IMAGE_GF=y
> >  # PTXCONF_IMAGE_HD_VDI is not set
> >  PTXCONF_IMAGE_HDIMG=y
> > -# PTXCONF_IMAGE_HDIMG_GPT is not set
> > +PTXCONF_IMAGE_HDIMG_GPT=y
> >  PTXCONF_IMAGE_HDIMG_NONE=y
> >  # PTXCONF_IMAGE_HDIMG_BAREBOX is not set
> >  # PTXCONF_IMAGE_HDIMG_VFAT is not set
> > diff --git a/configs/platform-v7a_noneon/config/images/at91-sd.config b/configs/platform-v7a_noneon/config/images/at91-sd.config
> > index caecd247065a..e8a4592b5c05 100644
> > --- a/configs/platform-v7a_noneon/config/images/at91-sd.config
> > +++ b/configs/platform-v7a_noneon/config/images/at91-sd.config
> > @@ -9,19 +9,18 @@ image @IMAGE@-boot.vfat {
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x67823abf
> > +		partition-table-type = hybrid
> >  	}
> >  	partition boot {
> >  		image = @IMAGE@-boot.vfat
> >  		partition-type = 0xc
> > +		partition-type-uuid = F
> >  		bootable = true
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v7a_noneon/config/images/vexpress.config b/configs/platform-v7a_noneon/config/images/vexpress.config
> > index 5291cb31e385..bd82e3b8a4f6 100644
> > --- a/configs/platform-v7a_noneon/config/images/vexpress.config
> > +++ b/configs/platform-v7a_noneon/config/images/vexpress.config
> > @@ -3,17 +3,15 @@ image @IMAGE@ {
> >  	size = 256M
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0x74823abf
> >  		fill = true
> > +		partition-table-type = gpt
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  		size = 192M
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> > -		size = 63M
> > +		size = 62M
> >  	}
> >  }
> >  
> > diff --git a/configs/platform-v8a/config/images/espressobin.config b/configs/platform-v8a/config/images/espressobin.config
> > index c4ab201691a9..ec6fac6b19ec 100644
> > --- a/configs/platform-v8a/config/images/espressobin.config
> > +++ b/configs/platform-v8a/config/images/espressobin.config
> > @@ -1,14 +1,13 @@
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > +		partition-table-type = gpt
> >  	}
> >  	partition root-A {
> >  		image = root.ext2
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > diff --git a/configs/platform-v8a/config/images/rock3a.config b/configs/platform-v8a/config/images/rock3a.config
> > index 522d82cdc9c9..c3edc9617c86 100644
> > --- a/configs/platform-v8a/config/images/rock3a.config
> > +++ b/configs/platform-v8a/config/images/rock3a.config
> > @@ -1,7 +1,7 @@
> >  image @IMAGE@ {
> >  	hdimage {
> >  		align = 1M
> > -		disk-signature = 0xf5feaddc
> > +		partition-table-type = gpt
> >  	}
> >  	partition boot1 {
> >  		offset = 32k
> > @@ -24,10 +24,8 @@ image @IMAGE@ {
> >  	partition root-A {
> >  		offset = 5M
> >  		image = "root.ext2"
> > -		partition-type = 0x83
> >  	}
> >  	partition data {
> > -		partition-type = 0x83
> >  		size = 512M
> >  	}
> >  }
> > -- 
> > 2.39.2
> > 
> > 
> > 
> 
> -- 
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [DistroKit] [PATCH 5/6] images: remove qemu size hack
  2023-10-11  6:51   ` Michael Olbrich
@ 2023-10-11  9:40     ` Roland Hieber
  2023-10-11  9:45       ` Roland Hieber
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Hieber @ 2023-10-11  9:40 UTC (permalink / raw)
  To: distrokit

On Wed, Oct 11, 2023 at 08:51:15AM +0200, Michael Olbrich wrote:
> On Tue, Oct 10, 2023 at 09:16:30PM +0200, Roland Hieber wrote:
> > 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.
> > 
> > On MIPS, we also need to decrease the size of the last partition so that
> > it still fits inside the specified image size, because the first MiB
> > (when using 1 MiB alignment) is occupied by the partition table, so the
> > first partition only starts at offset 1 MiB.
> > 
> > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > ---
> >  .../platform-mips/config/images/ar9331.config    | 16 ++++------------
> >  configs/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   | 15 +++------------
> >  .../config/images/vexpress-nor.config            | 10 +++-------
> >  .../config/images/vexpress.config                | 15 +++------------
> >  7 files changed, 24 insertions(+), 74 deletions(-)
> > 
> > diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
> > index 07125bea4c88..8012cf0f839d 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
> > +		size = 511M
> 
> The last partition can have a 'fill = true' property if the image size is
> explicitly specified. That's better than calculating it manually.

Apparently not…?

    ----------------------
    target: vexpress.hdimg
    ----------------------
    
    'next/configs/platform-v7a_noneon/config/images/vexpress.config' after substitutions:
    ----------------
    image vexpress.hdimg {
            /* 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
                    partition-type = 0x83
                    size = 192M
            }
            partition data {
                    partition-type = 0x83
                    fill = true
            }
    }
    
    /* vim: set tabstop=8 noexpandtab : */
    ----------------
    
    ptxdist: executing:  genimage --loglevel 2 --rootpath /ptx/work/WORK_XUNGI/rhi/distrokit/next/platform-v7a_noneon/build-target/image-vexpress --tmppath /tmp/ptxdist.xhJOma/genimage.QTRARn --outputpath /ptx/work/WORK_XUNGI/rhi/distrokit/next/platform-v7a_noneon/images --inputpath /ptx/work/WORK_XUNGI/rhi/distrokit/next/platform-v7a_noneon/images --config /tmp/ptxdist.xhJOma/genimage-config.lptj9g/vexpress.config
    
    /tmp/ptxdist.xhJOma/genimage-config.lptj9g/vexpress.config:17: no such option 'fill'
    make: *** [/ptx/work/WORK_XUNGI/rhi/distrokit/next/configs/platform-v7a_noneon/rules/image-vexpress.make:28: /ptx/work/WORK_XUNGI/rhi/distrokit/next/platform-v7a_noneon/images/vexpress.hdimg] Error 1
    

 - Roland

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [DistroKit] [PATCH 5/6] images: remove qemu size hack
  2023-10-11  9:40     ` Roland Hieber
@ 2023-10-11  9:45       ` Roland Hieber
  2023-10-11 10:03         ` Roland Hieber
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Hieber @ 2023-10-11  9:45 UTC (permalink / raw)
  To: distrokit

On Wed, Oct 11, 2023 at 11:40:40AM +0200, Roland Hieber wrote:
> On Wed, Oct 11, 2023 at 08:51:15AM +0200, Michael Olbrich wrote:
> > On Tue, Oct 10, 2023 at 09:16:30PM +0200, Roland Hieber wrote:
> > > 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.
> > > 
> > > On MIPS, we also need to decrease the size of the last partition so that
> > > it still fits inside the specified image size, because the first MiB
> > > (when using 1 MiB alignment) is occupied by the partition table, so the
> > > first partition only starts at offset 1 MiB.
> > > 
> > > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > > ---
> > >  .../platform-mips/config/images/ar9331.config    | 16 ++++------------
> > >  configs/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   | 15 +++------------
> > >  .../config/images/vexpress-nor.config            | 10 +++-------
> > >  .../config/images/vexpress.config                | 15 +++------------
> > >  7 files changed, 24 insertions(+), 74 deletions(-)
> > > 
> > > diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
> > > index 07125bea4c88..8012cf0f839d 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
> > > +		size = 511M
> > 
> > The last partition can have a 'fill = true' property if the image size is
> > explicitly specified. That's better than calculating it manually.
> 
> Apparently not…?

Ah. Because it was only added in genimage commit e123753a4f03, which is
not released yet, so PTXdist can't have it yet.

https://github.com/pengutronix/genimage/commit/e123753a4f03415dad7c

 - Roland

> 
>     ----------------------
>     target: vexpress.hdimg
>     ----------------------
>     
>     'next/configs/platform-v7a_noneon/config/images/vexpress.config' after substitutions:
>     ----------------
>     image vexpress.hdimg {
>             /* 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
>                     partition-type = 0x83
>                     size = 192M
>             }
>             partition data {
>                     partition-type = 0x83
>                     fill = true
>             }
>     }
>     
>     /* vim: set tabstop=8 noexpandtab : */
>     ----------------
>     
>     ptxdist: executing:  genimage --loglevel 2 --rootpath /ptx/work/WORK_XUNGI/rhi/distrokit/next/platform-v7a_noneon/build-target/image-vexpress --tmppath /tmp/ptxdist.xhJOma/genimage.QTRARn --outputpath /ptx/work/WORK_XUNGI/rhi/distrokit/next/platform-v7a_noneon/images --inputpath /ptx/work/WORK_XUNGI/rhi/distrokit/next/platform-v7a_noneon/images --config /tmp/ptxdist.xhJOma/genimage-config.lptj9g/vexpress.config
>     
>     /tmp/ptxdist.xhJOma/genimage-config.lptj9g/vexpress.config:17: no such option 'fill'
>     make: *** [/ptx/work/WORK_XUNGI/rhi/distrokit/next/configs/platform-v7a_noneon/rules/image-vexpress.make:28: /ptx/work/WORK_XUNGI/rhi/distrokit/next/platform-v7a_noneon/images/vexpress.hdimg] Error 1
>     
> 
>  - Roland
> 
> -- 
> Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
> Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
> 31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |
> 
> 

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [DistroKit] [PATCH 5/6] images: remove qemu size hack
  2023-10-11  9:45       ` Roland Hieber
@ 2023-10-11 10:03         ` Roland Hieber
  0 siblings, 0 replies; 12+ messages in thread
From: Roland Hieber @ 2023-10-11 10:03 UTC (permalink / raw)
  To: distrokit

On Wed, Oct 11, 2023 at 11:45:37AM +0200, Roland Hieber wrote:
> On Wed, Oct 11, 2023 at 11:40:40AM +0200, Roland Hieber wrote:
> > On Wed, Oct 11, 2023 at 08:51:15AM +0200, Michael Olbrich wrote:
> > > On Tue, Oct 10, 2023 at 09:16:30PM +0200, Roland Hieber wrote:
> > > > 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.
> > > > 
> > > > On MIPS, we also need to decrease the size of the last partition so that
> > > > it still fits inside the specified image size, because the first MiB
> > > > (when using 1 MiB alignment) is occupied by the partition table, so the
> > > > first partition only starts at offset 1 MiB.
> > > > 
> > > > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > > > ---
> > > >  .../platform-mips/config/images/ar9331.config    | 16 ++++------------
> > > >  configs/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   | 15 +++------------
> > > >  .../config/images/vexpress-nor.config            | 10 +++-------
> > > >  .../config/images/vexpress.config                | 15 +++------------
> > > >  7 files changed, 24 insertions(+), 74 deletions(-)
> > > > 
> > > > diff --git a/configs/platform-mips/config/images/ar9331.config b/configs/platform-mips/config/images/ar9331.config
> > > > index 07125bea4c88..8012cf0f839d 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
> > > > +		size = 511M
> > > 
> > > The last partition can have a 'fill = true' property if the image size is
> > > explicitly specified. That's better than calculating it manually.
> > 
> > Apparently not…?
> 
> Ah. Because it was only added in genimage commit e123753a4f03, which is
> not released yet, so PTXdist can't have it yet.
> 
> https://github.com/pengutronix/genimage/commit/e123753a4f03415dad7c

Ah, but there is the option 'autoresize', which works as expected in
hdimage sections. Will use that for v2.

 - Roland

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-10-11 10:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-10 19:16 [DistroKit] [PATCH 1/6] v7a: image-stm32mp: use 'partition-table-type' option instead of 'gpt' Roland Hieber
2023-10-10 19:16 ` [DistroKit] [PATCH 2/6] v7a: images: use 'partition-table-type' option instead of 'partition-table' Roland Hieber
2023-10-10 19:16 ` [DistroKit] [PATCH 3/6] v7a: barebox: pass root=mmcblkXpN instead of root=PARTUUID=… to kernel Roland Hieber
2023-10-10 19:16 ` [DistroKit] [PATCH 4/6] v7a: barebox: enable GUID Partition Table support Roland Hieber
2023-10-10 19:16 ` [DistroKit] [PATCH 5/6] images: remove qemu size hack Roland Hieber
2023-10-11  6:51   ` Michael Olbrich
2023-10-11  9:40     ` Roland Hieber
2023-10-11  9:45       ` Roland Hieber
2023-10-11 10:03         ` Roland Hieber
2023-10-10 19:16 ` [DistroKit] [PATCH 6/6] images: convert to GPT format Roland Hieber
2023-10-11  6:58   ` Michael Olbrich
2023-10-11  9:34     ` Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox