Re: [yocto] [meta-rockchip][PATCH 3/3] rockchip-next-img: add image for rockchip next-dev u-boot

2017-02-18 Thread Trevor Woerner
On Sat 2017-02-18 @ 06:50:05 PM, Romain Perier wrote:
> 1 patch per feature or per different component. So  I should get a patch
> for rk3288.inc and another one for the class :)

I could argue that this is one patch since the only way to flash (for example)
the Firefly is to use the image this class generates so now that this bbclass
exists, rk3288 builds should be using it.

In any case I've split them up and taken the opportunity to rename and re-work
the commit.

> Suppose I am a user of meta-rockchip. I want to use a class for generating
> a image. The name "rockchip-img-next" is not clear at all for me.
> If that's for the sdcard call it rockchip-img-sdmmc if later you plan to
> add a class for emmc call it rockchip-img-emmc :)

Agreed, it is too vague. A v2 is on its way! :-)
-- 
___
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


Re: [yocto] [meta-rockchip][PATCH 3/3] rockchip-next-img: add image for rockchip next-dev u-boot

2017-02-18 Thread Romain Perier
Hi,

1 patch per feature or per different component. So  I should get a patch
for rk3288.inc and another one for the class :)

Suppose I am a user of meta-rockchip. I want to use a class for generating
a image. The name "rockchip-img-next" is not clear at all for me.
If that's for the sdcard call it rockchip-img-sdmmc if later you plan to
add a class for emmc call it rockchip-img-emmc :)

Why so complicated when you can make it simple ? ;)

Also, could you add more details to your commit messages please

Regards,
Romain



2017-02-17 19:07 GMT+01:00 Trevor Woerner :

> From: Jacob Chen 
>
> Being different from the previous rk-boot which use parameter, next-dev
> u-boot
> use gpt partition, so it needs to generate a different image.
>
> Reviewed-by: Trevor Woerner 
> Signed-off-by: Jacob Chen 
> ---
>  classes/rockchip-next-img.bbclass | 130 ++
> 
>  conf/machine/include/rk3288.inc   |   4 ++
>  2 files changed, 134 insertions(+)
>  create mode 100644 classes/rockchip-next-img.bbclass
>
> diff --git a/classes/rockchip-next-img.bbclass
> b/classes/rockchip-next-img.bbclass
> new file mode 100644
> index 000..cd87dee
> --- /dev/null
> +++ b/classes/rockchip-next-img.bbclass
> @@ -0,0 +1,130 @@
> +# Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd
> +# Released under the MIT license (see COPYING.MIT for the terms)
> +
> +inherit image_types
> +
> +# Use an uncompressed ext4 by default as rootfs
> +IMG_ROOTFS_TYPE = "ext4"
> +IMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.${IMG_ROOTFS_TYPE}"
> +
> +# This image depends on the rootfs image
> +IMAGE_TYPEDEP_rockchip-next-img = "${IMG_ROOTFS_TYPE}"
> +
> +NEXT_IMG   = "${IMAGE_NAME}.next.img"
> +BOOT_IMG   = "boot.img"
> +MINILOADER = "loader.bin"
> +UBOOT  = "u-boot.out"
> +TRUST  = "trust.out"
> +
> +# Target image total size [in MiB]
> +NEXT_IMG_SIZE ?= "4096"
> +
> +# default partitions [in Sectors]
> +# More info at http://rockchip.wikidot.com/partitions
> +LOADER1_SIZE = "8000"
> +RESERVED1_SIZE = "128"
> +RESERVED2_SIZE = "8192"
> +LOADER2_SIZE = "8192"
> +ATF_SIZE = "8192"
> +BOOT_SIZE = "229376"
> +
> +IMAGE_DEPENDS_rockchip-next-img = "parted-native \
> +   u-boot-mkimage-native \
> +   mtools-native \
> +   dosfstools-native \
> +   virtual/kernel:do_deploy \
> +   virtual/bootloader:do_deploy"
> +
> +PER_CHIP_IMG_GENERATION_COMMAND_rk3288 = "generate_rk3288_image"
> +
> +IMAGE_CMD_rockchip-next-img () {
> +   # Change to image directory
> +   cd ${DEPLOY_DIR_IMAGE}
> +
> +   create_rk_image
> +
> +   ${PER_CHIP_IMG_GENERATION_COMMAND}
> +}
> +
> +create_rk_image () {
> +
> +   echo "Creating filesystem with total size ${NEXT_IMG_SIZE} MiB"
> +
> +   # Remove the exist image
> +   rm -rf *.next.img
> +
> +   # Initialize sdcard image file
> +   dd if=/dev/zero of=${NEXT_IMG} bs=1M count=0 seek=${NEXT_IMG_SIZE}
> +
> +   # Create partition table
> +   parted -s ${NEXT_IMG} mklabel gpt
> +
> +   # Create vendor defined partitions
> +   LOADER1_START=64
> +   RESERVED1_START=`expr ${LOADER1_START}  + ${LOADER1_SIZE}`
> +   RESERVED2_START=`expr ${RESERVED1_START}  + ${RESERVED1_SIZE}`
> +   LOADER2_START=`expr ${RESERVED2_START}  + ${RESERVED2_SIZE}`
> +   ATF_START=`expr ${LOADER2_START}  + ${LOADER2_SIZE}`
> +   BOOT_START=`expr ${ATF_START}  + ${ATF_SIZE}`
> +   ROOTFS_START=`expr ${BOOT_START}  + ${BOOT_SIZE}`
> +
> +   parted -s ${NEXT_IMG} unit s mkpart loader1 ${LOADER1_START} `expr
> ${RESERVED1_START} - 1`
> +   parted -s ${NEXT_IMG} unit s mkpart reserved1 ${RESERVED1_START}
> `expr ${RESERVED2_START} - 1`
> +   parted -s ${NEXT_IMG} unit s mkpart reserved2 ${RESERVED2_START}
> `expr ${LOADER2_START} - 1`
> +   parted -s ${NEXT_IMG} unit s mkpart loader2 ${LOADER2_START} `expr
> ${ATF_START} - 1`
> +   parted -s ${NEXT_IMG} unit s mkpart atf ${ATF_START} `expr
> ${BOOT_START} - 1`
> +
> +   # Create boot partition and mark it as bootable
> +   parted -s ${NEXT_IMG} unit s mkpart boot ${BOOT_START} `expr
> ${ROOTFS_START} - 1`
> +   parted -s ${NEXT_IMG} set 6 boot on
> +
> +   # Create rootfs partition
> +   parted -s ${NEXT_IMG} unit s mkpart root ${ROOTFS_START} 100%
> +
> +   parted ${NEXT_IMG} print
> +
> +   # Delete the boot image to avoid trouble with the build cache
> +   rm -f ${WORKDIR}/${BOOT_IMG}
> +
> +   # Create boot partition image
> +   BOOT_BLOCKS=$(LC_ALL=C parted -s ${NEXT_IMG} unit b print | awk '/
> 6 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
> +   BOOT_BLOCKS=`expr $BOOT_BLOCKS / 63 \* 63`
> +
> +   mkfs.vfat -n "boot" -S 512 -C ${WORKDIR}/${BOOT_IMG} $BOOT_BLOCKS
> +   mcopy -i ${WORKDIR}/${BOOT_IMG} -s 
> ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin
> ::${KERNEL_IMAGETYPE}