Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Nano ATmega328 (old bootloader) cannot open connection #23

Open
davidezanella opened this issue Aug 19, 2021 · 6 comments
Open

Comments

@davidezanella
Copy link

It seems that the library is not able to open a connection with my Arduino Nano ATmega328 (old bootloader) even if it is correctly identified. It is something related to the UART protocol, I suppose. The following is the avrdude output while uploading from Arduino IDE:

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM9
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.16
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

This is the log of the library while trying to open a connection: (I changed some log to report more data)

D/AutoCommunicator: POSSIBLY WCH
    Yes WCH!
D/UartWinCH34x: Trying VID: 6790
D/UsbCdcConnection: VID PASS 6790
    PID PASS 29987
    ACM PASS
    ch == chNum
    deviceIsConnected 0
D/UsbAccessor: Device(0) : UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=6790,mProductId=29987,mClass=255,mSubclass=0,mProtocol=0,mManufacturerName=null,mProductName=USB2.0-Ser!,mVersion=2.54,mSerialNumberReader=android.hardware.usb.IUsbSerialReader$Stub$Proxy@505625,mConfigurations=[
    UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=48,mInterfaces=[
    UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]]]
D/UsbAccessor: Device(0) : UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=6790,mProductId=29987,mClass=255,mSubclass=0,mProtocol=0,mManufacturerName=null,mProductName=USB2.0-Ser!,mVersion=2.54,mSerialNumberReader=android.hardware.usb.IUsbSerialReader$Stub$Proxy@60badab,mConfigurations=[
    UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=48,mInterfaces=[
    UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]]]
D/UsbAccessor: Interface(0,0) : UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]
D/UsbCdcConnection: Find VID:1a86, PID:7523, DevNum:0, IntfNum:0
D/UsbAccessor: Device(0) : UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=6790,mProductId=29987,mClass=255,mSubclass=0,mProtocol=0,mManufacturerName=null,mProductName=USB2.0-Ser!,mVersion=2.54,mSerialNumberReader=android.hardware.usb.IUsbSerialReader$Stub$Proxy@f253c08,mConfigurations=[
    UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=48,mInterfaces=[
    UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]]]
D/UsbAccessor: Interface(0,0) : UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]
D/UsbAccessor: Device(0) : UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=6790,mProductId=29987,mClass=255,mSubclass=0,mProtocol=0,mManufacturerName=null,mProductName=USB2.0-Ser!,mVersion=2.54,mSerialNumberReader=android.hardware.usb.IUsbSerialReader$Stub$Proxy@1552fa1,mConfigurations=[
    UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=48,mInterfaces=[
    UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]]]
D/UsbAccessor: Interface(0,0) : UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]
    Endpoint(0,0,0) : UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
D/UsbAccessor: Device(0) : UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=6790,mProductId=29987,mClass=255,mSubclass=0,mProtocol=0,mManufacturerName=null,mProductName=USB2.0-Ser!,mVersion=2.54,mSerialNumberReader=android.hardware.usb.IUsbSerialReader$Stub$Proxy@d4e85c6,mConfigurations=[
    UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=48,mInterfaces=[
    UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]]]
D/UsbAccessor: Interface(0,0) : UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]
D/UsbAccessor: Device(0) : UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=6790,mProductId=29987,mClass=255,mSubclass=0,mProtocol=0,mManufacturerName=null,mProductName=USB2.0-Ser!,mVersion=2.54,mSerialNumberReader=android.hardware.usb.IUsbSerialReader$Stub$Proxy@4557987,mConfigurations=[
    UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=48,mInterfaces=[
    UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]]]
D/UsbAccessor: Interface(0,0) : UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]
    Endpoint(0,0,0) : UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
D/UsbAccessor: Device(0) : UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=6790,mProductId=29987,mClass=255,mSubclass=0,mProtocol=0,mManufacturerName=null,mProductName=USB2.0-Ser!,mVersion=2.54,mSerialNumberReader=android.hardware.usb.IUsbSerialReader$Stub$Proxy@8d610b4,mConfigurations=[
    UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=48,mInterfaces=[
    UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]]]
D/UsbAccessor: Interface(0,0) : UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=1,mProtocol=2,mEndpoints=[
    UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
    UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=8,mInterval=1]]
    Endpoint(0,0,1) : UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=32,mInterval=0]
D/UartWinCH34x: Opening WCH, VID: 6790
    init
D/UartWinCH34x: init r != 2 for 0x5f, r: -1 size: 8 buff: [0, 0, 0, 0, 0, 0, 0, 0]
    Trying VID: 17224
D/UsbCdcConnection: Cannot find VID:17224, PID:0
D/UartWinCH34x: Opening WCH failed
D/AutoCommunicator: Nothing on USB

What I get is that it doesn't receive any data from the Arduino during the init phase. Can someone please help me understanding the problem or redirecting me to some documentations/specifications?

@xxxajk
Copy link
Owner

xxxajk commented Aug 19, 2021

D/UartWinCH34x: init r != 2 for 0x5f, r: -1 size: 8 buff: [0, 0, 0, 0, 0, 0, 0, 0]
seems to be the bug with your hardware...

https://github.com/xxxajk/PhysicaloidLibrary/blob/master/PhysicaloidLibrary/src/com/physicaloid/lib/usb/driver/uart/UartWinCH34x.java#L263

:-)

@xxxajk
Copy link
Owner

xxxajk commented Aug 19, 2021

Actually, what is the VID:PID?

@davidezanella
Copy link
Author

The VID is: 1A86 and PID: 7523

@xxxajk
Copy link
Owner

xxxajk commented Aug 19, 2021

Found the issue, I'll have time on Sunday to fix it. Thanks for locating the bug!

@jangminhyeok
Copy link

jangminhyeok commented Dec 8, 2021

I fixed this problem with below codes in 'UartWinCH34x.java'.

// USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT

private static final byte REQTYPE_HOST_TO_INTERFACE = (byte) (UsbConstants.USB_TYPE_VENDOR | UsbConstants.USB_DIR_OUT);

// USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN

private static final byte REQTYPE_INTERFACE_TO_HOST = (byte) (UsbConstants.USB_TYPE_VENDOR | UsbConstants.USB_DIR_IN);

@xxxajk
Copy link
Owner

xxxajk commented Dec 9, 2021

Please make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants