Accessing the hardware (Kirkstone)
This chapter gives a short overview of how to access the different hardware parts and interfaces from within the Linux operating system. It is written universally in order to fit all SECO Northern Europe platforms in general.
Machine type
The SECO Northern Europe i.MX6 based platforms are generally very similar and run the same OS versions. If it is needed to find out the actual hardware that the software is run on, it can be read out using the command line.
Ethernet
If all network devices are properly configured as described in the manual, they can be used by the POSIX socket API.
There is a huge amount of documentation about socket programming available. Therefore it is not documented here.
The POSIX specification is available here.
If you have some problem in connecting to network through ethernet. Please look into the following trouble shoot link.
Serial interfaces (RS-232 / RS-485 / MDB)
Most of the serial interfaces are exported as TTY devices and thus accessible via their device nodes under /dev/ttymxc<number>. Depending on your hardware platform (and maybe its assembly option), different transceivers (RS232, RS485, MDB) can be connected to these TTY devices. See the following table for the mapping between device nodes and hardware connectors on i.MX6:
TTY device | Hardware function |
---|---|
/dev/ttymxc0 | RS-232 #1 |
/dev/ttymxc1 | RS-232 #2 |
/dev/ttymxc2 | MDB (Master) |
/dev/ttymxc3 | MDB (Slave) |
RS485 can be used in half duplex or full duplex mode. This mode has to be set on the hardware (see the according hardware manual) as well as in the software. Per default, the interface is working in full duplex mode.
Real Time Clock (RTC)
All SECO Northern Europe systems are equipped with a hardware real time clock. The system time is automatically set during the boot sequence by reading the RTC.
Keypad connector
The so called keypad connector is a general purpose connector. It can be used in different modes. The mode is selected using the kernel command line. See [Kernel command line] on how it can be modified.
The command line configuration of the keypad functionality is only needed and possible on the platforms SANTARO and SANTOKA. On the other platforms the available functionality is fix.
The actual pin mapping is described in the hardware guide for your device.
There are three available functions.
SPI
There are two ways of controlling SPI bus devices from a Linux system:
Writing a kernel SPI device driver and accessing this driver from user space by using its interface.
Accessing the SPI bus via the Linux kernel’s spidev API directly.
Describing the process of writing a Linux SPI device driver is out of the scope of this manual. The AT25 SPI eeprom can serve as a good and simple example for such a driver. It is located in the kernel directory under:
drivers/misc/eeprom/at25.c
The interface provided to the user space by such a kernel driver depends on the sort of this driver (e.g. character misc driver, input subsystem device driver, etc.). A very common usecase for an SPI driver is a touchscreen driver that uses the input event subsystem.
Accessing the SPI bus from userspace directly via spidev is described in the Linux kernel documentation and available in the kernel directory under:
Documentation/spi/spidev.rst
Additionally, there is an example C program available in the same location:
tools/spi/spidev_test.c
The header for spidev is available under:
include /uapi/linux/spi/spidev.h
If spidev is used to access the SPI bus directly, the user is responsible for keeping the interoperability consistent with all other SPI devices that are controlled by the Linux kernel.
I2C
There are two ways of controlling I2C bus devices from a Linux system:
Writing a kernel I2C device driver and accessing this driver from user space by using its interface.
Accessing the I2C bus via the Linux kernel’s i2c-dev API directly.
Describing the process of writing a Linux I2C device driver is out of this scope of this manual. The AT24 I2C EEPROM can serve as a good and simple example for such a driver. It is located in the kernel directory under:
drivers/misc/eeprom/at24.c
The interface provided to the user space by such a kernel driver depends on the sort of this driver (e.g. character misc driver, input subsystem device driver, etc.). A very common usecase for an I2C driver is a touchscreen driver that uses the input event subsystem.
Accessing the I2C bus from userspace directly via i2c-dev is described in the Linux kernel documentation and available inside the kernel directory under:
Documentation/i2c/dev-interface.rst
The header for i2c-dev is available under:
include/linux/i2c-dev.h
CAN
CAN bus devices are controlled through the SocketCAN framework in the Linux kernel. As a consequence, CAN interfaces are network interfaces. Applications receive and transmit CAN messages via the BSD Socket API. CAN interfaces are configured via the netlink protocol. Refer to the hardware manual corresponding to your device to find the physical port location..
The structure for a CAN message is defined in the kernel header include/uapi/linux/can.h
:
A more detailed documentation of the CAN bus handling in the Linux kernel can be found in the documentation directory of the Linux kernel source tree.
USB
There are two general types of USB devices:
USB Host: the Linux platform device is the host and controls several devices supported by corresponding Linux drivers.
USB Device: the Linux platform device acts as a USB device itself by emulating a specific device type.
USB Host
For USB Host functionality, SECO Northern Europe platforms per default support the following devices:
USB Mass Storage
USB Keyboard
There are many more device drivers available in the Linux kernel. They are not activated by default, because SECO Northern Europe cannot maintain and test the huge amount of existing drivers. Instead, the customer may do this themselves or engage SECO Northern Europe to implement their special use case. Existing drivers can easily be activated by reconfiguring and rebuilding the Linux kernel inside the BSP.
The USB Host bus can also be directly accessed by using libusb. This library is installed on SECO Northern Europe platforms per default. Further information can be found here.
USB Device
For USB Device functionality, the following device emulations are supported per default:
USB Serial Gadget
Again, further drivers can be activated by reconfiguring the Linux kernel. The USB Device drivers are not compiled into the kernel by default, but are located as modules in the file system. In order to use the Serial Gadget for example, the according module has to be loaded:
The Serial Gadget creates a virtual serial port over USB, accessible via the device node /dev/ttyGS0.
SD cards and USB mass storage
SD cards and USB mass storage devices can be accessed directly by using their devices nodes. The SD card can be found under /dev/mmcblk1, its single partitions are located under /dev/mmcblk1pX with X being a positive number. The USB mass storage devices can be found under /dev/sdX with X=a..z, its single partitions under /dev/sdXY with Y being a positive number
Temperature Sensor
Most SECO Northern Europe systems are equipped with an on-board hardware temperature sensor. The sensor is a Texas Instruments LM73 / LM75 connected via I2C. To measure the current temperature you can read the corresponding sysfs file in /sys/class/hwmon/hwmon0/.
Touchscreen
The touchscreen device is used by the window manager (a Wayland compositor) using libinput which itself accesses the touchscreen via the Linux input subsystem kernel API, i.e. its device node /dev/input/event0. Applications ( i.e. based on Qt) get the input events from the compositor.
Calibration for touchscreens, which is mandatory for resistive touchscreens but also useful for capacitive ones, is done by libinput internally.
Audio
SECO Northern Europe systems with an integrated audio codec make use of ALSA (Advanced Linux Sound Architecture) as a software interface. This project includes a user-space library (alsa-lib) and a set of tools (aplay, arecord, amixer, alsactl) for controlling and accessing the audio hardware from user applications or the console. Please refer to the official ALSA webpage for a full documentation.
HDMI
The HDMI port can be used as primary or secondary display of the device. Furthermore, an audio-enabled HDMI device can be used as secondary sound card.
There are a few different use case for the HDMI display:
HDMI as primary display
HDMI as secondary display
HDMI as mirror of the internal display
Depends on configurations, different settings for the HDMI output can be configured by an xml file. See the chapter [Initial Device Configuration] for further instructions.
Display power
The display can be powered on or off by software. The value is exported as a virtual file in the sysfs under /sys/class/backlight/backlight/bl_power. It can be accessed using the standard file operations open(), read(), write() and close().
Display backlight
The brightness of the display backlight can be adjusted in a range from 0 to a maximum level. The value is exported as a virtual file in the sysfs under /sys/class/backlight/backlight/brightness. It can be accessed using the standard file operations open(), read(), write() and close().