CM-FX6: Linux: Debian

From Compulab Mediawiki
Jump to: navigation, search

Overview

The example run-time Linux filesystem image for the CompuLab CM-FX6 System-on-Module / Computer-on-Module is based on Debian GNU/Linux Stretch. The CompuLab Linux package for CM-FX6 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 Stretch Linux image includes more than 400 software packages. Among them:

  • Core system
  • Debian package management system
  • X11 Windowing System
  • Fluxbox desktop manager
  • SSH server and client
  • PulseAudio configuration and usage utilities
  • CAN Bus utilities
  • Bluez5 Bluetooth tools and daemons
  • iw/wpasupplicant wireless tools

The Getting started with Linux on CM-FX6 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-FX6.


Using Debian Linux on CM-FX6

Connection and Logging In

Use the following username to login:

Account with administrative privileges:

User: root

To login into the Linux system, you may use a serial console (ttymxc3) at 115200 bps, or connect through the network (ssh), or use a keyboard and DVI/LCD/HDMI display (tty1, tty2, tty3, tty4).

root password

This Debian rootfs comes w/out default root password.
The root password has to be set at the very 1-st login:

Debian GNU/Linux stretch/sid imx6-sid ttymxc3

imx6-sid login: root
You are required to change your password immediately (root enforced)
Enter new UNIX password:

Networking

SBC-FX6 allows using two network interfaces:

  • FEC

This is an internal iMX6 SoC NIC (accessible in U-Boot). A network interface assigned for this device gets named eth0.

  • i211

This is an external NIC resides on SB-FX6. In order to make it work, the SB-FX6 P31 jumper must be open. A network interface assigned for this device gets named enp1s0.
A udev rule can be used for renaming this device into a convenient ethX name. Here is a rule:

cat << eof >> /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:0x0x1539 (i211)
SUBSYSTEM=="net", ACTION=="add", ATTRS{vendor}=="0x8086", ATTRS{device}=="0x1539", KERNEL=="eth*", NAME="eth1"
eof

Applying the rule w/out a reboot:

udevadm control --reload
modprobe igb -r
modprobe igb

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:

The majority of network setup can be done via the interfaces configuration file at /etc/network/interfaces.

Admolition note.png auto line is required for interfaces that have to be brought up at boot time.
  • Using DHCP to automatically configure the interface
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
  • Configuring the interface manually
auto eth0
    iface eth0 inet static
        address 192.168.1.170
        netmask 255.255.0.0
        gateway 192.0.0.1

Consoles

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. systemd is able to configure most of them. Detail information can be found here:

X Windows system

The CompuLab distribution contains full featured X Windows system with Fluxbox window manager. Before starting X Windows, connect USB mouse and keyboard to the system. You can run X Windows by typing startx.

Software Management

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

Audio Outputs

CM-FX6 provides free different audio interfaces. These interfaces registered as standard ALSA sound cards. If the default CM-FX6 configuration is used, all audio drivers are loaded automatically in the boot process. More information about Linux audio subsystem can be found at ALSA project official website.

aplay -l shows list of all soundcards and digital audio devices registered on the system. Here is an aplay -l sample output.
**** List of PLAYBACK Hardware Devices ****
card 0: cmfx6 [cm-fx6], device 0: 202c000.ssi-wm8731-hifi wm8731-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: imxhdmisoc [imx-hdmi-soc], device 0: i.MX HDMI Audio Tx hdmi-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: imxspdif [imx-spdif], device 0: S/PDIF PCM snd-soc-dummy-dai-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Default Audio Device

The default audio interface in this Linux dsistribution is cm-fx6.

Analog Audio

The CM-FX6 analog audio functionality is implemented by interfacing the Wolfson wm8731 audio codec with i.MX6 AUDMUX port 4. The interface controls:

# amixer controls
numid=2,iface=MIXER,name='Master Playback ZC Switch'
numid=1,iface=MIXER,name='Master Playback Volume'
numid=4,iface=MIXER,name='Line Capture Switch'
numid=5,iface=MIXER,name='Mic Boost Volume'
numid=6,iface=MIXER,name='Mic Capture Switch'
numid=8,iface=MIXER,name='ADC High Pass Filter Switch'
numid=3,iface=MIXER,name='Capture Volume'
numid=10,iface=MIXER,name='Playback Deemphasis Switch'
numid=11,iface=MIXER,name='Input Mux'
numid=14,iface=MIXER,name='Output Mixer HiFi Playback Switch'
numid=12,iface=MIXER,name='Output Mixer Line Bypass Switch'
numid=13,iface=MIXER,name='Output Mixer Mic Sidetone Switch'
numid=7,iface=MIXER,name='Sidetone Playback Volume'
numid=9,iface=MIXER,name='Store DC Offset Switch'
  • Analog Audio Settings.

wm8731 codec has a controll named as “Output Mixer HiFi Playback Switch”. This controll has two values: 0/1 - On/Off. The default value is '0'. Turn it on in order to unmute the analog output. Issue this command:

# amixer cset numid=14,iface=MIXER,name='Output Mixer HiFi Playback Switch' on

Save the card state in order to make these settings permanent.

# alsactl store cm-fx6
  • Playback using wm8731 output:
# aplay -D hw:0,0 <wav-file>

HDMI

Admolition note.png The HDMI audio will work only if the HDMI cable is plugged in.

The interface controls:

# amixer -c 1 controls
numid=1,iface=MIXER,name='IEC958 Playback Default'
numid=2,iface=MIXER,name='HDMI Support Channels'
numid=4,iface=MIXER,name='HDMI Support Formats'
numid=3,iface=MIXER,name='HDMI Support Rates'

Playback using HDMI output:

# aplay -D hw:1,0 <wav-file>

SPDIF

The Sony/Philips Digital Interface (SPDIF) module is a stereo that allows the processor transmit digital audio over it using the IEC60958 standard, consumer format. i.MX 6Dual/6Quad provides one SPDIF transmitter with one output and one SPDIF receiver with one input.

  • SB-FX6 P40 is SPDIF OUT
  • SB-FX6 P47 is SPDIF IN
Admolition note.png The SPDIF audio will work only if the SPDIF cable is plugged in.

The interface controls:

# amixer -c 2 controls
numid=1,iface=MIXER,name='IEC958 Playback Default'
numid=2,iface=PCM,name='IEC958 Capture Default'
numid=4,iface=PCM,name='IEC958 Q-subcode Capture Default'
numid=3,iface=PCM,name='IEC958 Subcode Capture Default'
numid=7,iface=PCM,name='IEC958 USyncMode CDText'
numid=5,iface=PCM,name='IEC958 V-Bit Errors'
numid=6,iface=PCM,name='RX Sample Rate'

Playback using SPDIF output:

# aplay -D hw:2,0 <wav-file>

Sound Capture Devices

arecord -l shows all devices that can be used for audio capturing.

# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: cmfx6 [cm-fx6], device 0: 202c000.ssi-wm8731-hifi wm8731-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: imxspdif [imx-spdif], device 0: S/PDIF PCM snd-soc-dummy-dai-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Analog Audio Recording

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

  • Set bitrate options:
# export RATE_OPT="--rate=32000"
  • Line In recording:
# : Line In recording
amixer cset numid=3 31
amixer cset numid=4 1
amixer cset numid=6 0
amixer cset numid=11 0
: Filters
amixer cset numid=8 1
amixer cset numid=10 1
: Line Output ByPass On
amixer cset numid=12 1
: Mic Output ByPass Off
amixer cset numid=13 0
: Recording
arecord -f cd -t wav --duration=30 ${RATE_OPT} /tmp/file.vaw
  • Mic In recording:
# : Mic In recording
amixer cset numid=3 31
amixer cset numid=4 0
amixer cset numid=6 1
amixer cset numid=11 1
: Filters
amixer cset numid=8 1
amixer cset numid=10 1
: Line Output ByPass Off
amixer cset numid=12 0
: Mic Output ByPass On
amixer cset numid=13 1
: Recording
arecord -f cd -t wav --duration=30 ${RATE_OPT} /tmp/file.vaw
  • Playback a recorded file:
# aplay -vv /tmp/file.wav

Controller–area network (CAN)

CM-FX6 features two CAN bus interfaces. The CAN bus interfaces are implemented with the i.MX6 on chip “Flexible Controller Area Network” (FlexCAN) communication modules. FlexCAN supports the following main features:

  • Compliant with the CAN 2.0B protocol specification
  • Programmable bit rate up to 1 Mb/sec

For information on enabling CAN kernel support, please, see the Linux Kernel for CM-FX6 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:
# ip -V
ip utility, iproute2-ss140804
  • Configure the CAN interface bit-rate to 125 Kbits/sec (values of up to 1Mbit/sec are supported):
# ip link set can0 type can bitrate 125000
  • Enable the CAN interface:
# ip link set can0 up
flexcan imx6q-flexcan.0: writing ctrl=0x0e312005
Send/Receive packets

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

  • Send standard CAN frame (on the first device):
# cansend can0 111#1122334455667788
  • Send extended CAN frame (on the first device):
# cansend can0 11111111#1122334455667788
  • Dump all received data frames as well as error frames (on the second device):
# 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

USB On-The-Go (OTG)

CM-FX6 features a high-speed USB 2.0 OTG controller. CM-FX6 OTG port is USB host and USB device (gadget) capable.
In CM-FX6 default kernel configuration, the USB host driver is compiled into the kernel, whereas USB gadget drivers are compiled as modules.
Gadget drivers should be loaded for OTG support.
Default CM-FX6 kernel configuration enables g_serial, g_file_storage, g_ether and g_audio gadget drivers. Additional gadget drivers can be enabled in the kernel configuration.

Testing OTG port

Host mode

Connect a USB keyboard to the OTG port P48 using a UsbOTGAdapter. Make sure that the device was recognized by the system. Evaluate lsusb and dmesg outputs.

# lsusb
Bus 002 Device 002: ID 413c:2106 Dell Computer Corp. Dell QuietKey Keyboard
# dmesg
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 low-speed USB device number 2 using ci_hdrc
input: Dell Dell QuietKey Keyboard as /devices/soc0/soc/2100000.aips-bus/2184000.usb/ci_hdrc.0/usb2/2-1/2-1:1.0/0003:413C:2106.0004/input/input4
hid-generic 0003:413C:2106.0004: input: USB HID v1.10 Keyboard [Dell Dell QuietKey Keyboard] on usb-ci_hdrc.0-1/input0
Gadget mode
  • g_audio
# modprobe g_audio
g_audio gadget: Hardware params: access 3, format 2, channels 2, rate 48000
g_audio gadget: Linux USB Audio Gadget, version: Feb 2, 2012
g_audio gadget: g_audio ready

Connect a desktop PC to the OTG port.

g_audio gadget: high speed config #1: Linux USB Audio Gadget

In case the desktop PC is running Linux, this gadget will show up in the aplay -l and lsusb}:

# : Desktop PC shell
# aplay -l | awk '/Gadget/,0'
card 3: Gadget [Linux USB Audio Gadget], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
# lsusb  | awk '/Gadget/'
Bus 001 Device 111: ID 1d6b:0101 Linux Foundation Audio Gadget
  • Playback using the USB Gabget:

The sound goes to the SB-FX6 J3 audio out.

# aplay -D hw:3,0 <wav-file>
  • g_mass_storage
# modprobe g_mass_storage file=/dev/sdb
	Mass Storage Function, version: 2009/09/11
	LUN: removable file: (no medium)
	LUN: file: /dev/sdb
	Number of LUNs=1
	g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
	g_mass_storage gadget: userspace failed to provide iSerialNumber
	g_mass_storage gadget: g_mass_storage ready
	g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage

Connect desktop PC to OTG port.
In case the desktop PC is running Linux, this gadget will show up in the lsusb list:

# lsusb
...
Bus 001 Device 117: ID 0525:a4a5 Netchip Technology, Inc. Pocketbook Pro 903
...

The new device information shows up in the system log.

# dmesg
[93333.477394] usb 1-1.2.4: new high-speed USB device number 119 using ehci-pci
[93333.587166] usb 1-1.2.4: New USB device found, idVendor=0525, idProduct=a4a5
[93333.587172] usb 1-1.2.4: New USB device strings: Mfr=3, Product=4, SerialNumber=0
[93333.587175] usb 1-1.2.4: Product: Mass Storage Gadget
[93333.587177] usb 1-1.2.4: Manufacturer: Linux 4.1.15-cm-fx6-8.0 with 2184000.usb
[93333.595095] usb-storage 1-1.2.4:1.0: USB Mass Storage device detected
[93333.595371] usb-storage 1-1.2.4:1.0: Quirks match for vid 0525 pid a4a5: 10000
[93333.595505] scsi host74: usb-storage 1-1.2.4:1.0
[93334.594259] scsi 74:0:0:0: Direct-Access     Linux    File-Stor Gadget 0401 PQ: 0 ANSI: 2
[93334.594924] sd 74:0:0:0: Attached scsi generic sg8 type 0
[93334.596081] sd 74:0:0:0: [sdi] 7813120 512-byte logical blocks: (4.00 GB/3.73 GiB)
[93334.697138] sd 74:0:0:0: [sdi] Write Protect is off
[93334.697146] sd 74:0:0:0: [sdi] Mode Sense: 0f 00 00 00
[93334.807116] sd 74:0:0:0: [sdi] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
  • g_ether
# modprobe g_ether
	using random self ethernet address
	using random host ethernet address
	usb0: HOST MAC 9a:6b:67:42:a2:07
	usb0: MAC a2:3f:2a:96:aa:18
	using random self ethernet address
	using random host ethernet address
	g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
	g_ether gadget: g_ether ready
	g_ether gadget: high-speed config #1: CDC Ethernet (ECM)

In case the desktop PC is running Linux, this gadget will show up in the lsusb list:

# lsusb
...
Bus 001 Device 120: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget
...

A new network interface turns out in the ((cmd list:

usb0      Link encap:Ethernet  HWaddr 8a:d5:23:f0:e4:d5  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  • g_serial
# modprobe g_serial
	g_serial gadget: Gadget Serial v2.4
	g_serial gadget: g_serial ready
	g_serial gadget: high-speed config #2: CDC ACM config

In case the desktop PC is running Linux, this gadget will show up in the lsusb list:

# lsusb
...
Bus 001 Device 122: ID 0525:a4a7 Netchip Technology, Inc. Linux-USB Serial Gadget (CDC ACM mode)
...

The new device information shows up in the system log.

# dmesg
[93774.027732] usb 1-1.2.4: new high-speed USB device number 122 using ehci-pci
[93774.137513] usb 1-1.2.4: New USB device found, idVendor=0525, idProduct=a4a7
[93774.137519] usb 1-1.2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[93774.137522] usb 1-1.2.4: Product: Gadget Serial v2.4
[93774.137524] usb 1-1.2.4: Manufacturer: Linux 4.1.15-cm-fx6-8.0 with 2184000.usb
[93774.201770] cdc_acm 1-1.2.4:2.0: ttyACM0: USB ACM device
[93774.202155] usbcore: registered new interface driver cdc_acm
[93774.202158] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

WiFi

CM-FX6 features 802.11b/g/n wireless connectivity solution, implemented with the AzureWave AW-NH387 Wireless controller module.

WiFi Initialization

  • WiFi requires no user interaction for being configured. The driver gets loaded automatically.

Make sure that the WiFi driver is loaded:

# lsmod | grep mwifiex
mwifiex_sdio           12214  0 
mwifiex               113596  1 mwifiex_sdio

The WiFi driver can be loaded manually:

# modprobe mwifiex_sdio
mwifiex_sdio mmc1:0001:1: WLAN FW already running! Skip FW download
mwifiex_sdio mmc1:0001:1: WLAN FW is active
mwifiex_sdio mmc1:0001:1: info: successfully registered wiphy device
mwifiex_sdio mmc1:0001:1: info: mlan0: Marvell 802.11 Adapter
mwifiex_sdio mmc1:0001:1: driver_version = mwifiex 1.0 (14.57.5.p44) 
  • iwconfig command from wireless-tools package can be used to retrieve detailed information about the WiFi interfaces:
# iwconfig mlan0
mlan0     IEEE 802.11bgn  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
  • Activate the interface:
# ifconfig mlan0 up
  • Sample WiFi scanning:
# iwlist mlan0 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 WiFi interfaces refer to “wpa_supplicant” and “wireless-tools” man pages.

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.

# 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
# ifconfig mlan0 up
# wpa_supplicant -B -Dwext -c /etc/wpa_supplicant.conf -i mlan0
# dhclient mlan0

Bluetooth

CM-FX6 features Bluetooth 3.0 + High Speed (HS) interface. Following sections describe the initialization and simple use cases of the Bluetooth interface.

Host Controller Interface (HCI) Initialization

  • HCI requires no user interaction for being configured. The driver gets loaded automatically unless this option has been disabled by putting a black list rule for this device.

Make sure that the Bluetooth driver is loaded:

# lsmod | grep btmrvl
btmrvl_sdio             9024  0 
btmrvl                 10572  3 btmrvl_sdio

The Bluetooth driver can be loaded manually:

# modprobe btmrvl_sdio
Bluetooth: vendor=0x2df, device=0x911a, class=255, fn=2
  • HCI device configuration utility can be run to retrieve detailed information about the Bluetooth interfaces:
# hciconfig -a
hci0:	Type: BR/EDR  Bus: SDIO
	BD Address: 4C:AA:16:66:C4:E0  ACL MTU: 1021:7  SCO MTU: 120:6
	UP RUNNING PSCAN 
	RX bytes:1136 acl:0 sco:0 events:40 errors:0
	TX bytes:1546 acl:0 sco:0 commands:39 errors:0
	Features: 0xff 0xee 0x8f 0xfe 0x9b 0xff 0x79 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV3 
	Link policy: RSWITCH HOLD SNIFF 
	Link mode: SLAVE ACCEPT 
	Name: 'cm-debian-0'
	Class: 0x4a0100
	Service Classes: Networking, Capturing, Telephony
	Device Class: Computer, Uncategorized
	HCI Version: 2.1 (0x4)  Revision: 0x8300
	LMP Version: 2.1 (0x5)  Subversion: 0x810
	Manufacturer: Marvell Technology Group Ltd. (72)
  • If the HCI device is not running, use the below command to enable the HCI device:
# hciconfig hci0 up

Bluez5 & PulseAudio

Debian is using BlueZ 5 and PluseAudio 5, which are fairly new.
BlueZ 5 dropped support for alsa, so the solution for now is to use PulseAudio.
PulseAudio 5 only supports the A2DP profile and not HSP/HFP.

  • Software to install pulseaudio, pulseaudio-module-bluetooth
Admolition note.png debian-image.tar.bz2 has all these packages pre-installed.
# apt-get install --no-install-recommends pulseaudio pulseaudio-module-bluetooth
  • Create a systemd service for running pulseaudio as the pulse user.
# 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

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

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

</busconfig>
eof

# chmod 0666 /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
  • Paste the following lines to the end of /etc/pulse/system.pa:
# 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. Change its ownership.
# mkdir -p /var/run/pulse/.config/pulse
# chown -R pulse:pulse /var/run/pulse
  • Make the root belong to the pulse-access,audio groups
# usermod -a -G pulse-access,audio root
  • Start PulseAudio service
# systemctl daemon-reload
# systemctl start pulseaudio.service
  • Make sure that the service is active, running and reports on no errors.
# 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 per default.
Make sure the following packages are installed: pulseaudio pulseaudio-module-bluetooth pulseaudio-utils, bluez, bluez-tools.

Admolition note.png Without pulseaudio-module-bluetooth you won't be able to connect after the next pairing and you won't get any usable error messages.
  • Start the Bluetooth system:
# systemctl start bluetooth

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

# bluetoothctl

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

# power on
# agent on
# default-agent
# scan on

Now make sure that your headset 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. We will now use that MAC address to initiate the pairing:

# pair 00:07:A4:F2:B3:CB

After pairing, you also need to explicitly connect the device (every time?):

# connect 00:07:A4:F2:B3:CB

If everything works correctly, you now have a separate output device in PulseAudio.
You can now disable scanning again and exit the program:

# scan off
# 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
# pactl list cards  | awk '/00_07_A4_F2_B3_CB/' RS=""
Card #2
	Name: bluez_card.00_07_A4_F2_B3_CB
	Driver: module-bluez5-device.c
	Owner Module: 16
	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_sink: 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_sink
	Ports:
		headset-output: Headset (priority: 0, latency offset: 0 usec)
			Part of profile(s): a2dp_sink
		headset-input: Headset (priority: 0, latency offset: 0 usec, not available)

  • Switch the active card profile to a2dp_sink
# pactl set-card-profile 2 a2dp_sink
  • Show the PulseAudio sink
# pactl list sinks | awk '/00_07_A4_F2_B3_CB/' RS=""
Sink #2
	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: 16
	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:
# paplay -d bluez_sink.00_07_A4_F2_B3_CB /mnt/media/vegas.wav

PulseAudio Helpful Links

Touchscreen

See Touchscreen controllers support sections for kernel configuration details to enable support for the particular touchscreen. The touchscreen driver is modularized if you use default CM-FX6 configuration and is loaded by udev automatically on Linux boot. If the touchscreen driver is not loaded, the following command will load the touchscreen driver:

  • For TI TSC2046 touch panel:
modprobe ads7846

The X Windows system of CM-FX6 uses evdev X server input driver to get the input from the touchscreen.

Touchscreen calibration

All supported touchscreen devices can be calibrated using xinput_calibrator utility.

To calibrate the touchscreen:

  • Create an empty calibration file:
# cat << eof > /etc/X11/xorg.conf.d/99-calibration.conf
Section "InputClass"
	Identifier	"calibration"
	MatchProduct	"ADS7846 Touchscreen"
	Driver "evdev"
EndSection
eof
  • Run X Server by issuing startx & command
  • Make sure the touchscreen driver is loaded as described in Touchscreen section
  • 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.
  • Add Option fields into the /usr/share/X11/xorg.conf.d/99-calibration.conf:
# xinput_calibrator
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: 165, 3864, 3789, 268
        --> 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"	"129 3968 3750 161"
	Option	"SwapAxes"	"0"
	Driver "evdev"
EndSection

MMC/SD

The support for MMC/SD card on CM-FX6 is built into the Linux kernel. To mount a memory card, monitor /proc/partitions to see what partitions were detected on the MMC/SD card. For example, suppose an MMC/SD partition you'd like to mount is mmcblk0p1 then:

# [ ! -d /mnt/mmcblk0p1 ] && mkdir /mnt/mmcblk0p1
# mount /dev/mmcblk0p1 /mnt/mmcblk0p1

Display options

CM-FX6 evaluation platform can be used with either of five display interfaces: LCD, DSI, DVI, HDMI and LVDS. Default configuration of Linux kernel and Debian Linux for CM-FX6 uses LCD as primary video output interface. It is possible to use either the DVI, DSI or the LCD interface at the same time. HDMI can be used simultaneously with LVDS and either LCD or DVI interfaces.
Linux kernel implementation of the CM-FX6 display subsystem (IPU) is described in LCD, DSI, DVI, HDMI and LVDS support section. In the default Linux configuration for CM-FX6, four main framebuffers are available: /dev/fb0, /dev/fb2, /dev/fb3, and /dev/fb5.

Frame Buffer Mapping Using DTB

  • Quad configuration with the imx6q-sbc-fx6.dtb blob.
  • LCD/DVI <---> /dev/fb0
  • HDMI <---> /dev/fb2
  • LVDS0 <---> /dev/fb3
  • LVDS1 <---> /dev/fb5
  • Quad configuration with the imx6q-sbc-fx6-hdmi.dtb blob.
  • HDMI <---> /dev/fb0
  • LCD/DVI <---> /dev/fb2
  • LVDS0 <---> /dev/fb3
  • LVDS1 <---> /dev/fb5
  • Quad configuration with the imx6q-sbc-fx6-mipi.dtb blob.
  • MIPI <---> /dev/fb0
  • HDMI <---> /dev/fb2
  • LVDS0 <---> /dev/fb3
  • LVDS1 <---> /dev/fb5

Frame Buffer Tunning Using Kernel Arguments

In order to set a desired frame buffer resolution, the following kernel command line parameters can be used:

  • For LCD on /dev/fb0:
    video=mxcfb0:dev=lcd,800x480M-32@50,if=RGB32
  • For HDMI on /dev/fb2:
    video=mxcfb2:dev=hdmi,1920x1080M-32@50,if=RGB32
  • For LVDS0 on /dev/fb3:
    video=mxcfb3:dev=ldb,1366x768M-18@60,if=RGB666
  • For LVDS1 on /dev/fb5:
    video=mxcfb5:dev=ldb,1366x768M-18@60,if=RGB666

Configuring mxcfb0 only

  • HDMI on mxcfb0:
    video=mxcfb0:dev=hdmi,1920x1080M-32@50,bpp=32,if=RGB32 video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off
  • LDB on mxcfb0:
    video=mxcfb0:dev=ldb,1368x768M-18@60,bpp=16,if=RGB666 video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off

Starting X Server

Start X server on a default frame buffer:

# startx&

Use Another Frame Buffer

  • Edit the xorg.conf conf file and set a desire frame buffer:
Section "Device"
    Identifier  "i.MX Accelerated Framebuffer Device"
    Driver      "vivante"
    Option      "fbdev"     "/dev/fb2"
    Option      "vivante_fbdev" "/dev/fb2"
    Option      "HWcursor"  "false"
EndSection

Section "ServerFlags"
    Option "BlankTime"  "0"
    Option "StandbyTime"  "0"
    Option "SuspendTime"  "0"
    Option "OffTime"  "0"
EndSection
  • Alternative method of using FRAMEBUFFER environment variable:
Admolition note.png This approach works w/out the xorg configuration file.
The /etc/X11/xorg.conf has to be removed first.
# FRAMEBUFFER=/dev/fb2 startx

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 140 as output and set value to high:

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

Multi Media Support

In order to provide the FreeScale Multi Media Support some packages has to be installed onto a Debian Stretch clean system. The package/extra/fsl-support contains all packages that required for it.


Admolition note.png The CompuLab Debian Stretch release have all these packages installed

Video Playback

Frame Buffer Mode
  • gst-play
# gst-play /media/ElephantsDream-DivXPlusHD.mkv
X11

Start X and set DISPLAY:

# startx &
# export DISPLAY=:0

Make use either:

  • gst-play
# gst-play /media/ElephantsDream-DivXPlusHD.mkv
  • google-chrome [--kiosk] [URL]
# : Browse a local ''/media'' directory
# google-chrome --kiosk /media
# : Browse a remote ''http://192.168.11.170/media'' directory
# google-chrome --kiosk http://192.168.11.170/media

Camera Support

Admolition note.png
  • ov5640 camera works with SB-FX6 Rev 1.2 only
  • In this article we assume that an ov5640 camera is connected to the SB-FX6 P66 connector

Linux provides a variety of streaming tools for the V4L2 compliant devices. We provide some gst-streamer examples that operate on your camera and capture images.

Streaming the camera output to the frame buffer
gst-launch-1.0  imxv4l2videosrc ! imxg2dvideosink
Streaming the camera output to a file
  • Camera output -> mpeg4 codec -> matroska container
gst-launch-1.0 -v imxv4l2videosrc device=/dev/video0 ! videoconvert ! queue ! imxvpuenc_mpeg4 ! matroskamux ! filesink location=test.mkv
  • Camera output -> H-264 codec -> avi container
gst-launch-1.0 imxv4l2videosrc device=/dev/video0 ! videoconvert ! queue ! imxvpuenc_h264 ! avimux ! filesink location=test.avi

GPU Demos

# cd /opt/viv_samples/vdk/
  • Run any of the available tests: ./tutorial[1..7]_es20
# ./tutorial1_es20

Press 'ESC' for exit

See also