How to create a USBsniffer ?

This forum is for general developer support questions.
Post Reply
tpascoal
Posts: 4
Joined: Sun Oct 30, 2011 10:42 am
Location: Portugal / France

How to create a USBsniffer ?

Post by tpascoal »

How to create a "USBsniffer"
to see USB received & transfered DATA from/to a device and logging it and save the output.
This will help people to understand how works some devices connected to usb like graphics tablets, touchscreens, touchpads or even other keyboard or other graphic device, webcams that don't respect exactly "HID, HCD protocol, UHCI spec".
Andy Broad made an opensource driver for UClogicTablet and the idea is to have much more devices supported.
Some of them are difficult to support, because the documentation is closed and there are little few linux documentation & poor SDK form the manufacturer.
for this reason an USBsniffer will help... any some idea how to start the source code ? which includes to use ?
use both: usbresource.library & usbsys.device ?
User avatar
ZeroG
Posts: 124
Joined: Sat Jun 18, 2011 11:31 am
Location: Germany

Re: How to create a USBsniffer ?

Post by ZeroG »

I think a USBsniffer for Windows/Linux would be more usefull because you want to see what the original driver does to make it work. Or did i miss something?
tpascoal
Posts: 4
Joined: Sun Oct 30, 2011 10:42 am
Location: Portugal / France

Re: How to create a USBsniffer ?

Post by tpascoal »

You mean that each time I plug & unplug a device, a driver must initalise it ? if not the device does nothing... ? every time?
it is not the case of some device like mouse and touch device for example I think. when there are plug they start sending data accross the usb.
My problem (like probably other people, is to caught / log these input events...)

I'm true ? or every I had to initialise the device with a driver to allow send it DATA accross usb ? (on amigaos4)
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: How to create a USBsniffer ?

Post by abalaban »

tpascoal wrote:You mean that each time I plug & unplug a device, a driver must initalise it ? if not the device does nothing... ? every time?
it is not the case of some device like mouse and touch device for example I think. when there are plug they start sending data accross the usb.
My problem (like probably other people, is to caught / log these input events...)

I'm true ? or every I had to initialise the device with a driver to allow send it DATA accross usb ? (on amigaos4)
That's not specific to AmigaOS (4, 3, whatever) any USB device *needs* a driver to operate on any OS. Some systems are offering standard drivers for many kind of devices (HID, MassStorage, ... see USB spec document to know every kind of USB device). The problem with AmigaOS is that it only provides a few of this standard drivers currently only some HID, MassStorage and PTP IIRC and if a device is not fully compliant to the USB spec then you don't have the possibility to install vendor's driver because no manufacturer will ever build an Amiga driver in the near future :-( So you ends up with at most an half working device at worst a non working device...

To end this, an USB driver is a passive component: it does not start to send data on USB without having invited to do so before by the USB stack, and the USB stack can only do that if it has an appropriate driver. As ZeroG suggested you need a Windows (Linux would not be a good idea because generally this is already a reverse engineered driver) USB Sniffer.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
tpascoal
Posts: 4
Joined: Sun Oct 30, 2011 10:42 am
Location: Portugal / France

Re: How to create a USBsniffer ?

Post by tpascoal »

How to capture for USB logs ? the only I know is for example on shell with :
USBinspector ram:t/usb.log

is there any other more RAW method ? to see realtime packets for example analysing the usb device ?
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1479
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: How to create a USBsniffer ?

Post by tonyw »

There is a program called USBSnoop which on my system is located in SDK:C/. I can't remember whether it came as part of the USB stack or part of the SDK. But I think it does what you want.
cheers
tony
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: How to create a USBsniffer ?

Post by abalaban »

@tpascoal

again don't expect any wonder from an USBSniffer on AmigaOS 4 (which I don't think we have) at least not for currently unsupported devices. As I said in my previous post from November: an USB device won't start sending the system any data until the system asked it to do so, this can *ONLY* happen when the USB stack found an installed suitable driver because only such driver will know how to send/receive data to/from the device.
Eventually what you will see in such case is the USB stack asking the driver its product class ID, function class ID and vendor ID and then the USB stack having no suitable driver for such device will stop there.

However those information (product ID, function ID and vendor ID) can be very interesting for a developer if the device is supposed to work but is not detected by the driver (it can be a problem in the ID detection by the driver). Nevertheless those information do not need an USBSniffer, USBInspector should be able to give you all (IIRC).

On the other hand, if you want to provide a developer with information to develop a new driver. What you *need* is an USBSniffer on a *system having a working driver for the device* (most probably Windows) as this will enable the willing developer to analyze the exchange and do some reverse engineering on them. In this case USBSniffer on AmigaOS 4 won't be of any help !
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
Raziel
Posts: 1173
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: How to create a USBsniffer ?

Post by Raziel »

tonyw wrote:There is a program called USBSnoop which on my system is located in SDK:C/. I can't remember whether it came as part of the USB stack or part of the SDK. But I think it does what you want.
I'm intruiged...i have the SDK and the latest update installed, but nowhere is this tool to be found on my system.

Care to share it?
If it's not a beta-tool, of course
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1479
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: How to create a USBsniffer ?

Post by tonyw »

It was released to betatesters as a testing tool only (back in 2010).

I'll ask if it can be added to the SDK for the next release. But, as others have said in this thread, it will only give you information about the data exchanged with supported devices.
cheers
tony
billt
Posts: 9
Joined: Fri Feb 10, 2012 5:35 pm

Re: How to create a USBsniffer ?

Post by billt »

Ugh, timeout ate my post and I hadn't saved a draft.

Check out this, it was suggested for this sort of thing on stack exchange.
http://jacky5488.myweb.hinet.net/

I'd think of such a tool as an FPGA project. FPGA on PCI, or PCI-Express card with memory. The Raggedstone PCI FPGA cards have USB ports available as addons. The first one with memory there too is a PCI-Express card, so that may be more of a PC based sniffer tool, or you could use it with a PCI to PCI-Express adapter for AmigaOne/Sam440 or Classic+PCI users.. There's some of those on Ebay for cheap nowadays.

I'd have USB pass through the FPGA from one USB port to the other. Inside the FPGA, determine what makes sense to grab a chunk at a time of USB data in the FPGA on its way through, capture it and store it off to memory on the FPGA board. If you like, make it smart enough to look for things in the USB stream to trigger on. Then, later, have software read the memory contents out of the FPGA board for decoding, graphing, waves, whatever you want the stuff to look like.

Check opencores.org for open-source PCI controllers, memory controllers, USB controllers (though I'm not sure if a controller is needed for a sniffer)

Then look up info on FPGA logic analyzers to get ideas on how to fit things together and capture the data stream. There's an interesting one about a PCI bus sniffer to interpolate from.
http://www.fpga4fun.com/PCI3.html
also check on sump FPGA logic analyzer software and related hardware projects.


Perhaps someone with an X1000 would say this is an XMOS project. Could be, but I'm not as familiar with those things to know.
Post Reply