I am looking at generating my own IMAGE_FSTYPES=sdcard
image for a Freescale Variscite VAR-SOM-MX6. I have copied the meta-fsl-arm/classes/image_types_fsl.bbclass
class and modified it slightly so that there are three partitions rather than two. I am looking to include a third partition which is formatted as FAT (vfat) so that files can be added onto the sdcard so that they do not sit alongside files in the boot partition or the root file system.
I have made additions to the generate_imx_sdcard()
function where I create a new partition:
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
I have ensured that the total sdcard side accommodates this by including this, where I add the new partition size ${THIRD_PARTITION}
to the total sdcard (device) size:
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})
When I bitbake my layer and burn the output sdcard image to an SD card, the partitions are appropriately sized and available however the question/problem that I have is, how do I format this newly created partition?
I understand that a regular method of doing this would be something along the lines of mkfs.vfat -n "Partition Name" /dev/sdd
, where I supply a device, however I am unsure how to go about this in Yocto as there is no device identifier, just the ${SDCARD}
variable. I understand that if the partition was to be formatted as an ext4 file system then it would be possible to provide offsets to do the formatting however it seems like there is no option to do this if I wanted it formatted as vfat.
Any help would be greatly appreciated.