iMXRT1062 - Ethernet over USB

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iMXRT1062 - Ethernet over USB

5,602 Views
EmbeddedTech
Contributor III

Hi,

I would like to connect my board to host PC via Ethernet. But in our actual board we will not be having the Ethernet socket on our hardware. So we would like to use the USB Ethernet adapter to connect to the host PC. Is there any sample code in the SDK which I can try for this? Is the evkmimxrt1060_dev_cdc_vnic_freertos support the above requirement?

I tired downloading that code but got the following terminal message,

PHY Link down, please check the cable connection.
USB device CDC virtual nic demo

Any help on this is highly appreciated.

Thanks

0 Kudos
Reply
12 Replies

5,580 Views
mjbcswitzerland
Specialist V

Hi

Please find attached an RNDIS device reference for the MIMXRT1060EVK.

To load it to the board the NXP MCUBootUtility can be used as described in the section 4 of https://www.utasker.com/docs/iMX/uTaskerV1.4_iMX.pdf
(it may work by dragging and dropping it onto the debug USB/MSD disk too).

Just connect the USB device connector to a PC and install the RNDIS driver as described in the installation section of https://www.utasker.com/docs/uTasker/uTaskerRNDIS.pdf (assuming you are on Windows).

This allows any USB processor to function as a network to a PC without needing it to do a USB-Ethernet adapter function. The network first needs to be configured though by using the the VCOM port on the debugger (LPUART on the i.MX RT t 115200 Baud):
- Hit enter to connect and then 'N' plus ENTER to move into the network menu, which looks like this:

     Network
===================
up           go to main menu
phy_ref      Select PHY interface
ipstat       Show IP statistics
r_ipstat     Reset Ethernet statistics
set_dhcp_c   <enable/disable> DHCP client
set_dhcp_s   <enable/disable> DHCP server
set_ip_add   Set IPV4 address
set_ip_mask  Set IP subnet mask
set_ip_gway  Set default gateway
set_ip_dns   Set default DNS
set_ip_tr    Set trusted IP
show_config  Show configured network config.
show_config_w Show working network config.
set_config   Update working network config
get_config   Set working config to pars
save         Save configuration to FLASH
validate     Validate temporary config. in FLASH
ping         Ping IPv4 addr [cnt]/i (infinite)}
ping?        Ping status
arp -a       Request ARP table
arp -d       Delete ARP table
prime        Prime IP
dhcpc        Show DHCP clients
hosts        List multicast host groups
join         [multicast] join group
leave        [host ID] leave group
multi        <ip> send test frame
help         Display menu specific help
quit         Leave command mode


With "show_config" the default settings can be seen, which will be

#show_config

IPV4 address = 192.168.1.3
MAC address = 00-00-00-00-00-00
Subnet mask = 255.255.255.0
Default gateway = 192.168.1.1
DNS server = 192.168.1.1
Trusted IP = 0.0.0.0
DHCP CLIENT - disabled
DHCP SERVER - disabled



Since the PC will try to obtain its address on the interface from the RNDIS adapter "set_dhcp_s enable" can be used to enable a DHCP server on the interface.
Change the MAC address (sometimes 00-00-00-00-00-00 is not accepted) to anything else, like "MAC 00-00-00-00-00-01" This will cause it to automatically reset and save but you can save at any time with "save" and change various other network settings as desired.

The PC will tend to now start using the new adapter and will probably ask you whether it should allow sharing on it (as it does when it finds a new network).

Then you can ping the IP address of the adapter (as above). Since it has its own network with TCP/IP stack there are various other services whereby I enable HTTP and FTP you can browse to its web server and load pages via FTP, for example (these will be saved to QSPI flash based file system) - you can get a set of reference web pages to load at https://www.utasker.com/iMX/RT1060.html (at link web page package).

The binary image contains the uTasker serial loader so by holding the USER button down at reset the loader mode can be entered (also by commanding "boot" in the administration menu) so than new applications can be simply loaded via USB-MSD.
Also firmware can be updated via FTP or web server (via RNDIS adapter from PC). All applications are AES256 encrypted by default.

The uTasker project allows RNDIS networking on any i.MX RT board (with or without RNDIS to Ethernet bridging) and allows both RNDIS device and RNDIS host (for example when there is an RNDIS capable WiFi or Cellular modem connected on the HS USB host connector) as well as various other WiFi connections to achieve multiple network and multiple interface solutions which are run-time configurable (eg. the PC connected via RNDIS could use it as a bridge to Ethernet, WiFi, Cellular connections on multiple networks - some allowing access to the iMX RT TCP/IP stack features and some isolated from it).
The iMX RT can also appear as multiple networks with multiple devices if configured accordingly.

Regards

Mark

Full details and immediate industrially proven solutions for i.MX RT networking / USB requirements at https://www.utasker.com

0 Kudos
Reply

5,553 Views
EmbeddedTech
Contributor III

Thanks Mark for the detail explanation.

0 Kudos
Reply

5,593 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @EmbeddedTech ,

Yes, this example can support your requirement. But it is much simple.

Before you start running, you should connect enet cable first. Please see the readme.pdf in demo's folder.

 

Regards,

Jing

0 Kudos
Reply

5,549 Views
EmbeddedTech
Contributor III

Hi Jing,

If I want to use an USB to Ethernet adapter to connect to the USB port of the iMXRT and connect the ethernet cable from the adapter to my PC as shown, do I still need one more test PC? Do I need to make any modifications to the vnic code in order for it to work with this setup?

Thanks.Ethrnt.jpg

0 Kudos
Reply

5,542 Views
mjbcswitzerland
Specialist V

Hi

What you show is a USB host adapter connecting the EVK to an Ethernet cable.
This means that the EVK needs to operate as a corresponding USB class host (as you have also stated).

The USB class that the host needs to use depends on the exact adapter it is connected to - some may work with USB-RNDIS, others with USB-ECM, or with USB-EEM. However practically a lot of the adapters that are used will operate with a vendor specific USB class that is not specified (outside of the company manufacturing it) and so would need to be reverse engineered if such a defined one needs to be supported.

The NXP SDK includes a simple device example but - as far as I know - no USB host examples for any Ethernet classes.

Due to the fact that you need to specify the adapter that needs to be used (to ensure that its class is supported in the i.MX RT system) it is generally  a much less desirable solution. The simple USB cable connection (device) is simpler, more efficient and also doesn't need external HW.

Regards

Mark

 

0 Kudos
Reply

5,533 Views
EmbeddedTech
Contributor III

Hi Mark,

Thank you for your quick response.

Sorry for the confusion. We desire to use our iMXRT board as a device and connect to the PC host. Planning to use USB micro B Ethernet adapter. Do I need any driver for using that? When using the adapter to connect to the PC via Ethernet cable, will the code work directly or needs some modification? Do I still need one more test PC apart from the host PC?

Sorry to load you with questions as I am new to this topic and trying to get a hold of it.

Thanks.

0 Kudos
Reply

5,526 Views
mjbcswitzerland
Specialist V

Hi

>>We desire to use our iMXRT board as a device and connect to the PC host.
>>Planning to use USB micro B Ethernet adapter.
If you use the Ethernet adapter you will be a USB host and not a device

>>Do I need any driver for using that?
The PC is not involved in this configuration and needs no drivers.It just uses its Ethernet connection.

>>When using the adapter to connect to the PC via Ethernet cable, will the code work directly or needs some modification?
There is no SDK code to do this so you would need to develop all for the chosen Ethernet adapter.

If you choose an Ethernet adapter this supports the RNDIS class the uTasker project has a turn key solution for this configuration too.

>>Do I still need one more test PC apart from the host PC?
There is never an additional PC involved as test PC.

Regards

Mark

0 Kudos
Reply

5,465 Views
EmbeddedTech
Contributor III

Thanks Mark for your patience in explaining.

So is there any guideline on how to implement the USB host functionality with ECM or RNDIS class for USB to Ethernet adapter configuration?

To start with, will the sdk example lwip_dhcp_usb help?

Thanks.

 

0 Kudos
Reply

5,458 Views
mjbcswitzerland
Specialist V

Hi


All class specifications can be obtained at www.usb.org but in the case of vendor specific solutions you will need to contact the manufacturer to see whether they allow sharing their implementation or reverse engineering it (in the case of Ethernet adapters this is not that complicated since once connected the data transfers are raw Ethernet (assuming they don't do something to actively block reverse engineering [eg. by adding their own content encryption]).

You then need a basic CDC class implementation to transport the higher layers and the basic USB host driver.

On top of the USB part you will need a TCP/IP implementation and on top of that anything that is application specific.

Overall it is not something that can be made operational within a few minutes based on the available examples but the one you mention may give a helping hand for some of the basics.

As example of a complete solution I have configured the uTasker project to build an i.MX RT 1060EVK target with RNDIS device on the first USB and RNDIS host on the second USB, which effectively adds RNDIS host capability to the previous working example I posted (with the first application installed reset the EVK with the USER button held and it will pop up as a hard drive and you can drag and drop the new application on to it). This allows connecting a USB-Ethernet adapter or a mobile phone to the HS USB and, if it supports RNDIS, it will allow the EVB to use the interface. Although not a very useful real-work application it would also allow the PC connected to the EVK via RNDIS device to use the adapter or mobile phone via the RNDIS device ad RNDIS host bridge.

I don't yet understand whether you are doing your work as a school project or hobby, or whether you are an engineer requiring a solution for a product development. But if you are doing it to learn how to build up such a solution from scratch based on various NXP and open source examples it will be best to study the referenced class specifications and use a USB analyser to see how other devices operate and which parts the examples support and what then needs to be added.
If a solution to engineer a product is required where the operation needs to be guaranteed but your team doesn't want to build up all the internal known-how a turn-key solution may be more suitable.
Since I develop (and supply) such solutions to many Kinetis and i.MX RT product development teams I can offer remote desk-top training to teams that need help in adapting what they presently have to a full solution.

Regards

Mark

P.S below shows the VCOM LPUART output when connecting and android phone and setting it to its tethered mode (initially it enumerates as a vendor connection which doesn't support RNDIS but then re-enumerates to the final operation). You can connect and other device to see whether its interfaces are identified.


Self-powered device with 2 interface(s)
Interface 0
Discarded class 0xff
Interface 1
Discarded class 0x08
Enumerated (1) [1]
USB (1) device removed
USB (1) HS device detected
USB device information ready:
USB2.0 device with 64 byte pipe
Vendor/Product = 0x12d1/0x108a
Manufacturer = "HUAWEI"
Product = "POT-LX1"
Serial Number = "39V4C2061600123"

Self-powered device with 2 interface(s)
Associated Interfaces = 2
Interface 0
2 = INTERRUPT with size 8 (interval = 32ms)
Interface 1
1 = BULK IN with size 512
1 = BULK OUT with size 512
CDC (RNDIS) class
Enumerated (1) [1]
RNDIS Init
REMOTE_NDIS_INITIALIZE_COMPLETE
Version = 1.0
ETHERNET type
Query: REMOTE_NDIS_QUERY_COMPLETE
OIDs
00010101 = OID_GEN_SUPPORTED_LIST
00010102 = OID_GEN_HARDWARE_STATUS
00010103 = OID_GEN_MEDIA_SUPPORTED
00010104 = OID_GEN_MEDIA_IN_USE
00010106 = OID_GEN_MAXIMUM_FRAME_SIZE
00010107 = OID_GEN_LINK_SPEED
0001010a = OID_GEN_TRANSMIT_BLOCK_SIZE
0001010b = OID_GEN_RECEIVE_BLOCK_SIZE
0001010c = OID_GEN_VENDOR_ID
0001010d = OID_GEN_VENDOR_DESCRIPTION
00010116 = OID_GEN_VENDOR_DRIVER_VERSION
0001010e = OID_GEN_CURRENT_PACKET_FILTER
00010111 = OID_GEN_MAXIMUM_TOTAL_SIZE
00010114 = OID_GEN_MEDIA_CONNECT_STATUS
00010202 = Unknown
00020101 = OID_GEN_XMIT_OK
00020102 = OID_GEN_RCV_OK
00020103 = OID_GEN_XMIT_ERROR
00020104 = OID_GEN_RCV_ERROR
00020105 = OID_GEN_RCV_NO_BUFFER
01010101 = OID_802_3_PERMANENT_ADDRESS
01010102 = OID_802_3_CURRENT_ADDRESS
01010103 = OID_802_3_MULTICAST_LIST
01010105 = OID_802_3_MAC_OPTIONS
01010104 = OID_802_3_MAXIMUM_LIST_SIZE
01020101 = OID_802_3_RCV_ERROR_ALIGNMENT
01020102 = OID_802_3_XMIT_ONE_COLLISION
01020103 = OID_802_3_XMIT_MORE_COLLISIONS
Query: RNDIS Status: Connected
REMOTE_NDIS_QUERY_COMPLETE
OID 00010202 = Unknown received [0x00000000]
Query: REMOTE_NDIS_QUERY_COMPLETE
OID 00010106 = OID_GEN_MAXIMUM_FRAME_SIZE received [0x000005dc]
Query: REMOTE_NDIS_QUERY_COMPLETE
OID 00010107 = OID_GEN_LINK_SPEED received [0x00410000]
Query: REMOTE_NDIS_QUERY_COMPLETE
OID 00010114 = OID_GEN_MEDIA_CONNECT_STATUS received [0x00000000]
Query: REMOTE_NDIS_QUERY_COMPLETE
OID 01010102 = OID_802_3_CURRENT_ADDRESS received [ 0x02 0x03 0x39 0x51 0x37 0x46]
Query: REMOTE_NDIS_QUERY_COMPLETE
OID 01010101 = OID_802_3_PERMANENT_ADDRESS received [ 0x02 0x03 0x39 0x51 0x37 0x46]
Query: Set complete
Query: Set complete
Query: Set complete
Query: REMOTE_NDIS_QUERY_COMPLETE
OID 00010111 = OID_GEN_MAXIMUM_TOTAL_SIZE received [0x00000616]
RNDIS initialisation complete
RNDIS operating

 

0 Kudos
Reply

5,426 Views
EmbeddedTech
Contributor III

Hi Mark,

Sorry for the delayed response. I am a product development engineer and looking for the possibility of providing Ethernet support via USB Ethernet adapter instead of Ethernet port on our board. Only very few customers will need this option, so we may not provide the Ethernet port and give them the option of using the Adapter instead. Do you have any suggestions of any USB ethernet adapters using RNDIS class? I don't find any adapters specifying the USB class they use. 

Thanks.

0 Kudos
Reply

5,406 Views
mjbcswitzerland
Specialist V

Hi

In my experience RNDIS bases Ethernet adapters are very rare. The general, cheap ones that are found in shops and Internet stores will be proprietary and so don't follow any such class specifications.

Another option is to add a WiFi adapter rather than an Ethernet adapter. There are more that follow class specs (eg. Telit ones).

Understanding your requirements for a low number of users needing a connection to the board I still would use RNDIS device and not host since it saves needing to have an adapter and is achieved with a simple USB cable instead.

In the case of an adapter you have to deliver it (the user can't choose their own) and you will probably need to do a custom class development for the exact one that you chose. This sounds costly and over complicated you so that a few rare users can connect.

Regards

Mark

 

0 Kudos
Reply

5,367 Views
EmbeddedTech
Contributor III

Hi,

Since the RNDIS device requires a PC for every device connected, that is not the preferred option. There will be multiple devices connected to a central system via LAN and the system will request the required data from each device. So the requirement is to support the ethernet adapter. Say if I want to use the ethernet adapters using Realtek USB GbE family controller what would be the steps involved considering the USB tethering example as a base and is it something achievable with some effort?

Thanks.

0 Kudos
Reply