Patchwork [3/4] cubox-i: add machine config and new image type

login
register
mail settings
Submitter Carlos Rafael Giani
Date Jan. 22, 2014, 4:45 p.m.
Message ID <1390409134-7450-4-git-send-email-dv@pseudoterminal.org>
Download mbox | patch
Permalink /patch/65567/
State Changes Requested
Delegated to: Otavio Salvador
Headers show

Comments

Carlos Rafael Giani - Jan. 22, 2014, 4:45 p.m.
The new cubox-i machine config produces images that can be used for
all CuBox-i and HummingBoard devices (u-boot SPL autodetects the platform)

The new image type is based on image_types_fsl and is necessary because
the SPL u-boot build is made up of two blobs (SPL and u-boot.img) instead
of one (u-boot.imx)

Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
---
 classes/image_types_cubox-i.bbclass | 34 ++++++++++++++++++++++++++++++++++
 conf/machine/cubox-i.conf           | 25 +++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 classes/image_types_cubox-i.bbclass
 create mode 100644 conf/machine/cubox-i.conf
Otavio Salvador - Jan. 22, 2014, 5:12 p.m.
On Wed, Jan 22, 2014 at 2:45 PM, Carlos Rafael Giani
<dv@pseudoterminal.org> wrote:
> The new cubox-i machine config produces images that can be used for
> all CuBox-i and HummingBoard devices (u-boot SPL autodetects the platform)
>
> The new image type is based on image_types_fsl and is necessary because
> the SPL u-boot build is made up of two blobs (SPL and u-boot.img) instead
> of one (u-boot.imx)
>
> Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
...
> +UENV_FILENAME = "uEnv-cubox-i.txt"
> +SPL_FILENAME = "SPL-cubox-i"

Please use the SPL_BINARY.

To properly integrate it, please rework the imx generation to check
for the SPL_BINARY content and behave different, so we avoid the
cobux-i specific method.

UENV_FILENAME can be set here but please use "uEnv-${MACHINE}.txt"

It also must be checked in the u-boot recipe so it has a default value.

> +BOOT_SCRIPTS = "${UENV_FILENAME}:uEnv.txt"

Patch

diff --git a/classes/image_types_cubox-i.bbclass b/classes/image_types_cubox-i.bbclass
new file mode 100644
index 0000000..70d16a3
--- /dev/null
+++ b/classes/image_types_cubox-i.bbclass
@@ -0,0 +1,34 @@ 
+inherit image_types_fsl
+
+SDCARD_GENERATION_COMMAND_cubox-i = "generate_imx_sdcard_cuboxi"
+
+generate_imx_sdcard_cuboxi() {
+	# 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)
+	parted ${SDCARD} print
+
+	# Burn bootloader
+	dd if=${DEPLOY_DIR_IMAGE}/${SPL_FILENAME} of=${SDCARD} conv=notrunc seek=2 bs=512
+	dd if=${DEPLOY_DIR_IMAGE}/u-boot.img of=${SDCARD} conv=notrunc seek=42 bs=1K
+
+	# Create boot partition image
+	BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
+	                  | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 1024 }')
+	mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
+	mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE}
+
+	# Copy boot scripts
+	for item in ${BOOT_SCRIPTS}; do
+		src=`echo $item | awk -F':' '{ print $1 }'`
+		dst=`echo $item | awk -F':' '{ print $2 }'`
+
+		mcopy -i ${WORKDIR}/boot.img -s $src ::/$dst
+	done
+
+	# Burn Partition
+	dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
+	dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
+}
+
diff --git a/conf/machine/cubox-i.conf b/conf/machine/cubox-i.conf
new file mode 100644
index 0000000..dc5aeba
--- /dev/null
+++ b/conf/machine/cubox-i.conf
@@ -0,0 +1,25 @@ 
+# machine config for the SolidRun CuBox-i series
+# this also includes the SolidRun HummingBoard devices
+
+require conf/machine/include/imx6sabresd-common.inc
+
+SOC_FAMILY = "mx6:mx6s"
+
+PREFERRED_PROVIDER_u-boot = "u-boot-cubox-i"
+
+PREFERRED_VERSION_linux-imx = "3.0.35"
+PREFERRED_PROVIDER_virtual/kernel = "linux-imx"
+
+UBOOT_MAKE_TARGET = ""
+UBOOT_SUFFIX = "img"
+UBOOT_CONFIG ??= "sd"
+UBOOT_CONFIG[sd] = "mx6_cubox-i_config,sdcard"
+UBOOT_ENTRYPOINT = "0x10800000"
+
+UENV_FILENAME = "uEnv-cubox-i.txt"
+SPL_FILENAME = "SPL-cubox-i"
+
+BOOT_SCRIPTS = "${UENV_FILENAME}:uEnv.txt"
+
+IMAGE_CLASSES += "image_types_cubox-i"
+