All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] IMAGE_CMD_sdimg first cut
@ 2011-08-26 19:54 Joel A Fernandes
  2011-08-27  7:05 ` Koen Kooi
       [not found] ` <927b350f86974e67949bd78aaa0adc5d@DFLE70.ent.ti.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Joel A Fernandes @ 2011-08-26 19:54 UTC (permalink / raw)
  To: openembedded-core; +Cc: Jason, Kridner, Koen Kooi

Here's an initial version of the SDCard image build functionality. Its not a direct copy paste from Narcissus, I had to replace paths and am copying files from IMAGE_ROOTFS instead of how Narcissus untars into a mount point.

Not build tested.

@Koen and all, here are some questions:
1. Where in openembedded-core do we store the "img.gz" template files so that they are available to image.bbclass?
   I'm thinking in the images/ directory where the beagleboard-gnome-image bb recipe is itself stored? What's a clean way?
2. I've hardcoded loop device names just like Narcissus, what's a cleaner way?
3. Same as 2. but for temporary mount point names?
4. For copying ubifs, how do we ensure IMAGE_CMD_ubifs runs first before IMAGE_CMD_sdimg does?

Thanks, if you get a chance to work on it, that'll be cool. I will continue to work on it after my class.

Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
Cc: Koen Kooi <k-kooi@ti.com>
Cc: Jason Kridner <jdk@ti.com>
---
 meta/classes/image_types.bbclass |   99 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index cd901c1..39e7984 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -88,6 +88,105 @@ IMAGE_CMD_ubi () {
 }
 IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubifs.img ${MKUBIFS_ARGS}"
 
+IMAGE_CMD_sdimg () {
+        MD5SUM_SD="$(md5sum ${IMAGE_ROOTFS}/boot/uImage | awk '{print $1}')" 
+        for sdsize in $(ls ${WORKDIR}/conf/sd/sd-master* | sed -e s:${WORKDIR}/conf/sd/sd-master-::g -e 's:.img.gz::g' | xargs echo) ; do
+        echo "SD size: $sdsize"
+
+        if true ; then
+                echo "No cached SD image found, generating new one"
+                zcat ${WORKDIR}/conf/sd/sd-master-$sdsize.img.gz > ${WORKDIR}/sd.img
+                /sbin/fdisk -l -u ${WORKDIR}/sd.img
+
+                # Output looks like:
+                # Disk sd-master-1GiB.img: 0 MB, 0 bytes
+                # 255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
+                # Units = sectors of 1 * 512 = 512 bytes
+                # Sector size (logical/physical): 512 bytes / 512 bytes
+                # I/O size (minimum/optimal): 512 bytes / 512 bytes
+                # Disk identifier: 0x00000000
+                # 
+                #             Device Boot      Start         End      Blocks   Id  System
+                # sd-master-1GiB.img1   *          63      144584       72261    c  W95 FAT32 (LBA)
+                # sd-master-1GiB.img2          144585     1959929      907672+  83  Linux
+
+
+                BYTES_PER_SECTOR="$(/sbin/fdisk -l -u sd.img | grep Units | awk '{print $9}')"
+                VFAT_SECTOR_OFFSET="$(/sbin/fdisk -l -u sd.img | grep img1 | awk '{print $3}')"
+                EXT3_SECTOR_OFFSET="$(/sbin/fdisk -l -u sd.img | grep img2 | awk '{print $2}')"
+
+                LOOP_DEV="/dev/loop1"
+                LOOP_DEV_FS="/dev/loop2"
+                umount ${LOOP_DEV} || true
+                umount ${LOOP_DEV_FS} || true
+                /sbin/losetup -d ${LOOP_DEV} || true
+                /sbin/losetup -d ${LOOP_DEV_FS} || true
+
+                echo ""
+
+                # VFAT
+                echo "/sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${VFAT_SECTOR_OFFSET}) ${LOOP_DEV} ${WORKDIR}/sd.img"
+                /sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${VFAT_SECTOR_OFFSET}) ${LOOP_DEV} ${WORKDIR}/sd.img
+
+                # EXT3
+                echo "/sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${EXT3_SECTOR_OFFSET}) ${LOOP_DEV_FS} ${WORKDIR}/sd.img"
+                /sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${EXT3_SECTOR_OFFSET}) ${LOOP_DEV_FS} ${WORKDIR}/sd.img
+                echo "/sbin/mkfs.ext3 -L Narcissus-rootfs ${LOOP_DEV_FS}"
+                /sbin/mkfs.ext3 -L Narcissus-rootfs ${LOOP_DEV_FS}
+
+                echo ""
+
+                echo "mount ${LOOP_DEV}"
+                mount ${LOOP_DEV}
+
+                echo "mount ${LOOP_DEV_FS}"
+                mount ${LOOP_DEV_FS}
+
+                # report mount status to log
+                mount | grep loop
+
+                if [ -e ${IMAGE_ROOTFS}/boot/MLO ] ; then
+                	cp -v ${IMAGE_ROOTFS}/boot/MLO /mnt/narcissus/sd_image1/MLO
+                fi
+
+                echo "Remounting ${LOOP_DEV}"
+                umount ${LOOP_DEV}
+                mount ${LOOP_DEV}
+
+                echo "Copying file system:"
+		cp -r ${IMAGE_ROOTFS}/* /mnt/narcissus/sd_images2/ || true
+
+		echo "Copying bootloaders into the boot partition"
+                cp -v /mnt/narcissus/sd_image2/boot/u-boot-*.bin /mnt/narcissus/sd_image1/u-boot.bin || true
+                cp -v /mnt/narcissus/sd_image2/boot/uImage-2.6* /mnt/narcissus/sd_image1/uImage || true
+                cp -v /mnt/narcissus/sd_image2/boot/user.txt /mnt/narcissus/sd_image1/ || true
+                cp -v /mnt/narcissus/sd_image2/boot/uEnv.txt /mnt/narcissus/sd_image1/ || true
+
+                if [ ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubi ] ; then
+                        echo "Copying UBIFS image to file system:"
+                        cp ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubi /mnt/narcissus/sd_image2/boot/fs.ubi
+                fi
+
+                touch  /mnt/narcissus/sd_image2/narcissus-was-here
+                echo "Remounting ${LOOP_DEV_FS}"
+                umount ${LOOP_DEV_FS}
+                mount ${LOOP_DEV_FS}
+
+                echo "files in ext3 partition:" $(du -hs /mnt/narcissus/sd_image2/* | sed s:/mnt/narcissus/sd_image2/::g)
+
+                echo "umount ${LOOP_DEV}"       
+                umount ${LOOP_DEV}
+                echo "umount ${LOOP_DEV_FS}"
+                umount ${LOOP_DEV_FS}
+
+                /sbin/losetup -d ${LOOP_DEV}
+                /sbin/losetup -d ${LOOP_DEV_FS}
+
+                gzip -c sd.img > ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}-${MACHINE}-sd-$sdsize.img.gz
+        fi
+        done
+}
+
 EXTRA_IMAGECMD = ""
 EXTRA_IMAGECMD_jffs2 ?= "--pad --little-endian --eraseblock=0x40000"
 # Change these if you want default genext2fs behavior (i.e. create minimal inode number)
-- 
1.7.0.4




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC] IMAGE_CMD_sdimg first cut
  2011-08-26 19:54 [RFC] IMAGE_CMD_sdimg first cut Joel A Fernandes
@ 2011-08-27  7:05 ` Koen Kooi
       [not found] ` <927b350f86974e67949bd78aaa0adc5d@DFLE70.ent.ti.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Koen Kooi @ 2011-08-27  7:05 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer; +Cc: Jason Kridner

Op 26 aug. 2011, om 21:54 heeft Joel A Fernandes het volgende geschreven:

> Here's an initial version of the SDCard image build functionality. Its not a direct copy paste from Narcissus

Be careful when doing that, narcissus is GPLv2, OE-core is MIT

> , I had to replace paths and am copying files from IMAGE_ROOTFS instead of how Narcissus untars into a mount point.
> 
> Not build tested.
> 
> @Koen and all, here are some questions:
> 1. Where in openembedded-core do we store the "img.gz" template files so that they are available to image.bbclass?

We don't, we can generate is everytime now that we aren't running as www-data

>   I'm thinking in the images/ directory where the beagleboard-gnome-image bb recipe is itself stored? What's a clean way?/
> 2. I've hardcoded loop device names just like Narcissus, what's a cleaner way?
> 3. Same as 2. but for temporary mount point names?
> 4. For copying ubifs, how do we ensure IMAGE_CMD_ubifs runs first before IMAGE_CMD_sdimg does?
> 
> Thanks, if you get a chance to work on it, that'll be cool. I will continue to work on it after my class.
> 
> Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
> Cc: Koen Kooi <k-kooi@ti.com>
> Cc: Jason Kridner <jdk@ti.com>
> ---
> meta/classes/image_types.bbclass |   99 ++++++++++++++++++++++++++++++++++++++
> 1 files changed, 99 insertions(+), 0 deletions(-)
> 
> diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
> index cd901c1..39e7984 100644
> --- a/meta/classes/image_types.bbclass
> +++ b/meta/classes/image_types.bbclass
> @@ -88,6 +88,105 @@ IMAGE_CMD_ubi () {
> }
> IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubifs.img ${MKUBIFS_ARGS}"
> 
> +IMAGE_CMD_sdimg () {
> +        MD5SUM_SD="$(md5sum ${IMAGE_ROOTFS}/boot/uImage | awk '{print $1}')" 
> +        for sdsize in $(ls ${WORKDIR}/conf/sd/sd-master* | sed -e s:${WORKDIR}/conf/sd/sd-master-::g -e 's:.img.gz::g' | xargs echo) ; do
> +        echo "SD size: $sdsize"
> +
> +        if true ; then
> +                echo "No cached SD image found, generating new one"
> +                zcat ${WORKDIR}/conf/sd/sd-master-$sdsize.img.gz > ${WORKDIR}/sd.img
> +                /sbin/fdisk -l -u ${WORKDIR}/sd.img
> +
> +                # Output looks like:
> +                # Disk sd-master-1GiB.img: 0 MB, 0 bytes
> +                # 255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
> +                # Units = sectors of 1 * 512 = 512 bytes
> +                # Sector size (logical/physical): 512 bytes / 512 bytes
> +                # I/O size (minimum/optimal): 512 bytes / 512 bytes
> +                # Disk identifier: 0x00000000
> +                # 
> +                #             Device Boot      Start         End      Blocks   Id  System
> +                # sd-master-1GiB.img1   *          63      144584       72261    c  W95 FAT32 (LBA)
> +                # sd-master-1GiB.img2          144585     1959929      907672+  83  Linux
> +
> +
> +                BYTES_PER_SECTOR="$(/sbin/fdisk -l -u sd.img | grep Units | awk '{print $9}')"
> +                VFAT_SECTOR_OFFSET="$(/sbin/fdisk -l -u sd.img | grep img1 | awk '{print $3}')"
> +                EXT3_SECTOR_OFFSET="$(/sbin/fdisk -l -u sd.img | grep img2 | awk '{print $2}')"
> +
> +                LOOP_DEV="/dev/loop1"
> +                LOOP_DEV_FS="/dev/loop2"
> +                umount ${LOOP_DEV} || true
> +                umount ${LOOP_DEV_FS} || true
> +                /sbin/losetup -d ${LOOP_DEV} || true
> +                /sbin/losetup -d ${LOOP_DEV_FS} || true
> +
> +                echo ""
> +
> +                # VFAT
> +                echo "/sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${VFAT_SECTOR_OFFSET}) ${LOOP_DEV} ${WORKDIR}/sd.img"
> +                /sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${VFAT_SECTOR_OFFSET}) ${LOOP_DEV} ${WORKDIR}/sd.img
> +
> +                # EXT3
> +                echo "/sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${EXT3_SECTOR_OFFSET}) ${LOOP_DEV_FS} ${WORKDIR}/sd.img"
> +                /sbin/losetup -v -o $(expr ${BYTES_PER_SECTOR} "*" ${EXT3_SECTOR_OFFSET}) ${LOOP_DEV_FS} ${WORKDIR}/sd.img
> +                echo "/sbin/mkfs.ext3 -L Narcissus-rootfs ${LOOP_DEV_FS}"
> +                /sbin/mkfs.ext3 -L Narcissus-rootfs ${LOOP_DEV_FS}
> +
> +                echo ""
> +
> +                echo "mount ${LOOP_DEV}"
> +                mount ${LOOP_DEV}
> +
> +                echo "mount ${LOOP_DEV_FS}"
> +                mount ${LOOP_DEV_FS}
> +
> +                # report mount status to log
> +                mount | grep loop
> +
> +                if [ -e ${IMAGE_ROOTFS}/boot/MLO ] ; then
> +                	cp -v ${IMAGE_ROOTFS}/boot/MLO /mnt/narcissus/sd_image1/MLO
> +                fi
> +
> +                echo "Remounting ${LOOP_DEV}"
> +                umount ${LOOP_DEV}
> +                mount ${LOOP_DEV}
> +
> +                echo "Copying file system:"
> +		cp -r ${IMAGE_ROOTFS}/* /mnt/narcissus/sd_images2/ || true
> +
> +		echo "Copying bootloaders into the boot partition"
> +                cp -v /mnt/narcissus/sd_image2/boot/u-boot-*.bin /mnt/narcissus/sd_image1/u-boot.bin || true
> +                cp -v /mnt/narcissus/sd_image2/boot/uImage-2.6* /mnt/narcissus/sd_image1/uImage || true
> +                cp -v /mnt/narcissus/sd_image2/boot/user.txt /mnt/narcissus/sd_image1/ || true
> +                cp -v /mnt/narcissus/sd_image2/boot/uEnv.txt /mnt/narcissus/sd_image1/ || true
> +
> +                if [ ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubi ] ; then
> +                        echo "Copying UBIFS image to file system:"
> +                        cp ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubi /mnt/narcissus/sd_image2/boot/fs.ubi
> +                fi
> +
> +                touch  /mnt/narcissus/sd_image2/narcissus-was-here
> +                echo "Remounting ${LOOP_DEV_FS}"
> +                umount ${LOOP_DEV_FS}
> +                mount ${LOOP_DEV_FS}
> +
> +                echo "files in ext3 partition:" $(du -hs /mnt/narcissus/sd_image2/* | sed s:/mnt/narcissus/sd_image2/::g)
> +
> +                echo "umount ${LOOP_DEV}"       
> +                umount ${LOOP_DEV}
> +                echo "umount ${LOOP_DEV_FS}"
> +                umount ${LOOP_DEV_FS}
> +
> +                /sbin/losetup -d ${LOOP_DEV}
> +                /sbin/losetup -d ${LOOP_DEV_FS}
> +
> +                gzip -c sd.img > ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}-${MACHINE}-sd-$sdsize.img.gz
> +        fi
> +        done
> +}
> +
> EXTRA_IMAGECMD = ""
> EXTRA_IMAGECMD_jffs2 ?= "--pad --little-endian --eraseblock=0x40000"
> # Change these if you want default genext2fs behavior (i.e. create minimal inode number)
> -- 
> 1.7.0.4
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] IMAGE_CMD_sdimg first cut
       [not found] ` <927b350f86974e67949bd78aaa0adc5d@DFLE70.ent.ti.com>
@ 2011-08-27 21:17   ` Joel A Fernandes
  2011-08-27 21:18     ` Joel A Fernandes
  2011-09-03 21:48     ` Jason Kridner
  0 siblings, 2 replies; 5+ messages in thread
From: Joel A Fernandes @ 2011-08-27 21:17 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

Hi Koen,

Thanks for your feedback.

On Sat, Aug 27, 2011 at 2:05 AM, Koen Kooi <koen@dominion.thruhere.net> wrote:
> Op 26 aug. 2011, om 21:54 heeft Joel A Fernandes het volgende geschreven:
>
>> Here's an initial version of the SDCard image build functionality. Its not a direct copy paste from Narcissus
>
> Be careful when doing that, narcissus is GPLv2, OE-core is MIT
>
>> , I had to replace paths and am copying files from IMAGE_ROOTFS instead of how Narcissus untars into a mount point.
>>
>> Not build tested.
>>
>> @Koen and all, here are some questions:
>> 1. Where in openembedded-core do we store the "img.gz" template files so that they are available to image.bbclass?
>
> We don't, we can generate is everytime now that we aren't running as www-data
>

I didn't follow What has running as www-data or any regular user go to
do with generating img.gz?

So what you're suggesting is we run dd and fdisk to create an sdcard
image template everytime we bitbake an image?

thanks!
Joel



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] IMAGE_CMD_sdimg first cut
  2011-08-27 21:17   ` Joel A Fernandes
@ 2011-08-27 21:18     ` Joel A Fernandes
  2011-09-03 21:48     ` Jason Kridner
  1 sibling, 0 replies; 5+ messages in thread
From: Joel A Fernandes @ 2011-08-27 21:18 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer
  Cc: Kridner, Jason, Kooi, Koen

+Koen Jason

On Sat, Aug 27, 2011 at 4:17 PM, Joel A Fernandes <agnel.joel@gmail.com> wrote:
> Hi Koen,
>
> Thanks for your feedback.
>
> On Sat, Aug 27, 2011 at 2:05 AM, Koen Kooi <koen@dominion.thruhere.net> wrote:
>> Op 26 aug. 2011, om 21:54 heeft Joel A Fernandes het volgende geschreven:
>>
>>> Here's an initial version of the SDCard image build functionality. Its not a direct copy paste from Narcissus
>>
>> Be careful when doing that, narcissus is GPLv2, OE-core is MIT
>>
>>> , I had to replace paths and am copying files from IMAGE_ROOTFS instead of how Narcissus untars into a mount point.
>>>
>>> Not build tested.
>>>
>>> @Koen and all, here are some questions:
>>> 1. Where in openembedded-core do we store the "img.gz" template files so that they are available to image.bbclass?
>>
>> We don't, we can generate is everytime now that we aren't running as www-data
>>
>
> I didn't follow What has running as www-data or any regular user go to
> do with generating img.gz?
>
> So what you're suggesting is we run dd and fdisk to create an sdcard
> image template everytime we bitbake an image?
>
> thanks!
> Joel
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] IMAGE_CMD_sdimg first cut
  2011-08-27 21:17   ` Joel A Fernandes
  2011-08-27 21:18     ` Joel A Fernandes
@ 2011-09-03 21:48     ` Jason Kridner
  1 sibling, 0 replies; 5+ messages in thread
From: Jason Kridner @ 2011-09-03 21:48 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

On Sat, Aug 27, 2011 at 5:17 PM, Joel A Fernandes <agnel.joel@gmail.com> wrote:
> Hi Koen,
>
> Thanks for your feedback.
>
> On Sat, Aug 27, 2011 at 2:05 AM, Koen Kooi <koen@dominion.thruhere.net> wrote:
>> Op 26 aug. 2011, om 21:54 heeft Joel A Fernandes het volgende geschreven:
>>
>>> Here's an initial version of the SDCard image build functionality. Its not a direct copy paste from Narcissus
>>
>> Be careful when doing that, narcissus is GPLv2, OE-core is MIT
>>
>>> , I had to replace paths and am copying files from IMAGE_ROOTFS instead of how Narcissus untars into a mount point.
>>>
>>> Not build tested.
>>>
>>> @Koen and all, here are some questions:
>>> 1. Where in openembedded-core do we store the "img.gz" template files so that they are available to image.bbclass?
>>
>> We don't, we can generate is everytime now that we aren't running as www-data
>>
>
> I didn't follow What has running as www-data or any regular user go to
> do with generating img.gz?

Narcissus ran as www-data.  It was necessary to run Narcissus as an
unprivileged account, since it is a web service.

>
> So what you're suggesting is we run dd and fdisk to create an sdcard
> image template everytime we bitbake an image?
>
> thanks!
> Joel
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-03 21:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26 19:54 [RFC] IMAGE_CMD_sdimg first cut Joel A Fernandes
2011-08-27  7:05 ` Koen Kooi
     [not found] ` <927b350f86974e67949bd78aaa0adc5d@DFLE70.ent.ti.com>
2011-08-27 21:17   ` Joel A Fernandes
2011-08-27 21:18     ` Joel A Fernandes
2011-09-03 21:48     ` Jason Kridner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.