ataradov / usb-sniffer-lite

A simple USB sniffer based on Raspberry Pi RP2040
BSD 3-Clause "New" or "Revised" License
524 stars 45 forks source link

When I connect both the D+ and D- wires to the board, the connection between the testing Cool Disk with the computer is lost! #4

Closed Pe3a-XaH closed 1 year ago

Pe3a-XaH commented 1 year ago

Hello Thanks for your interesting design.

I made the circuit and I saw its menu with the Putty terminal program and the LED was blinking and I used a cool disk for testing, but there was a problem.

When I disconnect one of the wires connected to GPIO 10 or GPIO 11 from the pico board, Cool Disk works and is recognized by the computer.

But when I connect both the D+ (Green) and D- (White) wires to the board, the connection between the Cool Disk and the computer is disconnected.

Please advise.

Thanks

ataradov commented 1 year ago

What is Cool Disk?

Pe3a-XaH commented 1 year ago

Hi,

I meant USB Flash Drives Storage.

In my country it is more famous as Cool Disk.

ataradov commented 1 year ago

This sniffer will not be useful with flash drives. They still should function, but that depends on the quality of the connections. But sniffing will not work, since USB drives enumerate as High-Speed devices and this sniffer can only work with Full-Speed devices.

Try with something simpler, like a keyboard or a mouse.

Pe3a-XaH commented 1 year ago

I tested with a non-smartphone and it seems to work.

I am using putty terminal with speed 576000 to communicate with pico.

But my question is how to save buffer data inside a file? Because it is not completely possible using copy and paste from Putty terminal.

I also get the following error at first, but after pressing the S key a couple of times to capture, it seems to get only small parts of the exchanged data correctly.

Capture started Capture stopped Synchronization error. Check your speed setting.

Capture buffer is empty

[When press (s) key many times ...]

1583027 : NAK 1583033 : IN: 0x02/2 1583036 : NAK : : 1583116 : NAK 1583122 : IN: 0x02/2 1583125 : NAK 1583133 : IN: 0x02/2 1583135 : DATA0 (7): 43 4d 47 52 3d 33 0d 1583143 : ACK 1583400 : IN: 0x02/2 1583403 : NAK 1583410 : IN: 0x02/2 1583413 : NAK 1583420 : IN: 0x02/2 : : 1583946 : IN: 0x02/2 1583948 : NAK ... : Folded 1 frame

Capture buffer: 0 : RESERVED 1869129088 : RESERVED 4154500480 : RESERVED 0 : SPLIT: HubAddr=0x77, SC=1, Port=05, S=0, E=0, ET=2 ... : Folded 1 frame 103123066 : SOF #551 103123078 : IN: 0x00/0 103123088 : IN: 0x00/0 103123098 : IN: 0x00/0 : : 103123714 : IN: 0x00/0 103123724 : IN: 0x00/0 103123733 : IN: 0x00/0 103123829 : MDATA (280): 41 2a f8 07 f8 07 00 00 fc 03 01 00 fe 01 00 ff ... 17 : DATA1 (4294967294): 33 : DATA1 (43400): 25 06 20 15 27 2a 02 00 00 00 11 00 00 00 e9 8b ... 103141441 : IN: 0x00/0 103141450 : IN: 0x00/0 103141461 : IN: 0x00/0 : : 103141568 : IN: 0x00/0 103141578 : IN: 0x00/0 0 : RESERVED

ataradov commented 1 year ago

Get a better terminal that lets you save things into a file. The baudrate setting does not matter, since it is a purely virtual port.

The synchronization errors are common if device is already working and you start the capture. This sniffer assumes that the line is idle and if you start the capture in the middle of the packet, then it will not be able to synchronize properly. There may be a way to improve it, but I don't have time at the moment and in the end there is only so much PIO can do.

The optimal use for this is to start the capture, then plug in the device. This way you are guaranteed to start in the idle bus state.

Pe3a-XaH commented 1 year ago

Thanks a lot

ataradov commented 1 year ago

I've just pushed an update that should address a lot of synchronization issues. I expect it to be much more robust now.

Pe3a-XaH commented 1 year ago

Hi, Thank you for your update.

I used the sniffer by Tana (https://github.com/tana/pico_usb_sniffer) for my job, because it makes Wireshark (.pcap) output.

Both of sniffers can not sniff full speed devices.

I used it series with a USB Isolator to reduce high speed devices to full speed mode, but this trick did not work for me and both of sniffers ( Tana and yours) makes many error packets.

ataradov commented 1 year ago

What isolator did you use? They generally don't do anything active to reduce the speed. They often just make HS devices not work at all.

Does the device itself work as expected? Does OS show that it has enumerated as an FS device?

Also, not all HS devices can fully function at an FS speed. But they still should not generate errors.