How to format partitions in sdcard image

cancel
Showing results for 
Search instead for 
Did you mean: 

How to format partitions in sdcard image

1,447 Views
brendanta
Contributor II

Hello,

I am looking at generating my own IMAGE_FSTYPES=sdcard image. 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:

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})

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?  

Any help would be greatly appreciated. 

4 Replies

375 Views
BiyongSUN
NXP Employee
NXP Employee

Please refer to 
AndroidSDCARDMirrorCreator
https://community.freescale.com/docs/DOC-329596

0 Kudos

375 Views
jbirdvegas
Contributor I

The link is now 404 so if you have experience customizing the format please share.

0 Kudos

375 Views
b36401
NXP TechSupport
NXP TechSupport

You can format this partition with "mkfs.vfat /dev/sdd" shell command later, after Yocto.

Have a great day,
Victor

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

375 Views
brendanta
Contributor II

Thanks for your reply.  That is currently the solution I am doing however I am after a more complete solution with the .bbclass file handling formatting and partitioning.

0 Kudos