IOT-GATE-IMX8PLUS and SBC-IOT-IMX8PLUS: Debian Linux: How-To Guide

From Compulab Mediawiki
Jump to: navigation, search

Overview

The example run-time Linux filesystem image for the CompuLab IOT-GATE-IMX8PLUS Internet of Things Gateway and SBC-IOT-IMX8PLUS Internet of Things Single Board Computer is based on Debian GNU/Linux Bullseye. The default Debian buster Linux image includes more than 650 software packages. Among them:

  • Core system
  • Debian package management system
  • SSH server and client
  • PulseAudio configuration and usage utilities
  • NetworkManager
  • ModemManager
  • Bluez5 Bluetooth tools and daemons
  • Docker

Serial Console

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS provides a serial console on the front panel micro-USB Console connector.

Connecting to a host PC

  1. Use a micro-USB cable to connect the Console connector to a USB port on your host PC.
  2. Make sure the CP2104 driver is available with your operating system, otherwise install CP2104 driver onto the host PC from https://www.silabs.com/documents/public/software/CP210x_Windows_Drivers_with_Serial_Enumeration.zip
  3. Identify the host PC interface and port number that will be used for communication with the device:
    • In most Linux PCs, the serial port will be denoted as one of the following (where n is a positive integer): /dev/ttyUSB0, /dev/ttyUSB1 ... /dev/ttyUSBn
    • In Windows PCs, the serial port usually will be denoted as one of the following (where n is a positive integer): COM1, COM2 ... COMn
  4. Start a terminal emulation program (such as PuTTY on Windows or minicom on Linux).
  5. In the port configuration section of the terminal emulation program select the port identified in previous step and set the following serial port parameters:
Baud Rate Data Bits Stop Bits Parity Flow Control
115200 8 1 none none

Connection and Login

This Debian rootfs comes with a default sudo user compulab. User password has to be set at the very first login:

Debian GNU/Linux 11 iot-gate-imx8plus ttymxc1

iot-gate-imx8plus login: compulab
You are required to change your password immediately (administrator enforced).
New password: 
Retype new password: 

To login into the Linux system, use a terminal emulator as described here, or connect through the network (ssh).

Package Management

The IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS Debian Linux image includes everything required to use the Debian package management utilities.
Use apt and dpkg for managing software packages.

Device Serial Number and Configuration

Product information is stored in on-board EEPROM.

  • To read the product serial number, issue the folowing command:
compulab@iot-gate-imx8plus:~$ cat /proc/device-tree/baseboard-sn
  • To read the product configuration part number, issue the following command:
compulab@iot-gate-imx8plus:~$ cat /proc/device-tree/baseboard-options

Device Tree

Available Device Tree Files

IOT-GATE-iMX8PLUS Debian package includes the following dtb files:

<fdt_file_name> Description Remarks
iot-gate-imx8plus.dtb default hardware configuration
iot-gate-imx8plus-m2tpm.dtb default hardware configuration + TPM add-on board TPM add-on uses the M.2 expansion socket (P19).
Cannot be combined with any other add-on board
iot-gate-imx8plus-brkout_pwm_gpio.dtb default hardware configuration + break-out add-on board (2x PWMs, 4x GPIOs) Break-out add-on uses the M.2 expansion socket (P19).
Cannot be combined with any other add-on board
iot-gate-imx8plus-m2emmc.dtb default hardware configuration + eMMC/TPM add-on board eMMC/TPM add-on uses the M.2 expansion socket (P19).
Cannot be combined with any other add-on board
iot-gate-imx8plus-m2adc.dtb default hardware configuration + ADC/TPM add-on board ADC/TPM add-on uses the M.2 expansion socket (P19).
Cannot be combined with any other add-on board

Set a device tree

IOT-GATE-iMX8PLUS Debian provides two methods to switch between dtb files:

  • U-Boot environment

The U-boot fdtfile variable contains the device tree name that will be loaded into the RAM. This variable can be changed by:

Environment Command
U-Boot setenv fdtfile <fdt_file_name>; saveenv;
Linux fw_setenv fdtfile <fdt_file_name>
  • GRUB environment
Environment Command/Procedure
GRUB Boot Menu Goto "Advanced Boot Options" and choose a device tree from the provided dtb list.
Linux grub-editenv /boot/EFI/BOOT/grubenv set fdt_file=<fdt_file_name>

Docker

The Docker Engine is preinstalled.

  • The following command downloads a test image and runs it in a container. The container sample prints a message and exits.
compulab@iot-gate-imx8plus:~$ sudo docker run -it ubuntu
...
0;root@b053b4b3817d: /root@b053b4b3817d:/# cat /etc/issue
Ubuntu 22.04.1 LTS \n \l
...

Cellular Modem

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS cellular interface is implemented with a mini-PCIe cellular modem module and a nano-SIM socket. To set up IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS for cellular functionality, install an active SIM card into the front panel nano-SIM socket (U10).
Cellular module should be installed into mini-PCIe socket P3.

ModemManager

The ModemManager can be used to log into almost any Internet Service Provider with simple configuration setup.

In the following example:

  • Replace ISP-APN with the APN name of the cellular provider.
compulab@iot-gate-imx8plus:~$ sudo nmcli connection add type gsm ifname '*' con-name CellularCon apn <ISP-APN>
  • Connect cellular network
compulab@iot-gate-imx8plus:~$ sudo nmcli connection up CellularCon
  • Disconnect cellular network
compulab@iot-gate-imx8plus:~$ sudo nmcli connection down CellularCon

GPS

IOT-GATE-IMX8PLUS features an optional GPS interface implemented with the cellular modem module.

GPS antenna

GPS antenna is required for GPS operation. GPS antenna is not included with IOT-GATE-IMX8PLUS. Any active GPS antenna with a male SMA connector can be used with IOT-GATE-IMX8PLUS.
GPS antenna should be attached to the AUX SMA connector on the gateway.

Admolition note.png GPS antenna should be positioned at least 1m away from the gateway

Using GPS

The cgps client can be used to display the GPS information.
The ModemManager can be used to check the modem status. For example, the following command shows the presence of the modem and the id of its interfaces.

root@iot-gate-imx8plus:~# mmcli -m 0

The cgps client utility depends on the gpsd daemon (starts automatically after the initialization command is performed).

  • Initialization of the GPS interface:
root@iot-gate-imx8plus:~# sed -i "/^DEVICES=.*/c\DEVICES=\"/dev/ttyUSB1\"" /etc/default/gpsd
  • Enable the GPS with the following AT commands:
root@iot-gate-imx8plus:~# echo AT+QGPS= 1 | socat - /dev/ttyUSB2,crnl
  • Full power cycle is required before using GPS. Shut down the gateway, remove main DC power for at least 20 sec and restart.
  • Start the cgps client to display GPS information.

The synchronization process might take a few minutes.

root@iot-gate-imx8plus:~# cgps
┌───────────────────────────────────────────┐┌─────────────────────────────────┐
│    Time:       2022-05-04T14:13:30.000Z   ││PRN:   Elev:  Azim:  SNR:  Used: │
│    Latitude:    32.65985123 N             ││  71    29    123    22      Y   │
│    Longitude:   35.10027205 E             ││  85    27    047    22      Y   │
│    Altitude:   102.700 m                  ││                                 │
│    Speed:      0.00 kph                   ││                                 │
│    Heading:    128.7 deg (true)           ││                                 │
│    Climb:      6.00 m/min                 ││                                 │
│    Status:     3D FIX (53 secs)           ││                                 │
│    Longitude Err:   n/a                   ││                                 │
│    Latitude Err:    n/a                   ││                                 │
│    Altitude Err:    +/- 18 m              ││                                 │
│    Course Err:      n/a                   ││                                 │
│    Speed Err:       n/a                   ││                                 │
│    Time offset:     -3.682                ││                                 │
│    Grid Square:     KM72np                ││                                 │
└───────────────────────────────────────────┘└─────────────────────────────────┘
  • Disable the GPS with the following AT commands:
root@iot-gate-imx8plus:~# echo AT+QGPSEND | socat - /dev/ttyUSB2,crnl

WiFi

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS features an optional 802.11ax WiFi interface, implemented with the Intel WiFi 6 AX210 module.
The NetworkManager can be used to manage WiFi interface.

Enable/Disable WiFi Interface

  • To enable WiFi interface:
compulab@iot-gate-imx8plus:~$ sudo nmcli radio wifi on
  • To disable WiFi interface:
compulab@iot-gate-imx8plus:~$ sudo nmcli radio wifi off

Network Scanning

  • Sample WiFi scanning:
compulab@iot-gate-imx8plus:~$ nmcli dev wifi list
The output will show the list of Access Points and Ad-Hoc cells in range.

Connecting to Access Point

In the following example:

  • Replace <SSID> and <PASSWORD> with the actual access point parameters:
compulab@iot-gate-imx8plus:~$ sudo nmcli device wifi connect <SSID> password <PASSWORD> name WifiCon
  • Disconnect wireless network:
compulab@iot-gate-imx8plus:~$ sudo nmcli connection down WifiCon
  • Connect wireless network again:
compulab@iot-gate-imx8plus:~$ sudo nmcli connection up WifiCon

Creating Access Point

In the following example:

  • Replace <SSID> and <PASSWORD> with desired access point parameters:
sudo nmcli device wifi hotspot ssid <SSID> password <PASSWORD> con-name HotspotCon
  • Disable wireless AP:
compulab@iot-gate-imx8plus:~$ sudo nmcli connection down HotspotCon
  • Enable wireless AP again:
compulab@iot-gate-imx8plus:~$ sudo nmcli connection up HotspotCon

CAN bus

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS features up to two CAN 2.0B ports implemented with i.MX8M Plus CAN controllers.

  • canE: permanent: always enabled and accessible
  • canC: optional: always enabled, but can be accessed only when CAN I/O module is installed
Admolition note.png IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS CAN signals are routed to industrial I/O connector (P8)

The following example demonstrates how to configure and use the permanent CAN interface canE.

CAN interface configuration

  • Configure the CAN interface bit-rate to 1 Mbits/sec:
compulab@iot-gate-imx8plus:~$ sudo ip link set canE type can bitrate 1000000
  • Enable the CAN interface:
compulab@iot-gate-imx8plus:~$ sudo ip link set canE up

Send/Receive packets

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

  • Send standard CAN frame (on the first device):
compulab@iot-gate-imx8plus:~$ sudo cansend canE 111#1122334455667788
  • Send extended CAN frame (on the first device):
compulab@iot-gate-imx8plus:~$ sudo cansend canE 11111111#1122334455667788
  • CAN frames (extended mode) generator, random payload, interval between two successive flames 50 msec:
compulab@iot-gate-imx8plus:~$ sudo cangen -g 50 -e -D r -v canE
...
  canE  1E5137F4#0F.4D.8B.7A.25.4D.DB.21
  canE  1B6C965C#8C.DE.96.58.69.5F.D5.26
  canE  1BD23086#8D.DB.C4.3E.81.57.BA.34
  canE  127B2322#F4.16.31.2E.34.04.62
  canE  1A6366DB#A8.73.C0.37.D8
  canE  03620EE4#
  canE  023AC34D#C6.08.BD.2A.04.B3.BF.43
  canE  1C19AD2E#09.C1.B3.26.23.E5.6A.5A
  canE  02BCA994#48.32.46.7C.F0.3F.29.1E
  canE  08104C67#59.9F.FE.44
  canE  1C280582#6F.D4.9C.38.A5.28.A3
  canE  0BC219EE#D9.2C.05
  canE  04AA80B8#A1.93
  canE  1A3E2392#AD.98
  canE  0025950E#E3.99.38
...
  • Dump all received data frames as well as error frames:
compulab@iot-gate-imx8plus:~$ sudo candump any,0:0,#FFFFFFFF
...
  canE  0CC89C1A   [1]  51
  canE  0A097EFB   [0] 
  canE  02B59BD5   [5]  68 6F 47 64 D9
  canE  03743A1E   [7]  FA BF E4 38 3E BF C8
  canE  13C9B644   [8]  30 FB 60 6F E1 FC 55 65
  canE  018A8975   [0] 
  canE  0C9C8179   [0] 
  canE  011F5D90   [6]  65 DB DD 5A AA F9
  canE  07B7FD18   [6]  CC 96 26 1D 13 7C
  canE  1FBD7177   [8]  69 BF 8D 1E 4C 0D 73 02
  canE  107A7E2D   [2]  25 D3
  canE  12B9E279   [8]  89 77 B7 54 BD 98 83 06
  canE  112A44EA   [8]  9E 95 D9 6B 60 CE B4 52
  canE  0ADF9869   [3]  C8 A0 27
  canE  1580C274   [5]  B2 7A F7 43 04
  canE  06DDDBCC   [7]  AF 19 88 04 E4 D8 95
  canE  127FA5CE   [8]  F7 54 57 20 45 17 3D 12
  canE  09A37893   [0] 
  canE  01BA4332   [6]  0B AF 0C 2E AB 25
  canE  180A8AD5   [5]  68 BE F7 5A C0
  canE  06DC994E   [7]  20 9E E9 7B B8 31 BC
...

Industrial Interfaces

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS implements industrial interfaces with four I/O slots (IE) that can be fitted with up-to four different I/O modules. Slots are referred to as A, B, C and D.

Available I/O modules types:

  • RS232 (2-wire)
  • RS485 (half duplex)
  • Digital I/O (4x DI + 4x DO)
  • CAN 2.0B


Admolition note.png IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS industrial I/O signals are routed to Industrial I/O Connector (P8)

Please refer to Industrial I/O Connector pin-out for more details.

So far industrial I/O modules do not require any special configuration.

RS232

RS232 function is implemented with MAX3221 (or compatible) transceiver interfaced with i.MX8M Plus UART ports.

RS232 modules can be installed into I/O slots A, B and C (configuration options FARS2, FBRS2, FCRS2). Up to three RS232 modules can be installed simultaneously.

Configuration and Access

Once properly installed on a specific I/O slot, RS232 interface can be accessed in Linux via ttyRS232_X tty device, where X is a slot name: A, B, C.

RS485

RS485 function is implemented with MAX13488 (or compatible) transceiver interfaced with i.MX8M Plus UART ports.

RS485 modules can be installed in I/O slots A, B and C (configuration options FARS4, FBRS4, FCRS4). Up to three RS485 modules can be installed simultaneously.

Configuration and Access

Once properly installed on a specific I/O slot, RS485 interface can be accessed in Linux via ttyRS485_X tty device, where X is a slot name: A, B, C.

RS485 has an optional software-enabled termination. Please note that the termination is disabled each time the device goes through power-cycle.
Linux commands to switch termination state:

SLOT Enable termination Disable termination
A GPIOSET 5 12=0 GPIOSET 5 12=1
B GPIOSET 5 13=0 GPIOSET 5 13=1
C GPIOSET 5 14=0 GPIOSET 5 14=1

Modbus RS485

The following example demonstrates how to use RS485 module installed into industrial I/O slot A in a Modbus RS485 Network. IOTG-IMX8PLUS performs as a Master device and queries XY-MD02 temperature and humidity sensor.

Software installation

Download and install modpoll - a command line based Modbus master simulator and test utility.

compulab@iot-gate-imx8plus:~$ wget https://www.modbusdriver.com/downloads/modpoll.tgz -P /tmp/
...
compulab@iot-gate-imx8plus:~$ sudo tar -xvf /tmp/modpoll.tgz -C /opt/
...

Device connection

  • Connect XY-MD02 sensor to appropriate Industrial I/O connector pins as below:
  • A+: XY-MD02 A+ to IOT-GATE-iMX8PLUS / SBC-IOT-IMX8PLUS P8-01
  • B-: XY-MD02 B- to IOT-GATE-iMX8PLUS / SBC-IOT-IMX8PLUS P8-03
--------------------                                  -------------------------
|                  |                                  |                       |
|                  *--(+)---< <------------- 5V-30V   |     IOTG-IMX8PLUS     |
|                  |                                  |   (SBC-IOT-IMX8PLUS)  |
|                  *--(-)---< <-------------- GND     |------  ------------   |
| XY-MD02 (RS485)  |                                  |     |==| IE-RS485 |   |
|                  *--(A+)--< <---...---> >---(1)---*-|     |  ------------   |
|                  |                                  | P8  |     Slot A      |
|                  *--(B-)--< <---...---> >---(3)---*-|     |                 |
|                  |                                  |------                 |
--------------------                                  ------------------------- 

Read data

  • Read temperature once:
compulab@iot-gate-imx8plus:~$ /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 2 -1 /dev/ttyRS485_A
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: Modbus RTU, FC4
Slave configuration...: address = 1, start reference = 2, count = 1
Communication.........: /dev/ttyRS485_A, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
[2]: 250
  • Poll temperature:
compulab@iot-gate-imx8plus:~$ /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 2 /dev/ttyRS485_A
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: Modbus RTU, FC4
Slave configuration...: address = 1, start reference = 2, count = 1
Communication.........: /dev/ttyRS485_A, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave... (Ctrl-C to stop)
[2]: 254
-- Polling slave... (Ctrl-C to stop)
[2]: 254
-- Polling slave... (Ctrl-C to stop)
[2]: 254
...
  • Read humidity once:
compulab@iot-gate-imx8plus:~$ /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 3 -1 /dev/ttyRS485_A
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: Modbus RTU, FC4
Slave configuration...: address = 1, start reference = 3, count = 1
Communication.........: /dev/ttyRS485_A, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
[3]: 515
  • Poll humidity:
compulab@iot-gate-imx8plus:~$ /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 3 /dev/ttyRS485_A
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: Modbus RTU, FC4
Slave configuration...: address = 1, start reference = 3, count = 1
Communication.........: /dev/ttyRS485_A, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave... (Ctrl-C to stop)
[3]: 894
-- Polling slave... (Ctrl-C to stop)
[3]: 895
-- Polling slave... (Ctrl-C to stop)
[3]: 896
...
  • Read temperature & humidity once:
compulab@iot-gate-imx8plus:~$ /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 2 -r 2 -1 /dev/ttyRS485_A
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: Modbus RTU, FC4
Slave configuration...: address = 1, start reference = 2, count = 2
Communication.........: /dev/ttyRS485_A, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
[2]: 263
[3]: 606
  • Poll temperature & humidity:
compulab@iot-gate-imx8plus:~$ /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 2 -r 2 /dev/ttyRS485_A
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: Modbus RTU, FC4
Slave configuration...: address = 1, start reference = 2, count = 2
Communication.........: /dev/ttyRS485_A, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave... (Ctrl-C to stop)
[2]: 263
[3]: 545
-- Polling slave... (Ctrl-C to stop)
[2]: 263
[3]: 543
-- Polling slave... (Ctrl-C to stop)
[2]: 263
[3]: 542
...
  • Read slave address, baudrate, temperature & humidity corrections:
compulab@iot-gate-imx8plus:~$ /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 4 -c 4 -r 258 -1 /dev/ttyRS485_A
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: Modbus RTU, FC3
Slave configuration...: address = 1, start reference = 258, count = 4
Communication.........: /dev/ttyRS485_A, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave...
[258]: 1
[259]: 9600
[260]: 0
[261]: 0

Digital I/O

Digital I/O module features 4 digital inputs and 4 digital outputs and can be installed into slot D (configuration option FDIO).
Four digital inputs are implemented with the CLT3-4B digital termination following EN 61131-2. Four digital outputs are implemented with the VNI4140K solid-state relay following EN 61131-2.

Admolition note.png Digital I/O module requires an external voltage supply up to 24V to be properly connected. Please refer to Industrial I/O Connector pin-out for more details.

Configuration and Access

Use iotg-imx8plus-dio utility to access digital inputs and outputs.

The example below shows how to access Digital inputs and outputs.

  • Drive OUT2 pin HI:
compulab@iot-gate-imx8plus:~$ sudo iotg-imx8plus-dio -o 2 1
  • Read IN3 pin state (LO):
compulab@iot-gate-imx8plus:~$ sudo iotg-imx8plus-dio -i 3
0

CAN

CAN function is implemented with i.MX8M Plus Flexible Controller Area Network (FlexCAN) communication controller.
CAN module can be installed into I/O slot C (configuration option FCCAN).

Configuration and Access

Once properly installed, CAN I/O module can be accessed in Linux via canC network interface. Refer to the CAN section for configuration and usage example.

Add-on boards

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS features expansion interface via M.2 Key-E socket P19. The expansion connector allows integration of custom add-on boards into IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS. The expansion connector features embedded interfaces such as I2C, SPI, PWM, GPIO, etc.

Admolition note.png Please refer to Expansion Connector pin-out for more details.

Available add-on boards:

  • TPM 2.0: implemented with Infineon SLB9670
  • Break-out: exposes expansion connector signals on 100-mil headers

TPM

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS can be optionally (configuration option FXTPM) assembled with a TPM 2.0 add-on board implemented with Infineon SLB9670.

  • Install TPM add-on board into M.2 Socket (P19) if required
  • Boot Linux kernel with iot-gate-imx8plus-m2tpm.dtb device tree
  • Verify that the TPM device was created:
compulab@iot-gate-imx8plus:~$ ls -lh /dev/tpm*
  • Otherwise load TPM kernel object:
compulab@iot-gate-imx8plus:~$ sudo modprobe tpm_tis_spi
  • Install the tpm2-tools package:
compulab@iot-gate-imx8plus:~$ sudo apt-get update && apt-get install tpm2-tools
  • Validate basic functionality
compulab@iot-gate-imx8plus:~$ sudo tpm2_getrandom 16

Break-out

Break-out add-on board exposes expansion connector signals on 100-mil headers.
The IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS Debian Linux image contains iot-gate-imx8plus-brkout_pwm_gpio.dtb device tree. It provides break-out add-on board usage example by configuring:

  • 2x PWMs
  • 4x GPIOs
  • 1x I2C
Interface/Bus Name in Linux Signal Name Channel/Offset Header-Offset
PWM3 pwmchip0 PWM3_OUT 0 P5-09
PWM4 pwmchip1 PWM4_OUT 0 P5-07
GPIO5 gpiochip4 GPIO5_IO10 10 P5-13
GPIO5_IO11 11 P5-11
GPIO5_IO12 12 P5-14
GPIO5_IO13 13 P5-15
I2C5 i2c-4 I2C5_SDA P5-08
I2C5_SCL P5-10

PWM

The following example demonstrates how to use pwmchip0 from Linux shell.

  • Boot Linux kernel with iot-gate-imx8plus-brkout_pwm_gpio.dtb device tree
  • Export PWM channel 0 on pwmchip0:
echo "0" | sudo tee -a /sys/class/pwm/pwmchip0/export
  • Setup PWM signal period of 100usec and duty cycle of 30%:
echo 100000 | sudo tee -a /sys/class/pwm/pwmchip0/pwm0/period
echo 30000 | sudo tee -a /sys/class/pwm/pwmchip0/pwm0/duty_cycle
  • Enable PWM signal:
echo 1 | sudo tee -a /sys/class/pwm/pwmchip0/pwm0/enable
  • Disable PWM signal:
echo 0 | sudo tee -a /sys/class/pwm/pwmchip0/pwm0/enable
  • Un-export PWM channel 0 on pwmchip0:
echo "0" | sudo tee -a /sys/class/pwm/pwmchip0/unexport

RTC

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS RTC is implemented with the AM1805 real-time clock (RTC) chip.
Back-up battery keeps the RTC running to maintain clock and time information whenever the main power supply is not present.

Accessing and setting the RTC

  • To access the RTC time and date run:
compulab@iot-gate-imx8plus:~$ sudo hwclock
2022-08-04 12:38:10.577874+00:00
  • To set the date and write it into the RTC do the following:
compulab@iot-gate-imx8plus:~$ sudo date -s "31 Dec 2021 10:00:00"
Fri Dec 31 10:00:00 IST 2021
compulab@iot-gate-imx8plus:~$ sudo hwclock -w
compulab@iot-gate-imx8plus:~$ sudo hwclock 
2021-12-31 10:00:08.317403+02:00

Watchdog

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS watchdog function is implemented with the i.MX8M Plus watchdog.
By default watchdog is not configured.

compulab@iot-gate-imx8plus:~$ systemctl show | grep RuntimeWatchdog
RuntimeWatchdogUSec=0

The value RuntimeWatchdogUSec=0 means watchdog logic is disabled: no watchdog device is opened, configured, or pinged

Watchdog configuration

  • Edit /etc/systemd/system.conf file to configure watchdog related parameters, in particular RuntimeWatchdogSec and ShutdownWatchdogSec.
RuntimeWatchdogSec - specifies the watchdog timeout for runtime services, meaning services that are actively running during normal system operation. The value is in seconds and should be set to a positive integer.
ShutdownWatchdogSec - specifies the watchdog timeout for the shutdown process, insuring the system doesn't hang indefinitely during the shutdown. The value is in seconds and should be set to a positive integer.
  • Reboot the device
  • Verify watchdog configuration
compulab@iot-gate-imx8plus:~$ systemctl show | grep RuntimeWatchdog
RuntimeWatchdogUSec=10s

Watchdog testing

  • Run the following command to simulate kernel panic:
compulab@iot-gate-imx8plus:~$ sudo su
root@iot-gate-imx8plus:/home/compulab# echo "c" > /proc/sysrq-trigger
  • As a result, the watchdog is not fed and the system reboots after 10 sec.

Low Power Modes

IOT-GATE-IMX8PLUS supports the following low-power modes:

  • Sleep mode - RAM content is preserved, and the system can quickly wake up into the operating system. Power consumption in sleep mode is ~0.25W.
  • Power-off mode - RAM content is not preserved, and the system will restart into a clean boot. Power consumption in power-off mode is ~0.02W.

IOT-GATE-IMX8PLUS supports two wake-up sources:

  • Short press on the power button
  • Timer alarm set in internal RTC (rtc1)
Admolition important.png Only the internal RTC (rtc1) can be used for the wake-up alarm. Main DC power must be present to preserve alarm settings.

Low power mode examples

  • Sleep mode with exit by power button press:
echo mem >/sys/power/state
  • Sleep mode with exit by RTC wake-up call or power button press:
rtcwake --device /dev/rtc1 -s 60 -m mem
  • Power-off mode with boot on RTC wake-up call:
rtcwake --device /dev/rtc1 -s 60 -m off
In this example system reboots after 60 seconds.

LEDs

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS features two user Bi-Color (Red + Green) LEDs found on front panel.
LEDs are controlled via GPIO pins and can be accessed via sysfs interface.

  • LEDs are referred to as Green_1, Red_1, Green_2 and Red_2
  • Choose a LED (LED2 Red in this example):
compulab@iot-gate-imx8plus:~$ LED=Red_2
  • Turn the LED ON
compulab@iot-gate-imx8plus:~$ echo "1" | sudo tee -a /sys/class/leds/${LED}/brightness
  • Turn the LED OFF
compulab@iot-gate-imx8plus:~$ echo "0" | sudo tee -a /sys/class/leds/${LED}/brightness
  • Set LED's trigger
compulab@iot-gate-imx8plus:~$ echo "heartbeat" | sudo tee -a /sys/class/leds/${LED}/trigger