Differences between the A3U and A1U USB peripheral

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to port some code from the A3U to the A1U. I read the errata, the USB on the A1U is a bit broken... It's a 64A1U if that matters.

 

Anyway I am at the point where setting the USB address fails. The hardware is fine, the Atmel ASF code works fine. This code works fine on the A3U too.

 

I cache the set address command and wait for an IN packet, then set it. That works fine on the A3U but not on the A1U. I've experimented a bit but can't find a point at which setting it works.

 

Sadly my crappy Saleae logic analyzer is not fast enough to reliably capture USB Full Speed, and the protocol analyzer is rubbish anyway. Can't get sigrok working either.

 

Any ideas? My understanding is that the response packet must be sent with the old EP address (usually zero) before using the new one.

This topic has a solution.
Last Edited: Fri. Jun 4, 2021 - 12:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mojo-chan wrote:
Can't get sigrok working either.
That's odd as sigrok has a USB packet protocol decoder (good enough)

https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=tree;f=decoders/usb_packet;h=a1186ef57fa0f6df6395c63e31ac934e553df0d6;hb=HEAD

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

mojo-chan wrote:
Can't get sigrok working either.
That's odd as sigrok has a USB packet protocol decoder (good enough)

https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=tree;f=decoders/usb_packet;h=a1186ef57fa0f6df6395c63e31ac934e553df0d6;hb=HEAD

 

 

I mean I can't get it working with the Saleae. I really need a better LA, this thing is too slow (24MHz) and the software is rubbish. Are there any good ones that are supported by Sigrok and not too expensive?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mojo-chan wrote:
I really need a better LA, this thing is too slow (24MHz)
IIRC, 48MHz minimum for full-speed USB.

Is low-speed USB acceptable?

mojo-chan wrote:
... and the software is rubbish.
Splash cash for a Saleae Logic 8?

mojo-chan wrote:
Are there any good ones that are supported by Sigrok and not too expensive?
Maybe

If the USB packet is correctly framed then consider a USB sniffer on a PC.

 


Supported Protocols - Saleae Support

GitHub - saleae/usb-analyzer: Saleae USB Analyzer

 

ASIX: OMEGA and SIGMA2 - Accessories

 

CaptureSetup/USB - The Wireshark Wiki

GitHub - djpnewton/busdog: busdog is a filter driver for MS Windows (XP and above) to sniff USB traffic.

USB Sniffer - USB Analyzer - USB port monitor

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will have a look at that tomorrow. I'm not giving Saleae another penny!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So buy a logic 16 pro clone on eBay for $40 ( 100Mhz).  It works with sigrok so happy trouble shooting

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I made a bit of progress by exporting from Saleae Logic and importing into PulseView, but the important packets always seem to be corrupt.

 

Anyway, it has to be some small difference in the two USB peripherals. Anyone got experience porting between them?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I made some more progress. I was originally checking in the USB_TRNCOMPL_vect interrupt for the USB_EP_TRNCOMPL0_bm bit in endpoint 0's STATUS register. Apparently it NEVER gets set. Works fine on the A3U.

 

I don't use auto ZLP which I know is broken on the A1U. Wondering what else it could be.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, I think it is the ZLP. I thought I wasn't using it but I am, obviously a few broken bits in my brain's memory cells.

 

So the question is how do you handle the ZLP in firmware?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Yeah, I've been trying to get some. One of the reasons I wanted my own USB stack is that the ASF is some of the worst spaghetti code I've ever seen.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mojo-chan wrote:
So the question is how do you handle the ZLP in firmware?
... or not (USB host's operation of winusb.dll)

ZLP in LUFA (SOLVED) | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

mojo-chan wrote:

So the question is how do you handle the ZLP in firmware?

 

... or not (USB host's operation of winusb.dll)

ZLP in LUFA (SOLVED) | AVR Freaks

 

 

Thanks, I meant how to handle it in the code though. I found the issue, my code was setting the ZLP flag in the CNT register. The errata says doesn't work, it doesn't say it actually breaks the transfer by making it send >0 bytes.

 

It's still not working but at least that issue is fixed.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Okay, got it working. In summary:

 

- The Auto ZLP is broken on A1U, as the errata states. What it doesn't mention is that the MSB in the CNTH register (which enabled ZLP) is counted towards packet length so must be cleared. It looks like the bug is they wired it into the packet length as well as the Auto ZLP enable logic.

 

- A knock-on effect of the Auto ZLP being broken is that you have to delay setting USB.ADDR. On A3U you can set it when the transaction complete interrupt fires with the SETUP bit set on the IN control endpoint (EP0). With Auto ZLP the ZLP packet responds to the old address (usually 0) IN packet. On A1U you have to delay setting USB.ADDR until after you have manually sent the ZLP response to the ADDRESS_SET command (0x05). My solution is to cache the address and set it in the interrupt when the TRNCOMPL0 bit is set on EP0 IN.

 

- As the errata also states, your endpoint table must be aligned to 16 bytes, not 2 as it says in the manual. Apparently Microchip didn't think it was worth updating the manual!

 

Also a little tip for people struggling with the Saleae Logic and Sigrok. You can capture in Logic, export as binary, and then import into PulseView. When importing select Saleae binary format, make sure you select Logic1 format as auto-detect doesn't seem to work, and then import. You can click the reload button to keep your current settings and just refresh the waveform after saving a new capture over the old one.