CM-T43: Linux: Debian

From Compulab Mediawiki
Revision as of 12:17, 18 January 2016 by Nikita (talk | contribs) (Controller-area network (CAN))
Jump to: navigation, search

Overview

The example run-time Linux filesystem image for the CompuLab CM-T43 System-on-Module / Computer-on-Module is based on Debian GNU/Linux Jessie. The CompuLab Linux package for CM-T43 includes ready to run Linux kernel binary, root filesystem demo image archive, Linux kernel configuration and source code patches.

The default Debian Jessie Linux image includes more than 400 software packages. Among them:

  • Core system
  • Debian package management system
  • X11 Windowing System
  • Fluxbox desktop manager
  • Netsurf browser
  • Samba connectivity suite
  • SSH server and client
  • ALSA configuration and usage utilities
  • Bluetooth 5.0 tools and daemons

The CM-T43: Linux: Getting started page provides a brief introduction on how to install the run-time Linux image.

Package contents

version.txt

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

images

  • zImage-cm-t43 - ready to run Linux kernel image binary for CM-T43
  • am437x-sb-som-t43.dtb - SB-SOM-T43 Device Tree binary
  • debian-image.tar.bz2 - archive of the Debian root file system
  • kernel.img - Kernel image required for installation onto the eMMC
  • ramdisk.img - Ramdisk image required for installation onto the eMMC
  • bootscr.img - U-Boot script used for image installation

kernel

  • zImage-4.2.0-cm-t43-4.bin - ready to run Linux kernel version 4.2-cm-t43-4 for CM-T43
  • modules-4.2.0-cm-t43-4.tar.bz2 - archive of pre-compiled modules for Linux kernel version 4.2-cm-t43-4
  • linux-4.2.0-cm-t43-4.config - Linux kernel 4.2-cm-t43-4 configuration file
  • linux-4.2.0-cm-t43-4.patch - patch vs. Linux kernel 4.2 with support for CM-T43 peripherals
  • patches - ordered collection of patches, that form the single patch above (linux-4.2.0-cm-t43-4.patch)

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 or USB storage device

Using Debian Linux on CM-T43

Connection and Logging In

Use the following username and password to login:

Account with administrative privileges:

cm-debian login: root
Password: 111111

Regular user account:

cm-debian login: user	
Password: 111111

To login into the Linux system, you may use a serial console (ttyO0) at 115200 bps, or connect through the network.

Networking

CM-T43 can operate in two modes: dual MAC mode, or as a 3 port ethernet switch. The default mode of operation is dual MAC mode. A user guide for both operation modes can be found in the Linux Core CPSW User's Guide article in the TI wiki. To configure networking, edit /etc/network/interfaces, /etc/resolv.conf, /etc/hostname and /etc/hosts. For more information about Debian Linux network configuration read Network setup chapter in the Debian Reference.

Switching to 3-port switch mode

To enable 3-port switch mode, the device tree blob must be modified to remove the dual_emac property before Linux boots. This can be done using the following U-Boot commands:

# fdt addr <address fdt was loaded to>
# fdt rm /ocp/ethernet@4a100000 dual_emac

X Windows system

CompuLab Debian Jessie Linux demo image 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.

Fluxbox window manager

CM-T43 Debian Linux features installed Fluxbox package - a lightweight window manager for the X Windowing System.

  • Fluxbox provides configurable window decorations, a root menu to launch applications and a toolbar that shows the current workspace name, a set of application names and the current time. There is also a workspace menu which allows you to add or remove workspaces. The slit can be used to dock small applications, e.g. most of the bbtools can use slit.
  • Fluxbox can iconify windows to the toolbar, in addition to adding the window to the Icons submenu of the workspace menu.

Visit Fluxbox Wiki and Official home page for more details.

Software Management

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

MMC/SD

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

mkdir -p /mnt/mmcblk0p1 && mount /dev/mmcblk0p1 /mnt/mmcblk0p1

Display options

CM-T43 evaluation platform has three video output interfaces: LCD, DVI, and LVDS. Default configuration of Debian Linux for CM-T43 uses LCD as primary video output.

USB Dual-Role-Device

CM-T43 has USB DWC3 based controller. It features USB 2.0 Dual-Role-Device (DRD) subsystem with integrated HS/FS (USB2.0) PHY. CM-T43 DRD port is USB host and USB device (gadget) capable. USB Device Gadget drivers are compiled as modules with default CM-T43 kernel configuration. Current Linux kernel support of DWC3 features does not allow dynamic role (host/device) switching during runtime. By default, host role is assigned to CM-T43 DRD port.

Device mode can be enabled by running the following U-Boot commands before boot:

# fdt addr <address fdt was loaded to>
# fdt resize
# fdt set /ocp/omap_dwc3@48380000/usb@48390000 dr_mode peripheral

Testing Device (gadget) mode

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

  • Connect USB OTG micro B-cable (ID pin Float) to P3 USB DRD port of SB-SOM baseboard.
  • Connect other side Standard-A connector to Linux Host PC USB Host port.
Emulate a serial link
  • Load gadget driver on CM-T43 Eval board:
root@cm-debian:~# modprobe g_serial
[  114.805045] g_serial gadget: Gadget Serial v2.4
[  114.809968] g_serial gadget: g_serial ready
[  115.306074] g_serial gadget: high-speed config #2: CDC ACM config
  • Ensure the connection is established on the Host PC:
user@linux-host:~$ dmesg
...
[72415.607738] cdc_acm 2-1.8.2:2.0: ttyACM0: USB ACM device
[72415.608446] usbcore: registered new interface driver cdc_acm
[72415.608447] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
  • Receive data on CM-T43 Eval board:
root@cm-debian:~# cat /dev/ttyGS0
  • Send data from Host PC:
user@linux-host:~$ echo "Test message" > /dev/ttyACM0

Bluetooth

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            14294  0 
btmrvl                  9612  1 btmrvl_sdio
bluetooth             304454  22 bnep,btmrvl,btmrvl_sdio
  • 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 jessie 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
# 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 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 package it will be impossible to connect after the next pairing and there will be no 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 the 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, connect to the device explicitly:

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

A new PulseAudio output device is ready.
Disable the scanning 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 #1
	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: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
		off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
	Active Profile: a2dp
	Ports:
		headset-output: Headset (priority: 0, latency offset: 0 usec)
			Part of profile(s): a2dp
		headset-input: Headset (priority: 0, latency offset: 0 usec, not available)

  • Switch the active card profile to A2DP
# pactl set-card-profile 1 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

ObexFTP transfers

  • To transfer files between CM-T43 and a remote device, make sure that the remote device supports ObexFTP transfers by running the ObexFTP daemon on the remote device:
user@linux-host:~$ obexftpd -b
  • To send a file from CM-T43 to a target device, run the following command:
root@cm-debian:~# obexftp -b <MAC_address_of_device> -p <filename>
  • To download a file from a target device to CM-T43, run the following command:
root@cm-debian:~# obexftp -b <MAC_address_of_device> -g <filename>

Touchscreen

CM-T43 Evaluation Kit is equipped with Startek KD050C LCD 800x480 LCD touch panel.

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

Touchscreen calibration

A touchscreen device can be calibrated using xinput_calibrator utility.

To calibrate the touchscreen:

  • Run X Server by issuing startx command
  • Make sure the touchscreen driver is loaded 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 at the displayed markers.
  • Create a file /usr/share/X11/xorg.conf.d/99-calibration.conf and paste there a snippet with the calibration results:
xinput_calibrator 
Calibrating EVDEV driver for "ti-tsc" 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: 105, 3975, 3763, 174
	--> 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	"ti-tsc"
	Option	"Calibration"	"105 3975 3763 174"
	Option	"SwapAxes"	"0"
EndSection

RTC

Accessing and setting the RTC

To access the RTC time and date run:

root@cm-debian:~# hwclock
Sat Jan 1 00:00:00 2000 -10.011159 seconds

To set the date and write it into the RTC do the following:

root@cm-debian:~# date -s "31 JUL 2015 10:00:00"
Fri Jul 31 10:00:00 UTC 2015
root@cm-debian:~# hwclock -w
root@cm-debian:~# hwclock
Fri Jul 31 10:00:13 2015  -1.066224 seconds

CAN bus

Install can-utils using:

# apt-get install can-utils

CAN interface configuration

  • Load the can bus modules:
# modprobe can-raw
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
# modprobe can-bcm
can: broadcast manager protocol (rev 20120528 t)

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
c_can_platform 481d0000.can can0: setting BTR=0518 BRPE=0000
Send/Receive packets

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

  • Send standard CAN frame (on the first device):
# 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

See also