]> code.ossystems Code Review - meta-freescale.git/commitdiff
bbsdcard-image: add new class
authorEric Bénard <eric@eukrea.com>
Thu, 8 Mar 2012 16:22:50 +0000 (17:22 +0100)
committerOtavio Salvador <otavio@ossystems.com.br>
Thu, 8 Mar 2012 16:34:38 +0000 (16:34 +0000)
this class allows the generation of a ready to use SDCard image
using barebox bootloader.

example on how to use it (with angstrom distro) :
1- add these 3 lines to your local.conf :
ROOTFS = "${DEPLOY_DIR_IMAGE}/console-image-imx53qsb.ext3"
INHERIT += "bbsdcard_image"
BBSDIMG_SIZE = "512"

2- build the image
bitbake console-image

3- copy it to the sdcard (update device for you sdcard, take care to not erase your hard drive ;-)
sudo dd if=build/tmp-angstrom_2010_x-eglibc/deploy/images/imx53qsb/console-image-imx53qsb.bbsdimg of=/dev/mmcblk0

Signed-off-by: Eric Bénard <eric@eukrea.com>
meta-fsl-arm/classes/bbsdcard_image.bbclass [new file with mode: 0644]

diff --git a/meta-fsl-arm/classes/bbsdcard_image.bbclass b/meta-fsl-arm/classes/bbsdcard_image.bbclass
new file mode 100644 (file)
index 0000000..18914d0
--- /dev/null
@@ -0,0 +1,37 @@
+#
+# Create an image that can by written onto a SD card using dd.
+#
+# External variables needed:
+#   ${ROOTFS} - the rootfs image to incorporate
+
+# Add the fstypes we need
+IMAGE_FSTYPES += "bbsdimg"
+
+# Ensure required utilities are present
+IMAGE_DEPENDS_bbsdimg = "parted-native virtual/kernel barebox"
+
+# Default to 2GiB images
+BBSDIMG_SIZE ?= "2000"
+
+# Addional space for boot partition
+BOOT_SPACE ?= "5M"
+
+IMAGE_CMD_bbsdimg () {
+       TMP=${WORKDIR}/tmp
+       SDIMG=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.bbsdimg
+
+       if [ -f ${SDIMG} ]; then
+               rm ${SDIMG}
+       fi
+       dd if=/dev/zero of=${SDIMG} bs=$(expr 1000 \* 1000) count=${BBSDIMG_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}/barebox-${MACHINE}.bin of=${SDIMG} conv=notrunc seek=1 skip=1 bs=512
+       dd if=${DEPLOY_DIR_IMAGE}/bareboxenv-${MACHINE}.bin of=${SDIMG} conv=notrunc seek=1 bs=512k
+       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}
+}