Difference between revisions of "Making qemu images"

From Gumstix User Wiki
Jump to: navigation, search
(remove spam)
 
Line 1: Line 1:
----
 
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 
----
 
=[http://unugeboq.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]=
 
----
 
=[http://unugeboq.co.cc CLICK HERE]=
 
----
 
</div>
 
 
= Preparing flash / disk images for qemu =
 
= Preparing flash / disk images for qemu =
  
Line 23: Line 15:
 
The following 3 files are needed
 
The following 3 files are needed
  
* &lt;tt&gt;u-boot-verdex-400-r1587.bin&lt;/tt&gt; - u-boot
+
* <tt>u-boot-verdex-400-r1587.bin</tt> - u-boot
* &lt;tt&gt;gumstix-basic-image-gumstix-custom-verdex.jffs2&lt;/tt&gt; - root file system  
+
* <tt>gumstix-basic-image-gumstix-custom-verdex.jffs2</tt> - root file system  
* &lt;tt&gt;uImage-2.6.21-r1-gumstix-custom-verdex.bin&lt;/tt&gt; - kernel.
+
* <tt>uImage-2.6.21-r1-gumstix-custom-verdex.bin</tt> - kernel.
  
Except for the u-boot image which is not yet built by openembedded, those files can be found in the &lt;tt&gt;tmp/deploy/glibc/images/&lt;/tt&gt; sub-directory of &lt;tt&gt;gumstix-oe&lt;/tt&gt; after running bitbake.
+
Except for the u-boot image which is not yet built by openembedded, those files can be found in the <tt>tmp/deploy/glibc/images/</tt> sub-directory of <tt>gumstix-oe</tt> after running bitbake.
  
To assemble the image &lt;tt&gt;flash.img&lt;/tt&gt; run the following commands:
+
To assemble the image <tt>flash.img</tt> run the following commands:
  
&lt;pre&gt;
+
<pre>
 
$ dd of=flash.img bs=128k count=256 if=/dev/zero
 
$ dd of=flash.img bs=128k count=256 if=/dev/zero
 
$ dd of=flash.img bs=128k conv=notrunc if=u-boot-verdex-400-r1587.bin
 
$ dd of=flash.img bs=128k conv=notrunc if=u-boot-verdex-400-r1587.bin
 
$ dd of=flash.img bs=128k conv=notrunc seek=2 if=gumstix-basic-image-gumstix-custom-verdex.jffs2
 
$ dd of=flash.img bs=128k conv=notrunc seek=2 if=gumstix-basic-image-gumstix-custom-verdex.jffs2
 
$ dd of=flash.img bs=128k conv=notrunc seek=248 if=uImage-2.6.21-r1-gumstix-custom-verdex.bin
 
$ dd of=flash.img bs=128k conv=notrunc seek=248 if=uImage-2.6.21-r1-gumstix-custom-verdex.bin
&lt;/pre&gt;
+
</pre>
  
 
=== Connex ===
 
=== Connex ===
Line 42: Line 34:
 
For Connex boards with 16MB flash the steps slightly differ:
 
For Connex boards with 16MB flash the steps slightly differ:
  
&lt;pre&gt;
+
<pre>
 
$ dd of=cflash.img bs=128k count=128 if=/dev/zero
 
$ dd of=cflash.img bs=128k count=128 if=/dev/zero
 
$ dd of=cflash.img bs=128k conv=notrunc if=u-boot-connex-400-r1604.bin
 
$ dd of=cflash.img bs=128k conv=notrunc if=u-boot-connex-400-r1604.bin
 
$ dd of=cflash.img bs=128k conv=notrunc seek=2 if=gumstix-basic-image-gumstix-custom-connex.jffs2
 
$ dd of=cflash.img bs=128k conv=notrunc seek=2 if=gumstix-basic-image-gumstix-custom-connex.jffs2
 
$ dd of=cflash.img bs=128k conv=notrunc seek=120 if=uImage-2.6.21-r1-gumstix-custom-connex.bin
 
$ dd of=cflash.img bs=128k conv=notrunc seek=120 if=uImage-2.6.21-r1-gumstix-custom-connex.bin
&lt;/pre&gt;
+
</pre>
  
 
== mmc/CF images ==
 
== mmc/CF images ==
Line 54: Line 46:
 
boot from them or just to store more data in them.  
 
boot from them or just to store more data in them.  
  
On the Linux host, the &lt;tt&gt;losetup&lt;/tt&gt;(1) utility is used to access those images as real block devices,  
+
On the Linux host, the <tt>losetup</tt>(1) utility is used to access those images as real block devices,  
  
 
/!\ The current qemu version seems to be limited to 1GB card images. The examples presented here will thus use 1GB images.
 
/!\ The current qemu version seems to be limited to 1GB card images. The examples presented here will thus use 1GB images.
Line 74: Line 66:
 
In the most simple case, one single partition (VFAT, ext2 or ext3) can cover the whole card. However, in order to boot from the card and use it for the root file system, at least 2 partitions, one small VFAT to hold the kernel and the u-boot script, and a bigger one, ext2  for the root file system. The folloing example shows a basic setup (using fdisk 'p' command):
 
In the most simple case, one single partition (VFAT, ext2 or ext3) can cover the whole card. However, in order to boot from the card and use it for the root file system, at least 2 partitions, one small VFAT to hold the kernel and the u-boot script, and a bigger one, ext2  for the root file system. The folloing example shows a basic setup (using fdisk 'p' command):
  
&lt;pre&gt;
+
<pre>
 
   Command (m for help): p
 
   Command (m for help): p
  
Line 85: Line 77:
 
  /dev/loop0p1              1          7      56196    6  FAT16
 
  /dev/loop0p1              1          7      56196    6  FAT16
 
  /dev/loop0p2              8        130      987997+  83  Linux
 
  /dev/loop0p2              8        130      987997+  83  Linux
&lt;/pre&gt;
+
</pre>
  
 
=== Accessing the partitions ===
 
=== Accessing the partitions ===
  
In order to access the partitions, 2 more loop devices have to be created with losetup. The offsets into the main loop device (&lt;tt&gt;/dev/loop0&lt;/tt&gt;) need to be specified. For this, use &lt;tt&gt;fdisk -ul&lt;/tt&gt; to find the starting block of your partitions:
+
In order to access the partitions, 2 more loop devices have to be created with losetup. The offsets into the main loop device (<tt>/dev/loop0</tt>) need to be specified. For this, use <tt>fdisk -ul</tt> to find the starting block of your partitions:
&lt;pre&gt;
+
<pre>
  
 
Disk /dev/loop0: 1073 MB, 1073741824 bytes
 
Disk /dev/loop0: 1073 MB, 1073741824 bytes
Line 100: Line 92:
 
/dev/loop0p1              63      112454      56196    6  FAT16
 
/dev/loop0p1              63      112454      56196    6  FAT16
 
/dev/loop0p2          112455    2088449      987997+  83  Linux
 
/dev/loop0p2          112455    2088449      987997+  83  Linux
&lt;/pre&gt;
+
</pre>
  
 
Partition 1 starts at block 63 (which is 63*512 = 32256 bytes) and partition 2 starts at block 112455 (which is 112455*512 = 57576960 bytes).
 
Partition 1 starts at block 63 (which is 63*512 = 32256 bytes) and partition 2 starts at block 112455 (which is 112455*512 = 57576960 bytes).
Line 126: Line 118:
 
=== Copying data ===
 
=== Copying data ===
  
The kernel image (called &lt;tt&gt;uImage&lt;/tt&gt; on the docs on using root on MMC/SD), the u-boot script &lt;tt&gt;gumstix-factory.script&lt;/tt&gt; are needed on /mnt/1.
+
The kernel image (called <tt>uImage</tt> on the docs on using root on MMC/SD), the u-boot script <tt>gumstix-factory.script</tt> are needed on /mnt/1.
  
To transfer the root filesystem to /mnt/2, un-tar the &lt;tt&gt;gumstix-basic-image-gumstix-custom-verdex.tar.gz&lt;/tt&gt; found in the &lt;tt&gt;tmp/deploy/glibc/images/gumstix-custom-verdex/&lt;/tt&gt; directory.  
+
To transfer the root filesystem to /mnt/2, un-tar the <tt>gumstix-basic-image-gumstix-custom-verdex.tar.gz</tt> found in the <tt>tmp/deploy/glibc/images/gumstix-custom-verdex/</tt> directory.  
  
 
=== Cleaning up ===
 
=== Cleaning up ===

Latest revision as of 16:10, 23 November 2010

Preparing flash / disk images for qemu

Flash images

You need a kernel and root filesystem for your Gumstix board. Additionally, download one of the u-boot images for your platform.

Verdex

The flash image emulates the flash memory on the Gumstix motherboard. It's a single file that has the size of the emulated flash memory (32MB in the case of the verdex board emulated by qemu). It will contain the same images as the real flash, at the same offsets:

  • The u-boot image at offset 0
  • The root file system image at offset 256kB
  • The kernel image at the end of the image offset 31MB

The following 3 files are needed

  • u-boot-verdex-400-r1587.bin - u-boot
  • gumstix-basic-image-gumstix-custom-verdex.jffs2 - root file system
  • uImage-2.6.21-r1-gumstix-custom-verdex.bin - kernel.

Except for the u-boot image which is not yet built by openembedded, those files can be found in the tmp/deploy/glibc/images/ sub-directory of gumstix-oe after running bitbake.

To assemble the image flash.img run the following commands:

$ dd of=flash.img bs=128k count=256 if=/dev/zero
$ dd of=flash.img bs=128k conv=notrunc if=u-boot-verdex-400-r1587.bin
$ dd of=flash.img bs=128k conv=notrunc seek=2 if=gumstix-basic-image-gumstix-custom-verdex.jffs2
$ dd of=flash.img bs=128k conv=notrunc seek=248 if=uImage-2.6.21-r1-gumstix-custom-verdex.bin

Connex

For Connex boards with 16MB flash the steps slightly differ:

$ dd of=cflash.img bs=128k count=128 if=/dev/zero
$ dd of=cflash.img bs=128k conv=notrunc if=u-boot-connex-400-r1604.bin
$ dd of=cflash.img bs=128k conv=notrunc seek=2 if=gumstix-basic-image-gumstix-custom-connex.jffs2
$ dd of=cflash.img bs=128k conv=notrunc seek=120 if=uImage-2.6.21-r1-gumstix-custom-connex.bin

mmc/CF images

Those images are used to emulate the flash memory cards that are present on netmicroSD, netMMC, netCF... expansion boards. It is possible to boot from them or just to store more data in them.

On the Linux host, the losetup(1) utility is used to access those images as real block devices,

/!\ The current qemu version seems to be limited to 1GB card images. The examples presented here will thus use 1GB images.

  • Creating the empty image
dd of=mmc.img bs=1M count=1024 if=/dev/zero
  • Creating a block device for the whole image
losetup /dev/loop0 mmc.img
  • Running fdisk to partition the card
fdisk /dev/loop0

Partitionning the card

In the most simple case, one single partition (VFAT, ext2 or ext3) can cover the whole card. However, in order to boot from the card and use it for the root file system, at least 2 partitions, one small VFAT to hold the kernel and the u-boot script, and a bigger one, ext2 for the root file system. The folloing example shows a basic setup (using fdisk 'p' command):

  Command (m for help): p

 Disk /dev/loop0: 1073 MB, 1073741824 bytes
 255 heads, 63 sectors/track, 130 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Disk identifier: 0x25c4dea4

      Device Boot      Start         End      Blocks   Id  System
 /dev/loop0p1               1           7       56196    6  FAT16
 /dev/loop0p2               8         130      987997+  83  Linux

Accessing the partitions

In order to access the partitions, 2 more loop devices have to be created with losetup. The offsets into the main loop device (/dev/loop0) need to be specified. For this, use fdisk -ul to find the starting block of your partitions:


Disk /dev/loop0: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x25c4dea4

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1              63      112454       56196    6  FAT16
/dev/loop0p2          112455     2088449      987997+  83  Linux

Partition 1 starts at block 63 (which is 63*512 = 32256 bytes) and partition 2 starts at block 112455 (which is 112455*512 = 57576960 bytes).

The following commands will then create the 2 loop devices:

losetup -o 32256 /dev/loop1 /dev/loop0
losetup -o 57576960 /dev/loop2 /dev/loop0

/dev/loop1 and /dev/loop2 will now access the 2 partitions.

Formatting and mounting

The loop device will extend to the end of the image file, even though the partition does not. For this reason it is important to specify the amount of blocks when creating the filesystem. The number of blocks were shown in the previous fdisk output. (Be aware that mkfs may give a warning about a block count mismatch. This is because the loop device may be larger than the partition. In this situation, the warning can be ignored.)

 mkfs -t vfat /dev/loop1 56196
 mkfs -t ext2 /dev/loop2 987997
 mkdir /mnt/1
 mkdir /mnt/2
 mount /dev/loop1 /mnt/1
 mount /dev/loop2 /mnt/2

Copying data

The kernel image (called uImage on the docs on using root on MMC/SD), the u-boot script gumstix-factory.script are needed on /mnt/1.

To transfer the root filesystem to /mnt/2, un-tar the gumstix-basic-image-gumstix-custom-verdex.tar.gz found in the tmp/deploy/glibc/images/gumstix-custom-verdex/ directory.

Cleaning up

Before starting qemu, both partitions should be un-monted and the 3 loop devices should be un-configured. Failing to do that will almost certainly corrupt the images.

umount /mnt/2
umount /mnt/1
losetup -d /dev/loop2 
losetup -d /dev/loop1
losetup -d /dev/loop0