USB Host Ethernet Driver

vjmuzik

Well-known member
USB Host Ethernet Driver
Based on the suggestion by Defragster, here's a new thread for the efforts going towards getting a driver going for USB to Ethernet adapters.
My own example can be found here: TeensyASIXEthernet
It's based on the ASIX AX88772B chipset although it may work for other ASIX chipsets.
Any help that can be offered would be greatly appreciated because I know this can turn into something that could be pretty useful.

Basic testing shows this is receiving messages and can also transmit messages so it's at least a start.
Screen Shot 2019-09-20 at 5.28.13 PM.jpg
 
Was just browsing the other thread and peaked my interest. Just ordered a USB2LAN adapter (usb2.0 amazon basic). Already have a usb 2 wireless adapter so that will get interesting. :) Think it will really get fun when the usb 2 wireless is working.
 
USB Host Ethernet Driver
Based on the suggestion by Defragster, here's a new thread for the efforts going towards getting a driver going for USB to Ethernet adapters.
My own example can be found here: TeensyASIXEthernet
It's based on the ASIX AX88772B chipset although it may work for other ASIX chipsets.
Any help that can be offered would be greatly appreciated because I know this can turn into something that could be pretty useful.

Basic testing shows this is receiving messages and can also transmit messages so it's at least a start.
View attachment 17679

@vjmuzik - Just ordered the adapter from Amazon. Will be here this next Tuesday. Thanks for the link to GitHub. Once this layer is working, Maybe wireless;)
Did you get your reference manual from the ASIX website?
 
So more progress has been made, I've been working on porting the fNET TCP/IP Stack and I believe I've got the whole thing working, but the most I've tested is making sure DHCP works and the stack seems to be responding to everything pretty well.

As you can see here between the Serial monitor and Wireshark the DHCP is responding and the Teensy has an IP Address.
Screen Shot 2019-09-25 at 1.39.17 PM.jpg
 
So more progress has been made, I've been working on porting the fNET TCP/IP Stack and I believe I've got the whole thing working, but the most I've tested is making sure DHCP works and the stack seems to be responding to everything pretty well.

As you can see here between the Serial monitor and Wireshark the DHCP is responding and the Teensy has an IP Address.
View attachment 17714

@vjmuzik - Again, this is great:) Looks like the Teensy is walking away from SPI Ethernet and going to faster transfer speeds. Are you using this for MIDI applications? I got my Amazon Basic USB 2.0 yesterday. Cloned your code. In ASIXEternet_test.ino I had to comment out the code with 'hostAddress' out to get it to compile but after that it was working. It looks like you are using this for MIDI applications. In any case this will move us closer to WIFI.
 
Not specifically MIDI, but it may as well be. The Ethernet should work in the general sense for just about anything, this TCP/ IP stack seems to be pretty powerful at least more so than the standard Ethernet library we already use. Good thing is that the way I’ve ported the library it has nothing to do with USB itself and can be used with pretty much any interface. It basically works by presenting the Arduino sketch with a bunch of callbacks that need assigned for various things, but at the most basic point two callbacks are used for input and output from the stack. So it can more or less be used with any mode of transport so what I write in my callback functions calls to the usb driver, but they aren’t codependent on each other.

That being said, I still need to clean up some of the code from my porting and then that will be published as it’s own library that can be used to go along with the USB driver.
 
Not specifically MIDI, but it may as well be. The Ethernet should work in the general sense for just about anything, this TCP/ IP stack seems to be pretty powerful at least more so than the standard Ethernet library we already use. Good thing is that the way I’ve ported the library it has nothing to do with USB itself and can be used with pretty much any interface. It basically works by presenting the Arduino sketch with a bunch of callbacks that need assigned for various things, but at the most basic point two callbacks are used for input and output from the stack. So it can more or less be used with any mode of transport so what I write in my callback functions calls to the usb driver, but they aren’t codependent on each other.

That being said, I still need to clean up some of the code from my porting and then that will be published as it’s own library that can be used to go along with the USB driver.

@vjmuzik - Understood. I think a lot of people are watching this. Watching and learning. Good stuff:)
 
Also coincidentally fNET already has native ports for the native Ethernet for the chips used in the Teensy 3.6/4.0 so once we have a bigger version of the 4.0 we should have native Ethernet pretty easily. Probably a little bit of tweaking to get it working with TEENSYDUINO, but at least most of the code will already be done as far as configuring the Ethernet and setting up the buffers. As far as the Teensy 3.6 if anyone has one of the shields that Paul designed for it I’m sure this would be a great way to test the native ethernet besides the ones already done with lwip.
 
My amazon cart - with the wired Basic Lan to USB unit - got sent with last order - will be here 9/26. @mjs513 probably already unpacked his?

Don't expect to help much except some test runs.
 
Went to github.com/vjmuzik/TeensyASIXEthernet
Moved ino into folder named for it.
Getting the error: ASIXEthernet_Test:101: error: 'hostAddress' was not declared in this scope

Removed 'hostAddress' refs as noted above and suppose it is working …

Also noticed it is okay to unplug/replug LAN cable and it recovers/continues. Same pulling the USB cable too! :)

Tested first on the @loglaw T4 beta breakout
 
Alright I believe this is ready for more testing to be done, I've pushed commits to GitHub and forked the FNET library into an Arduino library.
TeensyASIXEthernet Driver
FNET Arduino Library
Included with the FNET library is a simple DHCP example that uses TeensyThreads to run the USB and TCP/IP stack in its own thread.
This example doesn't technically support hot plugging completely right now, the usb and the ethernet cable have to be plugged in when it's first powered on, but after that it can be hot plugged. I'm pretty sure this is an easy fix though since the only thing stopping it is how I have DHCP setup, but for now all cables do have to be plugged in when you first power it on.
The USB driver still needs work to transfer big packets of data as you can only ping up to 464 bytes right now, but it works up to that from my testing.
Screen Shot 2019-09-27 at 11.43.05 AM.png
This ping test is going over WiFi to my laptop so don't be too discouraged by the numbers.
 
@vjmuzik

Just downloaded both libraries that you linked in post #13 but didn't see any example sketches in the FNET or ASIX libraries
 
Very cool sounding update and progress!

@vjmuzik

Just downloaded both libraries that you linked in post #13 but didn't see any example sketches in the FNET or ASIX libraries

Indeed - same - not seeing sketch in 'examples' or other folder. Can't test ping :(
 
Running the sample I get this … not sure what to do with it? IPAddress: 1700A8C0 ???
Code:
USB Host InputFunctions example
USB Ready
TCP/IP stack initialization is done.

SetMACAddress: 0050B6BE8BB4
MulticastJoin: 333300000001
MulticastJoin: 3333FFE225AB
netif Initialized
DHCP initialization done!
Looped: 1
LoopedUSB: 1993441
Looped: 1
LoopedUSB: 0
Looped: 1
LoopedUSB: 0
IPAddress: 0
SubnetMask: 0
Gateway: 0
DHCPServer: 0
State: 2


IPAddress: 1700A8C0
SubnetMask: FFFFFF
Gateway: 100A8C0
DHCPServer: 100A8C0
State: 5
 
Those are in Network Byte order so your IP address is C0,A8,00,17 or 192.168.0.23, I need to make that readable in the Serial Monitor, but network byte order is what the TCP/IP stack gives me.
 
Thanks - I knew it wasn't right forward - hadn't gotten as far as reversing bytes. Initial Fail then better on wired PC to wired T4::
Code:
Pinging 192.168.0.23 with 32 bytes of data:
Request timed out.
Reply from 192.168.0.23: bytes=32 time=1ms TTL=64
Reply from 192.168.0.23: bytes=32 time<1ms TTL=64
Reply from 192.168.0.23: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.0.23:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

C:\>ping 192.168.0.23

Pinging 192.168.0.23 with 32 bytes of data:
Reply from 192.168.0.23: bytes=32 time<1ms TTL=64
Reply from 192.168.0.23: bytes=32 time=1ms TTL=64
Reply from 192.168.0.23: bytes=32 time<1ms TTL=64
Reply from 192.168.0.23: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.0.23:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms
 
Yeah I noticed sometimes the first byte of a ping message is lost because your computer will ask your modem who's at the IP address and it would send the ping before knowing who to send it to resulting in a request timed out.
 
Cool after that initial (on a restart) it works well - occasional 3 or more ms on one ping in a group ping but this group of 10 - size 400 bytes - all fast:
Code:
C:>ping -l 400 -n 10  192.168.0.23

Pinging 192.168.0.23 with 400 bytes of data:
Reply from 192.168.0.23: bytes=400 time=1ms TTL=64
Reply from 192.168.0.23: bytes=400 time=1ms TTL=64
Reply from 192.168.0.23: bytes=400 time<1ms TTL=64
Reply from 192.168.0.23: bytes=400 time<1ms TTL=64
Reply from 192.168.0.23: bytes=400 time=2ms TTL=64
Reply from 192.168.0.23: bytes=400 time<1ms TTL=64
Reply from 192.168.0.23: bytes=400 time=1ms TTL=64
Reply from 192.168.0.23: bytes=400 time=1ms TTL=64
Reply from 192.168.0.23: bytes=400 time<1ms TTL=64
Reply from 192.168.0.23: bytes=400 time<1ms TTL=64

Ping statistics for 192.168.0.23:
    Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    [B]Minimum = 0ms, Maximum = 2ms, Average = 0ms[/B]
 
Yes, yes you did - good work:
Code:
IPAddress: 192.168.0.23
SubnetMask: 255.255.255.0
Gateway: 192.168.0.1
DHCPServer: 192.168.0.1
State: 5

ALSO noteworthy and commendable - has USB Hub support!::

While running I pulled the USB LAN adapter from T4 Host plug - put it onto a powered HUB - plugged Hub into @loglow T4 USB breakout board - and PING worked without restart!

So now running with USB LAN adapter on powered HUB the "USB Host InputFunctions example" … ASIXEthernet_Test.ino

Cool that it is working with TeensyThreads! Was that out of necessity to make sure it ran or just because it seemed a cleaner way to start?

ONE BUILD NOTE from console::
>> Error while detecting libraries included by T:\tCode\libraries\FNET\src\service\serial\fnet_serial.c
 
Back
Top