Login / Signup

Bluetooth for Kirin3

  • user warning: Table './devemc/sessions' is marked as crashed and last (automatic?) repair failed query: SELECT COUNT(sid) AS count FROM sessions WHERE timestamp >= 1422620234 AND uid = 0 in /home/devemc/public_html/dev/includes/session.inc on line 157.
  • user warning: Table './devemc/sessions' is marked as crashed and last (automatic?) repair failed query: SELECT COUNT(DISTINCT s.uid) FROM sessions s WHERE s.timestamp >= 1422620234 AND s.uid > 0 in /home/devemc/public_html/dev/modules/user/user.module on line 790.

ColdFire Kirin3 is a microcontroller, rather than a microprocessor. As a result, Kirin3 can not run Linux or uCLinux which have complete TCP/IP, IrDA and Bluetooth stacks. Instead, Freescale teams up its software partners to offer turnkey solutions from RTOS, TCP/IP, FAT to USB stacks. The complementary software from Freescale is great for most connectivity oriented applications. However, the developers have to purchase software components or develop in-house if the application demands extra features. 

If Kirin3 has wireless connections, it can be more powerful. We can find the reference designs for IEEE802.15.4, Zigbee, Synchro and 2.5G/3G mobile modules from Freescale. Is it possible to support Bluetooth for ColdFire? Of course, it is always possible. However, the final solution could be various depend on your hardware (Bluetooth adapter) and stack partition. 

Bluetooth Stack Implementation and Partition

Bluetooth is a complicated protocol stack and has many ever growing application profiles. Each profile is made up of several protocols for specific application requirement. The selection of the adapter influences the stack implementation and profile availability. In general, there are two categories of Bluetooth adapters in the market: HCI adapter and Serial adapter (Maybe there is a better name for it).

HCI adapter, which offers HCI interface over USB/UART. The upper layers above HCI have to be implemented in the host controller (like PC, or Kirin3 in our case). Since you can implement higher level stacks by yourself, the HCI adapter offers flexibility for your applications. It is suitable for PC, SoC running complete stack. HCI adapter is not covered by this blog.

Before I drop into so-called serial adapter, I HAVE TO clarify some terminologies which are widely misunderstood in Bluetooth. The RFCOMM protocol defines a transport protocol for emulating RS-232 serial ports. However it may not be the serial port you want. The serial port you want should be SPP (Serial Port Profile) and its device driver instead. Some manufactures offer transparent cable replacement so you can use the serial port as normal RS232 serial port. It should be SPP interface, rather than RFCOMM interface. Hopefully you are not even more deeply confused by my expression.

Serial Bluetooth adapter, which offers application layer interface for host controller over UART/SPI. The lower layer of Bluetooth stack, including SDP is implemented by the embedded controller inside the module. There are various serial Bluetooth adapters with different interface. Some adapters offer RFCOMM, so you can implement many profiles like DUN/LAP/OBEX/SPP by yourself. Some other adapters offer more abstracted interface like emulated serial port (SPP) or AT command interface, the host controller can communication with it as a common UART or MODEM. The programming for emulated (or transparent) serial port is much easier, but you usually can not support more profiles. Please request user manual from the manufacture if you are using transparent adapter.

The UART is the common interface to the Bluetooth modules. So, please estimate your application and read the data sheet before you order it. 

Open Source Implementation for RFCOMM Bluetooth Adapter

Unfortunately, most of the Bluetooth stacks are commercial products. We can find BlueZ and OpenBT for Linux, which support HCI adapter and are not suitable for embedded processors, especially a microcontroller with limited RAM size like Kirin3. Finally, I found LwBT, an open source stack from EIStec (Embedded Internet Systems).

LwBT is an open source implementation for some profiles, which was designed with LwIP for Mulle Bluetooth sensor network project hosted by EISLab/EIStec. Since the software dependency is quite strict in the embedded system design. I have to find an existing LwIP for Kirin3, rather than RTCS from Freescale complementary package. The enclosed DVD-ROM shipped with Kirin3 MCF52259 demo kit contains some optional 3rd party reference designs including FreeRTOS LwIP demo. FreeRTOS demo may be used for add Bluetooth, because it offers a complete working lab with LwIP for Kirin3. 


The LwBT features (from upper layer to lower layer):

  • LAP (LAN Access Point) and DUN (Dial Up Networking) profiles data terminal control applications.
  • PPP, Point to Point Protocol including support for IPCP.
  • RFCOMM, for serial port emulation.
  • SDP, Service Discovery Protocol, including support for advertising service in user defined records.
  • L2CAP, Logical Link Control and Adaption Protocol for high level protocol multiplexing, packets segmentation.
  • HCI, Host Controller Interface for optionally providing a uniform interface method to access the lower layers of the Bluetooth Stack when they are implemented in a Bluetooth host controller (or referred as a Bluetooth module).

We can conclude that LwBT is a complete (almost) Bluetooth stack for embedded controller, offers HCI interface. However, I find the real product from EIStec uses a RFCOMM Bluetooth module from Mitsumi Japan.

Now, we have following reference design code bases:

Freescale: FreeRTOS + LwIP + HTTP Web server for Kirin3

EIStec: RTXC + LwIP + LwBT + DUN/LAP profiles for Bluetooth.

Everything Open Source

If we merge the code together, this Bluetooth project is fully based upon open source components:

  • RTOS: FreeRTOS, a popular, open source, mini, fully portable RTOS, can be used in commercial applications. Modified GPL.
  • TCP/IP: LwIP, by Adam Dunkel, Swedish Institute of Computer Science. Now it is developed by a WW team headed by Leon Woestenberg. BSD license.
  • Bluetooth: LwBT, by Conny Oehult, Embedded Internet Systems Laboratory. BSD license.

The MCF52259DEMOKIT has one RS232 on board. I bough a serial adapter, and connected it to the DEMOKIT with a gender changer (interesting name), which converts female connector to male connector. So, I got a hardware platform. The released LwBT doesn't contain detail documents. Reading source code is the only way to understanding the project. Up to now, I have not finished the project on Kirin3. 

Extra Profiles

The most popular Bluetooth profiles are:

  • A2DP (Advanced Audio Distribution Profile), stereo earphone for mobile phone.
  • AVRCP (Audio/Video Remote Control Profile), remote control.
  • BIP (Basic Imaging Profile), digital camera and camera phone.
  • FTP (File Transfer Profile), popular file exchange.
  • HID (Human Interface Device Profile), PC remote control.
  • OPP (Object Push Profile), file pushing service, popular in proximity commercial system.
  • SPP (Serial Port Profile), basic serial port in Bluetooth, used in GPS, POS and embedded systems. 

However you have to implement these profiles by yourself. Based upon the performance of ColdFire v2 and practical requirement for embedded systems, I think SPP should have the first priority since Bluetooth has the most coverage in mobile devices. Although BIP, OPP and FTP have great commercial values (in pushing message or advertisement clips to mobile phones), these profiles should be implemented in a complicated operation system like Linux and covered by Linux Bluetooth stacks. You can implement them though, since Freescale offers USB MSD, FAT, FTP, Telnet reference designs for MCF52259. 

Easy Programming for Serial Bluetooth Adapter

If your project only uses Bluetooth as cable replacement for peer to peer communication, the transparent serial adapter is suitable for you. You can find a lot of such adapters in the market. Check out another blog (Serial Port to Bluetooth Adapters), which list many Bluetooth adapters. I also find many adapters in local B2B web. Bluetooth adapters are very cheap in China, only 8USD. 

Read the Italian version: Bluetooth per il Kirin 3

If you want to know more about this Freescale product, please submit your request to Arrow Italy using this form.

NOTE: this form is valid ONLY for Companies or Customers based in Italy and working in the Italian area.


Bluetooth Profiles - Wikipedia




lwIP, light weight TCP/IP stack


lwBT, A light weight Bluetooth stack for lwIP


Bluetooth: A Technical Overview


EIStec for Embedded Internet Systems with sensor networks


Mitsumi WML-C46 AHR Bluetooth Module UART/PCM interface with RFCOMM stack


Who's online

There are currently users and guests online.

Recent comments