ArminJo / micronucleus-firmware

Fork for the firmware / digispark part of the micronucleus repository
Other
76 stars 19 forks source link

[BUG] can't upload on Linux #29

Closed g1ra closed 10 months ago

g1ra commented 1 year ago

Describe the bug The board works on Windows with Digistump.Drivers but on Linux it does not

To Reproduce Steps to reproduce the behavior:

  1. use linux .
  2. follow http://digistump.com/wiki/digispark/tutorials/linuxtroubleshooting
  3. run "dmesg -w" as a root user
  4. you will see `[ 3154.154694] usb 3-3.2: new low-speed USB device number 22 using xhci_hcd

[ 3154.155066] usb 3-3.2: Device not responding to setup address.

[ 3154.363051] usb 3-3.2: Device not responding to setup address.

[ 3154.570687] usb 3-3.2: device not accepting address 22, error -71

[ 3154.650683] usb 3-3.2: new low-speed USB device number 23 using xhci_hcd [ 3154.651052] usb 3-3.2: Device not responding to setup address. [ 3154.859053] usb 3-3.2: Device not responding to setup address. [ 3155.066671] usb 3-3.2: device not accepting address 23, error -71 [ 3155.066759] usb 3-3-port2: unable to enumerate USB device `

  1. try running "micronucleus --no-ansi --run --timeout 60 /tmp/arduino_build_110489/ATtiny85-note-play.ino.hex"

    Please plug in the device (will time out in 60 seconds) ...

Expected behavior "Device is found!"

Used Hardware blue color digispark clone attiny85

Desktop (please complete the following information):

g1ra commented 1 year ago

apt-cache policy libusb-*

libusb-java-lib: Installed: 0.8+ztex20090101-9 Candidate: 0.8+ztex20090101-9 Version table: 0.8+ztex20090101-9 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages 100 /var/lib/dpkg/status libusb-ocaml-33w17:i386: Installed: (none) Candidate: (none) Version table: libusb-ocaml-dev-ubde3: Installed: (none) Candidate: (none) Version table: libusb-1.0-0-dev: Installed: 2:1.0.26-1 Candidate: 2:1.0.26-1 Version table: 2:1.0.26-1 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages 100 /var/lib/dpkg/status libusb-1.0-doc: Installed: 2:1.0.26-1 Candidate: 2:1.0.26-1 Version table: 2:1.0.26-1 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://ftp.cz.debian.org/debian bookworm/main i386 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main i386 Packages 100 /var/lib/dpkg/status libusb-libusb-perl: Installed: (none) Candidate: 0.09-2+b2 Version table: 0.09-2+b2 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages libusb-ocaml: Installed: (none) Candidate: 1.3.1-4+b8 Version table: 1.3.1-4+b8 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages libusb-0.1-4: Installed: 2:0.1.12-32 Candidate: 2:0.1.12-32 Version table: 2:0.1.12-32 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages 100 /var/lib/dpkg/status libusb-1.0-0: Installed: 2:1.0.26-1 Candidate: 2:1.0.26-1 Version table: 2:1.0.26-1 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages 100 /var/lib/dpkg/status libusb-ocaml-dev-33w17:i386: Installed: (none) Candidate: (none) Version table: libusb-java: Installed: 0.8+ztex20090101-9 Candidate: 0.8+ztex20090101-9 Version table: 0.8+ztex20090101-9 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://ftp.cz.debian.org/debian bookworm/main i386 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main i386 Packages 100 /var/lib/dpkg/status libusb-ocaml-ubde3: Installed: (none) Candidate: (none) Version table: libusb-ocaml-dev: Installed: (none) Candidate: 1.3.1-4+b8 Version table: 1.3.1-4+b8 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages libusb-dev: Installed: 2:0.1.12-32 Candidate: 2:0.1.12-32 Version table: *** 2:0.1.12-32 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages 100 /var/lib/dpkg/status libusb-java-doc: Installed: (none) Candidate: 0.8+ztex20090101-9 Version table: 0.8+ztex20090101-9 500 500 http://ftp.cz.debian.org/debian bookworm/main amd64 Packages 500 http://ftp.cz.debian.org/debian bookworm/main i386 Packages 500 http://deb.debian.org/debian bookworm/main amd64 Packages 500 http://deb.debian.org/debian bookworm/main i386 Packages

g1ra commented 1 year ago

found that USB 3.1 port seems identify the device :

[ 5084.030683] usb 7-1: New USB device found, idVendor=16d0, idProduct=0753, bcdDevice= 2.06
[ 5084.030688] usb 7-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 
[ 5146.455831] usb 7-1: usbfs: USBDEVFS_CONTROL failed cmd micronucleus rqt 192 rq 0 len 8 ret -71
[ 5147.002508] usb 7-1: USB disconnect, device number 11
[ 5149.045838] usb 7-1: new low-speed USB device number 12 using xhci_hcd
[ 5149.201698] usb 7-1: New USB device found, idVendor=16d0, idProduct=0753, bcdDevice= 2.06
[ 5149.201702] usb 7-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 5152.984027] usb 7-1: usbfs: USBDEVFS_CONTROL failed cmd micronucleus rqt 192 rq 0 len 8 ret -71
[ 5155.962866] usb 7-1: usbfs: USBDEVFS_CONTROL failed cmd micronucleus rqt 192 rq 0 len 8 ret -71
g1ra commented 1 year ago

tried to change libusb headers in micronucleus_lib.h as I found at https://github.com/micronucleus/micronucleus/issues/81#issue-168379060

#include <lusb0_usb.h>         // libusb-win32
#else
//#include <usb.h>
#include </usr/include/libusb-1.0/libusb.h>
#endif

but got an error :

Building library: library/micronucleus_lib.c...                                                                                                                                                                    
gcc  -Ilibrary -O -g -D LINUX -c library/micronucleus_lib.c                                                                                                                                                        
In file included from library/micronucleus_lib.c:32:                                                                                                                                                               
library/micronucleus_lib.h:80:3: error: unknown type name ‘usb_dev_handle’                                                                                                                                         
   80 |   usb_dev_handle *device;                                                                                                                                                                                  
      |   ^~~~~~~~~~~~~~                                                                                                                                                                                           
Ho-Ro commented 1 year ago

tried to change libusb headers in micronucleus_lib.h as I found at micronucleus/micronucleus#81 (comment)

Why did you do that, couldn't you translate the original source? This issue #81 is very old, and the problem was that the translation did not work.

Micronucleus combined with USB3 can be problematic - you could try with an USB2 hub in between.

g1ra commented 1 year ago

@Ho-Ro USB2 don't work either . @Ho-Ro I looked in compile a bootloader with different libusb . But I couldn't find anything there for setting USB . so I tried compiling commandline micronucleus . Seems that other versions of commandline micronucleus does not make a difference . I tried with other versions too from other repos too .

only a bootloader matters . With micronucleus-1.11.hex I can connect immediately no problems , but all the newer bootloaders are not connecting . I'm thinking there must be something related to how bootloader connect to my linux libusb .

I did compile t85_entry_on_powerOn_activePullup_fastExit on Linux , and flash it . Not working either . What can I try changing in configurations for USB?

@Ho-Ro did you tried using linux with t85_entry_on_powerOn_activePullup_fastExit ?

Ho-Ro commented 1 year ago

did you tried using linux with t85_entry_on_powerOn_activePullup_fastExit ?

I did - but I never used micronucleus or bootloader since years :(

g1ra commented 1 year ago

suspect the issue must be caused by some changes in micronucleus-firmware/firmware/usbdrv/ which makes Linux libusb incompatible