我正在考虑IMAGE_FSTYPES=sdcard
为飞思卡尔 Variscite VAR-SOM-MX6 生成自己的图像。我已经复制了这个meta-fsl-arm/classes/image_types_fsl.bbclass
类并稍微修改了它,以便有三个分区而不是两个。我希望包含一个格式化为 FAT (vfat) 的第三个分区,以便可以将文件添加到 sdcard 上,这样它们就不会与引导分区或根文件系统中的文件并排放置。
我对generate_imx_sdcard()
创建新分区的功能进行了添加:
generate_imx_sdcard () {
# Create partition table
parted -s ${SDCARD} mklabel msdos
parted -s ${SDCARD} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED})
parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE)
# Line below is the new partition I have added
parted -s ${SDCARD} unit KiB mkpart primary fat32 $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE \+ ${THIRD_PARTITION})
parted ${SDCARD} print
我通过包括这个来确保整个 sdcard 端可以容纳这个,我将新的分区大小添加${THIRD_PARTITION}
到总 sdcard(设备)大小中:
IMAGE_CMD_sdcard () {
if [ -z "${SDCARD_ROOTFS}" ]; then
bberror "SDCARD_ROOTFS is undefined. To use sdcard image from Freescale's BSP it needs to be defined."
exit 1
fi
# Align boot partition and calculate total SD card image size
BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
SDCARD_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT} + ${THIRD_PARTITION})
当我对图层进行 bitbake 并将输出 sdcard 映像刻录到 SD 卡时,分区的大小合适且可用,但是我遇到的问题/问题是,如何格式化这个新创建的分区?
我知道执行此操作的常规方法类似于mkfs.vfat -n "Partition Name" /dev/sdd
我提供设备的地方,但是我不确定如何在 Yocto 中执行此操作,因为没有设备标识符,只有${SDCARD}
变量。我知道如果要将分区格式化为 ext4 文件系统,那么可以提供偏移量来进行格式化,但是如果我希望将其格式化为 vfat,似乎没有选项可以这样做。
任何帮助将不胜感激。