Ethernet over USB in MQX?

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

Ethernet over USB in MQX?

Jump to solution
2,604 Views
rickstuart
Contributor V

Hi,

I searched for this and have not found anything.  If I missed something I would appreciate it if someone would indicate where this is discussed.

I need to implement Ethernet over USB in MQX.  I suspect the usbnet and specifically g_ether are the solutions I am looking for.  Have these features been ported to MQX?  Or, perhaps, are similar features already in MQX under a different name?

-thanks

0 Kudos
1 Solution
1,368 Views
dereksnell
NXP Employee
NXP Employee

Hi Rick,

First, if you plan to use USB with Kinetis, then I suggest you use one of the examples from our USB stacks. The example you found included with IAR should work fine to demonstrate the functionality, but I wouldn’t recommend using that as your basis for development. Our USB stacks are maintained and updated with new releases, and offer better documentation and support. We have two USB stacks available for the Kinetis K70 devices today. Both include examples you can run on the TWR-K70F120M Tower board, and include documentation for any jumper settings required in the Tower system for the examples to work.

· MQX RTOS – http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MQX&fpsp=1&tab=Design_Tools_Tab

· Baremetal USB Stack (no RTOS) - http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MEDICALUSB&fpsp=1&tab=Design_Tools_Ta...

Also, I see a mixture of references between USB Device and USB Host examples. If you load a USB Host example, and then plug it into a PC, it will not enumerate as a USB Device with the PC. So if you’re goal is to communicate with the PC, be sure to use a USB Device example. Both stacks above have examples for both USB Device and USB Host.

You do want to use the USB connector on the TWR-SER board to access the Full-Speed USB peripheral in the K70. And as you found, there is a jumper on the TWR-SER board to setup the board for USB Host, Device, or OTG. For USB Host examples like your coworker uses to mount a USB drive, then the jumper should be on 1-2 on J16. For USB Device examples, the jumper should be on 3-4.

And regarding the IAR example you tried to load without the EWW workspace file, IAR does not require a workspace file to use a project. The .EWP project file can be added to a IAR workspace, and that is what is provided in the MQX example projects for IAR. To open the project file in IAR, use the menu Project->Add Existing Project, and navigate to the .EWP file. Or you can just drag-and-drop the .EWP file into the IAR IDE.

Thanks

View solution in original post

0 Kudos
7 Replies
1,368 Views
soledad
NXP Employee
NXP Employee

Hi rick stuart,

I only can suggest to check the virtual_nic example, you can find it at the path: C:\Freescale\Freescale_MQX_4_1\usb\device\examples\cdc\virtual_nic

The intention of this demo is to demonstrate the CDC class setting the USB as a Network Interface Card. Once you connect the USB to your PC you can configure the IP address and ping it. It only shows that you can have Ethernet communication using USB. This is something used in modems that sends Ethernet data through USB. The data you send from the MCU to the USB is up to the developer.

I hope this helps,


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,368 Views
rickstuart
Contributor V

Thank you for your response.  Now that I know what example I am looking for I found this thread:

USB Virtual NIC

Where [Martin] explained that the example was only to unpack the inbound Ethernet over USB and send it out the RJ45 Ethernet port.  And that the return path was not implemented.

What I was hoping for was more the feature that g_ether brings to Linux.  We have Ethernet content (i.e. a web server and more) running in MQX on our board.  What we need is to make this available on both the RJ45 and USB ports.  But the example only goes as far as hinting that I could redirect the network traffic in/out the USB port.

Do you see a way I could run network traffic over both USB and RJ45 ports at the same time. 

-thanks

0 Kudos
1,368 Views
rickstuart
Contributor V

As I dive into this, I would also like to ask how a Windows PC knows what device driver to install in order to support Ethernet over USB.  I assumed it was the file included in the Freescale directory structure that also contained the MQX project files.  But I have not been able to install this into a 64 bit Windows7 box.  Does selecting the correct driver only depend on the Product and Vendor IDs?  Or are there other features of USB enumeration / initialization that come into play.

Also, are there not generic Ethernet over USB drivers for Windows??  For example, what Windows driver would be necessary for the Linux g_ether gadget module used to place Ethernet traffic over USB?

-thanks

0 Kudos
1,368 Views
dereksnell
NXP Employee
NXP Employee

Hi Rick,

Unfortunately, we don’t have any enablement with MQX for your application to run your same network traffic over both USB and RTCS. I’m sorry we don’t have more help for you for that use-case at this time.

For your USB questions, the INF file provided at \Freescale_MQX_4_1_1\usb\device\examples\cdc\virtual_nic\inf\fsl_rndis.inf tells Windows what driver to use for the USB device, and yes, it is based on the VID and PID of the device. I tested this INF file on Windows7 64-bit with this virtual_nic demo, and the driver loaded fine in my case. I used the FRDM-K64F board with MQX v4.1.1 to test this. Do you have your Kinetis development board correctly configured for USB Device operation? You could also try some of the other MQX USB Device examples to see if they enumerate correctly with Windows. That could help diagnose if your issue is specific to the RNDIS driver, or if it’s more of a hardware issue impacting other examples as well.

Windows does include an RNDIS driver. This example uses the Windows driver, which is why the MQX example only needs to provide the INF file, not the driver file. You can learn more from Microsoft.

http://msdn.microsoft.com/en-us/library/windows/hardware/ff569967(v=vs.85).aspx

Thanks

1,368 Views
rickstuart
Contributor V

Thanks everyone for your help.

I could not find the *.eww file here:

C:\Freescale\Freescale_MQX_4_1\usb\device\examples\cdc\virtual_nic

...so I (think I) downloaded yet another copy using the "help menus" that come up when you start Workbench.  That copy had the *.eww file.  (Anyone know why they were missing from the above suggested directory?)

I built that (only a few warnings, is that normal?) and ran it.  But I don't see any new USB devices.  I see in the USB_DCD Readme.txt file this:

  TWR-SER setup

  ----------------

  J16  USB_MODE

  1-2  ON

  3-4  -

  5-6  ON


...which confuses me because I read that J16 1-2 was the Host Mode, 3-4 was the Device Mode & 5-6 was the OTG mode.  I just assumed ACTIVE was with the jumper IN.  Can anyone verify that I've got it backwards?

This is really odd because my counter part has only 1 jumper (AFAIK) on J16 across pins 1 to 2.  And he has been successfully using a USB Thumb drive for days now.  Hum,.

-thanks

...

0 Kudos
1,369 Views
dereksnell
NXP Employee
NXP Employee

Hi Rick,

First, if you plan to use USB with Kinetis, then I suggest you use one of the examples from our USB stacks. The example you found included with IAR should work fine to demonstrate the functionality, but I wouldn’t recommend using that as your basis for development. Our USB stacks are maintained and updated with new releases, and offer better documentation and support. We have two USB stacks available for the Kinetis K70 devices today. Both include examples you can run on the TWR-K70F120M Tower board, and include documentation for any jumper settings required in the Tower system for the examples to work.

· MQX RTOS – http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MQX&fpsp=1&tab=Design_Tools_Tab

· Baremetal USB Stack (no RTOS) - http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MEDICALUSB&fpsp=1&tab=Design_Tools_Ta...

Also, I see a mixture of references between USB Device and USB Host examples. If you load a USB Host example, and then plug it into a PC, it will not enumerate as a USB Device with the PC. So if you’re goal is to communicate with the PC, be sure to use a USB Device example. Both stacks above have examples for both USB Device and USB Host.

You do want to use the USB connector on the TWR-SER board to access the Full-Speed USB peripheral in the K70. And as you found, there is a jumper on the TWR-SER board to setup the board for USB Host, Device, or OTG. For USB Host examples like your coworker uses to mount a USB drive, then the jumper should be on 1-2 on J16. For USB Device examples, the jumper should be on 3-4.

And regarding the IAR example you tried to load without the EWW workspace file, IAR does not require a workspace file to use a project. The .EWP project file can be added to a IAR workspace, and that is what is provided in the MQX example projects for IAR. To open the project file in IAR, use the menu Project->Add Existing Project, and navigate to the .EWP file. Or you can just drag-and-drop the .EWP file into the IAR IDE.

Thanks

0 Kudos
1,368 Views
rickstuart
Contributor V

Tidying up this thread...

1) The gadget or g_ether is a Linux module that can create an Ethernet over USB Device.  Plugging that USB Device into a USB Host should cause a network to be created.  But it's Linux, not MQX.  Apples / Oranges stuff.

2) The 4.1.1. MQX Freescale CDC example has a problem in the USB to Ethernet direction.  I summed it up in this thread:

USB Virtual NIC

    To the point, my code is working (for ARP and Ping) but it's probably not the right solution.

Edit: added later...

I believe I found the problem.  I put code change details at the bottom of this thread:

I have compiled and uploaded the Freescale 4.1.1 virtual_nic example - how do I verify it is working...

0 Kudos