NXP i.MX RT10XX: Using Bluetooth Serial Port Profile

Bluetooth is widely used when it is necessary to provide a wireless access to the devices located in short distances. In this application note we will show how to organize a wireless control channel to the NXP i.MX RT10XX EVKB running Linux using a USB Bluetooth adapter. In practical embedded applications such a wireless channel may be used to implement a command/response protocol to control your i.MX RT10XX based device via Bluetooth from the host machine (computer, notebook, smart-phone, etc.).

1. Hardware Platform

The hardware platform used in this application note is the NXP i.MX RT10XX EVKB board with a USB Bluetooth adapter plugged into the USB1 or USB2 interface connector. The adapter used by Emcraft to perform the tests documented below was RFCOMM Protocol TDI Bluetooth Device. The generic Linux kernel device driver for the USB transport HCI layer (CONFIG_BT_HCIBTUSB) is used in this configuration so other USB Bluetooth adapters should work as described below too.

2. Software Platform

The goal is to have the i.MX RT10XX act as a device with the Serial Port Profile (SPP) in the Bluetooth network. The i.MX RT10XX will emulate the serial port over the Bluetooth transport and therefore the host will see the i.MX RT10XX as an ordinary serial RS-232 port.

The Bluetooth Serial Port Profile interface is implemented with the BT_RFCOMM_TTY kernel driver. The sdptool and rfcomm utilities, ported from the bluez-utils package to the Linux NXP i.MX RT10XX EVK BSP, are used for configuration. The sdptool utility is used to create the "Serial Port" profile, exported over Bluetooth. The rfcomm utility is started in the "listen" mode and, on the "Serial Port" profile activation, rfcomm emulates a virtual COM port on the /dev/rfcommX device file, looking from the i.MX RT10XX side.

The functionality described below is available from the rootfs.uImage project provided by Emcraft for NXP i.MX RT10XX EVKB.

3. Test Setup

We will use the following terminology below:

  • Target: NXP i.MX RT1050 EVKB board with the Bluetooth adapter plugged into the USB (J9) port or NXP i.MX RT1060 EVKB board with the Bluetooth adapter plugged into the USB (J47) port.
    The Bluetooth <Target address> in the examples below is 04:7F:0E:31:B7:94.

  • Host: Any computer with a Bluetooth interface, running Linux with the Bluetooth tools (bluez-utils) installed.
    The Bluetooth <Host address> in the examples below is 30:03:C8:C9:10:E6.

4. Test Connectivity

  1. Power-on the NXP i.MX RT10XX EVKB board and wait for the Linux to boot on the Target. Run the Bluetooth daemons in the background:

    ... / # hcid -n& [1] 97 hcid -n hcid[97]: Bluetooth HCI daemon / # sdpd -n& [2] 98 sdpd -n / #
  2. Plug-in the Bluetooth adapter to the USB1 interface of the NXP i.MX RT10XX EVK board. Observe the messages like these in the Target console:

    ci_hdrc ci_hdrc.0: EHCI Host Controller ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 2 ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00 hub 2-0:1.0: USB hub found hub 2-0:1.0: 1 port detected usb 2-1: new full-speed USB device number 2 using ci_hdrc usb 2-1: device no response, device descriptor read/64, error -71 Bluetooth: hci0: unexpected event for opcode 0x0000 Bluetooth: hci0: CSR: Setting up dongle with HCI ver=6 rev=22bb Bluetooth: hci0: LMP ver=6 subver=22bb; manufacturer=10 hcid[74]: HCI dev 0 registered hcid[74]: HCI dev 0 up hcid[74]: Starting security manager 0
  3. Get the <target address> Bluetooth address of the adapter you have just plugged-in:

    / # hcitool dev Devices: hci0 04:7F:0E:31:B7:94 / #
  4. Add the Serial Port profile to the list of Bluetooth profiles. In the example below the Bluetooth channel number to access this profile is 1:

  5. Start the background listening for raw connections on the channel 1:

  6. On the host, open a raw Bluetooth connection to the Target (<target address> Bluetooth Device, channel 1):

  7. In the target console observe an indication of the connection from the Host:

  8. Send a text string (command) to the Target over the Bluetooth serial port from the Host:

  9. On the Target receive the text string (command) just sent from Host:

  10. Send a text string (response) from the Target to Host over the Bluetooth serial port:

  11. Receive the text string (response) just sent from the Target over the Bluetooth serial port:

  12. Disconnect the Host from the Bluetooth serial line by pressing Ctrl-C in the rfcomm --raw connect ... terminal window:

  13. Observe the rfcomm termination on the Target side:

Please note that the rfcomm --raw listen command must be re-run on the Target to reopen the Bluetooth serial link again.