]> code.ossystems Code Review - meta-freescale.git/commitdiff
Major refactor in SDCard generation
authorOtavio Salvador <otavio@ossystems.com.br>
Mon, 19 Mar 2012 19:55:45 +0000 (19:55 +0000)
committerOtavio Salvador <otavio@ossystems.com.br>
Thu, 22 Mar 2012 15:07:18 +0000 (15:07 +0000)
The generation of SDCard has been completely refactored to work out of
box; now to use it you have to set, e.g:

SDCARD_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
SDCARD_SIZE = "128"
IMAGE_TYPES += "ext3 sdcard"

Now the sdcard has following layout:

 0  - 1M                  - reserved to bootloader and other data
 1M - BOOT_SPACE          - kernel
 BOOT_SPACE - SDCARD_SIZE - rootfs

All current supported machines on BSP will work out of box and
generate a 2GB SDCard with an ext3 rootfs on it.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
meta-fsl-arm/classes/image_types_fsl.bbclass [new file with mode: 0644]
meta-fsl-arm/classes/sdcard_image.bbclass [deleted file]
meta-fsl-arm/conf/distro/include/fsl-default-settings.inc [new file with mode: 0644]
meta-fsl-arm/conf/machine/include/imx-base.inc

diff --git a/meta-fsl-arm/classes/image_types_fsl.bbclass b/meta-fsl-arm/classes/image_types_fsl.bbclass
new file mode 100644 (file)
index 0000000..3ae0b17
--- /dev/null
@@ -0,0 +1,76 @@
+inherit image_types
+
+IMAGE_BOOTLOADER ?= "u-boot"
+
+# Handle u-boot suffixes
+UBOOT_SUFFIX ?= "bin"
+
+#
+# Create an image that can by written onto a SD card using dd.
+#
+# External variables needed:
+#   ${SDCARD_ROOTFS}    - the rootfs image to incorporate
+#   ${IMAGE_BOOTLOADER} - bootloader to use {u-boot, barebox}x
+#
+# The disk layout used is:
+#
+#    0  - 1M                  - reserved to bootloader and other data
+#    1M - BOOT_SPACE          - kernel
+#    BOOT_SPACE - SDCARD_SIZE - rootfs
+#
+
+# Default to 3.4GiB images
+SDCARD_SIZE ?= "3400"
+
+# Boot partition volume id
+BOOTDD_VOLUME_ID ?= "Boot ${MACHINE}"
+
+# Addional space for boot partition
+BOOT_SPACE ?= "5M"
+
+IMAGE_DEPENDS_sdcard = "parted-native dosfstools-native mtools-native \
+                        virtual/kernel ${IMAGE_BOOTLOADER}"
+
+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
+
+       TMP=${WORKDIR}/tmp
+       SDCARD=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.sdcard
+
+       dd if=/dev/zero of=${SDCARD} bs=$(expr 1000 \* 1000) count=${SDCARD_SIZE}
+
+       # Create partition table
+       parted -s ${SDCARD} mklabel msdos
+       parted -s ${SDCARD} mkpart primary 0 1M
+       parted -s ${SDCARD} mkpart primary 1M ${BOOT_SPACE}
+       parted -s ${SDCARD} mkpart primary ${BOOT_SPACE} 100%
+       parted ${SDCARD} print
+
+       case "${IMAGE_BOOTLOADER}" in
+               u-boot)
+               dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} of=${SDCARD} conv=notrunc seek=2 bs=512
+               ;;
+               barebox)
+               dd if=${DEPLOY_DIR_IMAGE}/barebox-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 skip=1 bs=512
+               dd if=${DEPLOY_DIR_IMAGE}/bareboxenv-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 bs=512k
+               ;;
+               *)
+               bberror "Unkown IMAGE_BOOTLOADER value"
+               exit 1
+               ;;
+       esac
+
+       BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
+                         | awk '/ 2 / { print substr($3, 1, length($3 -1)) / 512 }')
+       mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
+       mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/uImage-${MACHINE}.bin ::/uImage
+
+       dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=1 bs=1M
+       dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=${BOOT_SPACE}
+
+       cd ${DEPLOY_DIR_IMAGE}
+       ln -sf ${IMAGE_NAME}.sdcard ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.sdcard
+}
diff --git a/meta-fsl-arm/classes/sdcard_image.bbclass b/meta-fsl-arm/classes/sdcard_image.bbclass
deleted file mode 100644 (file)
index 96f7080..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# Create an image that can by written onto a SD card using dd.
-#
-# External variables needed:
-#   ${ROOTFS} - the rootfs image to incorporate
-#   ${IMAGE_BOOTLOADER} - bootloader to use {u-boot, barebox}x
-
-inherit image
-
-IMAGE_BOOTLOADER ?= "u-boot"
-
-do_rootfs[depends] += "parted-native:do_populate_sysroot \
-                       virtual/kernel:do_deploy \
-                       ${IMAGE_BOOTLOADER}:do_deploy"
-
-# Add the fstypes we need
-IMAGE_FSTYPES += "sdimg"
-
-# 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
-
-       case "${IMAGE_BOOTLOADER}" in
-               u-boot)
-               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
-               ;;
-               barebox)
-               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
-               ;;
-               *)
-               bberror "Unkown IMAGE_BOOTLOADER value"
-               exit 1
-               ;;
-       esac
-
-       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
-}
diff --git a/meta-fsl-arm/conf/distro/include/fsl-default-settings.inc b/meta-fsl-arm/conf/distro/include/fsl-default-settings.inc
new file mode 100644 (file)
index 0000000..b36e75a
--- /dev/null
@@ -0,0 +1,3 @@
+# Freescale BSP default settings
+
+IMAGE_CLASSES += "image_types_fsl"
index 906cc0ae129bc707e982dd37fe6d9e2858bd2e86..aa1e48e7f9a8fa85153188f14f20c39b832a26a9 100644 (file)
@@ -1,5 +1,6 @@
 # Provides the i.MX common settings
 
+include conf/distro/include/fsl-default-settings.inc
 include conf/distro/include/fsl-default-versions.inc
 include conf/distro/include/fsl-default-revisions.inc
 include conf/distro/include/fsl-default-providers.inc
@@ -31,7 +32,9 @@ MACHINE_EXTRA_RRECOMMENDS += "imx-lib imx-audio \
 
 EXTRA_IMAGEDEPENDS = "u-boot"
 
-IMAGE_FSTYPES ?= "tar.bz2 jffs2"
+SDCARD_ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
+IMAGE_FSTYPES ?= "tar.bz2 ext3 sdcard"
+
 EXTRA_IMAGECMD_jffs2 = "-lnp "
 
 SERIAL_CONSOLE = "115200 ttymxc0"