CL-SOM-iMX6UL: Linux: Debian

From Compulab Mediawiki
Jump to: navigation, search


The example run-time Linux filesystem image for the CompuLab CL-SOM-iMX6UL System-on-Module / Computer-on-Module is based on Debian GNU/Linux Sid. The CompuLab Linux package for CL-SOM-iMX6UL 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 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-iMX6UL 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-iMX6UL.

Package contents


├── extra
│   └── WiLink8
│       └──
├── images
│   ├── bootscr.img
│   ├── debian-image.tar.bz2
│   ├── imx6ul-sbc-imx6ul.dtb
│   ├── imx6ul-sbc-imx6ul-wilink.dtb
│   ├── kernel.img
│   ├── ramdisk.img
│   └── zImage-cl-som-imx6ul
├── kernel
│   ├── dtb
│   │   ├── imx6ul-cl-som-imx6ul.dtb
│   │   ├── imx6ul-cl-som-imx6ul-wilink.dtb
│   │   ├── imx6ul-sbc-imx6ul.dtb
│   │   └── imx6ul-sbc-imx6ul-wilink.dtb
│   ├── linux-3.14.38-cl-som-imx6ul-1.0.config
│   ├── linux-3.14.38-cl-som-imx6ul-1.0.patch
│   ├── modules_3.14.38-cl-som-imx6ul-1.0.tar.gz
│   ├── patches
│   │   ├── 0001-ARM-i.MX6UL-dts-Add-initial-support-for-cl-som-imx6u.patch
│   │   ├── ...
│   │   └── 0030-ARM-i.MX6UL-tag-kernel-version-cl-som-imx6ul-1.0.patch
│   └── zImage-3.14.38-cl-som-imx6ul-1.0.bin
├── README.txt
├── utilities
│   ├──
│   ├── bootscr.src
│   ├── eeprom-util
│   │   ├── eeprom-util
│   │   ├── eeprom-util-static
│   │   └── eeprom-util-v2.1-sources.tar.gz
│   └──
└── version.txt


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


  • zImage-cl-som-imx6ul - ready to run Linux kernel image binary for CL-SOM-iMX6UL
  • debian-image.tar.bz2 - Debian Sid armhf root file system with:
Fluxbox WindowManager
  • kernel.img - Kernel image required for installation onto the NAND flash or the eMMC
  • ramdisk.img - Ramdisk image required for installation onto the NAND flash or the eMMC
  • bootscr.img - U-Boot script used for image installation


  • zImage-3.14.38-cl-som-imx6ul-1.0.bin - ready to run Linux kernel version 3.14.38-cl-som-imx6ul-1.0 for CL-SOM-iMX6UL
  • dtb - Device tree blobs folder
  • linux-3.14.38-cl-som-imx6ul-1.0.config - Linux kernel 3.14.38-cl-som-imx6ul-1.0 configuration file
  • linux-3.14.38-cl-som-imx6ul-1.0.patch - patch vs. FreeScale rel_imx_3.14.38_6ul_ga with support for CL-SOM-iMX6UL peripherals
  • patches - ordered collection of patches, that form the single patch above (linux-3.14.38-cl-som-imx6ul-1.0.patch)
  • modules_3.14.38-cl-som-imx6ul-1.0.tar.gz - a modules tarball, that matches the ready to run Linux kernel (zImage-3.14.38-cl-som-imx6ul-1.0.bin)


The utilities directory contains miscellaneous utilities useful for development

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


  • - WiLink8 firmware files and user spase utilities

Using Debian Linux on CL-SOM-iMX6UL

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 (ttymxc2) at 115200 bps, or connect through the network (ssh), or use a keyboard and DVI/LCD display (tty1,tty2,tty3,tty4).


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


The Linux file system image is designed to suit different kernel versions and configurations. Therefore, during the operating system startup, consoles at several serial ports and DVI/LCD display are enabled. Some of these devices may not be supported, either because of kernel versions incompatibilities, or because the kernel was not configured to support these devices. systemd is able to configure most of them. Detail information can be found here:

X Windows system

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

Software Management

The Debian Linux image for CL-SOM-iMX6UL 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-iMX6UL features a high-speed USB 2.0 OTG controller. CL-SOM-iMX6UL OTG port is USB host and USB device (gadget) capable.
In CL-SOM-iMX6UL 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-iMX6UL 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: EHCI Host Controller
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 2
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
usb 2-1: new low-speed USB device number 2 using ci_hdrc
input: Dell Dell USB Optical Mouse as /devices/soc0/soc.0/2100000.aips-bus/2184000.usb/ci_hdrc.0/usb2/2-1/2-1:1.0/0003:413C:3012.0004/input/input5
evbug: Connected device: input5 (Dell Dell USB Optical Mouse at usb-ci_hdrc.0-1/input0)
hid-generic 0003:413C:3012.0004: input: USB HID v1.11 Mouse [Dell Dell USB Optical Mouse] on usb-ci_hdrc.0-1/input0
Gadget mode
  • g_mass_storage
# modprobe g_mass_storage file=/dev/mmcblk1
	Number of LUNs=8
	Mass Storage Function, version: 2009/09/11
	LUN: removable file: (no medium)
	Number of LUNs=1
	LUN: file: /dev/mmcblk1
	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.

[184050.818953] sd 19:0:0:0: [sdi] 7733248 512-byte logical blocks: (3.95 GB/3.68 GiB)
[184050.928532] sd 19:0:0:0: [sdi] Write Protect is off
[184050.928538] sd 19:0:0:0: [sdi] Mode Sense: 0f 00 00 00
[184051.038587] sd 19:0:0:0: [sdi] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[184051.259316]  sdi: sdi1 sdi2
[184051.478789] sd 19:0:0:0: [sdi] Attached SCSI disk
  • g_ether
# modprobe g_ether
	using random self ethernet address
	using random host ethernet address
	usb0: HOST MAC 3a:81:6d:ae:e9:f9
	usb0: MAC 2e:24:22:f5:67:9f
	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 22:e6:7b:cc:9b:4d  
          inet6 addr: fe80::20e6:7bff:fecc:9b4d/64 Scope:Link
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:60 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  • g_serial
i# 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


CL-SOM-iMX6UL features 802.11b/g/n wireless connectivity solution, implemented with a TI WiLink8 Wireless controller module. Make sure to leave CL-SOM-iMX6UL pin 21 floating to select WLAN interface via on board SDIO mux.

WiFi Initialization

WiFi chip shares the SDIO interface with the MMC/SD-card. The CL-SOM-iMX6UL evaluation board allows two operation modes:

  • MMC/SD-Card Enabled: pins #25 and #26 on connector P5 are short
  • WiFi Enabled: pins #25 and #26 on connector P5 are open
Admolition note.png Make sure that the EVK is in WiFi Enabled Mode
  • WiFi requires no user interaction for being configured. The driver gets loaded automatically.

Make sure that the WiFi driver is loaded:

# lsmod | grep wl18xx
wl18xx                 77610  0

The WiFi driver can be loaded manually:

# 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:
# 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:
# ifconfig wlan0 up
  • Sample WiFi scanning:
# 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.


  • Configuration sample

wpa_supplicant requires a configuration file to be created in order to get connected to a scanned wireless network.
Make use of the example bellow and put the network name and the password into the "ssid/psk" fields.

# cat << eof > /etc/wpa_supplicant.conf

  • Sample run
# ifconfig wlan0 up
# wpa_supplicant -B -Dwext -c /etc/wpa_supplicant.conf -i wlan0
# dhclient wlan0


CL-SOM-iMX6UL 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 btwilink
btwilink                5359  0

The Bluetooth driver can be loaded manually:

# modprobe btwilink
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 hci0 -a
hci0:	Type: BR/EDR  Bus: UART
	BD Address: 20:C3:8F:88:BB:D4  ACL MTU: 1021:6  SCO MTU: 180:4
	RX bytes:1202 acl:0 sco:0 events:52 errors:0
	TX bytes:1803 acl:0 sco:0 commands:45 errors:0
	Features: 0xff 0xfe 0x2d 0xfe 0xdb 0xff 0x7b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link mode: SLAVE ACCEPT 
	Name: 'cl-som-imx6ul'
	Class: 0x000000
	Service Classes: Unspecified
	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:
# hciconfig hci0 up
	hdev 883a5000
	HCI device registered (hdev 883a5000)
	hci0 883a5000
	(stc):  chnl_id list empty :4 
	(stk) : st_kim_start
	(stk) :ldisc_install = 1
	(stc): st_tty_open 
	(stk) :line discipline installed
	(stk) :TIInit_11.8.32.bts
	(stk) :change remote baud rate command in firmware
	(stk) :skipping the wait event of change remote baud
	(stc): add_channel_to_table: id 4
	(stc): add_channel_to_table: id 2
	(stc): add_channel_to_table: id 3
  • HCI Inquire remote devices.
# hcitool scan

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.
# 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
Description=Pulse Audio

ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm


# 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

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


# chmod 0666 /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
  • Paste the following lines to the end of /etc/pulse/
# cat << eof >> /etc/pulse/
### Automatically load driver modules for Bluetooth hardware
load-module module-bluetooth-policy

load-module module-bluetooth-discover
  • Create /var/run/pulse/.config/pulse directory. Change its ownership.
# mkdir -p /var/run/pulse/.config/pulse
# chown -R pulse:pulse /var/run/pulse
  • Make the root belong to the pulse-access,audio groups
# usermod -a -G pulse-access,audio root
  • Start PulseAudio service
# systemctl daemon-reload
# systemctl start pulseaudio.service
  • Make sure that the service is active, running and reports on no errors.
# systemctl status pulseaudio.service
   Loaded: loaded (/etc/systemd/system/pulseaudio.service; disabled)
   Active: active (running) since Mon 2015-07-20 12:00:13 UTC; 1min 34s ago
 Main PID: 805 (pulseaudio)
   CGroup: /system.slice/pulseaudio.service
           └─805 /usr/bin/pulseaudio --system --disallow-exit --disable-shm
Bluez5 pairing

PulseAudio 5.x supports A2DP per default.
Make sure the following packages are installed: pulseaudio pulseaudio-module-bluetooth pulseaudio-utils, bluez, bluez-tools.

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

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

# bluetoothctl

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

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

Now make sure that your headset is in pairing mode. It should be discovered shortly. For example,

[NEW] Device 00:07:A4:F2:B3:CB Motorola HT820

shows a device that calls itself "Motorola HT820" and has MAC address 00:07:A4:F2:B3:CB. We will now use that MAC address to initiate the pairing:

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

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

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

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

# scan off
# exit
Playback using PulseAudio
Admolition note.png Next examples assume that the device mac address is 00_07_A4_F2_B3_CB
  • Show the PulseAudio device
# pactl list cards  | awk '/00_07_A4_F2_B3_CB/' RS=""
Card #2
	Name: bluez_card.00_07_A4_F2_B3_CB
	Driver: module-bluez5-device.c
	Owner Module: 16
		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"
		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
		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 2 a2dp
  • Show the PulseAudio sink
# pactl list sinks | awk '/00_07_A4_F2_B3_CB/' RS=""
Sink #2
	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
		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"
		headset-output: Headset (priority: 0)
	Active Port: headset-output
  • Play sound using paplay. Example:
# paplay -d bluez_sink.00_07_A4_F2_B3_CB /mnt/media/vegas.wav


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-iMX6UL configuration and is loaded by udev automatically on Linux boot. If the touchscreen driver is not loaded, the following command will load the touchscreen driver:

  • For TI TSC2046 touch panel:
modprobe ads7846

The X Windows system of CL-SOM-iMX6UL 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:
# 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"


The support for MMC/SD card on CL-SOM-iMX6UL is built into the Linux kernel. Make sure to connect CL-SOM-iMX6UL pin 21 to GND to select MMC/SD interface via on board SDIO mux (Install jumper on P5-25 and P5-26 pins on SB-SOM-iMX6UL). 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

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

Frame Buffer Mapping

  • The device make use of the same frame buffer for LCD and DVI
  • LCD/DVI <---> /dev/fb0

Starting X Server

X server has an option to use FRAMEBUFFER environment variable in order to redefine the default frame buffer device. This variable can be used in order to make the X Server use a specified frame buffer. Bellow are examples of starting X Server using different frame buffers

  • fb0 -> LCD/DVI
FRAMEBUFFER=/dev/fb0 startx

Setting Desired Frame Buffer Parameters

Using fbset and gtf

In order to set a desired frame buffer resolution, the following commands can be issued:

RESOLUTION="1024 768 60"
fbset $(gtf ${RESOLUTION} -f | awk '/geometry|timings/ { $1="--"$1 ; print $0 }' ORS=" ")

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.


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