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

From Compulab Mediawiki
Revision as of 10:58, 10 October 2022 by Igor (talk | contribs)
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

Connection and Login

This Debian rootfs comes with a default sudo user compulab. User's assword 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.

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

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

IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS features one CAN 2.0B port implemented with i.MX8M Plus CAN controller.
CAN bus signals are routed to industrial I/O connector P8.

CAN interface configuration

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


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

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

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

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