Difference between revisions of "CL-SOM-iMX7: Linux: Debian"

From Compulab Mediawiki
Jump to: navigation, search
(GPIO access)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
The example run-time Linux filesystem image for the CompuLab CL-SOM-iMX7 System-on-Module / Computer-on-Module is based on Debian GNU/Linux Sid.
+
The example run-time Linux filesystem image for the CompuLab CL-SOM-iMX7 System-on-Module / Computer-on-Module is based on Debian GNU/Linux stretch.
 
The CompuLab Linux package for CL-SOM-iMX7 includes ready to run 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 CL-SOM-iMX7 includes ready to run image, Linux kernel configuration and source code patches, and an archive of the root filesystem, used to create the image.
  
The default Debian Wheezy Linux image includes more than 400 software packages. Among them:
+
The default Debian GNU/Linux 10 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
* Fluxbox desktop manager
+
* Xfce, LXDE, OpenBox desktop managers
 
* SSH server and client
 
* SSH server and client
 
* PulseAudio configuration and usage utilities  
 
* PulseAudio configuration and usage utilities  
Line 15: Line 15:
 
The [[CL-SOM-iMX7: Linux: Automatic Installation|Automatic Linux installation on CL-SOM-iMX7]] page provides a brief introduction on how to install the run-time Linux image.
 
The [[CL-SOM-iMX7: Linux: Automatic Installation|Automatic Linux installation on CL-SOM-iMX7]] 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 CL-SOM-iMX7.
 
This article describes package structure and peripheral device options specific to the CL-SOM-iMX7.
 +
 +
{{Note|The article uses {{cmd|cl-debian}} hostname. A real hostname may be different.}}
  
 
== Using Debian Linux on CL-SOM-iMX7 ==
 
== Using Debian Linux on CL-SOM-iMX7 ==
Line 23: Line 25:
 
=== Networking ===
 
=== Networking ===
 
{{:Transclusion: Debian: Networking}}
 
{{:Transclusion: Debian: Networking}}
 +
 +
=== SSH Server ===
 +
{{:Transclusion: SSH Server}}
  
 
=== Consoles ===
 
=== Consoles ===
Line 28: Line 33:
  
 
=== X Windows system ===
 
=== X Windows system ===
{{:Transclusion: Debian: X Windows: Fluxbox}}
+
{{:Transclusion: Debian: X Windows: Xfce}}
  
 
=== Software Management ===
 
=== Software Management ===
Line 34: Line 39:
  
 
=== Analog Audio ===
 
=== Analog Audio ===
 +
CL-SOM-iMX7 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@cl-rootfs:~# aplay -l
 +
**** List of PLAYBACK Hardware Devices ****
 +
card 0: clsomimx7 [cl-som-imx7], device 0: 308a0000.sai-wm8731-hifi wm8731-hifi-0 []
 +
  Subdevices: 1/1
 +
  Subdevice #0: subdevice #0
 +
</pre>
 
{{:Transclusion: Debian: CL-SOM-iMX7: Analog Audio}}
 
{{:Transclusion: Debian: CL-SOM-iMX7: Analog Audio}}
  
 
=== USB On-The-Go (OTG) ===
 
=== USB On-The-Go (OTG) ===
CL-SOM-iMX7 features a high-speed USB 2.0 OTG controller. CL-SOM-iMX7 OTG port is USB host and USB device (gadget) capable.<br>
+
{{:Transclusion: Debian: iMX7: USB OTG}}
In CL-SOM-iMX7 default kernel configuration, the USB host driver is compiled into the kernel, whereas USB gadget drivers are compiled as modules.<br>
 
Gadget drivers should be loaded for OTG support.
 
<br>
 
Default CL-SOM-iMX7 kernel configuration enables {{filename|g_serial}}, {{filename|g_mass_storage}} and {{filename|g_ether}} gadget drivers.
 
More gadget drivers can be enabled in the kernel configuration.
 
 
 
==== Testing OTG port ====
 
 
 
===== Host mode =====
 
Connect USB keyboard to OTG port.
 
<pre>
 
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
 
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
 
hub 1-0:1.0: USB hub found
 
hub 1-0:1.0: 1 port detected
 
usb 1-1: new low-speed USB device number 2 using ci_hdrc
 
input: DELL Dell USB Entry Keyboard as /devices/soc.2/30800000.aips-bus/30b10000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0/0003:413C:2107.0002/input/input2
 
hid-generic 0003:413C:2107.0002: input: USB HID v1.10 Keyboard [DELL Dell USB Entry Keyboard] on usb-ci_hdrc.0-1/input0
 
</pre>
 
 
 
===== Gadget mode =====
 
* g_mass_storage
 
<pre>
 
root@cl-som-imx7-sid:~# modprobe g_mass_storage file=/dev/mmcblk0
 
Number of LUNs=8
 
Mass Storage Function, version: 2009/09/11
 
LUN: removable file: (no medium)
 
Number of LUNs=1
 
LUN: read only file: /dev/mmcblk0
 
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
 
</pre>
 
Connect desktop PC to OTG port.<br>
 
In case the desktop PC is running Linux, this gadget will show up in the {{cmd|lsusb}} list:
 
<pre>
 
Bus 001 Device 047: ID 0525:a4a5 Netchip Technology, Inc. Linux-USB File Storage Gadge
 
</pre>
 
The new device information shows up in the system log.
 
<pre>
 
[1825168.393211] sd 64:0:0:0: Attached scsi generic sg3 type 0
 
[1825168.393890] sd 64:0:0:0: [sdd] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
 
[1825168.499913] sd 64:0:0:0: [sdd] Write Protect is on
 
[1825168.499919] sd 64:0:0:0: [sdd] Mode Sense: 0f 00 80 00
 
[1825168.609953] sd 64:0:0:0: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 
[1825168.839367]  sdd: sdd1
 
[1825169.059950] sd 64:0:0:0: [sdd] Attached SCSI disk
 
</pre>
 
* g_ether
 
<pre>
 
root@cl-som-imx7-sid:~# modprobe g_ether
 
using random self ethernet address
 
using random host ethernet address
 
usb0: HOST MAC 12:b1:f6:45:ac:50
 
usb0: MAC 7a:89:db:ad:9d:60
 
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)
 
</pre>
 
In case the desktop PC is running Linux, this gadget will show up in the {{cmd|lsusb}} list:
 
<pre>
 
Bus 001 Device 009: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget
 
</pre>
 
A new network interface turns out in the ((cmd|ifconfig -a}} list:
 
<pre>
 
usb0      Link encap:Ethernet  HWaddr 12:b1:f6:45:ac:50 
 
          inet6 addr: fe80::10b1:f6ff:fe45:ac50/64 Scope:Link
 
          UP 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)
 
</pre>
 
* g_serial
 
<pre>
 
root@cl-som-imx7-sid:~# 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
 
</pre>
 
In case the desktop PC is running Linux, this gadget will show up in the {{cmd|lsusb}} list:
 
<pre>
 
Bus 001 Device 055: ID 0525:a4a7 Netchip Technology, Inc. Linux-USB Serial Gadget (CDC ACM mode)
 
</pre>
 
The new device information shows up in the system log.
 
<pre>
 
[184764.380141] cdc_acm 1-1.2.1:2.0: ttyACM0: USB ACM device
 
</pre>
 
  
 
=== WiFi ===
 
=== WiFi ===
Line 136: Line 58:
 
=== Bluetooth ===
 
=== Bluetooth ===
 
{{:Transclusion: Debian: CL-SOM-iMX7: Bluetooth}}
 
{{:Transclusion: Debian: CL-SOM-iMX7: Bluetooth}}
 +
{{:Transclusion: Debian: iMX7: Bluez5 PulseAudio}}
  
 
=== Controller–area network (CAN) ===
 
=== Controller–area network (CAN) ===
 
CL-SOM-iMX7 features two Flexible Controller Area Network (FLEXCAN) modules. Each FLEXCAN implements full CAN protocol version 2.0B and supports both the standard and the extended frame format as well as a programmable data bit rate up to 1Mbit/s.
 
CL-SOM-iMX7 features two Flexible Controller Area Network (FLEXCAN) modules. Each FLEXCAN implements full CAN protocol version 2.0B and supports both the standard and the extended frame format as well as a programmable data bit rate up to 1Mbit/s.
 
{{Note|Please prepare the hardware as described in the [[CL-SOM-iMX7: Evaluation Kit: Hardware Guide#CAN | CL-SOM-iMX7  Evaluation Kit Hardware Guide]] and [[SB-SOM: HOWTO: CAN Connection |  CAN node connection guide]].}}
 
{{Note|Please prepare the hardware as described in the [[CL-SOM-iMX7: Evaluation Kit: Hardware Guide#CAN | CL-SOM-iMX7  Evaluation Kit Hardware Guide]] and [[SB-SOM: HOWTO: CAN Connection |  CAN node connection guide]].}}
* Software to install {{filename|'''can-utils'''}}
+
{{:Transclusion: Debian: iMX7: CAN Bus}}
<pre>
 
root@cl-som-imx7-sid:~# apt-get install --no-install-recommends can-utils
 
</pre>
 
 
 
===== Loading CAN modules =====
 
If the FLEXCAN driver and/or Raw CAN protocol compiled as module(s), they must be loaded prior to enabling CAN interface.
 
 
 
* The FLEXCAN driver gets loaded automatically. Make sure it is loaded:
 
<pre>
 
root@cl-som-imx7-sid:~# lsmod | grep can
 
flexcan                10206  0
 
</pre>
 
:The FLEXCAN driver can be loaded manually:
 
<pre>
 
root@cl-som-imx7-sid:~# modprobe flexcan
 
30a00000.can supply xceiver not found, using dummy regulator
 
flexcan 30a00000.can: device registered (reg_base=f5a00000, irq=277)
 
30a10000.can supply xceiver not found, using dummy regulator
 
flexcan 30a10000.can: device registered (reg_base=f5a10000, irq=278)
 
</pre>
 
* Load Raw CAN protocol module:
 
<pre>
 
root@cl-som-imx7-sid:~# modprobe can-raw
 
can: raw protocol (rev 20120528)
 
</pre>
 
 
 
===== CAN interface configuration =====
 
It is recommended configure the CAN interface, with the {{filename|iproute2}} utilities.
 
 
 
* To make sure the right {{filename|ip}} utility is used, run:
 
<pre>
 
root@cl-som-imx7-sid:~# ip -V
 
ip utility, iproute2-ss151103
 
</pre>
 
* Configure the CAN interface bit-rate to 125 Kbits/sec (values of up to 1Mbit/sec are supported):
 
<pre>
 
root@cl-som-imx7-sid:~# ip link set can0 type can bitrate 125000
 
</pre>
 
* Enable the CAN interface:
 
<pre>
 
root@cl-som-imx7-sid:~# ip link set can0 up
 
flexcan 30a00000.can can0: writing ctrl=0x0b312005
 
</pre>
 
 
 
===== Send/Receive packets =====
 
Use {{filename|cansend}} and {{filename|candump}} utilities to send and receive packets via CAN interface.
 
 
 
* Send standard CAN frame (on the first device):
 
<pre>
 
root@cl-som-imx7-sid:~# cansend can0 111#1122334455667788
 
</pre>
 
 
 
* Send extended CAN frame (on the first device):
 
<pre>
 
root@cl-som-imx7-sid:~# cansend can0 11111111#1122334455667788
 
</pre>
 
 
 
* Dump all received data frames as well as error frames (on the second device):
 
<pre>
 
root@cl-som-imx7-sid:~# 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
 
</pre>
 
  
 
=== Touchscreen ===
 
=== Touchscreen ===
 
See [[CL-SOM-iMX7:_Linux:_Kernel#Touchscreen_controllers_support|Touchscreen controllers support]] sections for kernel configuration details to enable support for the particular touchscreen.
 
See [[CL-SOM-iMX7:_Linux:_Kernel#Touchscreen_controllers_support|Touchscreen controllers support]] sections for kernel configuration details to enable support for the particular touchscreen.
The touchscreen driver is modularized if you use default CL-SOM-iMX7 configuration and is not loaded by {{filename|udev}} automatically on Linux boot. Use the following command to load the touchscreen driver module:
+
The TI TSC2046 touchscreen driver is built-in the kernel if you use default CL-SOM-iMX7 configuration.
 
 
* For TI TSC2046 touch panel:
 
<pre>
 
root@cl-som-imx7-sid:~# modprobe ads7846
 
</pre>
 
  
 
The X Windows system of CL-SOM-iMX7 uses tslib X server input driver to get the input from the touchscreen.
 
The X Windows system of CL-SOM-iMX7 uses tslib X server input driver to get the input from the touchscreen.
Line 220: Line 75:
  
 
To calibrate the touchscreen:
 
To calibrate the touchscreen:
* Run X Server by issuing {{cmd|'''startx &'''}} command
+
* Select the appropriate resolution for the touchscreen display in [[CL-SOM-iMX7:_U-Boot:_Display_and_console#Setting_the_.22displaytype.22_variable|U-Boot.]]
 
* Make sure the touchscreen driver is loaded as described in [[#Touchscreen|Touchscreen]] section
 
* Make sure the touchscreen driver is loaded as described in [[#Touchscreen|Touchscreen]] section
 
* Set the {{parameter|DISPLAY}} environment variable:
 
* Set the {{parameter|DISPLAY}} environment variable:
 
<pre> export DISPLAY=:0</pre>
 
<pre> export DISPLAY=:0</pre>
* 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.
+
* Start the X Server
 +
<pre>
 +
systemctl stop lightdm
 +
startx&
 +
</pre>
 +
* Install ''xinput-calibrator'' deb package if not installed:
 +
<pre>
 +
root@cl-debian:~$ apt install xinput-calibrator
 +
</pre>
 +
* 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:
 
* Create a file {{filename|/usr/share/X11/xorg.conf.d/99-calibration.conf}} and paste there a snippet with the calibration results:
 
<pre>
 
<pre>
root@cl-som-imx7-sid:~# xinput_calibrator  
+
root@cl-rootfs:~# xinput_calibrator  
Setting calibration data: 0, 4095, 0, 4095
+
Calibrating standard Xorg driver "ADS7846 Touchscreen"
Calibrating EVDEV driver for "ADS7846 Touchscreen" id=6
+
current calibration values: min_x=0, max_x=65535 and min_y=0, max_y=65535
        current calibration values (from XInput): min_x=0, max_x=4095 and min_y=0, max_y=4095
+
If these values are estimated wrong, either supply it manually with the --precalib option, or run the 'get_precalib.sh' script to automatically get it (through HAL).
 
+
--> Making the calibration permanent <--
Doing dynamic recalibration:
+
copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)
        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"
 
Section "InputClass"
         Identifier     "calibration"
+
         Identifier         "calibration"
         MatchProduct   "ADS7846 Touchscreen"
+
         MatchProduct "ADS7846 Touchscreen"
         Option  "Calibration"  "165 3864 3789 268"
+
         Option "MinX"  "2150"
         Option "SwapAxes"     "0"
+
        Option "MaxX" "63262"
 +
        Option "MinY"  "60654"
 +
        Option "MaxY"  "2492"
 +
        Option "SwapXY"    "0" # unless it was already set to 1
 +
        Option "InvertX"  "0" # unless it was already set
 +
         Option "InvertY"   "0" # unless it was already set
 
EndSection
 
EndSection
 +
</pre>
 +
* For inverting X-axis (if required) add the following string to the {{filename|/usr/share/X11/xorg.conf.d/99-calibration.conf}}:
 +
<pre>
 +
        Option "TransformationMatrix"  "-1 0 1 0 1 0 0 0 1"
 +
</pre>
 +
* For inverting Y-axis (if required) add the following string to the {{filename|/usr/share/X11/xorg.conf.d/99-calibration.conf}}:
 +
<pre>
 +
        Option "TransformationMatrix"  "1 0 0 0 -1 1 0 0 1"
 
</pre>
 
</pre>
  
Line 249: Line 123:
 
=== GPIO access ===
 
=== GPIO access ===
 
{{:Transclusion: Debian: GPIO}}
 
{{:Transclusion: Debian: GPIO}}
 +
 +
=== Watchdog ===
 +
{{:Transclusion: Debian: Watchdog}}
  
 
== See also ==
 
== See also ==

Latest revision as of 13:32, 6 July 2022

Overview

The example run-time Linux filesystem image for the CompuLab CL-SOM-iMX7 System-on-Module / Computer-on-Module is based on Debian GNU/Linux stretch. The CompuLab Linux package for CL-SOM-iMX7 includes ready to run image, Linux kernel configuration and source code patches, and an archive of the root filesystem, used to create the image.

The default Debian GNU/Linux 10 image includes more than 400 software packages. Among them:

  • Core system
  • Debian package management system
  • X11 Windowing System
  • Xfce, LXDE, OpenBox desktop managers
  • SSH server and client
  • PulseAudio configuration and usage utilities
  • Bluez5 Bluetooth tools and daemons

The Automatic Linux installation on CL-SOM-iMX7 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 CL-SOM-iMX7.


Admolition note.png The article uses cl-debian hostname. A real hostname may be different.

Using Debian Linux on CL-SOM-iMX7

Connection and Logging In

This Debian rootfs comes with a default sudo user compulab:

Debian GNU/Linux 10 cl-debian ttymxc0

cl-debian login: compulab
Password: compulab

This Debian rootfs comes without default root password. The root password has to be set at the very first login:

Debian GNU/Linux 10 cl-debian ttymxc0

cl-debian login: root
You are required to change your password immediately (administrator enforced)
New password: 
Retype new password: 

To login into the Linux system, you may use a serial console, or connect through the network (ssh), or use a keyboard and display.

Networking

To configure networking, edit /etc/network/interfaces, /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

SSH Server

The Debian rootfs comes with openssh-server package pre-installed, but without SSH keys, which should be regenerated before first use:

root@cl-debian:~# dpkg-reconfigure openssh-server

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 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 the Xfce window manager.
By default, Xfce is initiated automatically during startup. Xfce can be initiated manually by typing startx.
USB mouse and keyboard should be connected for interaction with X Windows.

Use the following credentials to login to the Xfce window manager:

User: compulab
Password: compulab

Software Management

The Debian Linux image for CL-SOM-iMX7 and derived products includes all the information required to use Debian package management utilities. You can use apt-get and dpkg out of the box.

Analog Audio

CL-SOM-iMX7 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@cl-rootfs:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: clsomimx7 [cl-som-imx7], device 0: 308a0000.sai-wm8731-hifi wm8731-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Use aplay -l to list all sound cards and digital audio devices registered on the system:

root@cl-rootfs:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: clsomimx7 [cl-som-imx7], device 0: 308a0000.sai-wm8731-hifi wm8731-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

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@cl-rootfs:~# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=clsomimx7
    cl-som-imx7, 
    Default Audio Device
sysdefault:CARD=clsomimx7
    cl-som-imx7, 
    Default Audio Device
dmix:CARD=clsomimx7,DEV=0
    cl-som-imx7, 
    Direct sample mixing device
dsnoop:CARD=clsomimx7,DEV=0
    cl-som-imx7, 
    Direct sample snooping device
hw:CARD=clsomimx7,DEV=0
    cl-som-imx7, 
    Direct hardware device without any conversions
plughw:CARD=clsomimx7,DEV=0
    cl-som-imx7, 
    Hardware device with all software conversions

The next command can be used for audio play back:

root@cl-rootfs:~# aplay -D sysdefault <wav-file>

Audio Input Settings

CL-SOM-iMX7 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
Capture Volume => 100
Line Capture Switch => off
Mic Capture Switch => on
Input Mux => Mic
  • amixer
amixer cset numid=1 65536
amixer -c 0 cset numid=3 31,31
amixer -c 0 cset numid=4 0
amixer -c 0 cset numid=6 1
amixer -c 0 cset numid=14 1
Line In
  • alsamixer
Capture Volume => 100
Line Capture Switch => on
Mic Capture Switch => off
Input Mux => Line In
  • amixer
amixer cset numid=1 65536
amixer -c 0 cset numid=3 31
amixer -c 0 cset numid=4 1
amixer -c 0 cset numid=6 0
amixer -c 0 cset numid=14 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@cl-rootfs:~# arecord -D sysdefault -d 10 -f dat -t wav /tmp/out.wav

USB On-The-Go (OTG)

This section describes USB OTG port (USB host and USB device (gadget) capable port) use cases for following Compulab devices built around the NXP i.MX7 SoC:

  • CL-SOM-iMX7
  • UCM-iMX7

In the 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 kernel configuration enables g_serial, g_mass_storage and g_ether gadget drivers. More gadget drivers can be enabled in the kernel configuration.

Testing OTG port

Host mode

Connect USB keyboard to OTG port.

ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
usb 1-1: new low-speed USB device number 2 using ci_hdrc
input: DELL Dell USB Entry Keyboard as /devices/soc.2/30800000.aips-bus/30b10000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0/0003:413C:2107.0002/input/input2
hid-generic 0003:413C:2107.0002: input: USB HID v1.10 Keyboard [DELL Dell USB Entry Keyboard] on usb-ci_hdrc.0-1/input0
Gadget mode
  • g_mass_storage
root@cl-rootfs:~# modprobe g_mass_storage file=/dev/mmcblk0
	Number of LUNs=8
	Mass Storage Function, version: 2009/09/11
	LUN: removable file: (no medium)
	Number of LUNs=1
	LUN: read only file: /dev/mmcblk0
	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:

Bus 001 Device 047: ID 0525:a4a5 Netchip Technology, Inc. Linux-USB File Storage Gadge

The new device information shows up in the system log.

[1825168.393211] sd 64:0:0:0: Attached scsi generic sg3 type 0
[1825168.393890] sd 64:0:0:0: [sdd] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
[1825168.499913] sd 64:0:0:0: [sdd] Write Protect is on
[1825168.499919] sd 64:0:0:0: [sdd] Mode Sense: 0f 00 80 00
[1825168.609953] sd 64:0:0:0: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[1825168.839367]  sdd: sdd1
[1825169.059950] sd 64:0:0:0: [sdd] Attached SCSI disk
  • g_ether
root@cl-rootfs:~# modprobe g_ether
	using random self ethernet address
	using random host ethernet address
	usb0: HOST MAC 12:b1:f6:45:ac:50
	usb0: MAC 7a:89:db:ad:9d:60
	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:

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

A new network interface turns out in the ((cmd|ifconfig -a}} list:

usb0      Link encap:Ethernet  HWaddr 12:b1:f6:45:ac:50  
          inet6 addr: fe80::10b1:f6ff:fe45:ac50/64 Scope:Link
          UP 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
root@cl-rootfs:~# 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:

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

The new device information shows up in the system log.

[184764.380141] cdc_acm 1-1.2.1:2.0: ttyACM0: USB ACM device

WiFi

CL-SOM-iMX7 features 802.11b/g/n wireless connectivity solution, implemented with a TI WiLink8 Combo module.

WiFi Initialization

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

Make sure that the WiFi driver is loaded:

root@cl-rootfs:~# lsmod | grep wl18xx
wl18xx                 70950  0

The WiFi driver can be loaded manually:

root@cl-rootfs:~# modprobe wl18xx
	wlcore: ERROR could not get configuration binary ti-connectivity/wl18xx-conf.bin: -2
	wlcore: WARNING falling back to default config
	wlcore: wl18xx HW: 183x or 180x, PG 2.2 (ROM 0x11)
	wlcore: loaded
  • iwconfig command from wireless-tools package can be used to retrieve detailed information about the WiFi interfaces:
root@cl-rootfs:~# iwconfig wlan0
wlan0     IEEE 802.11abgn  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
  • Activate the interface:
root@cl-rootfs:~# ifconfig wlan0 up
  • Sample WiFi scanning:
root@cl-rootfs:~# 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 WiFi interfaces refer to “wpa_supplicant” and “wireless-tools” man pages.

wpa_supplicant

  • Configuration sample

Please open a wpa_supplicant configuration file bellow and put a network name and a password into the "ssid" and "psk" fields respectively.

root@cl-rootfs:~# cat /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant

network={
	ssid="wireless_network_name"
	key_mgmt=WPA-PSK
	psk="wireless_network_password"
}
  • Sample run
root@cl-rootfs:~# ifconfig wlan0 up
root@cl-rootfs:~# wpa_supplicant -B -Dwext -c /etc/wpa_supplicant.conf -i wlan0
root@cl-rootfs:~# dhclient wlan0

Bluetooth

CL-SOM-iMX7 features Bluetooth 4.1 BLE interface, implemented with a TI WiLink8 Combo module.

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:

root@cl-debian:~# lsmod | grep hci_uart
hci_uart               10445  1

The Bluetooth driver can be loaded manually:

root@cl-rootfs:~# modprobe hci_uart
  • HCI device configuration utility can be run to retrieve detailed information about the Bluetooth interfaces:
root@cl-rootfs:~# hciconfig hci0 -a
hci0:   Type: Primary  Bus: UART
        BD Address: 3C:A3:08:A8:03:B9  ACL MTU: 1021:6  SCO MTU: 180:4
        UP RUNNING 
        RX bytes:746 acl:0 sco:0 events:49 errors:0
        TX bytes:3441 acl:0 sco:0 commands:49 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 
        Link mode: SLAVE ACCEPT 
        Name: 'cl-debian'
        Class: 0x0c0000
        Service Classes: Rendering, Capturing
        Device Class: Miscellaneous, 
        HCI Version: 4.1 (0x7)  Revision: 0x0
        LMP Version: 4.1 (0x7)  Subversion: 0xac03
        Manufacturer: Texas Instruments Inc. (13)
  • If the HCI device is not running, use the below command to enable the HCI device:
root@cl-rootfs:~# hciconfig hci0 up
  • HCI Inquire remote devices.
root@cl-rootfs:~# hcitool scan
Scanning ...

Bluez5 & PulseAudio

Debian stretch/sid 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. Continue to the Start PulseAudio section if you use this root filesystem.
Install and configure PulseAudio
root@cl-rootfs:~# apt-get install --no-install-recommends pulseaudio pulseaudio-module-bluetooth
  • Create a systemd service for running pulseaudio as the pulse user.
root@cl-rootfs:~# 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@cl-rootfs:~# 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@cl-rootfs:~# cat << eof > /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
<busconfig>

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

</busconfig>
eof

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

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

root@cl-rootfs:~# bluetoothctl
[bluetooth]#

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

[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# 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:

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

After pairing, you also need to explicitly connect the device:

[bluetooth]# 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:

[bluetooth]# scan off
[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@cl-rootfs:~# 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: 13                                                                                                                                                    
        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:                                                                                                                                                           
                headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: no)
                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): headset_head_unit, a2dp_sink
                headset-input: Headset (priority: 0, latency offset: 0 usec, not available)
                        Part of profile(s): headset_head_unit
  • Make sure the active card profile is a2dp_sink. Otherwise switch to it:
# pactl set-card-profile 1 a2dp_sink
  • Show the PulseAudio sink
root@cl-rootfs:~# pactl list sinks | awk '/00_07_A4_F2_B3_CB/' RS=""
Sink #2
        State: SUSPENDED
        Name: bluez_sink.00_07_A4_F2_B3_CB.a2dp_sink
        Description: Motorola HT820
        Driver: module-bluez5-device.c
        Sample Specification: s16le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 13
        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.a2dp_sink.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@cl-rootfs:~# paplay -d bluez_sink.00_07_A4_F2_B3_CB.a2dp_sink /path/to/<audio-file.wav>

Controller–area network (CAN)

CL-SOM-iMX7 features two Flexible Controller Area Network (FLEXCAN) modules. Each FLEXCAN implements full CAN protocol version 2.0B and supports both the standard and the extended frame format as well as a programmable data bit rate up to 1Mbit/s.

Admolition note.png Please prepare the hardware as described in the CL-SOM-iMX7 Evaluation Kit Hardware Guide and CAN node connection guide.
Software installation
  • Use the following command to install can-utils:
root@cl-rootfs:~# apt-get install --no-install-recommends can-utils
Loading CAN modules

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

  • The FLEXCAN driver gets loaded automatically. Make sure it is loaded:
root@cl-rootfs:~# lsmod | grep can
flexcan                102  0
The FLEXCAN driver can be loaded manually:
root@cl-rootfs:~# modprobe flexcan
30a00000.can supply xceiver not found, using dummy regulator
flexcan 30a00000.can: device registered (reg_base=f5a00000, irq=277)
30a10000.can supply xceiver not found, using dummy regulator
flexcan 30a10000.can: device registered (reg_base=f5a10000, irq=278)
  • Load Raw CAN protocol module:
root@cl-rootfs:~# modprobe can-raw
can: raw protocol (rev 20120528)
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@cl-rootfs:~# ip -V
ip utility, iproute2-ss151103
  • Configure the CAN interface bit-rate to 125 Kbits/sec (values of up to 1Mbit/sec are supported):
root@cl-rootfs:~# ip link set can0 type can bitrate 125000
  • Enable the CAN interface:
root@cl-rootfs:~# ip link set can0 up
flexcan 30a00000.can can0: writing ctrl=0x0b312005
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@cl-rootfs:~# cansend can0 111#1122334455667788
  • Send extended CAN frame (on the first device):
root@cl-rootfs:~# cansend can0 11111111#1122334455667788
  • Dump all received data frames as well as error frames (on the second device):
root@cl-rootfs:~# 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

Touchscreen

See Touchscreen controllers support sections for kernel configuration details to enable support for the particular touchscreen. The TI TSC2046 touchscreen driver is built-in the kernel if you use default CL-SOM-iMX7 configuration.

The X Windows system of CL-SOM-iMX7 uses tslib 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:

  • Select the appropriate resolution for the touchscreen display in U-Boot.
  • Make sure the touchscreen driver is loaded as described in Touchscreen section
  • Set the DISPLAY environment variable:
 export DISPLAY=:0
  • Start the X Server
systemctl stop lightdm
startx&
  • Install xinput-calibrator deb package if not installed:
root@cl-debian:~$ apt install xinput-calibrator
  • 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@cl-rootfs:~# xinput_calibrator 
Calibrating standard Xorg driver "ADS7846 Touchscreen"
current calibration values: min_x=0, max_x=65535 and min_y=0, max_y=65535
If these values are estimated wrong, either supply it manually with the --precalib option, or run the 'get_precalib.sh' script to automatically get it (through HAL).
--> 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 "MinX"  "2150"
        Option "MaxX"  "63262"
        Option "MinY"  "60654"
        Option "MaxY"  "2492"
        Option "SwapXY"    "0" # unless it was already set to 1
        Option "InvertX"   "0" # unless it was already set
        Option "InvertY"   "0" # unless it was already set
EndSection
  • For inverting X-axis (if required) add the following string to the /usr/share/X11/xorg.conf.d/99-calibration.conf:
        Option "TransformationMatrix"  "-1 0 1 0 1 0 0 0 1"
  • For inverting Y-axis (if required) add the following string to the /usr/share/X11/xorg.conf.d/99-calibration.conf:
        Option "TransformationMatrix"  "1 0 0 0 -1 1 0 0 1"

MMC/SD

The support for MMC/SD card on Compulab devices based on the NXP iMX7 SoC 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:

if [ ! -d /mnt/mmcblk0p1 ]; then mkdir /mnt/mmcblk0p1; fi
mount /dev/mmcblk0p1 /mnt/mmcblk0p1

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:

root@cl-rootfs:~# echo 140 > /sys/class/gpio/export
root@cl-rootfs:~# echo out > /sys/class/gpio/gpio140/direction
root@cl-rootfs:~# echo 1 > /sys/class/gpio/gpio140/value
Admolition note.png The above example assumes that the pinmux configuration of the corresponding pin is set to GPIO mode and the GPIO 140 is not requested in the Linux kernel.

Watchdog

CL-SOM-iMX7 watchdog function is implemented with iMX7 SoC built-in Watchdog Timer (WDOG1). By default watchdog is not configured in this Debian rootfs.

root@cl-debian:~# systemctl show | grep -i watchdog
RuntimeWatchdogUSec=0
ShutdownWatchdogUSec=10min
ServiceWatchdogs=yes

The value RuntimeWatchdogUSec=0 means watchdog logic is disabled: no watchdog device is opened, configured, or pinged.
Any non-zero value enables it. Please refer to systemd-system.conf manual for more details.

Watchdog configuration

Edit /etc/systemd/system.conf file to configure watchdog related parameters, in particular RuntimeWatchdogSec and ShutdownWatchdogSec.

Watchdog testing

Run the following command to simulate kernel panic:

root@cl-debian:~# echo "c" > /proc/sysrq-trigger

As a result, the watchdog is not fed and the system reboots after per-configured timeout.

See also