IOT-GATE-IMX8PLUS and SBC-IOT-IMX8PLUS: Yocto Linux: How-To Guide
Contents
Overview
The example run-time Yocto Linux image for the CompuLab IOT-GATE-IMX8PLUS and SBC-IOT-IMX8PLUS was generated with Kirkstone Yocto build. The image includes the needed drivers and utilities to operate the hardware components of the IOT-GATE-IMX8PLUS/SBC-IOT-IMX8PLUS.
The default Kirkstone Yocto image includes many software packages. Among them:
- Core system
- SSH server and client
- ConnMan
- ModemManager
- Bluez5 Bluetooth tools and daemons
- SocketCAN
- Minicom
Connection and Login
This Yocto rootfs comes with an empty root password. No password is required for login.
To login into the Linux system, you may use a terminal emulator as described here, or connect through the network (ssh).
The following examples assume root user. |
Connectivity
IOT-GATE-IMX8PLUS / SBC-IOT-IMX8PLUS Yocto Linux Image includes ConnMan is a command-line network manager designed for use with embedded devices and fast resolve times. It can be used for managing all type of network interfaces:
- Wired
- Wireless
- Cellular
- Start ConnMan service prior to accessing network interfaces
root@iot-gate-imx8plus:~# systemctl start connman
- Display supported technologies
root@iot-gate-imx8plus:~# connmanctl technologies /net/connman/technology/cellular Name = Cellular Type = cellular Powered = True Connected = True Tethering = False TetheringFreq = 2412 /net/connman/technology/ethernet Name = Wired Type = ethernet Powered = False Connected = False Tethering = False TetheringFreq = 2412 /net/connman/technology/wifi Name = WiFi Type = wifi Powered = True Connected = False Tethering = False TetheringFreq = 2412 /net/connman/technology/bluetooth Name = Bluetooth Type = bluetooth Powered = False Connected = False Tethering = False TetheringFreq = 0
Ethernet
Enable/Disable Ethernet Interfaces
- To enable Ethernet interfaces:
root@iot-gate-imx8plus:~# connmanctl enable ethernet
- To disable Ethernet interfaces:
root@iot-gate-imx8plus:~# connmanctl disable ethernet
Enable/Disable Ethernet Connections
- To display Ethernet Connections:
root@iot-gate-imx8plus:~# connmanctl services | grep ethernet
- Example (both Ethernet ports are connected to a LAN):
root@iot-gate-imx8plus:~# connmanctl services | grep ethernet
*AR Wired ethernet_0001c030d7c3_cable
*AR Wired ethernet_0001c031ffe2_cable
- To enable Ethernet interfaces:
root@iot-gate-imx8plus:~# connmanctl enable <ethernet service name>
- To disable Ethernet interfaces:
root@iot-gate-imx8plus:~# connmanctl disable <ethernet service name>
- Example:
root@iot-gate-imx8plus:~# connmanctl disconnect ethernet_0001c031ffe2_cable
Disconnected ethernet_0001c031ffe2_cable
root@iot-gate-imx8plus:~# connmanctl services | grep ethernet
*AR Wired ethernet_0001c030d7c3_cable
*A Wired ethernet_0001c031ffe2_cable
root@iot-gate-imx8plus:~# connmanctl connect ethernet_0001c031ffe2_cable
Connected ethernet_0001c031ffe2_cable
Cellular Modem
Enable/Disable Cellular Interface
- To enable Ethernet interfaces:
root@iot-gate-imx8plus:~# connmanctl enable cellular
- To disable Ethernet interfaces:
root@iot-gate-imx8plus:~# connmanctl disable cellular
Enable/Disable Cellular Connections
- To display Cellular Connections:
root@iot-gate-imx8plus:~# connmanctl services | grep cellular
- Example:
root@iot-gate-imx8plus:~# connmanctl services | grep cellular
*AR 425007 cellular_425071043611161_context1
- To connect Cellular network:
root@iot-gate-imx8plus:~# connmanctl enable <cellular service name>
- To disconnect Cellular network:
root@iot-gate-imx8plus:~# connmanctl disable <cellular service name>
WiFi
Enable/Disable WiFi Interface
- To enable WiFi interface:
root@iot-gate-imx8plus:~# connmanctl enable wifi
- To disable WiFi interface:
root@iot-gate-imx8plus:~# connmanctl disable wifi
Network Scanning
- Sample WiFi scanning:
root@iot-gate-imx8plus:~# connmanctl scan wifi
- Display list of Access Points and Ad-Hoc cells in range
root@iot-gate-imx8plus:~# connmanctl services | grep wifi
- Example:
Compulab-Guest wifi_8c1d96f18740_436f6d70756c61622d4775657374_managed_psk
...
AP-Free wifi_8c1d96f18740_6b77696b2d6d6f62_managed_none
- Where a service name pattern is as shown below:
wifi_<hashlocal>_<hashremote>_managed_<encrption>
Connecting to Open Access Point
In the following example replace <hashlocal> and <hashremote> with the actual service parameters.
- Connect wireless network:
root@iot-gate-imx8plus:~# connmanctl connect wifi_<hashlocal>_<hashremote>_managed_none
- Disconnect wireless network:
root@iot-gate-imx8plus:~# connmanctl disconnect wifi_<hashlocal>_<hashremote>_managed_none
Connecting to Protected Access Point
For protected access points some information (like password) has to be provided to the ConnMan daemon.
The commands in this section show how to run connmanctl in interactive mode, it is required for running the agent command.
- Start interactive mode:
root@iot-gate-imx8plus:~# connmanctl
- Sample WiFi scanning (wait for scan completed):
connmanctl> scan wifi
- Display a list of services:
connmanctl> services
Compulab-Guest wifi_8c1d96f18740_436f6d70756c61622d4775657374_managed_psk
...
AP-Free wifi_8c1d96f18740_6b77696b2d6d6f62_managed_none
- Register the agent to handle user requests:
connmanctl> agent on
- Connect to one of the protected services. Replace <hashlocal> and <hashremote> with the actual service parameters:
connmanctl> connect wifi_<hashlocal>_<hashremote>_managed_psk
Agent RequestInput wifi_<hashlocal>_<hashremote>_managed_psk
Passphrase = [ Type=psk, Requirement=mandatory ]
Passphrase?
- Provide any information required by the daemon to complete the connection. The information requested may vary depending on the type of network.
- Quit:
connmanctl> quit
- Disconnect wireless network:
root@iot-gate-imx8plus:~# connmanctl disconnect wifi_<hashlocal>_<hashremote>_managed_psk
- Connect wireless network again:
root@iot-gate-imx8plus:~# connmanctl connect wifi_<hashlocal>_<hashremote>_managed_psk
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:
root@iot-gate-imx8plus:~# ip link set can0 type can bitrate 1000000
- Enable the CAN interface:
root@iot-gate-imx8plus:~# 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):
root@iot-gate-imx8plus:~# cansend can0 111#1122334455667788
- Send extended CAN frame (on the first device):
root@iot-gate-imx8plus:~# cansend can0 11111111#1122334455667788
- CAN frames (extended mode) generator, random payload, interval between two successive flames 50 msec:
root@iot-gate-imx8plus:~# cangen -g 50 -e -D r -v can0 ... ...
- Dump all received data frames as well as error frames:
root@iot-gate-imx8plus:~# candump any,0:0,#FFFFFFFF ... ...
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)
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.
root@iot-gate-imx8plus:~# wget https://www.modbusdriver.com/downloads/modpoll.tgz -P /tmp/ ... root@iot-gate-imx8plus:~# 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:
root@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:
root@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:
root@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:
root@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:
root@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:
root@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:
root@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.
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:
root@iot-gate-imx8plus:~# iotg-imx8plus-dio -o 2 1
- Read IN3 pin state (LO):
root@iot-gate-imx8plus:~# iotg-imx8plus-dio -i 3 0
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):
root@iot-gate-imx8plus:~# LED=Red_2
- Turn the LED ON
root@iot-gate-imx8plus:~# echo "1" | tee -a /sys/class/leds/${LED}/brightness
- Turn the LED OFF
root@iot-gate-imx8plus:~# echo "0" | tee -a /sys/class/leds/${LED}/brightness
- Set LED's trigger
root@iot-gate-imx8plus:~# echo "heartbeat" | tee -a /sys/class/leds/${LED}/trigger
Video Playback
The operation below requires root access. |
IOT-GATE-IMX8PLUS and SBC-IOT-IMX8PLUS are built around UCM-iMX8M-Plus SoC that features 1080p60 H.264, VP8 video decoding capabilities. Before starting video playback, please, ensure that the display is connected to the board.
The following commands can be used to start video playback (1.mov is a media file):
- gst-play
root@iot-gate-imx8plus:~# gst-play /path/to/1.mov
- gplay-1.0
root@iot-gate-imx8plus:~# gplay-1.0 /path/to/1.mov
- gst-launch
This method is for advanced users. Please study this document before the start: i.MX8GStreamerUserGuide.pdf
root@iot-gate-imx8plus:~# gst-launch-1.0 -v filesrc location=/path/to/1.mov ! qtdemux name=d.video_0 ! h264parse ! avdec_h264 ! autovideosink