CM-FX6: Linux: Debian

From Compulab Mediawiki
Revision as of 13:53, 4 July 2013 by Grinberg (talk | contribs) (kernel)
Jump to: navigation, search

Overview

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

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

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.

Package contents

version.txt

The contents of the version.txt identifies the package version.

images

  • uImage-cm-fx6 - ready to run Linux kernel image binary for CM-FX6
  • debian-image.ubi - ready to run Debian Linux UBI image for installation onto the NAND flash
  • debian-image.tar.bz2 - archive of the Debian root file system
  • kernel.img - Kernel image required for installation onto the NAND flash or the SSD
  • ramdisk.img - Ramdisk image required for installation onto the NAND flash or the SSD
  • bootscr.img - U-Boot script used for image installation

kernel

  • uImage-3.0.35-cm-fx6-3.bin - ready to run Linux kernel version 3.0.35-cm-fx6-3 for CM-FX6
  • linux-3.0.35-cm-fx6-3.config - Linux kernel 3.0.35-cm-fx6-3 configuration file
  • linux-3.0.35-cm-fx6-3.patch - patch vs. Linux stable kernel 3.0.35 with support for CM-FX6 peripherals
  • patches - ordered collection of patches, that form the single patch above (linux-3.0.35-cm-fx6-3.patch)
  • modules_3.0.35-cm-fx6-3.tar.gz - a modules tarball, that matches the ready to run Linux kernel (uImage-3.0.35-cm-fx6-3.bin)

utilities

The utilities directory contains miscellaneous utilities useful for development

  • tftpd32.zip - TFTP server for Windows users
  • eeprom-util - CompuLab EEPROM utility for reading information found inside the EEPROM on CompuLab boards
  • bootscr.src - U-Boot script source used for loading kernel and ramdisk images from MMC/SD card
  • debian-image.cfg - configuration file used by ubinize utility for debian-image.ubi generation. For more information about UBIFS images please refer to the Linux Development for ARM modules article.


Using Debian Linux on CM-FX6

Connection and Logging In

Use the following usernames and passwords to login:

Account with administrative privileges:

User: root
Password: 111111

Regular user account:

User: user	
Password: 111111

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


Networking

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


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. When the console is enabled for such a device, the following or similar message can appear on active console:

INIT: Id "T0" respawning too fast: disabled for 5 minutes

This is not an error message, it is just a warning that can be eliminated by editing /etc/inittab file.

X Windows system

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

Enlightenment 17 window manager has a built in configuration set up to work best with phones, tablets and similar devices. To activate the "touchscreen" profile, enter Main->Settings Panel->Settings->Profiles. Select the Touchscreen profile.

To switch back to the standard profile, please see the Known Issues article.

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.

HDMI Audio

CM-FX6 provides a digital HDMI audio interface, which is registered as a standard ALSA sound card. If the default CM-FX6 configuration is used, the audio drivers are loaded automatically in the boot process.

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

More information about Linux audio subsystem can be found at ALSA project official website.

Analog Audio

CM-FX6 provides an analog audio interface, which is registered as a standard ALSA sound card. If the default CM-FX6 configuration is used, the audio drivers are loaded automatically in the boot process.

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: wm8731audio [wm8731-audio], device 0: HiFi wm8731-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: imxhdmisoc [imx-hdmi-soc], device 0: IMX HDMI TX mxc-hdmi-soc-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

The 'card 0' is an analog audio device.

Analog Audio Settings

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

  • alsamixer - set the “Output Mixer HiFi Playback Switch” control on with arrow buttons.

or

  • amixer - set the “Output Mixer HiFi Playback Switch” control on using command line interface:
    # amixer cset numid=14,iface=MIXER,name='Output Mixer HiFi Playback Switch' on

Analog Audio Playback

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

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

Here is a sample output of aplay -L command:

# aplay -L
default:CARD=wm8731audio
    wm8731-audio, 
    Default Audio Device
sysdefault:CARD=wm8731audio
    wm8731-audio, 
    Default Audio Device
default:CARD=imxhdmisoc
    imx-hdmi-soc, 
    Default Audio Device
sysdefault:CARD=imxhdmisoc
    imx-hdmi-soc, 
    Default Audio Device

The next command can be used for audio play back:

# aplay -D sysdefault:CARD=wm8731audio <wav-file>

The above command makes use of the wm8731 audio codec and passes the audio signal to the audio out (J3 on SB-FX6).

Recording Audio

CM-FX6 provides recording audio signal from ether “Line In” or “Mic In” sources.

Make use of arecord application for capturing audio signal. arecord -L shows all devices that can be used for audio capturing.

The below list of devices is shown on a CM-FX6 module:

# arecord -L
default:CARD=wm8731audio
    wm8731-audio, 
    Default Audio Device
sysdefault:CARD=wm8731audio
    wm8731-audio, 
    Default Audio Device

Audio Input Settings

CM-FX6 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
Input Mux => Mic
Mic Boost Volume => 1
  • amixer
# amixer cset numid=11,iface=MIXER,name='Input Mux' 1
# amixer cset numid=5,iface=MIXER,name='Mic Boost Volume' 1
Line In
  • alsamixer
Input Mux => Line In
  • amixer
# amixer cset numid=11,iface=MIXER,name='Input Mux' 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.

# arecord < -D sysdefault:CARD=wm8731audio > -t wav /tmp/out.wav

The below sample commands record audio signal from the selected 'Input Mux' device.

  • Mic Example
# amixer cset numid=11,iface=MIXER,name='Input Mux' 1
# amixer cset numid=5,iface=MIXER,name='Mic Boost Volume' 1
# arecord -t wav /tmp/out.wav
  • Line In Example
# amixer cset numid=11,iface=MIXER,name='Input Mux' 0
# arecord -t wav /tmp/out.wav

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.

  • Load a Gadget Driver
# modprobe g_audio    
g_audio gadget: controller 'fsl-usb2-udc' not recognized; trying Linux USB Audio Gadget
g_audio gadget: Hardware params: access 3, format 2, channels 2, rate 48000
g_audio gadget: audio_buf_size 48000, req_buf_size 200, req_count 256
g_audio gadget: Linux USB Audio Gadget, version: Dec 18, 2008
g_audio gadget: g_audio ready
Suspend udc for OTG auto detect
USB Gadget resume begins
fsl_udc_resume, Wait for wakeup thread finishes
dr_controller_run: udc out low power mode
USB Gadget resume ends
fsl-usb2-udc: bind to driver g_audio 

Default CM-FX6 kernel configuration enables g_serial, g_file_storage, g_ether and g_audio gadget drivers. More gadget drivers can be enabled in the kernel configuration.

Testing OTG port

Host mode

Connect USB keyboard to OTG port.

usb 1-1: new low speed USB device number 3 using fsl-ehci
usb 1-1: device v413c p2107 is not supported
input: DELL Dell USB Entry Keyboard as /devices/platform/fsl-ehci.0/usb1/1-1/1-1:1.0/input/input5
generic-usb 0003:413C:2107.0003: input,hidraw1: USB HID v1.10 Keyboard [DELL Dell USB Entry Keyboard] on usb-fsl-ehci.0-1/input0
Gadget mode

Load g_audio gadget driver.

# modprobe g_audio
g_audio gadget: controller 'fsl-usb2-udc' not recognized; trying Linux USB Audio Gadget
g_audio gadget: Hardware params: access 3, format 2, channels 2, rate 48000
g_audio gadget: audio_buf_size 48000, req_buf_size 200, req_count 256
g_audio gadget: Linux USB Audio Gadget, version: Dec 18, 2008
g_audio gadget: g_audio ready

Connect desktop PC to 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 list:

hw:CARD=Gadget,DEV=0
    Linux USB Audio Gadget, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Gadget,DEV=0
    Linux USB Audio Gadget, USB Audio
    Hardware device with all software conversions

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) 
  • wireless-tools 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
  • 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 tunning WiFi interfaces refer to “wpa_supplicant” and “wireless-tools” man pages.

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

A2DP Headphones

  • Scan for available devices to find out Headphones BT device address:
# hcitool scan
Scanning ...
	00:07:A4:F2:B3:CB	Motorola HT820
  • Add new PCM device by editing /etc/asound.conf:
pcm.btheadphones {
   type plug
   slave {
       pcm {
           type bluetooth
           device 00:07:A4:F2:B3:CB
           profile "auto"
       }
   }
   hint {
       show on
       description "BT Headphones"
   }
}
ctl.btheadphones {
  type bluetooth
}
  • List device names to ensure correct settings in /etc/asound.conf:
# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
btheadphones
    BT Headphones
default:CARD=wm8731audio
    wm8731-audio, 
    Default Audio Device
sysdefault:CARD=wm8731audio
    wm8731-audio, 
    Default Audio Device
default:CARD=imxhdmisoc
    imx-hdmi-soc, 
    Default Audio Device
sysdefault:CARD=imxhdmisoc
    imx-hdmi-soc, 
    Default Audio Device
  • Put the headphones in the pairing mode.
  • Launch bluez-simple-agent application and provide device PIN code on request:
# bluez-simple-agent hci0 00:07:A4:F2:B3:CB
RequestPinCode (/org/bluez/1335/hci0/dev_00_07_A4_F2_B3_CB)
Enter PIN Code: 0000
Release
New device (/org/bluez/1335/hci0/dev_00_07_A4_F2_B3_CB)
  • Launch aplay playback tool:
# aplay -D btheadphones sample_audio.wav
Playing WAVE 'sample_audio.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo

Touchscreen

The CM-FX6 Evaluation Kit is equipped with DataImage SCF0403852GGU04 LCD touch panel. See LCD, DVI and HDMI support and Touchscreen 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
  • For DataImage SCF0403852GGU04 LCD touch panel (Himax HX8520-C):
modprobe hx8520-c

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

Touchscreen calibration

Both supported touchscreen devices can be accessed through symbolic link /dev/input/touchscreen. The symlink is created by udev rules defined in /etc/udev/rules.d/10-touchscreen.rules.
Calibration utilities require proper setting of the TSLIB_TSDEVICE system variable (pointing to the touchscreen device special file). This is done automatically by the /etc/profile.d/tslib.sh script.

Touchscreen calibration is performed with the ts_calibrate utility available in package libts-bin. To calibrate the touchscreen:

  • Make sure X Server is not running
  • Make sure the touchscreen driver is loaded as described in Touchscreen section
  • Run the ts_calibrate utility. For proper calibration you are required to touch the touchscreen corners and center in the following order: top-left, top-right, bottom-right, bottom-left, center. The calibration results are saved to file /etc/pointercal.
  • Use the ts_test utility to test the calibration results.

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:

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

Display options

CM-FX6 evaluation platform can be used with either of four display interfaces: LCD or 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 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, DVI, HDMI and LVDS support section.

In the default Linux configuration for CM-FX6, three main framebuffers are available: /dev/fb0, /dev/fb2, and /dev/fb3. The default mapping is:

  • LCD/DVI <---> /dev/fb0
  • HDMI <---> /dev/fb2
  • LVDS <---> /dev/fb3

In order to change the mapping, the following kernel command line parameters can be provided:

  • For DVI on /dev/fb0:
    video=mxcfb0:dev=dvi,1280x800M-24@50,if=RGB24
  • For HDMI on /dev/fb0:
    video=mxcfb0:dev=hdmi,1920x1080M-24@50,if=RGB24
  • For LVDS on /dev/fb0:
    video=mxcfb0:dev=ldb,1366x768M-18@60,if=RGB666

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.


See also