Tag Archive for 'qemu'

Enttec DMX-USB firmware upgrade with Qemu

A year ago, I brought a Enttec Pro USB/DMX widget. Since then, a new firmware was released. If it doesn’t fix any critical bug to me, I still have to upgrade it (don’t mind asking why… ;) ). And to make things fun (read “dangerous”), I choose to do it with Qemu.

This article explains how I upgraded the firmware of my Enttec DMX/USB widget under linux thanks to Qemu.

First, plug your device in one of your computer’s USB port. We need to get the hardware UID of the widget. We can do so as root in a linux terminal:

cat /proc/bus/usb/devices

This command output a big mess in which you should find a block of lines separated by two blank lines (one above and one below) corresponding to your USB device. It’s easy to spot, as it contain the ENTTEC string. Mine look like this:

T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0403 ProdID=6001 Rev= 6.00
S:  Manufacturer=ENTTEC
S:  Product=DMX USB PRO
S:  SerialNumber=ENQXXXXX
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=300mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

What we are looking for is the vendor’s ID and the product’s ID, that’s all Qemu needs to talk to the device. This is found on the line starting with P:. For me:

  • Vendor ID: 0403
  • Products ID: 6001

With this information, we can launch Qemu and bind it to the device. Assuming you already have a Qemu image containing a working version of windows XP, the command looks like this:

qemu -m 512 -usb -usbdevice host:0403:6001 -hda ./qemu-win-xp-with-freestyler.qcow

Alternatively, you can “hotplug” the USB device once inside Qemu. This can be done by calling the Qemu interactive shell by pressing Ctrl + Alt + 2 simultaneously. Then, to hotplug the USB device, type:

usb_add host:0403:6001

If you’re as unlucky as I am, you’ll get this error message:

Could not add USB device 'host:0403:6001'

Which is doubled by the following message from your legacy console:

/proc/bus/usb/002/002: Permission denied

The latter point to the restrictive access rights on our device, which can be fixed by:

chmod -R a+rw /proc/bus/usb/002/002

qemu-usb-console

Instead, if you get the following error message:

usb_host: device already grabbed

It probably mean that your linux kernel has already identified the device when you plugged in and has loaded some drivers. To unload them and free the device, I had to do:

lsmod
rmmod dmx_usb
rmmod ftdi_sio

At last, you can check under the emulated Windows that your Enttec widget is recognized by windows:

enttec-usb-dmx-widget-on-windows-xp-through-qemu

And finally you’re free to upgrade (at your own risks) your widget’s firmware with the tools available on Enttec’s official website:

enttec-dmx-usb-widget-firmware-upgrade-on-windows-xp-through-qemu

FYI, all these operations where performed on a Mandriva 2008.1, Qemu 0.9.0 and linux kernel 2.6.24.

How-to grow any Qemu system image

Qemu images can’t be growed. In this exemple I will show you a little hack to grow a 6GiB qcow image to a 10GiB image. Beware: these operations can take a lot of time to perform and require lots of free space.

First, convert your qcow image to a plain raw file:

qemu-img convert system.qcow -O raw system.raw

Then, create a dummy file (filled with zeros) of the size of extra space you want to add to your image. In this case, 4GiB (=10GiB – 6GiB):

dd if=/dev/zero of=zeros.raw bs=1024k count=4096

Fearlessly, add your extra space to your raw system image:

cat system.raw zeros.raw > big10G.raw

After that you can boot qemu to verify that added free space is available:

qemu -hda big10G.raw

Here is an real case exemple of what you can see in a qemu image on which Windows XP was installed:
Windows XP in Qemu - Primary Disk Extra Free Space

Now, to grow your primary partition, I suggest you to download a Live CD like gparted Live CD or System Rescue CD, and boot on the .iso file with qemu:

qemu -hda big10G.raw -cdrom gparted-livecd-0.3.4-5.iso -boot d

This will allow you to grow and manipulate all your partitions safely thanks to parted and other open source system tools.

Finally you can convert back your raw image to a qcow one to not waste space:

qemu-img convert big10G.raw -O qcow growed-system.qcow

That’s all !

By the way, I think it’s possible to perform the second and third step of this how-to in a single operation using dd only.

Update: I missed it, but this issue is also described in the FAQ from the unofficial #qemu wiki (look at “How do I resize a disk image?” question).

Qemu 0.9 for Mandriva 2007

I’ve just backported qemu 0.9 to Mandriva 2007. This release include the kqemu 1.3.0pre11 kernel module, which was released under the GPL some weeks ago.

As usual, this package is available in my RPM repository.

Why kqemu doesn’t do its job ?

I was using qemu for more than 1 year, but I only noticed today that kqemu, which is supposed to speed qemu up, was not working on my machine: there was absolutely no differences with or without kqemu.

I finally found the reason on the qemu website FAQ: Why has kqemu not improved the speed of qemu on my Linux system?.

So, if you are using my kqemu RPM for Mandriva 2006, don’t forget to add the following line in your /etc/fstab file:

tmpfs /dev/shm tmpfs defaults 0 0

Then reboot your OS to enjoy the speed up !

Mandriva 2006.0 rpms: amarok, qemu, kqemu and baghira updated.

I updated the baghira rpm with the 24/02/2006 CVS version. This version correct a very annoying bug I had with the previous RPM. Now Kpdf doesn’t freeze anymore.

I also added newer version of qemu and kqemu v0.7.2 I found on P.Terjan repository and Amarok 1.4beta2 from the gkmweb.com repository.