[Solved] Xplained Pro UART (EDBG) data transparency issues with Macintosh?

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

For my next "why me" question...

I'm working on a version of the Optiboot (Arduino) bootloader for the Tiny0, tiny1, and mega0 chips.

Things are going reasonably well; the new NVM architecture is comparatively pleasant to deal with.

 

EXCEPT FOR MY ATmega4809 Xplained Pro board.  It talks the STK500v1 protocol with avrdude just fine, sends the signature, fakes the various answers that Optiboot fakes, successfully reads flash.

But a "program page" command hangs after sending the first page of data to be programmed.

Poking around in the debugger, it seems that the bootloader is receiving 4 bytes fewer than avrdude thinks it is sending.  :-(

This behavior is observed regardless of the UART bitrate.

 

The same bootloader code (although, compiledfor different UART pins, and with different USB/Serial converters) works fine on Curiosity Nano 4899, and on some home-built "bare board" 4809s.

It turns out that the same bootloader code, IN THE  SAME Xplained board, works fine on a PC.  (thus the adventures here: https://www.avrfreaks.net/commen... )

 

So... are there any known problems with the EDBG firmware affecting data transparency on a Mac?  I'll note that the 4809 has a page size of 128bytes, and with the STK500v1 protocol in use, the full message sent to the EDBG is 128+4 bytes long - isn't 128 bytes some USB message max?   Could the EDBG USB firmware be slightly broken in a way that causes failures with Mac, but not with a PC?

 

Any other ideas?

 

This topic has a solution.
Last Edited: Mon. Oct 7, 2019 - 11:25 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

You could try setting the EDBG in "strict" mode when using it on the Mac.
To find out what mode you are in:

atprogram.exe -t edbg parameters --get-ep-size

and to change to "strict mode":

atprogram.exe -t edbg parameters --set-ep-size strict

Might be worth a try. It helps on Linux systems in some cases...

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

Yep, that works!

(Where did you find that? A preliminary search to see what it was going to do showed up practically nothing, including "to see the atprogam documentation, run it on your system with the -help option" in microchip's online docs.)

 

And to check my understanding... This SHOULDN'T be necessary, right? A USB host ought to be sending messages that match the endpoint size that was negotiated during enumeration...

 

Do I have to switch back for HID (normal programmer use)?

 

C:\Users\billw\Documents>atprogram -t EDBG parameters --get-ep-size
Firmware check OK
MODE: default
  Default settings are 512 byte for HID and 64 byte for CDC.
  Strict mode uses 64 byte for HID and 512 byte for CDC
  Minimal mode uses 64 byte for both HID and CDC.

C:\Users\billw\Documents>atprogram.exe -t edbg parameters --set-ep-size strict
Firmware check OK
OK

C:\Users\billw\Documents>atprogram -t EDBG parameters --get-ep-size
Firmware check OK
MODE: strict
  Default settings are 512 byte for HID and 64 byte for CDC.
  Strict mode uses 64 byte for HID and 512 byte for CDC
  Minimal mode uses 64 byte for both HID and CDC.


C:\Users\billw\Documents>atprogram -t EDBG parameters --get-ep-size
Firmware check OK
MODE: default
  Default settings are 512 byte for HID and 64 byte for CDC.
  Strict mode uses 64 byte for HID and 512 byte for CDC
  Minimal mode uses 64 byte for both HID and CDC.

C:\Users\billw\Documents>atprogram.exe -t edbg parameters --set-ep-size strict
Firmware check OK
OK

C:\Users\billw\Documents>atprogram -t EDBG parameters --get-ep-size
Firmware check OK
MODE: strict
  Default settings are 512 byte for HID and 64 byte for CDC.
  Strict mode uses 64 byte for HID and 512 byte for CDC
  Minimal mode uses 64 byte for both HID and CDC.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think the only trace is in the PDF user guides' firmware revision history as "Made USB endpoint size configurable".

 

Apparently (I have no source to quote here) bulk endpoints (like CDC) on USB HS devices must use the 512b endpoint-size.  Some OS's are more strict (read: OSX and Linux) on this than others...

 

The "parameters" function of atprogram has all sort of non-target-related functions - it is also useful for setting the Vout on PowerDebugger or board voltage on Curiosity Nanos...
 

atprogram.exe help parameters

 

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

bulk endpoints (like CDC) on USB HS devices

Ah.  I was wondering whether it had something to do with "High Speed" USB.  Most of the xEDBG things are only Full Speed, right?