Difference between revisions of "CM-T335: Linux: Debian"

From Compulab Mediawiki
Jump to: navigation, search
(kernel)
(Loading CAN modules)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
The example run-time Linux filesystem image for the CompuLab CM-T335 System-on-Module / Computer-on-Module is based on Debian GNU/Linux Sid.
+
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 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 Sid Linux image includes more than 400 software packages. Among them:
+
The default Debian Jessie Linux image includes more than 400 software packages. Among them:
  
 
* Core system
 
* Core system
 
* Debian package management system
 
* Debian package management system
 
* X11 Windowing System
 
* X11 Windowing System
* Enlightenment desktop manager
+
* Fluxbox desktop manager
 
* Netsurf web browser
 
* Netsurf web browser
 +
* Apache web server
 
* Samba connectivity suite
 
* Samba connectivity suite
* SSH and FTP server and client
+
* SSH server and client
 
* ALSA configuration and usage utilities  
 
* ALSA configuration and usage utilities  
 
* CAN Bus utilities
 
* CAN Bus utilities
 
* Bluetooth tools and daemons
 
* Bluetooth tools and daemons
  
The [[CM-T335: Linux: Getting started|Getting started with Linux on CM-T335]] page provides a brief introduction on how to install the run-time Linux image.
+
The [[CM-T335: Linux: Automatic Linux Installation|Automatic Linux installation on CM-T335]] page provides a brief introduction on how to install the run-time Linux image.
This article describes package structure and peripheral device options specific to the CM-T335.
+
This article describes peripheral device options specific to the CM-T335.
 
 
== Package contents ==
 
 
 
=== version.txt ===
 
The contents of the {{filename|version.txt}} identifies the package version.
 
 
 
=== extra ===
 
* {{filename|sgx_3.2.0-cm-t335-4.5.tar.bz2}} - pre-built [http://downloads.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/gfxsdk/4_10_00_01/index_FDS.html Graphics SDK 4.10.00.01] tarball, that matches the ready to run Linux kernel ({{filename|uImage-3.2.0-cm-t335-4.5.bin}})
 
 
 
=== images ===
 
* {{filename|uImage-cm-t335}} - ready to run Linux kernel image binary for CM-T335
 
* {{filename|debian-image.tar.bz2}} - archive of the Debian root file system
 
* {{filename|kernel.img}} - Kernel image required for installation onto the NAND flash
 
* {{filename|ramdisk.img}} - Ramdisk image required for installation onto the NAND flash
 
* {{filename|bootscr.img}} - U-Boot script used for image installation
 
 
 
=== kernel ===
 
* {{filename|uImage-3.2.0-cm-t335-4.5.bin}} - ready to run Linux kernel version 3.2.0-cm-t335-4.5 for CM-T335
 
* {{filename|linux-3.2.0-cm-t335-4.5.config}} - Linux kernel 3.2.0-cm-t335-4.5 configuration file
 
* {{filename|linux-3.2.0-cm-t335-4.5.patch}} - patch vs. [http://arago-project.org/git/projects/?p=linux-am33x.git;a=commit;h=b81bf04091986fa3893f31955564594567be3b61 b81bf04091986fa3893f31955564594567be3b61] commit in the Linux Integration/Staging Tree for AM33x SoC by Arago progect with support for CM-T335 peripherals
 
* {{filename|patches}} - ordered collection of patches, that form the single patch above ({{filename|linux-3.2.0-cm-t335-4.5.patch}})
 
* {{filename|modules_3.2.0-cm-t335-4.5.tar.bz2}} - a modules tarball, that matches the ready to run Linux kernel ({{filename|uImage-3.2.0-cm-t335-4.5.bin}})
 
 
 
=== utilities ===
 
The {{filename|utilities}} directory contains miscellaneous utilities useful for development
 
* {{filename|tftpd32.zip}} - TFTP server for Windows users
 
* {{filename|eeprom-util}} - CompuLab EEPROM utility for reading information found inside the EEPROM on CompuLab boards
 
* {{filename|ti-utils}} -  TI utility used to calibrate TI WL12xx devices.
 
* {{filename|bootscr.src}} - U-Boot script source used for loading kernel and ramdisk images from MMC/SD card or USB storage device.
 
* {{filename|debian-image.cfg}} - configuration file used by {{filename|ubinize}} utility for {{filename|debian-image.ubi}} generation. For more information about UBIFS images please refer to the [[Linux_Development_for_ARM_modules#UBIFS_images|Linux Development for ARM modules]] article.
 
  
 
== Using Debian Linux on CM-T335 ==
 
== Using Debian Linux on CM-T335 ==
Line 72: Line 43:
 
To configure networking, edit {{filename|/etc/network/interfaces}}, {{filename|/etc/udev/rules.d/70-persistent-net.rules}}, {{filename|/etc/resolv.conf}}, {{filename|/etc/hostname}} and {{filename|/etc/hosts}}. For more information about Debian Linux network configuration read [http://www.debian.org/doc/manuals/reference/ch05.en.html Network setup] chapter in the [http://www.debian.org/doc/manuals/reference/index.en.html Debian Reference].
 
To configure networking, edit {{filename|/etc/network/interfaces}}, {{filename|/etc/udev/rules.d/70-persistent-net.rules}}, {{filename|/etc/resolv.conf}}, {{filename|/etc/hostname}} and {{filename|/etc/hosts}}. For more information about Debian Linux network configuration read [http://www.debian.org/doc/manuals/reference/ch05.en.html Network setup] chapter in the [http://www.debian.org/doc/manuals/reference/index.en.html Debian Reference].
  
=== Consoles ===
+
=== X Windows system ===
The Linux file system image is designed to suit different kernel versions and configurations. Therefore, during the operating system startup, consoles at several serial ports and DVI/LCD display are enabled. Some of these devices may not be supported, either because of kernel versions incompatibilities, or because the kernel was not configured to support these devices. When the console is enabled for such a device, the following or similar message can appear on active console:
+
CompuLab DEMO root filesystem image contains fully featured X server system with Fluxbox window manager.
<pre>
+
Before starting X server, connect USB mouse and keyboard to the system.
INIT: Id "T0" respawning too fast: disabled for 5 minutes
+
You can run X server and Fluxbox window manager by typing startx.
</pre>
+
 
This is not an error message, it is just a warning that can be eliminated by editing {{filename|/etc/inittab}} file.
+
=== Fluxbox window manager ===
  
=== X Windows system ===
+
CM-T335 Debian Linux features installed Fluxbox package - a lightweight window manager for the X server system.
The CompuLab distribution contains full featured X Windows system with Enlightenment 17 window manager.
 
Before starting X Windows, connect USB mouse and keyboard to the system.
 
You can run X Windows by typing '''''startx'''''.
 
  
Enlightenment 17 window manager has a built in configuration set up to work best with phones, tablets and similar devices.
+
* 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 {{parameter|slit}} can be used to dock small applications, e.g. most of the bbtools can use slit.  
To activate the "touchscreen" profile, enter '''Main->Settings Panel->Settings->Profiles'''. Select the '''Touchscreen''' profile.
+
* Fluxbox can iconify windows to the toolbar, in addition to adding the window to the Icons submenu of the workspace menu.
  
To switch back to the standard profile, please see the [[CM-T335: Linux: Known Issues|Known Issues]] article.
+
Visit [http://fluxbox-wiki.org Fluxbox Wiki] and [http://fluxbox.org/ Official home page] for more details.
  
 
=== Software Management ===
 
=== Software Management ===
  
The Debian Linux image for CM-T335 includes all the information required to use Debian package management utilities.
+
Debian Linux image for CM-T335 includes all the information required to use Debian package management utilities.
You can use [http://linux.die.net/man/8/apt-get apt-get] and [http://debian-handbook.info/browse/wheezy/sect.manipulating-packages-with-dpkg.html dpkg] out of the box.
+
You can use [http://linux.die.net/man/8/apt-get apt-get] and [http://linux.die.net/man/1/dpkg dpkg] out of the box.
  
 
=== Touchscreen ===
 
=== Touchscreen ===
 +
The touchscreen driver is modularized if you use default CM-T335 configuration and is loaded by {{filename|udev}} automatically on Linux boot.
 +
 
==== Touchscreen calibration ====
 
==== Touchscreen calibration ====
The supported touchscreen devices can be accessed through symbolic link {{filename|/dev/input/touchscreen}}.
+
A touchscreen device can be calibrated using {{cmd|xinput_calibrator}} utility.
The symlink is created by {{filename|udev}} rules defined in {{filename|/etc/udev/rules.d/10-touchscreen.rules}}.<br>
 
Calibration utilities require proper setting of {{parameter|TSLIB_TSDEVICE}} system variable (pointing to the touchscreen device special file).
 
This is done automatically by the {{filename|/etc/profile.d/tslib.sh}} script.
 
  
Touchscreen calibration can be performed with {{cmd|ts_calibrate}} utility available in package {{filename|libts-bin}}.
 
 
To calibrate the touchscreen:
 
To calibrate the touchscreen:
* Make sure X Server is not running
+
* Run X Server by issuing {{cmd|startx}} command
* Run {{cmd|ts_calibrate}} 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.  
+
* Make sure the touchscreen driver is loaded
The calibration results are saved to file {{filename|/etc/pointercal}}.
+
* Set the {{parameter|DISPLAY}} environment variable:  <pre> export DISPLAY=:0</pre>
* Use {{cmd|ts_test}} utility to test the calibration results.
+
* Run {{cmd|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 {{filename|/usr/share/X11/xorg.conf.d/99-calibration.conf}} and paste there a snippet with the calibration results:
 +
<pre>
 +
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"
 +
EndSection
 +
</pre>
 +
 
 +
=== Analog Audio ===
 +
CM-T335 provides an analog audio interface, which is registered as a standard ALSA sound card.
 +
Use {{cmd|aplay -l}} to list all soundcards and digital audio devices registered on the system:
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
==== Analog Audio Settings ====
 +
To enable the Analog audio playback, {{cmd|alsamixer}} or {{cmd|amixer}} applications can be used.
 +
* {{cmd|alsamixer}} - set the “''Output Mixer''” control on.
 +
or
 +
* {{cmd|amixer}} - set the “''Output Mixer Playback Switch''” control on using command line interface:
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
==== Analog Audio Playback ====
 +
In order to play back a sound file make use of the {{cmd|aplay}} application.
 +
<dl>
 +
* {{cmd|aplay -L}} can be used for listing of all pcm devices.
 +
</dl>
 +
Here is a sample output of {{cmd|aplay -L}} command:
 +
<pre>
 +
root@cm-debian:~# aplay -L
 +
null
 +
    Discard all samples (playback) or generate zero samples (capture)
 +
pulse
 +
    PulseAudio Sound Server
 +
default:CARD=cmt335
 +
    cm-t335,
 +
    Default Audio Device
 +
sysdefault:CARD=cmt335
 +
    cm-t335,
 +
    Default Audio Device
 +
dmix:CARD=cmt335,DEV=0
 +
    cm-t335,
 +
    Direct sample mixing device
 +
dsnoop:CARD=cmt335,DEV=0
 +
    cm-t335,
 +
    Direct sample snooping device
 +
hw:CARD=cmt335,DEV=0
 +
    cm-t335,
 +
    Direct hardware device without any conversions
 +
plughw:CARD=cmt335,DEV=0
 +
    cm-t335,
 +
    Hardware device with all software conversions
 +
</pre>
 +
 
 +
The next command can be used for audio play back:
 +
<pre>
 +
root@cm-debian:~# aplay <wav-file>
 +
</pre>
 +
 
 +
==== Audio Input Settings ====
 +
CM-T335 provides an audio capturing feature from either ''Mic'' or ''Line In'' input sources.
 +
{{cmd|alsamixer}} or {{cmd|amixer}} can be used in order to switch between these inputs.
 +
===== Mic =====
 +
* {{cmd|alsamixer}}
 +
:: Line Input => 100
 +
:: Line => off
 +
:: Mic => on
 +
* {{cmd|amixer}}
 +
<pre>
 +
amixer cset numid=4 31
 +
amixer cset numid=3 0
 +
amixer cset numid=5 1
 +
amixer cset numid=9 1
 +
</pre>
 +
===== Line In =====
 +
* {{cmd|alsamixer}}
 +
:: Line Input => 100
 +
:: Line => on
 +
:: Mic => off
 +
* {{cmd|amixer}}
 +
<pre>
 +
amixer cset numid=4 31
 +
amixer cset numid=3 0
 +
amixer cset numid=5 0
 +
amixer cset numid=9 0
 +
</pre>
 +
 
 +
==== 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 {{cmd|arecord}} usage for capturing audio signal from the selected input line.
 +
<pre>
 +
root@cm-debian:~# arecord -f dat -t wav /tmp/out.wav
 +
</pre>
  
 
=== Bluetooth ===
 
=== Bluetooth ===
  
CM-T335 features Bluetooth 4.0 interface. Following sections describe the initialization and simple use cases of Bluetooth device.
+
CM-T335 features Bluetooth 4.0 interface.
 +
Following sections describe the initialization and simple use cases of Bluetooth device.
  
 
==== Host Controller Interface (HCI) Initialization ====  
 
==== Host Controller Interface (HCI) Initialization ====  
Line 126: Line 206:
 
Bluetooth: HCILL protocol initialized
 
Bluetooth: HCILL protocol initialized
 
Device setup complete
 
Device setup complete
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 148: Line 227:
 
         LMP Version: 4.0 (0x6)  Subversion: 0x1f29
 
         LMP Version: 4.0 (0x6)  Subversion: 0x1f29
 
         Manufacturer: Texas Instruments Inc. (13)
 
         Manufacturer: Texas Instruments Inc. (13)
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
==== A2DP Headphones ====
+
==== 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.
  
* Scan for available devices to find out Headphones BT device address:
+
===== Install and configure PulseAudio =====
 
<pre>
 
<pre>
root@cm-debian:~# hcitool scan
+
root@debian-armhf:~# apt-get update
Scanning ...
+
root@debian-armhf:~# apt-get install pulseaudio pulseaudio-module-bluetooth
00:07:A4:F2:B3:CB Motorola HT820
 
root@cm-debian:~#
 
 
</pre>
 
</pre>
 +
* Create a systemd service for running pulseaudio as the pulse user.
 +
<pre>
 +
root@debian-armhf:~# cat << eof > /etc/systemd/system/pulseaudio.service
 +
[Unit]
 +
Description=Pulse Audio
 +
 +
[Service]
 +
Type=simple
 +
ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm
 +
 +
[Install]
 +
WantedBy=multi-user.target
 +
eof
  
* Add new PCM device by editing {{filename|/etc/asound.conf}}:
+
root@debian-armhf:~# chown pulse:pulse /etc/systemd/system/pulseaudio.service
 +
</pre>
  
 +
* Create a dbus configuration file for running pulseaudio. Give the pulse user permission to use Bluetooth.
 +
<pre>
 +
root@debian-armhf:~# cat << eof > /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
 +
<busconfig>
 +
 +
  <policy user="pulse">
 +
    <allow send_destination="org.bluez"/>
 +
  </policy>
 +
 +
</busconfig>
 +
eof
 +
 +
root@debian-armhf:~# chmod 0666 /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
 +
</pre>
 +
* Paste the following lines to the end of /etc/pulse/system.pa:
 +
<pre>
 +
root@debian-armhf:~# cat << eof >> /etc/pulse/system.pa
 +
### Automatically load driver modules for Bluetooth hardware
 +
.ifexists module-bluetooth-policy.so
 +
load-module module-bluetooth-policy
 +
.endif
 +
 +
.ifexists module-bluetooth-discover.so
 +
load-module module-bluetooth-discover
 +
.endif
 +
eof
 +
</pre>
 +
* Create {{filename|/var/run/pulse/.config/pulse}} directory and fix the ownership.
 +
<pre>
 +
root@debian-armhf:~# mkdir -p /var/run/pulse/.config/pulse
 +
root@debian-armhf:~# chown -R pulse:pulse /var/run/pulse
 +
</pre>
 +
* Add root to the pulse-access,audio groups
 
<pre>
 
<pre>
pcm.btheadphones {
+
root@debian-armhf:~# usermod -a -G pulse-access,audio root
  type plug
 
  slave {
 
      pcm {
 
          type bluetooth
 
          device 00:07:A4:F2:B3:CB
 
          profile "auto"
 
      }
 
  }
 
  hint {
 
      show on
 
      description "BT Headphones"
 
  }
 
}
 
ctl.btheadphones {
 
  type bluetooth
 
}
 
 
</pre>
 
</pre>
  
* List device names to ensure correct settings in {{filename|/etc/asound.conf}}:
+
===== Start PulseAudio =====
 +
* Start PulseAudio service
 +
<pre>
 +
root@debian-armhf:~# systemctl daemon-reload
 +
root@debian-armhf:~# systemctl start pulseaudio.service
 +
</pre>
 +
* Make sure that the service is active, running and reports no error.
 
<pre>
 
<pre>
root@cm-debian:~# aplay -L
+
root@debian-armhf:~# systemctl status pulseaudio.service
null
+
  Loaded: loaded (/etc/systemd/system/pulseaudio.service; disabled)
    Discard all samples (playback) or generate zero samples (capture)
+
  Active: active (running) since Mon 2015-07-20 12:00:13 UTC; 1min 34s ago
btheadphones
+
Main PID: 805 (pulseaudio)
    BT Headphones
+
  CGroup: /system.slice/pulseaudio.service
default:CARD=cmt335
+
          └─805 /usr/bin/pulseaudio --system --disallow-exit --disable-shm
    cm-t335,
 
    Default Audio Device
 
sysdefault:CARD=cmt335
 
    cm-t335,
 
    Default Audio Device
 
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
* Put the headphones in the pairing mode and launch {{filename|bluez-simple-agent}} application and provide device PIN code on request:
+
===== Bluez5 pairing =====
 +
PulseAudio 5.x supports A2DP by default.
 +
Make sure the following packages are installed:
 +
{{filename|pulseaudio}}, {{filename|pulseaudio-module-bluetooth}}, {{filename|pulseaudio-utils}}, {{filename|bluez}}, {{filename|bluez-tools}}.
 +
* Start the Bluetooth system:
 
<pre>
 
<pre>
root@cm-debian:~# bluez-simple-agent hci0 00:07:A4:F2:B3:CB
+
root@debian-armhf:~# systemctl start bluetooth
RequestPinCode (/org/bluez/1194/hci0/dev_00_07_A4_F2_B3_CB)
+
</pre>
Enter PIN Code: 0000
+
Now we can use the {{cmd|bluetoothctl}} command line utility to pair and connect. Run
Release
+
<pre>
New device (/org/bluez/1194/hci0/dev_00_07_A4_F2_B3_CB)
+
root@debian-armhf:~# bluetoothctl
root@cm-debian:~#  
+
[bluetooth]#
 +
</pre>
 +
to be greeted by its internal command prompt. Then enter:
 +
<pre>
 +
[bluetooth]# power on
 +
[bluetooth]# agent on
 +
[bluetooth]# default-agent
 +
[bluetooth]# scan on
 +
</pre>
 +
Make sure that an A2DP device is in pairing mode. It should be discovered shortly. For example,
 +
<pre>
 +
[NEW] Device 00:07:A4:F2:B3:CB Motorola HT820
 +
</pre>
 +
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:
 +
<pre>
 +
[bluetooth]# pair 00:07:A4:F2:B3:CB
 +
</pre>
 +
After pairing, connect the device:
 +
<pre>
 +
[bluetooth]# connect 00:07:A4:F2:B3:CB
 +
</pre>
 +
After the successful connection, the new output device will be created in PulseAudio.<br>
 +
Scanning can be disabled now:
 +
<pre>
 +
[bluetooth]# scan off
 +
</pre>
 +
Exit the program:
 +
<pre>
 +
[bluetooth]# exit
 
</pre>
 
</pre>
  
* Launch {{filename|aplay}} playback tool:
+
===== Playback using PulseAudio =====
 +
{{Note|Next examples assume that the device mac address is '''00_07_A4_F2_B3_CB'''}}
 +
* Show the PulseAudio device
 +
<pre>
 +
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
 +
        Properties:
 +
                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"
 +
        Profiles:
 +
                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
 +
        Ports:
 +
                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)
 +
</pre>
 +
:* Make sure the active card profile is a2dp_sink. Otherwise switch to it:
 +
<pre>
 +
# pactl set-card-profile 1 a2dp
 +
</pre>
 +
:* Show the PulseAudio sink
 +
<pre>
 +
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
 +
        Flags: HARDWARE DECIBEL_VOLUME LATENCY
 +
        Properties:
 +
                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"
 +
        Ports:
 +
                headset-output: Headset (priority: 0)
 +
        Active Port: headset-output
 +
        Formats:
 +
                pcm
 +
</pre>
 +
:* Play sound using {{filename|paplay}}. Example:
 
<pre>
 
<pre>
root@cm-debian:~# aplay -D btheadphones <audio-file.wav>
+
root@debian-armhf:~# paplay -d bluez_sink.00_07_A4_F2_B3_CB /path/to/<audio-file.wav>
 
</pre>
 
</pre>
  
Line 224: Line 437:
 
Scanning ...
 
Scanning ...
 
00:15:2A:20:63:94 Nokia 6230i
 
00:15:2A:20:63:94 Nokia 6230i
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 248: Line 460:
 
   "OBEX File Transfer" (0x1106)
 
   "OBEX File Transfer" (0x1106)
 
     Version: 0x0100
 
     Version: 0x0100
 
root@cm-debian:~#
 
</pre>
 
 
* Pair the device - provide PIN code upon request and confirm permission request on the phone:
 
<pre>
 
root@cm-debian:~# bluez-simple-agent hci0 00:15:2A:20:63:94
 
RequestPinCode (/org/bluez/1285/hci0/dev_00_15_2A_20_63_94)
 
Enter PIN Code: 1937
 
Release
 
New device (/org/bluez/1285/hci0/dev_00_15_2A_20_63_94)
 
 
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
{{Note|You can launch {{cmd|bluez-simple-agent}} with no parameters. The agent is tracking requests to all bluetooth devices and triggers pin code confirmation when needed.}}
+
* Follow the section "Bluez5 pairing" to pair the CM-T335 module with the phone.
 
 
 
* List phone's root folder:
 
* List phone's root folder:
 
<pre>
 
<pre>
Line 286: Line 484:
 
done
 
done
 
Disconnecting..-done
 
Disconnecting..-done
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 297: Line 494:
 
Sending "test_file.txt"...|done
 
Sending "test_file.txt"...|done
 
Disconnecting../done
 
Disconnecting../done
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 308: Line 504:
 
Receiving "test_file.txt".../done
 
Receiving "test_file.txt".../done
 
Disconnecting..-done
 
Disconnecting..-done
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 317: Line 512:
 
* The WL12xx WLAN driver gets loaded automatically. Make sure that the WLAN driver is loaded:
 
* The WL12xx WLAN driver gets loaded automatically. Make sure that the WLAN driver is loaded:
 
<pre>
 
<pre>
root@cm-debian:~# lsmod | grep wl12xx_spi
+
root@cm-debian:~# lsmod | grep wl12xx
wl12xx_spi              4527 0  
+
wl12xx                57190 0  
wl12xx               167292 1 wl12xx_spi
+
wlcore               180594 1 wl12xx
 +
mac80211              605465  2 wl12xx,wlcore
 
</pre>
 
</pre>
 
If the WLAN driver has not been loaded automatically, it can be loaded manually:
 
If the WLAN driver has not been loaded automatically, it can be loaded manually:
 
<pre>
 
<pre>
root@cm-debian:~# modprobe wl12xx_spi
+
root@cm-debian:~# modprobe wl12xx
cfg80211: Calling CRDA to update world regulatory domain
+
root@cm-debian:~# [  360.085386] wlcore: loaded
wl1271: loaded
 
 
</pre>
 
</pre>
* {{cmd|iwconfig}} command from {{cmd|wireless-tools}} packge can be used to retrieve detailed information about WLAN interfaces:
+
* {{cmd|iwconfig}} command from {{filename|wireless-tools}} package can be used to retrieve detailed information about WLAN interfaces:
 
<pre>
 
<pre>
 
root@cm-debian:~# iwconfig wlan0
 
root@cm-debian:~# iwconfig wlan0
Line 346: Line 541:
 
</pre>
 
</pre>
 
The output will show the list of Access Points and Ad-Hoc cells in range.
 
The output will show the list of Access Points and Ad-Hoc cells in range.
For more information about connecting to wireless networks and tunning WLAN interfaces refer to “wpa_supplicant” and “wireless-tools” man pages.
+
For more information about connecting to wireless networks and tuning WLAN interfaces refer to “wpa_supplicant” and “wireless-tools” man pages.
  
 
==== WL12xx calibration tool ====
 
==== WL12xx calibration tool ====
Line 360: Line 555:
 
MAC addr from NVS: de:ad:be:ef:00:00
 
MAC addr from NVS: de:ad:be:ef:00:00
 
</pre>
 
</pre>
{{Note|The CM-T335 WLAN MAC address is initialized from the chip fuse, not from NVS file.}}
+
{{Note|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.}}
 +
 
 +
==== wpa_supplicant ====
 +
* Configuration sample
 +
{{cmd|wpa_supplicant}} requires a configuration file to be created in order to get connected to a scanned wireless network.<br>
 +
Make use of the example bellow and put the network name and the password into the "ssid/psk" fields.
 +
 
 +
<pre>
 +
root@cm-debian:~# cat << eof > /etc/wpa_supplicant.conf
 +
ctrl_interface=/var/run/wpa_supplicant
 +
 
 +
network={
 +
ssid="wireless_network_name"
 +
key_mgmt=WPA-PSK
 +
psk="wireless_network_password"
 +
}
 +
eof
 +
</pre>
 +
* Sample run
 +
<pre>
 +
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
 +
</pre>
  
 
=== Controller–area network (CAN) ===
 
=== Controller–area network (CAN) ===
Line 371: Line 589:
 
<pre>
 
<pre>
 
root@cm-debian:~# modprobe can-raw
 
root@cm-debian:~# modprobe can-raw
can: raw protocol (rev 20090105)
+
can: controller area network core (rev 20120528 abi 9)
root@cm-debian:~#
+
NET: Registered protocol family 29
 +
can: raw protocol (rev 20120528)
 
</pre>
 
</pre>
 
* Load Broadcast Manager CAN protocol module:
 
* Load Broadcast Manager CAN protocol module:
 
<pre>
 
<pre>
 
root@cm-debian:~# modprobe can-bcm
 
root@cm-debian:~# modprobe can-bcm
can: broadcast manager protocol (rev 20090105 t)
+
can: broadcast manager protocol (rev 20120528 t)
root@cm-debian:~#
 
 
</pre>
 
</pre>
 
* Load D_CAN driver module:
 
* Load D_CAN driver module:
 
<pre>
 
<pre>
 
root@cm-debian:~# modprobe d_can_platform
 
root@cm-debian:~# modprobe d_can_platform
CAN bus driver for Bosch D_CAN controller 1.0
+
[  130.295962] d_can d_can.0: device registered (irq=52, irq_obj=53)
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)
d_can d_can.1: device registered (irq=55, irq_obj=56)
 
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
For information on enabling CAN kernel support, please, see the [[CM-T335:_Linux:_Kernel#Controller.E2.80.93area_network_.28CAN.29_support|Linux Kernel for CM-T335]] page.
+
For information on enabling CAN kernel support, please, see the [[CM-T335: Linux: Kernel#Controller.E2.80.93area_network_.28CAN.29_support|Linux Kernel for CM-T335]] page.
  
 
===== CAN interface configuration =====
 
===== CAN interface configuration =====
Line 397: Line 613:
 
<pre>
 
<pre>
 
root@cm-debian:~# ip -V
 
root@cm-debian:~# ip -V
ip utility, iproute2-ss100519
+
ip utility, iproute2-ss140804
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 404: Line 619:
 
<pre>
 
<pre>
 
root@cm-debian:~# ip link set can0 type can bitrate 125000
 
root@cm-debian:~# ip link set can0 type can bitrate 125000
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 410: Line 624:
 
<pre>
 
<pre>
 
root@cm-debian:~# ip link set can0 up
 
root@cm-debian:~# ip link set can0 up
d_can d_can.0: can0: setting CAN BT = 0x518
+
c_can_platform 481cc000.can can0: setting BTR=0518 BRPE=0000
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 421: Line 634:
 
<pre>
 
<pre>
 
root@cm-debian:~# cansend can0 111#1122334455667788
 
root@cm-debian:~# cansend can0 111#1122334455667788
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 427: Line 639:
 
<pre>
 
<pre>
 
root@cm-debian:~# cansend can0 11111111#1122334455667788
 
root@cm-debian:~# cansend can0 11111111#1122334455667788
root@cm-debian:~#
 
 
</pre>
 
</pre>
  
Line 449: Line 660:
 
</pre>
 
</pre>
 
{{Note|The above example assumes that the corresponding pin is set to mux {{parameter|mode 7}} and the GPIO 64 is '''not''' requested in the Linux kernel.}}
 
{{Note|The above example assumes that the corresponding pin is set to mux {{parameter|mode 7}} and the GPIO 64 is '''not''' requested in the Linux kernel.}}
 
=== Graphics SDK ===
 
The CM-T335 Linux package contains pre-built and ready to run SGX functionality demo programs.
 
* The SGX configuration script must be run on CM-T335 before '''first use''':
 
<pre>
 
root@cm-debian:~# /etc/init.d/335x-demo
 
</pre>
 
 
* The SGX kernel modules must be loaded prior running the demos:
 
<pre>
 
root@cm-debian:~# /etc/init.d/rc.pvr start
 
</pre>
 
 
==== Running Graphics SDK OpenGL ES1.x Demos ====
 
* To run OpenGL ES1.x demos, perform the following:
 
<pre>
 
root@cm-debian:~# cd /opt/gfxsdkdemos/ogles
 
root@cm-debian:/opt/gfxsdkdemos/ogles# ./OGLESEvilSkull
 
</pre>
 
This will execute the {{filename|OGLESEvilSkull}} demo. Press {{parameter|‘q’}} on the CM-T335 console to stop the demo execution.
 
 
==== Running Graphics SDK OpenGL ES2.0 Demos ====
 
* To run OpenGL ES2.x demos, perform the following:
 
<pre>
 
root@cm-debian:~# cd /opt/gfxsdkdemos/ogles2
 
root@cm-debian:/opt/gfxsdkdemos/ogles2# ./OGLES2FilmTV
 
</pre>
 
This will execute the {{filename|OGLESFilmTV}} demo. Press {{parameter|‘q’}} on the CM-T335 console to stop the demo
 
execution.
 
  
 
== See also ==
 
== See also ==
* [[CM-T335: Linux: Getting started]]
+
* [[CM-T335: Linux: Automatic Linux Installation|Automatic Linux installation on CM-T335]]
* [[CM-T335: Linux: Kernel]]
+
* [[CM-T335: Linux: Kernel|Linux Kernel for CM-T335]]
 
* [[Linux: Development for ARM modules]]
 
* [[Linux: Development for ARM modules]]
 
* [[Linux: Debian: Minimal ARM filesystem]]
 
* [[Linux: Debian: Minimal ARM filesystem]]

Latest revision as of 06:32, 25 January 2017

Overview

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).

Networking

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.

Touchscreen

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"
EndSection

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.

or

  • 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
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
default:CARD=cmt335
    cm-t335, 
    Default Audio Device
sysdefault:CARD=cmt335
    cm-t335, 
    Default Audio Device
dmix:CARD=cmt335,DEV=0
    cm-t335, 
    Direct sample mixing device
dsnoop:CARD=cmt335,DEV=0
    cm-t335, 
    Direct sample snooping device
hw:CARD=cmt335,DEV=0
    cm-t335, 
    Direct hardware device without any conversions
plughw:CARD=cmt335,DEV=0
    cm-t335, 
    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.

Mic
  • 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

Bluetooth

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
        UP RUNNING PSCAN 
        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
[Unit]
Description=Pulse Audio

[Service]
Type=simple
ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm

[Install]
WantedBy=multi-user.target
eof

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
<busconfig>

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

</busconfig>
eof

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

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
eof
  • 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
[bluetooth]#

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
        Properties:
                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"
        Profiles:
                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
        Ports:
                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
        Flags: HARDWARE DECIBEL_VOLUME LATENCY 
        Properties:
                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"
        Ports:
                headset-output: Headset (priority: 0)
        Active Port: headset-output
        Formats:
                pcm
  • 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 ...
Connecting..\done
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"/>
</folder-listing>
done
Disconnecting..-done
  • 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 ...
Connecting..\done
Tried to connect for 380ms
Sending "test_file.txt"...|done
Disconnecting../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 ...
Connecting..\done
Tried to connect for 267ms
Receiving "test_file.txt".../done
Disconnecting..-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 6.3.0.0.77)
  • 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.

wpa_supplicant

  • 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
ctrl_interface=/var/run/wpa_supplicant

network={
	ssid="wireless_network_name"
	key_mgmt=WPA-PSK
	psk="wireless_network_password"
}
eof
  • 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.

Example

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