Skip to contentSkip to conversation

classes/image_types: Add vfat image type

PATCH Superseded Joshua Watt 2 participants 4 messages Aug 15, 2023 – Aug 18, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 classes/image_types: Add vfat image type

From: Joshua Watt <[email protected]>

Adds support for creating FAT formatted file system images (useful for boot partitions on some SoCs).

---
 meta/classes-recipe/image_types.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)
meta/classes-recipe/image_types.bbclass +12 -0
index fdee835e7c8..c75fd212703 100644
@@ -131,6 +131,12 @@ IMAGE_CMD:erofs = "mkfs.erofs ${EXTRA_IMAGECMD} ${IMGDEPLOYDIR}/${IMAGE_NAME}.er
 IMAGE_CMD:erofs-lz4 = "mkfs.erofs -zlz4 ${EXTRA_IMAGECMD} ${IMGDEPLOYDIR}/${IMAGE_NAME}.erofs-lz4 ${IMAGE_ROOTFS}"
 IMAGE_CMD:erofs-lz4hc = "mkfs.erofs -zlz4hc ${EXTRA_IMAGECMD} ${IMGDEPLOYDIR}/${IMAGE_NAME}.erofs-lz4hc ${IMAGE_ROOTFS}"
 
+oe_mkvfatfs () {
+    mkfs.vfat $@ -C ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.vfat ${ROOTFS_SIZE}
+    mcopy -i "${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.vfat" -vsmpQ ${IMAGE_ROOTFS}/* ::/
+}
+
+IMAGE_CMD:vfat = "oe_mkvfatfs ${EXTRA_IMAGECMD}"
 
 IMAGE_CMD_TAR ?= "tar"
 # ignore return code 1 "file changed as we read it" as other tasks(e.g. do_image_wic) may be hardlinking rootfs
@@ -266,6 +272,10 @@ EXTRA_IMAGECMD:ext4 ?= "-i 4096"
 EXTRA_IMAGECMD:btrfs ?= "-n 4096 --shrink"
 EXTRA_IMAGECMD:f2fs ?= ""
 
+# If a specific FAT size is needed, set it here (e.g. "-F 32"/"-F 16"/"-F 12")
+# otherwise mkfs.vfat will automatically pick one
+EXTRA_IMAGECMD:vfat ?= ""
+
 do_image_cpio[depends] += "cpio-native:do_populate_sysroot"
 do_image_jffs2[depends] += "mtd-utils-native:do_populate_sysroot"
 do_image_cramfs[depends] += "util-linux-native:do_populate_sysroot"
@@ -285,6 +295,7 @@ do_image_f2fs[depends] += "f2fs-tools-native:do_populate_sysroot"
 do_image_erofs[depends] += "erofs-utils-native:do_populate_sysroot"
 do_image_erofs_lz4[depends] += "erofs-utils-native:do_populate_sysroot"
 do_image_erofs_lz4hc[depends] += "erofs-utils-native:do_populate_sysroot"
+do_image_vfat[depends] += "dosfstools-native:do_populate_sysroot mtools-native:do_populate_sysroot"
 
 # This variable is available to request which values are suitable for IMAGE_FSTYPES
 IMAGE_TYPES = " \
@@ -294,6 +305,7 @@ IMAGE_TYPES = " \
     ext3 ext3.gz \
     ext4 ext4.gz \
     btrfs \
+    vfat \
     squashfs squashfs-xz squashfs-lzo squashfs-lz4 squashfs-zst \
     ubi ubifs multiubi \
     tar tar.gz tar.bz2 tar.xz tar.lz4 tar.zst \
Signature · 1 line
2.33.0
#1 lore raw
Quoted 9 lines · Joshua Watt

From: Joshua Watt <[email protected]>

Adds support for creating FAT formatted file system images (useful for boot partitions on some SoCs).

---
 meta/classes-recipe/image_types.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)

This causes a selftest failure:

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/5616/steps/15/logs/stdio

[in other selftests as well, a consistent issue for a change!]

Cheers,

Richard

#2 lore raw
Quoted 7 lines · Richard Purdie
Quoted 5 lines · Joshua Watt

From: Joshua Watt <[email protected]>

Adds support for creating FAT formatted file system images (useful for boot partitions on some SoCs).

Quoted 6 lines
Quoted 4 lines
---
 meta/classes-recipe/image_types.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)

This causes a selftest failure:

Oops, sorry about that. I'll take a look

Quoted 8 lines

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/5616/steps/15/logs/stdio

[in other selftests as well, a consistent issue for a change!]

Cheers,

Richard

#3 lore raw

PATCH v2 1/1 classes/image_types: Add vfat image type

In reply to Joshua Watt

From: Joshua Watt <[email protected]>

Adds support for creating FAT formatted file system images (useful for boot partitions on some SoCs).

Note that FAT partitions are limited in what they can represent (no symlinks or device files), so they can't really be used for general purpose root file systems. As such, they are skipped when testing for that purpose.

---
 meta/classes-recipe/image_types.bbclass       | 15 +++++++++++++++
 meta/lib/oeqa/selftest/cases/imagefeatures.py |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
meta/classes-recipe/image_types.bbclass +15 -0
index fdee835e7c8..4aed64e27f3 100644
@@ -131,6 +131,15 @@ IMAGE_CMD:erofs = "mkfs.erofs ${EXTRA_IMAGECMD} ${IMGDEPLOYDIR}/${IMAGE_NAME}.er
 IMAGE_CMD:erofs-lz4 = "mkfs.erofs -zlz4 ${EXTRA_IMAGECMD} ${IMGDEPLOYDIR}/${IMAGE_NAME}.erofs-lz4 ${IMAGE_ROOTFS}"
 IMAGE_CMD:erofs-lz4hc = "mkfs.erofs -zlz4hc ${EXTRA_IMAGECMD} ${IMGDEPLOYDIR}/${IMAGE_NAME}.erofs-lz4hc ${IMAGE_ROOTFS}"
 
+# Note that vfat can't handle all types of files that a real linux file system
+# can (e.g. device files, symlinks, etc.) and therefore it not suitable for all
+# use cases
+oe_mkvfatfs () {
+    mkfs.vfat $@ -C ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.vfat ${ROOTFS_SIZE}
+    mcopy -i "${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.vfat" -vsmpQ ${IMAGE_ROOTFS}/* ::/
+}
+
+IMAGE_CMD:vfat = "oe_mkvfatfs ${EXTRA_IMAGECMD}"
 
 IMAGE_CMD_TAR ?= "tar"
 # ignore return code 1 "file changed as we read it" as other tasks(e.g. do_image_wic) may be hardlinking rootfs
@@ -266,6 +275,10 @@ EXTRA_IMAGECMD:ext4 ?= "-i 4096"
 EXTRA_IMAGECMD:btrfs ?= "-n 4096 --shrink"
 EXTRA_IMAGECMD:f2fs ?= ""
 
+# If a specific FAT size is needed, set it here (e.g. "-F 32"/"-F 16"/"-F 12")
+# otherwise mkfs.vfat will automatically pick one.
+EXTRA_IMAGECMD:vfat ?= ""
+
 do_image_cpio[depends] += "cpio-native:do_populate_sysroot"
 do_image_jffs2[depends] += "mtd-utils-native:do_populate_sysroot"
 do_image_cramfs[depends] += "util-linux-native:do_populate_sysroot"
@@ -285,6 +298,7 @@ do_image_f2fs[depends] += "f2fs-tools-native:do_populate_sysroot"
 do_image_erofs[depends] += "erofs-utils-native:do_populate_sysroot"
 do_image_erofs_lz4[depends] += "erofs-utils-native:do_populate_sysroot"
 do_image_erofs_lz4hc[depends] += "erofs-utils-native:do_populate_sysroot"
+do_image_vfat[depends] += "dosfstools-native:do_populate_sysroot mtools-native:do_populate_sysroot"
 
 # This variable is available to request which values are suitable for IMAGE_FSTYPES
 IMAGE_TYPES = " \
@@ -294,6 +308,7 @@ IMAGE_TYPES = " \
     ext3 ext3.gz \
     ext4 ext4.gz \
     btrfs \
+    vfat \
     squashfs squashfs-xz squashfs-lzo squashfs-lz4 squashfs-zst \
     ubi ubifs multiubi \
     tar tar.gz tar.bz2 tar.xz tar.lz4 tar.zst \
meta/lib/oeqa/selftest/cases/imagefeatures.py +1 -1
index a5e069d0be9..dc88c222bdc 100644
@@ -199,7 +199,7 @@ class ImageFeatures(OESelftestTestCase):
         image = 'core-image-minimal'
 
         all_image_types = set(get_bb_var("IMAGE_TYPES", image).split())
-        skip_image_types = set(('container', 'elf', 'f2fs', 'tar.zst', 'wic.zst', 'squashfs-lzo'))
+        skip_image_types = set(('container', 'elf', 'f2fs', 'tar.zst', 'wic.zst', 'squashfs-lzo', 'vfat'))
         img_types = all_image_types - skip_image_types
 
         config = """
Signature · 1 line
2.33.0