[yocto] Separate out image generation into a new task

Markus Volk f_l_k at t-online.de
Wed Jan 20 07:44:23 PST 2016


Another strange thing. The IMG_COMMAND did result in an empty second partition. It did take a while to realize, what  the problem was, because there was no error message at all. It just didn´t work. 

I had to do this:


-USBIMG_ROOTFS = "${IMAGE_NAME}.rootfs.${USBIMG_ROOTFS_TYPE}“
  +USBIMG_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.${USBIMG_ROOTFS_TYPE}“

> Am 16.01.2016 um 21:12 schrieb Markus Volk <f_l_k at t-online.de>:
> 
> I found the mistake. The Problem seems to be the hyphen in the IMAGE_CMD name
> 
> IMAGE_CMD_hd1-usbimg 	didn´t work
> IMAGE_CMD_usbimg 		does
> 
> I´m curious if it still works with IMAGE_CMD_rpi-sdimg on the raspberrypi. Has someone already tried ?
> 
>> 
>> Thank you,
>> 
>> unfortunately this has´t solved the problem for me
>> 
>>> Am 15.01.2016 um 02:56 schrieb Andre McCurdy <armccurdy at gmail.com>:
>>> 
>>> On Wed, Jan 13, 2016 at 12:36 PM, Markus Volk <f_l_k at t-online.de> wrote:
>>>> With the recent improvements in the master branch regarding image creation i´m not able to build usb images anymore.
>>> 
>>> This patch might help:
>>> 
>>> http://lists.openembedded.org/pipermail/openembedded-core/2016-January/115474.html
>>> 
>>>> do_image_ext3 and do_image_jffs2 works well, then i´m getting this error message:
>>>> 
>>>> Log data follows:
>>>> | DEBUG: Executing python function set_image_size
>>>> | DEBUG: Python function set_image_size finished
>>>> | DEBUG: Executing shell function do_image_hd1-usbimg
>>>> | /home/flk/yocto/poky/build-zee/tmp-glibc/work/coolstream_hd1-oe-linux-gnueabi/neutrino-image/1.0-r0/temp/run.do_image_hd1-usbimg.126432: 108: /home/flk/yocto/poky/build-zee/tmp-glibc/work/coolstream_hd1-oe-linux-gnueabi/neutrino-image/1.0-r0/temp/run.do_image_hd1-usbimg.126432: do_image_hd1-usbimg: not found
>>>> | WARNING: exit code 127 from a shell command.
>>>> | ERROR: Function failed: do_image_hd1-usbimg (log file is located at /home/flk/yocto/poky/build-zee/tmp-glibc/work/coolstream_hd1-oe-linux-gnueabi/neutrino-image/1.0-r0/temp/log.do_image_hd1-usbimg.126432)
>>>> ERROR: Task 18 (/home/flk/yocto/poky/meta-neutrino/recipes-images/images/neutrino-image.bb, do_image_hd1-usbimg) failed with exit code '1'
>>>> NOTE: Tasks Summary: Attempted 2349 tasks of which 742 didn't need to be rerun and 1 failed.
>>>> Waiting for 0 running tasks to finish:
>>>> 
>>>> Summary: 1 task failed:
>>>> /home/flk/yocto/poky/meta-neutrino/recipes-images/images/neutrino-image.bb, do_image_hd1-usbimg
>>>> Summary: There were 3 WARNING messages shown.
>>>> Summary: There was 1 ERROR message shown, returning a non-zero exit code.
>>>> 
>>>> 
>>>> Until now i used this file for building an usb image (very similar to the way the sd image for raspberrypi is created):
>>>> 
>>>> usb_image-hd1.bbclass:
>>>> 
>>>> inherit image_types
>>>> 
>>>> #
>>>> ## this is heavily inspired by the raspberry pi sdimage class.
>>>> #
>>>> # Create an image that can by written onto an USB stick.
>>>> #
>>>> # The disk layout used is:
>>>> #
>>>> #    0                      -> IMAGE_ROOTFS_ALIGNMENT - reserved for other data
>>>> #    IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE             - u-boot script and kernel
>>>> #    BOOT_SPACE             -> USBIMG_SIZE             - rootfs
>>>> #
>>>> #                                                     Default Free space = 1.3x
>>>> #                                                     Use IMAGE_OVERHEAD_FACTOR to add more space
>>>> #                                                     <--------->
>>>> #            1MiB              20MiB           USBIMG_ROOTFS
>>>> # <-----------------------> <----------> <---------------------->
>>>> #  ------------------------ ------------ ------------------------
>>>> # | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | ROOTFS_SIZE            |
>>>> #  ------------------------ ------------ ------------------------
>>>> # ^                        ^            ^                        ^
>>>> # |                        |            |                        |
>>>> # 0                      1MiB     1MiB + 20MiB       1MiB + 20Mib + USBIMG_ROOTFS
>>>> 
>>>> # This image depends on the rootfs image
>>>> IMAGE_TYPEDEP_hd1-usbimg = "${USBIMG_ROOTFS_TYPE}"
>>>> 
>>>> # Boot partition volume id
>>>> BOOTDD_VOLUME_ID ?= "KERNEL"
>>>> 
>>>> # Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT)
>>>> BOOT_SPACE ?= "20480"
>>>> 
>>>> # Set alignment to 4MB [in KiB]
>>>> IMAGE_ROOTFS_ALIGNMENT = "1024"
>>>> 
>>>> # Use an uncompressed ext3 by default as rootfs
>>>> USBIMG_ROOTFS_TYPE ?= "ext3"
>>>> USBIMG_ROOTFS = "${IMAGE_NAME}.rootfs.${USBIMG_ROOTFS_TYPE}"
>>>> 
>>>> IMAGE_DEPENDS_hd1-usbimg = " \
>>>>      parted-native \
>>>>      mtools-native \
>>>>      dosfstools-native \
>>>>      virtual/kernel \
>>>> "
>>>> 
>>>> # USB image name
>>>> USBIMG = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.hd1-usbimg"
>>>> 
>>>> # Compression method to apply to USBIMG after it has been created. Supported
>>>> # compression formats are "gzip", "bzip2" or "xz". The original .hd1-usbimg file
>>>> # is kept and a new compressed file is created if one of these compression
>>>> # formats is chosen. If USBIMG_COMPRESSION is set to any other value it is
>>>> # silently ignored.
>>>> #USBIMG_COMPRESSION ?= ""
>>>> 
>>>> # Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS.
>>>> FATPAYLOAD ?= ""
>>>> 
>>>> IMAGEDATESTAMP = "${@time.strftime('%Y.%m.%d',time.gmtime())}"
>>>> 
>>>> IMAGE_CMD_hd1-usbimg () {
>>>> 
>>>>      # Align partitions
>>>>      BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
>>>>      BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
>>>>      ROOTFS_SIZE=`du -bks ${USBIMG_ROOTFS} | awk '{print $1}'`
>>>>      # Round up RootFS size to the alignment size as well
>>>>      ROOTFS_SIZE_ALIGNED=$(expr ${ROOTFS_SIZE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
>>>>      ROOTFS_SIZE_ALIGNED=$(expr ${ROOTFS_SIZE_ALIGNED} - ${ROOTFS_SIZE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
>>>>      USBIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + ${ROOTFS_SIZE_ALIGNED})
>>>> 
>>>>      echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS ${ROOTFS_SIZE_ALIGNED} KiB"
>>>> 
>>>>      # Initialize usbstick image file
>>>>      dd if=/dev/zero of=${USBIMG} bs=1024 count=0 seek=${USBIMG_SIZE}
>>>> 
>>>>      # Create partition table
>>>>      parted -s ${USBIMG} mklabel msdos
>>>>      # Create boot partition and mark it as bootable (not necessary, but does not hurt)
>>>>      parted -s ${USBIMG} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT})
>>>>      parted -s ${USBIMG} set 1 boot on
>>>>      # Create rootfs partition to the end of disk
>>>>      parted -s ${USBIMG} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s
>>>>      parted ${USBIMG} print
>>>> 
>>>>      # Create a vfat image with boot files
>>>>      BOOT_BLOCKS=$(LC_ALL=C parted -s ${USBIMG} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
>>>>      rm -f ${WORKDIR}/boot.img
>>>>      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 ::zImage.img
>>>> 
>>>>      if [ -n ${FATPAYLOAD} ] ; then
>>>>              echo "Copying payload into VFAT"
>>>>              for entry in ${FATPAYLOAD} ; do
>>>>                              # add the || true to stop aborting on vfat issues like not supporting .~lock files
>>>>                              mcopy -i ${WORKDIR}/boot.img -s -v ${IMAGE_ROOTFS}$entry :: || true
>>>>              done
>>>>      fi
>>>> 
>>>>      # Add stamp file
>>>>      echo "${IMAGE_NAME}-${IMAGEDATESTAMP}" > ${WORKDIR}/image-version-info
>>>>      mcopy -i ${WORKDIR}/boot.img -v ${WORKDIR}//image-version-info ::
>>>> 
>>>>      # Burn Partitions
>>>>      dd if=${WORKDIR}/boot.img of=${USBIMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
>>>>      # If USBIMG_ROOTFS_TYPE is a .xz file use xzcat
>>>>      if echo "${USBIMG_ROOTFS_TYPE}" | egrep -q "*\.xz"
>>>>      then
>>>>              xzcat ${USBIMG_ROOTFS} | dd of=${USBIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
>>>>      else
>>>>              dd if=${USBIMG_ROOTFS} of=${USBIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
>>>>      fi
>>>> 
>>>>      # Optionally apply compression
>>>>      case "${USBIMG_COMPRESSION}" in
>>>>      "gzip")
>>>>              gzip -k9 "${USBIMG}"
>>>>              ;;
>>>>      "bzip2")
>>>>              bzip2 -k9 "${USBIMG}"
>>>>              ;;
>>>>      "xz")
>>>>              xz -k "${USBIMG}"
>>>>              ;;
>>>>      esac
>>>> }
>>>> 
>>>> 
>>>> When reverting those changes, the problem is gone:
>>>> 
>>>> git revert 3341f3fbee818a0bd62620b8bc34230b03c0689c
>>>> git revert 0a4e1f968ada5099e3270ed06404d2827e9729aa
>>>> git revert fdced52387613a09368716d1f3bb7a13a6edd46d
>>>> git revert cdc0aeed9b17387ea37dcbfef7d474cce372e8db
>>>> 
>>>> 
>>>> What am i missing here ?
>>>> --
>>>> _______________________________________________
>>>> yocto mailing list
>>>> yocto at yoctoproject.org
>>>> https://lists.yoctoproject.org/listinfo/yocto
>> 
>> -- 
>> _______________________________________________
>> yocto mailing list
>> yocto at yoctoproject.org
>> https://lists.yoctoproject.org/listinfo/yocto
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20160120/ac937771/attachment.html>


More information about the yocto mailing list