CM-T335: Linux: Debian

From Compulab Mediawiki
Jump to: navigation, search


The example run-time Linux filesystem image for the CompuLab CM-T335 System-on-Module / Computer-on-Module is based on Debian 8.2 GNU/Linux Jessie (armhf). The CompuLab Linux package for CM-T335 includes ready to run NAND flash image, Linux kernel configuration and source code patches, and an archive of the root filesystem, used to create the image.

The default Debian Jessie Linux image includes more than 400 software packages. Among them:

  • Core system
  • Debian package management system
  • X11 Windowing System
  • Fluxbox desktop manager
  • Netsurf web browser
  • Apache web server
  • Samba connectivity suite
  • SSH server and client
  • ALSA configuration and usage utilities
  • CAN Bus utilities
  • Bluetooth tools and daemons

The Automatic Linux installation on CM-T335 page provides a brief introduction on how to install the run-time Linux image. This article describes peripheral device options specific to the CM-T335.

Using Debian Linux on CM-T335

Connection and Logging In

Use the following usernames and passwords to login:

Account with administrative privileges:

User: root
Password: 111111

Regular user account:

User: user	
Password: 111111

In addition to these accounts CM-T335 allows anonymous FTP access. To login into the Linux system, you may use a serial console (ttyO0) at 115200 bps, or connect through the network, or use a keyboard and DVI/LCD display (tty1, tty2, tty3, tty4).


To configure networking, edit /etc/network/interfaces, /etc/udev/rules.d/70-persistent-net.rules, /etc/resolv.conf, /etc/hostname and /etc/hosts. For more information about Debian Linux network configuration read Network setup chapter in the Debian Reference.

X Windows system

CompuLab DEMO root filesystem image contains fully featured X server system with Fluxbox window manager. Before starting X server, connect USB mouse and keyboard to the system. You can run X server and Fluxbox window manager by typing startx.

Fluxbox window manager

CM-T335 Debian Linux features installed Fluxbox package - a lightweight window manager for the X server system.

  • Fluxbox provides configurable window decorations, a root menu to launch applications and a toolbar that shows the current workspace name, a set of application names and the current time. There is also a workspace menu which allows you to add or remove workspaces. The slit can be used to dock small applications, e.g. most of the bbtools can use slit.
  • Fluxbox can iconify windows to the toolbar, in addition to adding the window to the Icons submenu of the workspace menu.

Visit Fluxbox Wiki and Official home page for more details.

Software Management

Debian Linux image for CM-T335 includes all the information required to use Debian package management utilities. You can use apt-get and dpkg out of the box.


The touchscreen driver is modularized if you use default CM-T335 configuration and is loaded by udev automatically on Linux boot.

Touchscreen calibration

A touchscreen device can be calibrated using xinput_calibrator utility.

To calibrate the touchscreen:

  • Run X Server by issuing startx command
  • Make sure the touchscreen driver is loaded
  • Set the DISPLAY environment variable:
     export DISPLAY=:0
  • Run xinput_calibrator utility. For proper calibration you are required to touch the touchscreen corners and center in the following order: top-left, top-right, bottom-right, bottom-left, center.
  • Create a file /usr/share/X11/xorg.conf.d/99-calibration.conf and paste there a snippet with the calibration results:
root@cm-debian:~# xinput_calibrator --device ti-tsc
	Setting calibration data: 0, 4095, 0, 4095
Calibrating EVDEV driver for "ADS7846 Touchscreen" id=6
	current calibration values (from XInput): min_x=0, max_x=4095 and min_y=0, max_y=4095

Doing dynamic recalibration:
	Setting calibration data: 289, 3781, 3887, 227
	--> Making the calibration permanent <--
  copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)
Section "InputClass"
	Identifier	"calibration"
	MatchProduct	"ADS7846 Touchscreen"
	Option	"Calibration"	"289 3781 3887 227"
	Option	"SwapAxes"	"0"

Analog Audio

CM-T335 provides an analog audio interface, which is registered as a standard ALSA sound card. Use aplay -l to list all soundcards and digital audio devices registered on the system:

root@cm-debian:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: cmt335 [cm-t335], device 0: davinci-mcasp.0-tlv320aic23-hifi tlv320aic23-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Analog Audio Settings

To enable the Analog audio playback, alsamixer or amixer applications can be used.

  • alsamixer - set the “Output Mixer” control on.


  • amixer - set the “Output Mixer Playback Switch” control on using command line interface:
root@cm-debian:~# amixer cset numid=12 1
numid=12,iface=MIXER,name='Output Mixer Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on

Analog Audio Playback

In order to play back a sound file make use of the aplay application.

  • aplay -L can be used for listing of all pcm devices.

Here is a sample output of aplay -L command:

root@cm-debian:~# aplay -L
    Discard all samples (playback) or generate zero samples (capture)
    PulseAudio Sound Server
    Default Audio Device
    Default Audio Device
    Direct sample mixing device
    Direct sample snooping device
    Direct hardware device without any conversions
    Hardware device with all software conversions

The next command can be used for audio play back:

root@cm-debian:~# aplay <wav-file>

Audio Input Settings

CM-T335 provides an audio capturing feature from either Mic or Line In input sources. alsamixer or amixer can be used in order to switch between these inputs.

  • alsamixer
Line Input => 100
Line => off
Mic => on
  • amixer
amixer cset numid=4 31
amixer cset numid=3 0
amixer cset numid=5 1
amixer cset numid=9 1
Line In
  • alsamixer
Line Input => 100
Line => on
Mic => off
  • amixer
amixer cset numid=4 31
amixer cset numid=3 0
amixer cset numid=5 0
amixer cset numid=9 0

Sample Audio Recording

As soon as the correct input values have been set, audio signal can be captured. Here is a sample command that shows the arecord usage for capturing audio signal from the selected input line.

root@cm-debian:~# arecord -f dat -t wav /tmp/out.wav


CM-T335 features Bluetooth 4.0 interface. Following sections describe the initialization and simple use cases of Bluetooth device.

Host Controller Interface (HCI) Initialization

  • Attach the ttyO1 serial port to the HCI Bluetooth subsystem:
root@cm-debian:~# hciattach -s 115200 /dev/ttyO1 texas 3000000
Found a Texas Instruments' chip!
Firmware file : /lib/firmware/TIInit_7.6.15.bts
Loaded BTS script version 1
texas: changing baud rate to 3000000, flow control to 1
Bluetooth: HCI UART driver ver 2.2
Bluetooth: HCI H4 protocol initialized
Bluetooth: HCI BCSP protocol initialized
Bluetooth: HCILL protocol initialized
Device setup complete
  • Run HCI device configuration utility to retrieve detailed information about the Bluetooth device:
root@cm-debian:~# hciconfig -a
hci0:   Type: BR/EDR  Bus: UART
        BD Address: C4:ED:BA:3E:86:42  ACL MTU: 1021:4  SCO MTU: 180:4
        RX bytes:928 acl:0 sco:0 events:42 errors:0
        TX bytes:1452 acl:0 sco:0 commands:42 errors:0
        Features: 0xff 0xfe 0x2d 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
        Link policy: RSWITCH HOLD SNIFF PARK 
        Link mode: SLAVE ACCEPT 
        Name: 'cm-debian-0'
        Class: 0x4a0100
        Service Classes: Networking, Capturing, Telephony
        Device Class: Computer, Uncategorized
        HCI Version: 4.0 (0x6)  Revision: 0x0
        LMP Version: 4.0 (0x6)  Subversion: 0x1f29
        Manufacturer: Texas Instruments Inc. (13)

Bluez5 & PulseAudio

Debian uses BlueZ 5 and PluseAudio 5. BlueZ 5 does not support alsa, and uses PulseAudio. PulseAudio 5 only supports the A2DP profile and not HSP/HFP.

Install and configure PulseAudio
root@debian-armhf:~# apt-get update
root@debian-armhf:~# apt-get install pulseaudio pulseaudio-module-bluetooth
  • Create a systemd service for running pulseaudio as the pulse user.
root@debian-armhf:~# cat << eof > /etc/systemd/system/pulseaudio.service
Description=Pulse Audio

ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm


root@debian-armhf:~# chown pulse:pulse /etc/systemd/system/pulseaudio.service
  • Create a dbus configuration file for running pulseaudio. Give the pulse user permission to use Bluetooth.
root@debian-armhf:~# cat << eof > /etc/dbus-1/system.d/pulseaudio-bluetooth.conf

  <policy user="pulse">
    <allow send_destination="org.bluez"/>


root@debian-armhf:~# chmod 0666 /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
  • Paste the following lines to the end of /etc/pulse/
root@debian-armhf:~# cat << eof >> /etc/pulse/
### Automatically load driver modules for Bluetooth hardware
load-module module-bluetooth-policy

load-module module-bluetooth-discover
  • Create /var/run/pulse/.config/pulse directory and fix the ownership.
root@debian-armhf:~# mkdir -p /var/run/pulse/.config/pulse
root@debian-armhf:~# chown -R pulse:pulse /var/run/pulse
  • Add root to the pulse-access,audio groups
root@debian-armhf:~# usermod -a -G pulse-access,audio root
Start PulseAudio
  • Start PulseAudio service
root@debian-armhf:~# systemctl daemon-reload
root@debian-armhf:~# systemctl start pulseaudio.service
  • Make sure that the service is active, running and reports no error.
root@debian-armhf:~# systemctl status pulseaudio.service
   Loaded: loaded (/etc/systemd/system/pulseaudio.service; disabled)
   Active: active (running) since Mon 2015-07-20 12:00:13 UTC; 1min 34s ago
 Main PID: 805 (pulseaudio)
   CGroup: /system.slice/pulseaudio.service
           └─805 /usr/bin/pulseaudio --system --disallow-exit --disable-shm
Bluez5 pairing

PulseAudio 5.x supports A2DP by default. Make sure the following packages are installed: pulseaudio, pulseaudio-module-bluetooth, pulseaudio-utils, bluez, bluez-tools.

  • Start the Bluetooth system:
root@debian-armhf:~# systemctl start bluetooth

Now we can use the bluetoothctl command line utility to pair and connect. Run

root@debian-armhf:~# bluetoothctl

to be greeted by its internal command prompt. Then enter:

[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# scan on

Make sure that an A2DP device is in pairing mode. It should be discovered shortly. For example,

[NEW] Device 00:07:A4:F2:B3:CB Motorola HT820

shows a device that calls itself "Motorola HT820" and has MAC address 00:07:A4:F2:B3:CB. Use the MAC address to initiate the pairing:

[bluetooth]# pair 00:07:A4:F2:B3:CB

After pairing, connect the device:

[bluetooth]# connect 00:07:A4:F2:B3:CB

After the successful connection, the new output device will be created in PulseAudio.
Scanning can be disabled now:

[bluetooth]# scan off

Exit the program:

[bluetooth]# exit
Playback using PulseAudio
Admolition note.png Next examples assume that the device mac address is 00_07_A4_F2_B3_CB
  • Show the PulseAudio device
root@debian-armhf:~# pactl list cards | awk '/00_07_A4_F2_B3_CB/' RS=""
Card #1
        Name: bluez_card.00_07_A4_F2_B3_CB
        Driver: module-bluez5-device.c
        Owner Module: 14
                device.description = "Motorola HT820"
                device.string = "00:07:A4:F2:B3:CB"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_00_07_A4_F2_B3_CB"
                bluez.class = "0x240404"
                bluez.alias = "Motorola HT820"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
                a2dp: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: a2dp
                headset-output: Headset (priority: 0, latency offset: 0 usec)
                        Part of profile(s): a2dp
                headset-input: Headset (priority: 0, latency offset: 0 usec, not available)
  • Make sure the active card profile is a2dp_sink. Otherwise switch to it:
# pactl set-card-profile 1 a2dp
  • Show the PulseAudio sink
root@debian-armhf:~# pactl list sinks | awk '/00_07_A4_F2_B3_CB/' RS=""
Sink #1
        State: SUSPENDED
        Name: bluez_sink.00_07_A4_F2_B3_CB
        Description: Motorola HT820
        Driver: module-bluez5-device.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 14
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: bluez_sink.00_07_A4_F2_B3_CB.monitor
        Latency: 0 usec, configured 0 usec
                bluetooth.protocol = "a2dp_sink"
                device.description = "Motorola HT820"
                device.string = "00:07:A4:F2:B3:CB"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_00_07_A4_F2_B3_CB"
                bluez.class = "0x240404"
                bluez.alias = "Motorola HT820"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
                headset-output: Headset (priority: 0)
        Active Port: headset-output
  • Play sound using paplay. Example:
root@debian-armhf:~# paplay -d bluez_sink.00_07_A4_F2_B3_CB /path/to/<audio-file.wav>

Obex FTP service

The OBject EXchange protocol (OBEX) can be used to exchange all kind of objects like files, pictures, calendar entries (vCal) and business cards (vCard) over bluetooth, IrDA, USB and serial cable links. CM-T335 Linux example root file system contains file transfer utility for devices that use the OBEX protocol. Following examples demonstrate its usage with mobile phone device.

  • Enable bluetooth on the phone. On CM-T335, scan for available devices to find out phone's BT address:
root@cm-debian:~# hcitool scan
Scanning ...
	00:15:2A:20:63:94	Nokia 6230i
  • Ensure the phone supports Obex FTP service:
root@cm-debian:~# sdptool search FTP
Inquiring ...
Searching for FTP on 00:15:2A:20:63:94 ...
Service Name: OBEX File Transfer
Service RecHandle: 0x100de
Service Class ID List:
  "OBEX File Transfer" (0x1106)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 10
  "OBEX" (0x0008)
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "OBEX File Transfer" (0x1106)
    Version: 0x0100
  • Follow the section "Bluez5 pairing" to pair the CM-T335 module with the phone.
  • List phone's root folder:
root@cm-debian:~# obexftp -b 00:15:2A:20:63:94  --list
Browsing 00:15:2A:20:63:94 ...
Tried to connect for 579ms
Receiving "(null)".../<?xml version="1.0"?>
<!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd"
 [ <!ATTLIST folder mem-type CDATA #IMPLIED> ]>
<folder-listing version="1.0">
    <folder name="EXTENTSION" user-perm="RW" mem-type="MMC"/>
    <folder name="Images" created="19800101T000000" user-perm="R" mem-type="DEV"/>
    <folder name="Video clips" created="19800101T000000" user-perm="R" mem-type="DEV"/>
    <folder name="Music files" created="19800101T000000" user-perm="R" mem-type="DEV"/>
    <folder name="Themes" created="19800101T000000" user-perm="RW" mem-type="DEV"/>
    <folder name="Graphics" created="19800101T000000" user-perm="R" mem-type="DEV"/>
    <folder name="Tones" created="19800101T000000" user-perm="R" mem-type="DEV"/>
    <folder name="Recordings" created="19800101T000000" user-perm="R" mem-type="DEV"/>
  • Transfer a file from CM-T335 to the phone:
root@cm-debian:~# obexftp -b 00:15:2A:20:63:94 --put test_file.txt 
Browsing 00:15:2A:20:63:94 ...
Tried to connect for 380ms
Sending "test_file.txt"...|done
  • Retrieve a file from the phone to CM-T335:
root@cm-debian:~# obexftp -b 00:15:2A:20:63:94 --get test_file.txt 
Browsing 00:15:2A:20:63:94 ...
Tried to connect for 267ms
Receiving "test_file.txt".../done

Wireless local area network (WLAN)

The CM-T335 features 802.11b/g/n wireless interface, implemented with the TI WL1271 Wireless module.

WLAN Initialization

  • The WL12xx WLAN driver gets loaded automatically. Make sure that the WLAN driver is loaded:
root@cm-debian:~# lsmod | grep wl12xx
wl12xx                 57190  0 
wlcore                180594  1 wl12xx
mac80211              605465  2 wl12xx,wlcore

If the WLAN driver has not been loaded automatically, it can be loaded manually:

root@cm-debian:~# modprobe wl12xx
root@cm-debian:~# [  360.085386] wlcore: loaded
  • iwconfig command from wireless-tools package can be used to retrieve detailed information about WLAN interfaces:
root@cm-debian:~# iwconfig wlan0
wlan0     IEEE 802.11abgn  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
  • WLAN interface activating:
root@cm-debian:~# ifconfig wlan0 up
wl1271: firmware booted (Rev
  • Sample WLAN scanning:
root@cm-debian:~# iwlist wlan0 scan

The output will show the list of Access Points and Ad-Hoc cells in range. For more information about connecting to wireless networks and tuning WLAN interfaces refer to “wpa_supplicant” and “wireless-tools” man pages.

WL12xx calibration tool

Calibration of TI WL12xx wireless device is needed for generation of specific radio configuration parameters and saving into the NVS file. The NVS file is then used by the wl12xx driver.

The CM-T335 Linux package contains the statically compiled calibrator utility from ti-utils support package for WL12xx. For more details please read OMAP Wireless Connectivity Calibration Proccess NLCP article.

Example of reading WLAN MAC address stored in NVS file:

root@cm-debian:~# ./calibrator get nvs_mac /lib/firmware/ti-connectivity/wl1271-nvs.bin
MAC addr from NVS: de:ad:be:ef:00:00
Admolition note.png The default CM-T335 Demo root filesystem supplied NVS file contains 00:00:00:00:00:00 WLAN MAC address. Therefore the real WLAN MAC address is initialized from the chip fuse. Changing the default NVS file to contain a valid MAC address will change the WLAN MAC address of the CM-T335.


  • Configuration sample

wpa_supplicant requires a configuration file to be created in order to get connected to a scanned wireless network.
Make use of the example bellow and put the network name and the password into the "ssid/psk" fields.

root@cm-debian:~# cat << eof > /etc/wpa_supplicant.conf

  • Sample run
root@cm-debian:~# ifconfig wlan0 up
root@cm-debian:~# wpa_supplicant -B -Dwext -c /etc/wpa_supplicant.conf -i wlan0
root@cm-debian:~# dhclient wlan0

Controller–area network (CAN)

The CM-T335 features a TI DCAN Controller Area Network (DCAN), integrated into the Sitara AM335X SoC. The TI DCAN module supports bitrates up to 1 Mbit/s and is compliant to the CAN 2.0B protocol specification.

Loading CAN modules

If the D_CAN driver and/or CAN protocols (Raw and Broadcast Manager) compiled as module(s), they must be loaded prior to enabling CAN interface.

  • Load Raw CAN protocol module:
root@cm-debian:~# modprobe can-raw
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
  • Load Broadcast Manager CAN protocol module:
root@cm-debian:~# modprobe can-bcm
can: broadcast manager protocol (rev 20120528 t)
  • Load D_CAN driver module:
root@cm-debian:~# modprobe d_can_platform
[  130.295962] d_can d_can.0: device registered (irq=52, irq_obj=53)
[  130.303631] d_can d_can.1: device registered (irq=55, irq_obj=56)

For information on enabling CAN kernel support, please, see the Linux Kernel for CM-T335 page.

CAN interface configuration

It is recommended configure the CAN interface, with the iproute2 utilities.

  • To make sure the right ip utility is used, run:
root@cm-debian:~# ip -V
ip utility, iproute2-ss140804
  • Configure the CAN interface bit-rate to 125 Kbits/sec (values of up to 1Mbit/sec are supported):
root@cm-debian:~# ip link set can0 type can bitrate 125000
  • Enable the CAN interface:
root@cm-debian:~# ip link set can0 up
c_can_platform 481cc000.can can0: setting BTR=0518 BRPE=0000
Send/Receive packets

Use cansend and candump utilities to send and receive packets via CAN interface.

  • Send standard CAN frame (on the first device):
root@cm-debian:~# cansend can0 111#1122334455667788
  • Send extended CAN frame (on the first device):
root@cm-debian:~# cansend can0 11111111#1122334455667788
  • Dump all received data frames as well as error frames (on the second device):
root@cm-debian:~# candump any,0:0,#FFFFFFFF
  can0  111  [8] 11 22 33 44 55 66 77 88
  can0  11111111  [8] 11 22 33 44 55 66 77 88

GPIO access

Linux provides simple and convenient GPIO access via sysfs interface. A GPIO should be exported using /sys/class/gpio/export. After the GPIO is exported it is possible to change its direction and value using /sys/class/gpio/gpioX/direction and /sys/class/gpio/gpioX/value attributes.


The following example demonstrates how to configure GPIO 64 as output and set value to high:

echo 64 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio64/direction
echo 1 > /sys/class/gpio/gpio64/value
Admolition note.png The above example assumes that the corresponding pin is set to mux mode 7 and the GPIO 64 is not requested in the Linux kernel.

See also