USB tethering host (RNDIS protocol) implementation for Kinetis - How to use your cellphone to provide internet connectivity for your Freedom Board using KSDK

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

USB tethering host (RNDIS protocol) implementation for Kinetis - How to use your cellphone to provide internet connectivity for your Freedom Board using KSDK

USB tethering host (RNDIS protocol) implementation for Kinetis - How to use your cellphone to provide internet connectivity for your Freedom Board using KSDK

When you go with your laptop to a public place and you don't have a wi-fi connection available you can connect your cellphone in the USB port of your computer, turn on the USB tethering feature of your smartphone and you get full acess to the internet using your carrier data plan. The USB tethering uses the the RNDIS protocol and is easy to implement on a laptop.


But how to connect a Kinetis to the internet using a cellphone?


I'm sharing the the first version of the implementation I made of the RNDIS protocol.It's based in the KSDK 1.3 + MQX + LwIP and it can be used for reference in other projects. It's only a first release and I plan some additional implementation, bugfixes and support for other Kinetis boards in the near future but it already can be useful in some projects. Initially it only supports FRDM-K22F and FRDM-K64F but it can be implemented in any MCU with USB controller and enough FLASH. It's a low-cost and simple way to connect your MCU to the internet when you don't have a Ethernet cable available or an Wi-fi connection or a 4G module available in your board.




This project implements the RNDIS protocol on the top of the USB Host Stack and in the bottom of the LwIP (TCP/IP stack). When a cellphone is connected to a freedom board, it acts as a USB device and the Freedom board acts as a host.


117198_117198.pngosi model.png

* Software implementation


* Cellphone connected to a FRDM-K64F providing internet connection to the board


The user can design his own software in the top of the TCP/IP stack (LwIP) like if it's connected through an ethernet cable.




To run the demo you will need the KDS 1.3 (


To load all the projects needed to your project you have to extract the .zip file and in KDS go to File -> Import, Project of Projects -> Existing Project Sets, and browse to the *.wsd file present in the folder:


USB_RNDIS\KSDK_1.3.0\examples\[your board]\demo_apps\lwip\usb_tethering_demo\usb_tethering_demo_mqx\kds


It will import all the needed project in to your workspaces so you will be able to build all the projects and flash it into your board.


With the application flashed, open a Serial terminal with 115200kbps, 8N1 for the CDC interface of OpenSDA.When the board starts, it will display:


117206_117206.jpgplug your smart.jpg


Connect your cellphone in to the USB of the MCU. After connect the phone turn on the USB tethering feature and wait some seconds:



The Freedom Board will be connected to the internet. As an example, this demo connects to an HTTP server in the internet, download to MCU some data (Lastest news from an newspaper website) and displays it through the Serial connection.



You can modify this demo for your own application, using the TCP/IP and UDP/IP provided by the LwIP.


Typical Aplications


- Low-cost temporary internet connectivity to the MCU.

- Remote updat (i.e.: bootloader through USB downloading the new firmware direct from the web)

- Remote control

- Remote diagnostics


Known Issues and Limitations:

- This first version was only full implemented for FRDM-K22F and FRDM-K64F. I can implement for other boards through requests.

- It was tested on Android Phones (Samsung Galaxy, Motorola G, Motorola X). I don't have a iPhone to test yet.

- Some cellphones need additional current to detect that is attached to a host.A external power is needed in this situation.For FRDM-K64F I suggest to use the J27 footprint to provide 5V and short the diode D13.

- Not all the RNDIS messages was implemented yet, only the most fundamental ones.

- There's a flash size limitation due the size of the TCP/IP stacks ( that requires a considerably space of flash). It can adapted in the future for stacks with smaller footprint.

- Only support KDS 3.0 at this time. And it only supports MQX at this time.


Let me  know if you have any question. Hope it can be useful!


1-      With the application flashed, open a Serial terminal with 115200kbps, 8N1 for the CDC interface of OpenSDA.When the board starts, it will display:


Nice. It is a good example.

Hi dshimizu

Very cool stuff! I am currently looking at using a USB to Ethernet adapter with my ColdFire based board that only has USB ports. Do you think your example can be modified to accommodate a ColdFire based board?

I think i will have to use the cdc-acm to communicate with the adapter for this, was wondering if there is an off the shelf solution for this in MQX.



Thanks for the feedback, Evgeny!

What ColdFire and MQX version are you using?

Seems that your application needs to use a USB host + USB device virtual NIC (Network Interface Card). The NICs uses diferent protocols, one of them is RNDIS. So, if the NIC is compatible with RNDIS, it can be used.

You will also need some flash available in your MCU ,as you will need to accommodate a TCP/IP stack.

Hey dshimizu,

I use ColdFire v3 with MQX3.7, but i am planing to move to MQX4.2. What i want to achieve by using a USB to Ethernet cable, is to be able to connect to cellular modem, wall socket, router etc using RJ cable using a USB port on my device.

I understand that i need to use cdc from USB host to communicate with the adapter, but why should i use the USB device virtual NIC ? Regarding the TCP/IP stack, i believe it is a part of MQX4.2, right?



Hello Evgeny,

Yes, you are right, actually an usb to ethernet cable is a NIC device. We even have a USB device-Ethernet example that work in a Windows host machines in our MQX USB stack ( in the folder Freescale_MQX_4_2\usb\device\examples\cdc\virtual_nic ).

The point is: As I know, these usb to ethernet cables uses different protocols (​ ) , but only some of them uses RNDIS. And even our example of NIC in MQX does not use RNDIS. I choosed RNDIS in this example because is the one used by Android to make the tethering funcionality in cellphones. I am not exactly sure if the manufacturers of Ethernet-USB cables also uses RNDIS or other protocols. All of them uses CDC to communicate , but with different protocols above it.

And about the TCP/IP stack, you are also right, MQX alread has a TCP/IP stack protocol called RTCS. But in this implementation of hosting tethering in Kinetis I have used other TCP/IP stack,called LwIP, that is supported by the community. But this stack can be easily ported for ColdFire too.

If you think that this software connecting to the internet using a cellphone can be useful for you, let me know what ColdFire derivative (MCFxxxx) you are using and I can check if it's possible to adapt for it.




great project! thank you!

I'm using the FRDM K22F and I'm trying to migrate the project on KSDK 2.0 but it quite hard for me.

Have you any tip to help me?

thank you in advance


Hey Denis Shimizu,

Do you know if LwIP could be ported to MQX3.7 or do i need to get a newer MQX version? I could not find it in the documentation....



Hey dshimizu​,

Do you know if the usage of the RNDIS protocol is free of charge? Can you recommend an implementation of it to be used as a reference for implementing it for MQX (if there is such a thing....).



Do you think this can be change to USB CDC ECM protocol ? Currently many 3/4 G modules are supported by USB CDC ECM  mode, so this will be  useful!

That's a very cool example and I would like to try it, unfortunately I get three errors when building. Three libraries are missing. 


I could build the others but I can't build these three, they are nowhere to be found in the Zip and I can't find any projects to build them. 

Any suggestions what I did wrong? I'm just working for half a year with KDS and the KSDKs and this is the first time I got this Problem.

I would really like to get this running, because I'm working on a similar project with a Surf Stick instead of the Mobile Phone. Have you tried this?



No ratings
Version history
Last update:
‎12-17-2015 12:50 PM
Updated by: