]> code.ossystems Code Review - meta-freescale.git/commitdiff
sdcard_image.bbclass: allow for easy creating of SD card image
authorOtavio Salvador <otavio@ossystems.com.br>
Sun, 18 Dec 2011 18:02:31 +0000 (18:02 +0000)
committerOtavio Salvador <otavio@ossystems.com.br>
Tue, 20 Dec 2011 11:17:34 +0000 (11:17 +0000)
This creates an image suitable for writting onto a SD card and use on
i.MX53 boards allowing for easy image testing.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
meta-fsl-arm/classes/sdcard_image.bbclass [new file with mode: 0644]

diff --git a/meta-fsl-arm/classes/sdcard_image.bbclass b/meta-fsl-arm/classes/sdcard_image.bbclass
new file mode 100644 (file)
index 0000000..5887240
--- /dev/null
@@ -0,0 +1,38 @@
+#
+# Create an image that can by written onto a SD card using dd.
+#
+# External variables needed:
+#   ${ROOTFS} - the rootfs image to incorporate
+
+inherit image
+
+# Add the fstypes we need
+IMAGE_FSTYPES += "sdimg"
+
+# Ensure required utilities are present
+IMAGE_DEPENDS_sdimg = "parted-native"
+
+# Default to 3.4GiB images
+SDIMG_SIZE ?= "3400"
+
+# Addional space for boot partition
+BOOT_SPACE ?= "10M"
+
+IMAGE_CMD_sdimg () {
+       TMP=${WORKDIR}/tmp
+       SDIMG=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.sdimg
+
+       dd if=/dev/zero of=${SDIMG} bs=$(expr 1000 \* 1000) count=${SDIMG_SIZE}
+
+       # Create partition table
+       parted -s ${SDIMG} mklabel msdos
+       parted -s ${SDIMG} mkpart primary ${BOOT_SPACE} 100%
+       parted ${SDIMG} print
+
+       dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.bin of=${SDIMG} conv=notrunc seek=1 skip=1 bs=512
+       dd if=${DEPLOY_DIR_IMAGE}/uImage-${MACHINE}.bin of=${SDIMG} conv=notrunc seek=1 bs=1M
+       dd if=${ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=${BOOT_SPACE}
+
+       cd ${DEPLOY_DIR_IMAGE}
+       ln -sf ${IMAGE_NAME}.sdimg ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.sdimg
+}