Kai Liu

FRDM-KL25Z now talks to Android Phone

Discussion created by Kai Liu on Jul 11, 2013
Latest reply on Jul 18, 2018 by kirti raje

Hi,

 

I have just finished my work on running ADB protocol on FRDM-KL25Z.

 

ADB (Android Debug Bridge) is an important debug interface used in Android, ranges from Android 1.5 to lastest 4.2.2.

 

Any MCU running ADB can talks to any Android Phone (OS version<4.2.2), that means appcessory ecosystem can be built on a low cost Cortex-M0 MCU like KL25Z.

 

I port ADB protocol from UHS project for Arduino, with a lot of re-write code to adapt to FSL USB host stack. Yes, they are using totally different approaches, not only the registers, but also program structure.

 

If anyone is interested, you can follow my step to run it on your board as well.

 

  1. Built an add-on OTG port on FRDM-KL25Z (USB host HID demo times out on FRDM-KL25Z with reproduced USB host), alternatively, you must buy FRDM RevD.
  2. Put your FRDM into MSD programmer mode, according to QSP of KL25Z.
  3. Download attached srec file (USBH_Adb.srec) into programmer driver.
  4. Put your FRDM back into PEmicro debugger mode, according to QSP of KL25Z, otherwise you lose your serial port print on terminal
  5. Install apk in ServoControl.zip file to Android Phone. (Don't use Jelly Bean 4.2.2, older phone is all right)
  6. Connect your Android Phone to add-on OTG port.

 

If successful, you can find USB activities on serial terminal. And found ADB protocol talks as well.

 

In my code, the LPTMR value will be sent to Android phone as a bar, the user can touch the red block and move it, and its co-ordinate will be sent back to KL25Z. It is a simple demo.

 

Have fun. Your comments are highly welcome.

 

==================

 

Limitations

 

  • The source code is messy, I need more time to re-organize it.
  • The ADB only works Android phone with OS 1.5+ to 4.2.1. The latest 4.2.2 has enforced RSA authentication, which is not available so far.
  • The ADK/AOA protocol is implemented.

 

Plan

  • Reorganize source code for ADB for FSL
  • Offer API interface to high level applications
  • Offer more complex demos (Video surveillance with Android phone with PTZ control)
  • Evaluate serial bootloader (AN2295) and change it to adapt with bootloader.
  • Support RSA authentication if possible
  • Support AOA/ADK w/o audio
  • A new KL25Z USB OTG board called "GAP" (Generic Android/Application Peripheral) under development, in form of Arduino or mini board.

 

Long-term Plan (more aggressive, but only with more time, effort and human resources)

  • Support USB WiFi/Blutetooth dongle.
  • Support USB CDC with Android phone.
  • Support codesourcery toolchain
  • Support Arduino/Maple IDE
  • Support license in firmware.

 

Sorry for my poor English, and I updated URL to another thread. In fact, FRDM-KL25Z RevD supports USB OTG with wiring VBUS from OpenSDA to KL25Z. But use it at your own risk.  I am not sure if I should go open source or close source like traditional approach. Before I make my decision, I will release my hex code anyway, and release a library and related header file to user application development.    Message was edited by: Kai Liu

Original Attachment has been moved to: USBH_Adb.srec.zip

Original Attachment has been moved to: ServoControl.zip

Outcomes