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

From Compulab Mediawiki
Jump to: navigation, search
(See also)
(Example)
Line 97: Line 97:
 
* g_mass_storage
 
* g_mass_storage
 
<pre>
 
<pre>
# modprobe g_mass_storage file=/dev/mmcblk0
+
root@cl-som-imx7-sid:~# modprobe g_mass_storage file=/dev/mmcblk0
 
Number of LUNs=8
 
Number of LUNs=8
 
Mass Storage Function, version: 2009/09/11
 
Mass Storage Function, version: 2009/09/11
Line 126: Line 126:
 
* g_ether
 
* g_ether
 
<pre>
 
<pre>
# modprobe g_ether
+
root@cl-som-imx7-sid:~# modprobe g_ether
 
using random self ethernet address
 
using random self ethernet address
 
using random host ethernet address
 
using random host ethernet address
Line 153: Line 153:
 
* g_serial
 
* g_serial
 
<pre>
 
<pre>
i# modprobe g_serial
+
root@cl-som-imx7-sid:~# modprobe g_serial
 
g_serial gadget: Gadget Serial v2.4
 
g_serial gadget: Gadget Serial v2.4
 
g_serial gadget: g_serial ready
 
g_serial gadget: g_serial ready
Line 165: Line 165:
 
<pre>
 
<pre>
 
[184764.380141] cdc_acm 1-1.2.1:2.0: ttyACM0: USB ACM device
 
[184764.380141] cdc_acm 1-1.2.1:2.0: ttyACM0: USB ACM device
 +
</pre>
 +
 +
=== WiFi ===
 +
CL-SOM-iMX7 features 802.11b/g/n wireless connectivity solution, implemented with a TI WiLink8 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:
 +
<pre>
 +
root@cl-som-imx7-sid:~# lsmod | grep wl18xx
 +
wl18xx                70950  0
 +
</pre>
 +
The WiFi driver can be loaded manually:
 +
<pre>
 +
root@cl-som-imx7-sid:~# 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
 +
</pre>
 +
* {{cmd|iwconfig}} command from {{cmd|wireless-tools}} package can be used to retrieve detailed information about the WiFi interfaces:
 +
<pre>
 +
root@cl-som-imx7-sid:~# 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
 +
</pre>
 +
* Activate the interface:
 +
<pre>
 +
root@cl-som-imx7-sid:~# ifconfig wlan0 up
 +
</pre>
 +
* Sample WiFi scanning:
 +
<pre>
 +
root@cl-som-imx7-sid:~# iwlist wlan0 scan
 +
</pre>
 +
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
 +
{{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@cl-som-imx7-sid:~# 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@cl-som-imx7-sid:~# ifconfig wlan0 up
 +
root@cl-som-imx7-sid:~# wpa_supplicant -B -Dwext -c /etc/wpa_supplicant.conf -i wlan0
 +
root@cl-som-imx7-sid:~# dhclient wlan0
 
</pre>
 
</pre>
  
Line 173: Line 234:
 
* For TI TSC2046 touch panel:
 
* For TI TSC2046 touch panel:
 
<pre>
 
<pre>
modprobe ads7846
+
root@cl-som-imx7-sid:~# modprobe ads7846
 
</pre>
 
</pre>
  
Line 189: Line 250:
 
* 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>
# xinput_calibrator  
+
root@cl-som-imx7-sid:~# xinput_calibrator  
 
Setting calibration data: 0, 4095, 0, 4095
 
Setting calibration data: 0, 4095, 0, 4095
 
Calibrating EVDEV driver for "ADS7846 Touchscreen" id=6
 
Calibrating EVDEV driver for "ADS7846 Touchscreen" id=6
Line 222: Line 283:
 
The following example demonstrates how to configure GPIO 140 as output and set value to high:
 
The following example demonstrates how to configure GPIO 140 as output and set value to high:
 
<pre>
 
<pre>
echo 140 > /sys/class/gpio/export
+
root@cl-som-imx7-sid:~# echo 140 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio140/direction
+
root@cl-som-imx7-sid:~# echo out > /sys/class/gpio/gpio140/direction
echo 1 > /sys/class/gpio/gpio140/value
+
root@cl-som-imx7-sid:~# echo 1 > /sys/class/gpio/gpio140/value
 
</pre>
 
</pre>
 
{{Note|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.}}
 
{{Note|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.}}

Revision as of 06:28, 3 May 2016

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

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

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


Using Debian Linux on CL-SOM-iMX7

Connection and Logging In

Use the following username and password to login:

Account with administrative privileges:

User: root
Password: 111111

To login into the Linux system, you may use a serial console (ttymxc0) at 115200 bps, or connect through the network (ssh), or use a keyboard and 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:

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 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 CL-SOM-iMX7 includes all the information required to use Debian package management utilities. You can use apt-get and dpkg out of the box.

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.
In CL-SOM-iMX7 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 CL-SOM-iMX7 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-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

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

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

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

root@cl-som-imx7-sid:~# lsmod | grep wl18xx
wl18xx                 70950  0

The WiFi driver can be loaded manually:

root@cl-som-imx7-sid:~# 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-som-imx7-sid:~# 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-som-imx7-sid:~# ifconfig wlan0 up
  • Sample WiFi scanning:
root@cl-som-imx7-sid:~# 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

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@cl-som-imx7-sid:~# 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@cl-som-imx7-sid:~# ifconfig wlan0 up
root@cl-som-imx7-sid:~# wpa_supplicant -B -Dwext -c /etc/wpa_supplicant.conf -i wlan0
root@cl-som-imx7-sid:~# dhclient wlan0

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 CL-SOM-iMX7 configuration and is not loaded by udev automatically on Linux boot. Use the following command to load the touchscreen driver module:

  • For TI TSC2046 touch panel:
root@cl-som-imx7-sid:~# modprobe ads7846

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:

  • 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.
  • Create a file /usr/share/X11/xorg.conf.d/99-calibration.conf and paste there a snippet with the calibration results:
root@cl-som-imx7-sid:~# 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"   "165 3864 3789 268"
        Option  "SwapAxes"      "0"
EndSection

MMC/SD

The support for MMC/SD card on CL-SOM-iMX7 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-som-imx7-sid:~# echo 140 > /sys/class/gpio/export
root@cl-som-imx7-sid:~# echo out > /sys/class/gpio/gpio140/direction
root@cl-som-imx7-sid:~# 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.

See also