Port Teensy 3.6 's USBHost_t36 Library to Arduino Due / SAM3x8E possible ?

Status
Not open for further replies.

MartinZ

Member
Just wondering if it would be possible to port the wonderful "USBHost_t36" Library to Arduino Due with it's SAM3x8E.
The USBOTG unit include in the SAM seems quite similar to the one inside EHCI.

I looked inside this lib's files and it seems to me, that "only" the file "ehci.cpp" had to be completely adapted/rewritten.
(I know that one had to dig deeply in the datasheets of both chips to get that done, of course).

Do you see any chance of that being done, or are there other big obstacles, I do not see?
I am not so experienced in this, but I would give it a try, if you would see good a chance for it.
But better I ask someone with big experience before, to avoid putting big work in a useless matter.

Or would it be better / easier to put the Teensy's "Midi.cpp" on top of the Due's "USBHost.h"?

I would really find it great to have one library for both Teensy and Due.
The Due has one small advantage to the Teensy 3.6 with it's DAC-Unit on board, while for teensy an extra card is necessary for audio-out.
So the Due would fit for MIDI/Audio projects, but there seems to be no really working USBHost-Midi-Library for it yet.
There is just the "USBH_MIDI-Due forked from YuuichiAkagawa's USBH_MIDI for the USB-Host shield, but that is not really comparable to the Teeny's USBHost_t36's Midi-Library.
And the UHS30 is very alpha.

Greetz,
Martin
 
The USBOTG unit include in the SAM seems quite similar to the one inside EHCI.

Quite similar? Really?! Where are the QH (queue head) structures? How about the array of periodic schedule pointers? (which point to an inverted tree of QH structs) Or how about the circular linked list asynchronous schedule? SAM3X seems to have none of those features, which really are the essence of EHCI.

It does have DMA transfer descriptors, which are at least somewhat similar to EHCI's qTD structs, at least visually in this diagram.

sc.png

How these work, I don't know. The datasheet seems to have very little documentation about them, just some stuff about memory aligning but not even a detailed list of the fields in those descriptors. Maybe there's another document? Or maybe this stuff is only "documented" by code deep in the Atmel library?

From the diagrams on pages 1082-1083, my best guess is those DMA descriptors are for token-level operations. EHCI's qTD's work at the transfer level, automatically performing any number of tokens and data toggles. Admittedly this is quite a bit of guesswork on my part, not seeing more detailed documentation...

The host control registers in Table 39-5 also look nothing like EHCI's registers. Again, the datasheet seems to have only minimal descriptions, not even explaining the bit fields within the registers.

Maybe this would be clearer with more documentation (which I could not find on Microchip's site), but from what little appears in the datasheet, it really looks almost nothing like EHCI.
 
The Due has one small advantage to the Teensy 3.6 with it's DAC-Unit on board, while for teensy an extra card is necessary for audio-out.

Regarding the DAC, Teensy 3.6 does indeed have 2 built in DACs. They work better than the DACs on Arduino Due, able to give a full rail-to-rail voltage output (either 3.3V or 1.2V ref), rather than the limited range on Due (usually requiring an opamp and a fiddly trim pot adjusting process to null out Due's ~0.55V DC offset).

Teensy also comes with a far more capable audio library, which supports both the built in DAC and the audio shield, even using both simultaneously.

Really think you should just consider using Teensy 3.6 instead of Arduino Due. Teensy 3.6 is faster, has more memory, has the M4 DSP extension instructions, and is better than Due's features in pretty much every way.
 
Due is a an older M3 with half the RAM, half the Flash, half the clock-speed.. why people use a Due? Because its larger, more than double the size? :D
 
I'm guessing because they already have an Arduino Due laying around. Or maybe the ~$12 price of Chinese clones is the main appeal?

But Due definitely is old and the SAM3X chip leaves quite a lot to be desired. Arduino doesn't seem to be working on its software anymore (they haven't for years) in any substantial way. Whether Microchip is still developing those chips is also a good question. Many of Due's libraries, like SPI, are written so inefficiently that Due is about the same speed as Uno unless you access the hardware directly.

Not a bright future for Due...
 
Oh, I see.
With "quite similar" I just meant the overall technical data (all speeds, DMA) etc.
But you say, that the internal structure is really quite different.
Would it be a matter of "oh, what a lot of work..." or would there be severe technical limitations for the library because of these differences?


Regarding the DAC, Teensy 3.6 does indeed have 2 built in DACs. They work better than the DACs on Arduino Due, able to give a full rail-to-rail voltage output (either 3.3V or 1.2V ref), rather than the limited range on Due (usually requiring an opamp and a fiddly trim pot adjusting process to null out Due's ~0.55V DC offset).

Yes, you are perfectly right. I thought the Due's DACs were 16bit, but they are only 12Bit like on Teensy.
So I would need and add on 16Bit Audio-Out for Due as well as for Teensy, if I want full 16Bit Sound.
And of course the points go to Teensy for it's audio library, more of RAM and speed, DSP, size and so on - i know.

Really think you should just consider using Teensy 3.6 instead of Arduino Due.
Unfortunately, I own the Due... :(
And for actual my project it would have more than enough power anyway.
If I would only get the USBHost-MIDI to work with it...

Besides my own project it would be a nice thing to have USBHost_t36 ported for Due, because it would make good old Due more useable.



Without spoiling too much:
What can I expect of Teeensy 4 concerning Audio-DACs? If it has 16Bit it would be a good reason to wait for it.
 
Reading the Teensy 4 threads it will shows : No DAC's …. Sad but true - a compromise with the faster more involved chip design.

To use the Due - perhaps pick up one of the adapters used to Test the USBHub indicated in an ongoing thread for JoyStick or Bluetooth - I don't have one - as the T_3.6 and pending T 4 have native USNhost that is being developed. Those adapters interface and will give access to USBHost function and should have existing code that works to use to some extent. Reading there shows generic and orginal host adapters … there is a link on the PJRC.COM website that might be easier to find and she it used on older Teensy's.

But for the cost of that adapter and connecting it - finding the software:: getting a fresh, more capable and faster T_3.6 would be my choice.
 
Status
Not open for further replies.
Back
Top