USB Full-Speed Analyzer... Is that still a thing? - Page 1
Forum section: electronics / general

author: Saimoun
author_rank: Frequent Contributor
timestamp: July 13, 2022, 09:59:32 am
content: HeySo I'm starting to write my own USB stack and it's difficult without any debugging tool. I've been searching the net but I keep finding things that look SO OLDExamples:https://www.mqp.com/usbdev_buy.htm- 420GBP and manual comes on a CD (gosh it has been at least 5 years since my computer does not have a CD Drive...)https://www.sysnucleus.com/- "NEW!" supports now Windows 8 - I mean wowOther options I've seen are:https://www.totalphase.com/products/beagle-usb12/- $500https://freeusbanalyzer.com/- weird how they keep calling it "free" while this is a trial, the full version costs.... WAIT what - the page literally showed about $100 an hour ago, since then I installed the free version and now it only shows me the $180 price - GOSH that's fishy-https://www.hhdsoftware.com/usb-monitoring-controlDIY with Linux -https://elinux.org/images/1/17/USB_Debugging_and_Profiling_Techniques.pdfAny suggestions/experiences you guys want to share? Do you think a hardware analyzer is necessary or could I get away with getting a software one?CheersSimon

author: Saimoun
author_rank: Frequent Contributor
timestamp: July 13, 2022, 10:13:54 am
content: And I just found some free tools (software) as well:https://sourceforge.net/projects/usbsnoop/for Windowshttp://vusb-analyzer.sourceforge.net/for LinuxI might actually start with these and see if it is enough

author: wek
author_rank: Frequent Contributor
timestamp: July 13, 2022, 10:15:50 am
content: > I've been searching the net but I keep finding things that look SO OLDI am 50+ and to you would look SO OLD, but don't you dare to tell me that face to face!> Do you think a hardware analyzer is necessary or could I get away with getting a software one?Not necessary, but very, very, very useful. It has paid itself several times over:http://www.asix.net/dbg_sigma.htm(note that the USB analyzer plugin is paid extra). Not ideal, but workable.I've heard praises on the Beagle one. There are "real" 'scopes/LAs, which have USB decoder built in or as an option. For fun/enlightement, if you have a LA/'scope at hand, capture a piece of stream and try to decode by hand.Software analyzers show you things which may be beyond hw/sw layers which are of varying opacity, and usually present them in an unpalpable way (at least that was my impression). The free goto option is wireshark with some plugin (I am lazy to look it up - tried but was not impressed).JW

author: voltsandjolts
author_rank: Unknown
timestamp: July 13, 2022, 10:29:07 am
content: sigrok PulseView has USB FS decoding, maybe you already have a supported LA.Also, I haven't tried Alex's analyser, but I bet it works a treat...https://www.eevblog.com/forum/projects/usb-sniffer-using-rp2040/

author: Saimoun
author_rank: Frequent Contributor
timestamp: July 13, 2022, 11:04:46 am
content: Quote from: wek on July 13, 2022, 10:15:50 amHa ha ha sorry - did not mean to upset anyonePeople can age, that's fine. But software and hardware does not age well in a world where everything changes so much in a couple of years. My main concern was whether people still use these tools since most of them do not seem like they had any update for the last few years.The SIGMA sounds nice, but still about 300€ total so the same price as the other hardware options I've seen. Nice that it is EU-based though.Awesome about the wireshark option, you know of any plugin?Quote from: voltsandjolts on July 13, 2022, 10:29:07 amThanks for the links. Alex's analyzer runs on a Rasperry board as I understood? I would need to get one, compile, upload the firmware, etc. - that might take a while.My LA is an Analog Discovery (the first version, i.e. the black one). It has done the job so far. I never even thought about hooking it up to the USB lines to see - but without any plugin to sort out the data it will be a mess to look at I guess...

author: zzattack
author_rank: Regular Contributor
timestamp: July 13, 2022, 11:12:48 am
content: I've purchased the one designed by forum member John_ITIC (http://www.internationaltestinstruments.com/products/97-1480a-usb-20-protocol-analyzer.aspx).Comes with excellent software that's served me great in a few projects already. It's true HS compatible too, and price was pretty competitive as I recall. Maybe worth shooting him a message.There was a20% forum discountat the time too.

author: Saimoun
author_rank: Frequent Contributor
timestamp: July 13, 2022, 11:29:40 am
content: I am sure it would do the job perfectly, it looks overkill for my needs though (and ships from the US).

author: ataradov
author_rank: Super Contributor
timestamp: July 13, 2022, 03:25:58 pm
content: Quote from: simonlasnier on July 13, 2022, 11:04:46 amIt runs on the Pi Pico or any other RP2040 based board. They are readily available and cheap.You don't need to compile anything, the UF2 binary is provided. You would need to make a pass-through cable and connect it to the pins.This is not a perfect solution, but definitely the cheapest as far as hardware sniffers go.

author: Saimoun
author_rank: Frequent Contributor
timestamp: July 13, 2022, 09:58:48 pm
content: Thanks Alex for the reply and for making this!! I'll definitely give it a go

author: TimCambridge
author_rank: Regular Contributor
timestamp: July 14, 2022, 12:43:38 am
content: We make one (www.bugblat.com/products/minisniff2/index.html) and getting the parts to built it is every bit as purgatorial as readers of this site would expect.For instance, Digikey offer 2,842 non-obsolete Xilinx FPGAs. Of these 112 are in stock and only a few (all designed by Noah and his dad) are available in quantities of a few hundred.Pricing? The scalpers offer one $4 part for $80, not a good fit for a sub-$100 product.

author: Bassman59
author_rank: Super Contributor
timestamp: July 14, 2022, 06:44:39 pm
content: Quote from: TimCambridge on July 14, 2022, 12:43:38 amDoes your sniffer handle HS devices, and does it have Device Class decoding?

author: ataradov
author_rank: Super Contributor
timestamp: July 14, 2022, 07:05:25 pm
content: Quote from: Bassman59 on July 14, 2022, 06:44:39 pmIt says on the page that it prevents HS devices from going into HS mode. So, it technically works, but some HS devices will not do much in FS mode. I think all cameras will pretty much just have a dummy descriptor for the FS mode.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 14, 2022, 07:23:27 pm
content: I'm guessing that's not what Bassman59 necessarily had in mind as far as supporting HS meant. But that's interesting that you at least managed to prevent a device from going into HS. (For those that don't know the details of USB, an enumeration first starts in FS mode and only after a proper transaction, both the host and device switch to HS if they both support it.) How did you do it, as the sniffer is just "sniffing", isn't it? Or did you make it act as some kind of "bridge"?Anyway technically, handling HS mode with a RP2040 (I think you use the PIO for sampling?) would be absolutely impossible.

author: ataradov
author_rank: Super Contributor
timestamp: July 14, 2022, 08:01:59 pm
content: It was not me, it was for the TimCambridge product. My sniffer only supports FS mode. But the only way I see to prevent it is to disturb the HS chirp somehow, so it would not be a fully passive sniffer.I'm about to publish a design for a cheap sniffer that supports all modes. It is based on an FPGA and I was going to wait until FPGAs are actually available, but I guess that's not happening any time soon. It still may be useful to some.

author: Bassman59
author_rank: Super Contributor
timestamp: July 14, 2022, 09:38:06 pm
content: Quote from: SiliconWizard on July 14, 2022, 07:23:27 pmIf the thing only support HS devices by preventing them from actually running at HS, then it's not very useful. I keep putting off the purchase of a Total Phase analyzer, which actually does HS devices at HS.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 14, 2022, 10:05:37 pm
content: Quote from: ataradov on July 14, 2022, 08:01:59 pmOK, thought that was your own design ! So yeah, it must not be fully passive. I'm wondering how they do it. They must take control of the data pins in order to achieve this.Quote from: ataradov on July 14, 2022, 08:01:59 pmI'm sure that would be. Well, such sniffers do exist as commercial products, but they tend to be expensive.As a quick note, using an ULPI transceiver (only a couple bucks) and an FPGA would be the fastest way of implementing this. I'm sure there are projects out there already, I haven't checked. You can definitely use a ULPI transceiver for USB sniffing.

author: ataradov
author_rank: Super Contributor
timestamp: July 14, 2022, 10:16:54 pm
content: My design is based on CY7C68013A + LCMXO2-2000HC (1200 works too) + USB3343. I have a design based on MAX10 and just two USB transceivers for the capture and device side, but price-wise CY7 + cheap FPGA are much better. Plus this reduces system complexity, since there is no need to run the MCU inside the FPGA. User experience is also much better since CY7 can be updated remotely and I have FPGA programmer, so you don't need any programming tools even if you just built the board from blank parts.I also have dedicated 3-level comparators on the DP/DM lines, which lets you see when HS termination was enabled. This is pretty useful when debugging HS devices, especially if you are making your own controller.I was sitting on the design, since I did not have motivation to complete it, but I recently needed to use it for work and it was very useful, so I decided to focus on it and make it public finally.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 14, 2022, 10:52:02 pm
content: Quote from: ataradov on July 14, 2022, 10:16:54 pmOh OK, so that's basically what I suggested.Quote from: ataradov on July 14, 2022, 10:16:54 pmDoesn't the USB3343 already have means of detecting this internally, accessible via some register?

author: ataradov
author_rank: Super Contributor
timestamp: July 14, 2022, 10:57:24 pm
content: Quote from: SiliconWizard on July 14, 2022, 10:52:02 pmFS and HS modes are very different in a way they work. FS uses voltage signaling and HS is current driven and the typical voltage levels for the HS are much lover than 3.3 V.The switch to HS mode starts with a number of state toggles (chirp). After 10 toggles are detected, HS capable device enables the termination resistors, which drops the voltage level. FS devices ignore those toggles.This is impossible to detect with USB3343, since you need to tell it in what mode to receive and it uses completely separate analog paths for FS and HS.

author: bson
author_rank: Unknown
timestamp: July 16, 2022, 08:15:51 pm
content: If you're going to implement USB stacks, devices classes, that sort of thing then a USB protocol analyzer is an essential investment IMO. I've been very happy with my LeCroy Mercury T2, but these days I'd get one with USB PD capability. (I will probably upgrade the T2 for this reason, unfortunately it's not just a license code. It requires the T2C with USB-C connectors and hence CC pins.)

author: voltsandjolts
author_rank: Unknown
timestamp: July 16, 2022, 08:40:21 pm
content: Even a software only analyser is somewhat useful, maybe all you need if you are using a proven usb stack in your firmware. I've reverse eng'd and re-implemented proprietary usb device protocols using just Wireshark as the analyser tool. But yeh, for low-level stuff its no help at all.

author: prosper
author_rank: Regular Contributor
timestamp: July 26, 2022, 08:34:29 pm
content: I use a DSLogic Pro analyzer. Their software is good. Also works with PulseView from Sigrok. Both can decode USB. USB FS (12MBps) is no problem. High speed - not so much

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 26, 2022, 08:47:14 pm
content: Quote from: prosper on July 26, 2022, 08:34:29 pmGood tip. I do have a DSLogic Pro as well and it's a very useful tool for a reasonable price.Never used it for USB decoding, but it does support USB protocols including USB PD.Of course it won't work with USB HS due to the bandwidth of this device, but the OP only asked for FS.

author: NiHaoMike
author_rank: Super Contributor
timestamp: July 27, 2022, 01:05:17 am
content: Wouldn't it be possible to use a Raspberry Pi 4 since it supports device mode and host mode simultaneously? Back in the day, something similar could be done with the Beaglebone.

author: Saimoun
author_rank: Frequent Contributor
timestamp: August 01, 2022, 10:33:37 am
content: Thank you all for the replies!I've just ordered a R PI Pico, that's by far the cheapest and simplest option and I'm pretty sure it will be enough - all I need is to sort out the enumeration, once this is running my usage of USB is super basic.So thanks Alex for the awesome free software - I'll update here how it goesAlso - I had a quick look at DSLogic Products which look pretty good!! Love the company, the vibe, and funded with a KickstarterSo I'll definitely consider that for the future, especially since it's a nice upgrade to my current Logic analyzer (analog discovery 1).Do you guys know if the DSLogic Plus support USB debugging? I could not find that info anywhere...

author: pcprogrammer
author_rank: Super Contributor
timestamp: August 01, 2022, 10:45:54 am
content: Maybe this can be of interest for your task.https://github.com/sekigon-gonnoc/Pico-PIO-USBHas been discussed on the forum too:https://www.eevblog.com/forum/microcontrollers/amazing-project-usb-fshostdevice-implementation-using-pio-of-rp2040/msg4180372/#msg4180372

author: Saimoun
author_rank: Frequent Contributor
timestamp: August 01, 2022, 11:32:44 am
content: Quote from: pcprogrammer on August 01, 2022, 10:45:54 amThanks but I think you missed the pointI'm doing USB device only on a GD32 MCU, I just needed a USB HW debugger and plan on using the one Alex made running on a Raspberry Pi Pico

author: pcprogrammer
author_rank: Super Contributor
timestamp: August 01, 2022, 07:09:20 pm
content: Quote from: simonlasnier on August 01, 2022, 11:32:44 amThat you did not write in your posts here, at least I did not see it. Just that you needed a way to debug USB on a hardware level because you are writing your own stack.For this the code for the pico might be useful as a guideline.But with a device only USB implementation you don't need a separate hardware USB debugger per se. I did my own bare metal CH340 implementation on a STM32F103. During the development I used wireshark on my linux mint machine. There is USB support in it with some additional setup and it was helpful in solving some problems.I can dig up the steps I took to get wireshark up and running if you like.The code I wrote is a bit crude but it works. Code is here:https://github.com/pecostm32/STM32F103C8_USB_CH340

author: Saimoun
author_rank: Frequent Contributor
timestamp: August 05, 2022, 08:45:35 am
content: Sorry did not mean to pryThanks for the code - that's awesome!And yes I think with wireshark and Alex's USB debugger (I mean I bought the Pico now) I should be fine.Thank you all for the help

author: voltsandjolts
author_rank: Unknown
timestamp: August 05, 2022, 09:31:02 am
content: Quote from: simonlasnier on August 01, 2022, 10:33:37 amHmm, except that they are a bunch of thieving knobs who merely used the Kickstarter and open source vibe for their own benefit.When they started up, they stole the open source GPL licensedPulseViewGUI from thesigrokproject. Made their own changes to it as needed for their analyser and declined to openly publish their source code as required by the license. They made some token gesture to publish on github but AFAIK there were significant disparities between that repo and their shipped binary. Thegithub repostill exists but I would still be extremely suspicious that it reflects the current binary.The original PulseView developer discusses this situation at the link below (I'm avoiding youtube inlining).Code:https://youtu.be/xZ5wKYnCNcs?t=1622I use the Kingst analysers which are also good value and are supported in sigrok / PulseView. IIRC the specs are better than the non-pro DSLogic analysers.