Spagett1 / pineflash

A tool to flash ironos to the pinecil soldering iron and possibly other pine64 devices in the future
Other
213 stars 12 forks source link

dfu-util; No DFU capable USB device available #56

Closed Janik-Haag closed 1 year ago

Janik-Haag commented 1 year ago

When trying to use pineflash 0.5.1 and dfu-util 0.11 the throw this error:

dfu-util; No DFU capable USB device available

Maybe related to #45

Janik-Haag commented 1 year ago

Are there some udev rules I have to add for that to work?

Spagett1 commented 1 year ago

There shouldn't be any udev rules, could you please try flashing your pinecil manually with dfu-util from the cli and send the command here? https://ralim.github.io/IronOS/Flashing/Pinecil%20V1/#linux-and-mac

Janik-Haag commented 1 year ago

I'll try tomorrow since it's already quite late for me local time. Btw could you link me the code snippet where dfu-util gets called, I'm currently packaging pineflash for NixOS and will probably have to patch the expected dfu-util binary path.

Spagett1 commented 1 year ago

Sure, this is the code snippet for the v1 on Linux

            #[cfg(target_os = "linux")]
            let command = Command::new("pkexec")
                .arg("dfu-util")
                .arg("-D")
                .arg(firmware_path)
                .output()
                .expect("Could not flash soldering iron");

this is on line 93 of the src/submodules/flash.rs file, the pinecil v2 code is a bit further down the file.

Janik-Haag commented 1 year ago

Ah okay you are constructing a comment and then executing it in a shell context, that's what I thought, should be an easy fix I just have to patch dfu-util to the absolute path in the nix-store since in nix $PATH works a bit differently to be able to avoid version conflicts.

Spagett1 commented 1 year ago

Ah interesting, also you should know the Command::new() doesn't call a shell, it works off of PATH and other environment variables though, it may be easier for you to edit the command call with .env() but I'm really not sure, I've played with nixos briefly but never got into packaging for it so I'm not sure.

Janik-Haag commented 1 year ago

Since I couldn't sleep I did the totally normal thing of debugging this:

dfu-util -D Pinecil_EN.dfu doesn't work and throws this error:

dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Match vendor ID from file: 28e9
Match product ID from file: 0189
dfu-util: Cannot open DFU device 28e9:0189 found on devnum 31 (LIBUSB_ERROR_IO)
dfu-util: No DFU capable USB device available

lsusb shows a connected device:

Bus 001 Device 026: ID 28e9:0189 GDMicroelectronics GD32 DFU Bootloader (Longan Nano)

I randmesg --follow to get the usb status messages and here is the log:

[  257.914271] usb 1-4: new full-speed USB device number 31 using xhci_hcd
[  258.041662] usb 1-4: New USB device found, idVendor=28e9, idProduct=0189, bcdDevice= 1.00
[  258.041671] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  258.041674] usb 1-4: SerialNumber: 吳䩂
[  275.960768] usb 1-4: reset full-speed USB device number 31 using xhci_hcd
[  276.074785] usb 1-4: device descriptor read/64, error -71
[  276.296807] usb 1-4: device descriptor read/64, error -71
[  276.519790] usb 1-4: reset full-speed USB device number 31 using xhci_hcd
[  276.634760] usb 1-4: device descriptor read/64, error -71
[  276.856735] usb 1-4: device descriptor read/64, error -71
[  277.079611] usb 1-4: reset full-speed USB device number 31 using xhci_hcd
[  277.079786] usb 1-4: Device not responding to setup address.
[  277.286632] usb 1-4: Device not responding to setup address.
[  277.493540] usb 1-4: device not accepting address 31, error -71
[  277.607506] usb 1-4: reset full-speed USB device number 31 using xhci_hcd
[  277.607651] usb 1-4: Device not responding to setup address.
[  277.813582] usb 1-4: Device not responding to setup address.
[  278.021480] usb 1-4: device not accepting address 31, error -71
[  278.021548] usb 1-4: USB disconnect, device number 31
[  278.135422] usb 1-4: new full-speed USB device number 32 using xhci_hcd
[  278.249429] usb 1-4: device descriptor read/64, error -71
[  278.471415] usb 1-4: device descriptor read/64, error -71
[  278.687378] usb 1-4: new full-speed USB device number 33 using xhci_hcd
[  278.801381] usb 1-4: device descriptor read/64, error -71
[  279.024365] usb 1-4: device descriptor read/64, error -71
[  279.133409] usb usb1-port4: attempt power cycle
[  279.514403] usb 1-4: new full-speed USB device number 34 using xhci_hcd
[  279.514592] usb 1-4: Device not responding to setup address.
[  279.717511] usb 1-4: Device not responding to setup address.
[  279.925321] usb 1-4: device not accepting address 34, error -71
[  280.039300] usb 1-4: new full-speed USB device number 35 using xhci_hcd
[  280.039481] usb 1-4: Device not responding to setup address.
[  280.245450] usb 1-4: Device not responding to setup address.
[  280.453287] usb 1-4: device not accepting address 35, error -71
[  280.453358] usb usb1-port4: unable to enumerate USB device

I of course searched for the issue and found https://sourceforge.net/p/dfu-util/tickets/127/ And tried adding the udev rule as described in some comment and rebooted but that didn't do the trick for me. I'll ask in the local hackspace if some one can lend me there pinecil so I can check if mine is just borked or if it is some issue anywhere between libusb, dfu-util or NixOS. I know that a few people there also own a v2 so I can test that as well.

on another note the copy log button in pineflash isn't working for me :/ I'll have to look at how that is implemented, probably just some incompatibilities with sway had the same issue with another project https://github.com/AgathaSorceress/url-eater/issues/2

Also I'm guessing there is only a discord server and no matrix channel, right?

I'll close this since this seems to be a issue with dfu-util and not PineFlash

Spagett1 commented 1 year ago

Interesting, definitely seems like a dfu-util thing. It's possible someone in the pinecil matrix can help out if this is a known issue in general, I don't really use matrix much but I wouldn't be opposed to bridging it, I don't have a ton of time though to do that though.

Spagett1 commented 1 year ago

Well it turns out making and bridging a space is pretty easy, I've made a matrix space @Janik-Haag if you wanted to ask questions in relation to nix, suggestions, or whatever now. You can find the link in the readme.

Janik-Haag commented 1 year ago

Thank you, I joined the space and wrote some stuff :D