+ Reply to Thread
Results 1 to 11 of 11

Using DFU Tool on Linux using QEMU

This is a discussion on Using DFU Tool on Linux using QEMU within the Rockbox forums, part of the Community Development category; I've done an experiment with my M6 SP on using DFU Tool inside QEMU on Linux. The answer is currently ...

  1. #1
    Member
    Join Date
    Jan 2008
    Location
    Indonesia
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using DFU Tool on Linux using QEMU

    I've done an experiment with my M6 SP on using DFU Tool inside QEMU on Linux. The answer is currently "maybe".

    Preparation:
    1. Get the USBID of the DFU device: Put the device into DFU mode and connect it to the computer, then use lsusb to see the USBID.
    2. Install Windows XP inside QEMU, and then install DFU Tool on it.
    3. Copy M6.EBN into the DFU Tool folder in the Windows XP installation.

    Steps:
    1. Mount usbfs at /proc/bus/usb.
    2. Run QEMU as root. Remember to enable the USB option (-usb).
    3. Hold the M and Play buttons, then connect the M6 to the computer.
    4. Switch to the QEMU Monitor and add the usb device: usb_add host:0419:0141 (the USBID's for other models might be different).
    5. Switch back to the Windows XP desktop and run the DFU Tool.
    6. See that the device is detected, then press the "Download" button.

    My QEMU crashed at this point. This is the dmesg line:
    qemu[6429]: segfault at 220a2ec ip b7c40810 sp bfdfddec error 4 in libc-2.6.1.so[b7bd9000+12e000]

    That's why I said the answer is "maybe": maybe there is a bug in QEMU that prevents the download process from starting correctly. But there is certainly hope

  2. #2
    Passing By
    Join Date
    Feb 2008
    Location
    Europe
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wine?

    Excuse my simple question :-) Did someone try to use wine already?
    Otherwise, what are the experiences with the opensourcedfu-utils ?
    Lastly, we could always reverse engineer the usb protocol in windows and implement it in linux.. although I do prefer an easier solution since time is limited

  3. #3
    Passing By
    Join Date
    Jan 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What I don't get on wpyh Method:
    If you're willing to install WinXP on QEMU, you could as well install WinXP on a different partition and do a dual-boot.

    @Wbdsgnr: I think I read somewhere here, that the opensource dfu-utils aren't compatible to the samsung(?) version of dfu the M6 uses

  4. #4
    Member
    Join Date
    Jan 2008
    Location
    Indonesia
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'll answer some of the questions here:

    1. I can't speak for markun, but he's tried using wine to run the DFU tool but failed. This is because wine doesn't export the hardware, it just provides the Windows API.

    2. I'm installing WinXP on QEMU precisely because I don't want to dual boot. Why should I? Linux gives me a very good working environment, and I feel lost in Windows (XP, Vista, whatever). Dual booting is also very inconvenient. That, and I've allocated the whole harddisk to Linux.

    3. The dfu-util software (currently) can't flash the Meizu. I don't know but fnord23 may be right about the dfu versions. From my experiments, it seems to send data to the Meizu, but the player doesn't do a firmware update.

  5. #5
    Member
    Join Date
    Dec 2007
    Location
    Bucharest, Romania
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Low-level programs such as DFU tools cannot be emulated because they need direct access to the hardware and an emulator or compatibility layer like QEMU or WINE won't let the program do direct hardware access as it has to pass through them first. I doubt a virtual machine would work either.

  6. #6
    Member
    Join Date
    Jan 2008
    Location
    Indonesia
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, the DFU tool does access hardware directly, and QEMU has a USB passthrough mode / feature / option. That USB passthrough feature is what I'm using. And since QEMU talks directly with the hardware, I expected it to work.

    Now that might mean that the DFU tool tries to disconnect and reconnect the USB again, but I think the crash is due to a QEMU bug.

  7. #7
    Member
    Join Date
    Dec 2007
    Location
    Bucharest, Romania
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by wpyh View Post
    Well, the DFU tool does access hardware directly, and QEMU has a USB passthrough mode / feature / option. That USB passthrough feature is what I'm using. And since QEMU talks directly with the hardware, I expected it to work.

    Now that might mean that the DFU tool tries to disconnect and reconnect the USB again, but I think the crash is due to a QEMU bug.
    Even if it has such a mode (i have used QEMU several times but did not know about this feature), chances are it's going to be very buggy and highly dependant on the OS you run QEMU on.

  8. #8
    Member
    Join Date
    Jan 2008
    Location
    Indonesia
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is a short description of that feature here: QEMU

    Quote Originally Posted by Th3_uN1Qu3 View Post
    it's going to be very buggy
    Yes, it is indeed buggy, otherwise my post would contain instructions on how to successfully run DFU tool that way.

    Quote Originally Posted by Th3_uN1Qu3 View Post
    and highly dependant on the OS you run QEMU on.
    Yes, this is also a known fact. I forgot to mention that I'm running QEMU on Linux. Sorry for any confusion this might have caused.

  9. #9
    Member
    Join Date
    Jan 2008
    Location
    Indonesia
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is now possible to do a DFU restore on Linux, using VirtualBox.

    Preparation:
    1. Install Windows XP inside QEMU, and then install DFU Tool on it.
    2. Copy M3.EBN, M6.EBN or M6SL.EBN into the DFU Tool folder in the Windows XP installation.

    Steps:
    1. Mount usbfs at /proc/bus/usb.
    2. As root, loop every 0.5 seconds to chown all the files in /proc/bus/usb to the username you are using.
    3. Run VirtualBox. Remember to enable USB support for the VM.
    4. Hold the M and Play buttons, wait 2 seconds, then connect the device to the computer.
    5. Release the Play button.
    6. Connect the device to VirtualBox.
    7. Run DFU Tool, then press "Download" button.
    8. Unplug device.

    Notes:
    1. The Play button must be released after connecting the device to the PC, otherwise it will power off after a few seconds.
    2. Keep the M button pressed down through the recovery procedure.
    3. If anything fails, start over.

  10. #10
    Senior Member
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,655
    Thanks
    15
    Thanked 14 Times in 13 Posts
    So in other words, just forget it because no one wants to buy a second Windows XP license. Seriously, if you're going to do it legally, you need one. Just buy a new miniPlayer/musicCard.

  11. #11
    Member
    Join Date
    Jan 2008
    Location
    Indonesia
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    (this is very similar to my previous post, but I'll just copy the whole thing to make it easier to follow)

    I've figured out the DFU suffix part of the DFU restore operation using VirtualBox on Linux. We would need the current CVS libpcap and Wireshark for this. Wireshark is very helpful here, since it allows us to monitor everything that's going on between the device and the DFU tool.

    As always, preparation:
    1. Install Windows XP inside QEMU, and then install DFU Tool on it.
    2. Copy M3.EBN, M6.EBN or M6SL.EBN into the DFU Tool folder in the Windows XP installation.
    3. Download, compile and install the current CVS version of libpcap.
    4. Recompile Wireshark against the new libpcap.

    Steps:
    1. Mount usbfs at /proc/bus/usb.
    2. As root, loop every 0.5 seconds to chown all the files in /proc/bus/usb to the username you are using.
    3. Run VirtualBox. Remember to enable USB support for the VM.
    4. Run Wireshark, then start a capture on the appropriate USB port.
    5. Hold the M and Play buttons, wait 2 seconds, then connect the device to the computer.
    6. Release the Play button.
    7. Connect the device to VirtualBox.
    8. Run DFU Tool, then press "Download" button.
    9. Unplug device.
    10. Stop and save the capture.

    Notes:
    1. The Play button must be released after connecting the device to the PC, otherwise it will power off after a few seconds.
    2. Keep the M button pressed down through the recovery procedure.
    3. If anything fails, start over. Remember to restart the capture in Wireshark.


 

Similar Threads

  1. Tipps zum DFU Tool
    By Andreas67 in forum German
    Replies: 2
    Last Post: 02-06-2008, 10:42 PM
  2. wie benutzt man DFU Tool ?
    By qwer in forum German
    Replies: 1
    Last Post: 12-25-2007, 05:07 PM
  3. If M3 doesnt have a DFU tool
    By fdddd in forum Technical
    Replies: 0
    Last Post: 12-21-2007, 06:35 AM
  4. M3 DFU Tool
    By paxl13 in forum music card M3
    Replies: 5
    Last Post: 11-22-2007, 07:05 PM
  5. m6_patch_font tool
    By Asmo in forum Russian
    Replies: 28
    Last Post: 10-05-2007, 05:45 AM