IOT-DIN-IMX8PLUS: Debian Linux: I/O Modules Guide

From Compulab Mediawiki
Revision as of 15:09, 14 May 2025 by Igor (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

IOT-DIN-IMX8PLUS supports up to eight I/O Expansion Modules that can be stacked with the main gateway in order to extend the feature set of the system. A gateway assembly includes one gateway (the left most unit) and multiple I/O Expansion modules. Module stacking is done from left to right. Up to 8 I/O Expansion Modules can be supported in one gateway assembly. The modules are interconnected using Compulab’s proprietary StackLink expansion connector that extends a series of the IOT-DIN-IMX8PLUS interfaces, creating a chain of peripherals.

I/O Expansion Modules Stacking Rules

  • There can be up-to 8 I/O Expansion Modules in one assembly
  • Following modules can only be installed in position A (next to main gateway):
  • IFM-WB
  • IFM-NVME
  • IFM-NETX100
  • There can be up-to 3 (in total) modules of types:
  • IFM-RS485
  • IFM-RS232
  • IFM-WB
  • IFM-MESH
  • There can be up to 1 (in total) modules of types:
  • IFM-ADC8
  • IFM-CAN
  • There can be up-to 4 (in total) modules of types:
  • IFM-DI8O8
  • IFM-CAN

I/O Modules Configuration

I/O expansion modules are managed as a front-plane of virtual slots that map device access files to physical I/O modules per their positions in the stack.
During O/S boot IOT-DIN-IMX8PLUS automatically runs the StackLink configurator script that detects I/O modules and configures the virtual device files used to address the hardware.
The script creates the IFM front-plane file directory that includes type and access files for all populated stack slots.

IFM Front-Plane

During O/S boot the StackLink configurator script creates the IFM front-plane file directory that includes type and access files for all populated stack slots (from A to last populated slot).

/run/iotdin-imx8p/stack/frontplane

Front-plane directory structure

Example I/O modules stack:


+----------+-------+-------+-------+-------+
|  Slot #  |   A   |   B   |   C   |   D   |
+----------+-------+-------+-------+-------+
| IFM Type | ADC8  | DI8O8 | RS485 | RS232 |
+----------+-------+-------+-------+-------+

Front-plane file directory:

/run/iotdin-imx8p/stack/frontplane
|-- A
|   |-- access
|   |   |-- adc0 -> /sys/bus/iio/devices/iio:device0
|   |   `-- adc1 -> /sys/bus/iio/devices/iio:device1
|   `-- type.ADC8
|-- B
|   |-- access
|   |   |-- di.map
|   |   |-- do.map
|   |   `-- gpiochip -> /dev/gpiochip6
|   `-- type.DI8O8
|-- C
|   |-- access
|   |   |-- tty0 -> /dev/ttyIFM_RSx_0_0
|   |   |-- tty1 -> /dev/ttyIFM_RSx_0_1
|   |   |-- tty2 -> /dev/ttyIFM_RSx_0_2
|   |   `-- tty3 -> /dev/ttyIFM_RSx_0_3
|   `-- type.RS485
`-- D
    |-- access
    |   |-- tty0 -> /dev/ttyIFM_RSx_1_0
    |   |-- tty1 -> /dev/ttyIFM_RSx_1_1
    |   |-- tty2 -> /dev/ttyIFM_RSx_1_2
    |   `-- tty3 -> /dev/ttyIFM_RSx_1_3
    `-- type.RS232

Stack Detection Status

StackLink configurator script provides indication of I/O modules stack detection status using IOT-DIN-IMX8PLUS power LED:

Power LED Status Remarks
Blinking Blue Recognized and valid configuration Normal operation
Blinking Amber Unrecognized I/O module or invalid configuration Check the log for details

Stack Detection Info

StackLink configurator script stores stack detection info log in the following designated location:

/run/iotdin-imx8p/log/iotdin-imx8p.stack.log.<YYYYMMDD_HHMMSS>

Stack Troubleshooting


Admolition warning.png DO NOT attach or detach I/O Expansion modules while the gateway is connected to DC power! Disconnect all power sources from the gateway before attaching or detaching I/O modules.

In case of invalid IFM stack status:

  1. Check the stack detection log
  2. Double check if a desired stack conforms the Stacking Rules
  3. Verify proper mechanical attachment of modules
  4. Contact technical support

IFM Backplane


/run/iotdin-imx8p/stack/backplane directory stores the system information about the physical hardware devices installed in the stack. These files should not be altered.

IFM-DI8O8

IFM-DI8O8 module provides an isolated block of eight digital inputs and a block of eight digital outputs.

During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed IFM-DI8O8 modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.


Admolition note.png For correct operation of both digital inputs and outputs, isolated external voltage supplies in the range of 6–24 VDC must be provided for each block via the AUX connector.

Listing all Digital I/O modules

Use diodetect command to get an overview of all available Digital Inputs and Outputs:

compulab@compulab-imx8mp:~$ /opt/iotdin-imx8p/shell/diodetect
Main Gateway:   DI2O2   (2x DI; 2x DO)
Stack Slot B:   DI8O8   (8x DI; 8x DO)
Stack Slot D:   CAN     (4x DI; 4x DO)

Use dioget and dioset commands to access digital inputs and digital outputs.
It is recommended to set the following alias for more convenient work:

compulab@compulab-imx8mp:~$ dioget=/opt/iotdin-imx8p/shell/dioget
compulab@compulab-imx8mp:~$ dioset=/opt/iotdin-imx8p/shell/dioset

Reading Digital Inputs

Setup alias for more convenient work:

compulab@compulab-imx8mp:~$ dioget=/opt/iotdin-imx8p/shell/dioget
compulab@compulab-imx8mp:~$ sudo ${dioget} -h
Usage: dioget [options] <command>

Read digital input state from a Digital I/O (DIO) module

Command:
 -m <module> <offset>
        module: DIO module location:
            m|M - Main Gateway
            a|A - Virtual slot A
            ...
            h|H - Virtual slot H
        offset: input pin offset: <0..MaxOffset>
Options:
 -h:    display this help and exit

Example
Read state of input pin IN_4 on IFM-DI8O8 installed in slot B:

compulab@compulab-imx8mp:~$ sudo ${dioget} -m B 4

Setting Digital Outputs

Setup alias for more convenient work:

compulab@compulab-imx8mp:~$ dioset=/opt/iotdin-imx8p/shell/dioset
compulab@compulab-imx8mp:~$ sudo ${dioset} -h
Usage: dioset [options] <command>

Set the digital output state of a Digital I/O (DIO) module

Command:
 -m <module> <offset>  <state>
        module: DIO module location:
            m|M - Main Gateway
            a|A - Virtual slot A
            ...
            h|H - Virtual slot H
        offset: output pin offset: <0..MaxOffset>
        state:  output pin state to be set: <0|1>
Options:
 -h:    display this help and exit

Example
Setting output pin OUT_4 to HIGH state on IFM-DI8O8 installed in slot B:

compulab@compulab-imx8mp:~$ sudo ${dioset} -m B 4 1

IFM-CAN

IFM-CAN module provides two isolated blocks:

  • 2x CAN interfaces support both CAN 2.0B and CAN FD standards. Maximum supported data rate is 8Mbps (in CAN FD mode).
  • 4x digital inputs and 4x eight digital outputs.


During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed IFM-CAN modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Example

For an IFM-CAN module installed in slot D the configurator script will create the following access files:

/run/iotdin-imx8p/stack/frontplane/
|-- D
|   |-- access
|   |   |-- can0 -> /sys/class/net/canIFM_0
|   |   |-- can1 -> /sys/class/net/canIFM_1
|   |   |-- di.map
|   |   |-- do.map
|   |   `-- gpiochip -> /dev/gpiochip7
|   `-- type.CAN

CAN block access

  • Detect 1-st CAN interface:
compulab@iot-gate-imx8plus:~$ can0=$(basename $(readlink -e /run/iotdin-imx8p/stack/frontplane/D/access/can0))
  • Detect 20-nd CAN interface:
compulab@iot-gate-imx8plus:~$ can1=$(basename $(readlink -e /run/iotdin-imx8p/stack/frontplane/D/access/can1))

Use ${can0} and ${can1} variables for accessing CAN interfaces.

CAN 2.0B

In the same way as done for the IOT-DIN-IMX8PLUS CAN 2.0B interface.

Admolition note.png Use interface names set in ${can0} and ${can1} variables

CAN FD

CAN interface configuration

  • Disable the CAN interface:
compulab@@compulab-imx8mp:~$ sudo ip link set ${can0} down
  • Set the CAN FD interface arbitration bitrate to 1 Mbits/sec and the data bitrate to 8 Mbits/sec:
compulab@@compulab-imx8mp:~$ sudo ip link set dev ${can0} type can bitrate 1000000 fd on dbitrate 8000000
  • Enable the CAN interface:
compulab@@compulab-imx8mp:~$ 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 without switching bitrate:
compulab@@compulab-imx8mp:~$ sudo cansend ${can0} 111##0.1122334455667788
  • Send standard CAN frame with bitrate switch (BRS):
compulab@@compulab-imx8mp:~$ sudo cansend ${can0} 111##1.1122334455667788
  • Send extended CAN frame (on the first device) without switching bitrate:
compulab@@compulab-imx8mp:~$ sudo cansend ${can0}  11111111##0.111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000
  • Send extended CAN frame (on the first device) with bitrate switch (BRS):
compulab@@compulab-imx8mp:~$ sudo cansend ${can0}  11111111##1.111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000


  • CAN FD frames (extended mode) generator, bitrate switch (BRS), random payload, interval between two successive frames 50 msec:
compulab@@compulab-imx8mp:~$ sudo cangen -g 50 -e -b -D r -v ${can0} -n 10
...
  canIFM_0  1014153E##1.25.92.D3.6B.31.4D.EE.23.25.92.D3.6B.31.4D.EE.23
  canIFM_0  0FC455A2##1.B4.2F.8B.08.F7.DF.14.4E.B4.2F.8B.08.F7.DF.14.4E.B4.2F.8B.08
  canIFM_0  0719498A##1.B3.BF.81.14.3D.F8.66.63.B3.BF.81.14.3D.F8.66.63.B3.BF.81.14.3D.F8.66.63.B3.BF.81.14.3D.F8.66.63
  canIFM_0  09FA61BF##1.7D.BE.9A.74
  canIFM_0  1996A5B0##1.44.CA.26.54.D3.CA.B7.19.44.CA.26.54
  canIFM_0  0A6C7B75##1.E2.29.1F.15.1F
  canIFM_0  140711D5##1.16.6F.98.3A
  canIFM_0  10CF8325##1.F3.2A.4B.4C.63.98.E3
  canIFM_0  0D5D59E1##1.94.E5.D1.44.84.AF.21.5D
  canIFM_0  0126B2B3##1.7B.8F.36.2B.3D.FC.3F.68
...
  • Dump all received data frames as well as error frames:
compulab@@compulab-imx8mp:~$ sudo candump any,0:0,#FFFFFFFF
...
  canIFM_1  1014153E  [16]  25 92 D3 6B 31 4D EE 23 25 92 D3 6B 31 4D EE 23
  canIFM_1  0FC455A2  [20]  B4 2F 8B 08 F7 DF 14 4E B4 2F 8B 08 F7 DF 14 4E B4 2F 8B 08
  canIFM_1  0719498A  [32]  B3 BF 81 14 3D F8 66 63 B3 BF 81 14 3D F8 66 63 B3 BF 81 14 3D F8 66 63 B3 BF 81 14 3D F8 66 63
  canIFM_1  09FA61BF  [04]  7D BE 9A 74
  canIFM_1  1996A5B0  [12]  44 CA 26 54 D3 CA B7 19 44 CA 26 54
  canIFM_1  0A6C7B75  [05]  E2 29 1F 15 1F
  canIFM_1  140711D5  [04]  16 6F 98 3A
  canIFM_1  10CF8325  [07]  F3 2A 4B 4C 63 98 E3
  canIFM_1  0D5D59E1  [08]  94 E5 D1 44 84 AF 21 5D
  canIFM_1  0126B2B3  [08]  7B 8F 36 2B 3D FC 3F 68
...

DIO block access

Read Digital Inputs and set Digital Outputs in the same way as done for the IFM-DI8O8 module

IFM-ADC8

IFM-ADC8 provides eight single-ended analog input channels (0-7), divided into two blocks of 4. Inputs operate between 0-10V or 4-20mA ranges for use with industrial sensors. Each block can be set into current or voltage input mode via jumper.

During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Example
Read a detected value of channel 5 of IFM-ADC8 module installed in slot A:

compulab@compulab-imx8mp:~$ X=5 ; slot=A
compulab@compulab-imx8mp:~$ sudo cat /run/iotdin-imx8p/stack/frontplane/${slot}/access/adc$((X/4))/in_voltage$((X%4))_raw

IFM-RS485

IFM-RS485 I/O module provides four half-duplex RS485 ports.
During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Example

For an IFM-RS485 module installed in slot C the configurator script will create the following access files:

/run/iotdin-imx8p/stack/frontplane/
|-- C
|   |-- access
|   |   |-- tty0 -> /dev/ttyIFM_RSx_0_0
|   |   |-- tty1 -> /dev/ttyIFM_RSx_0_1
|   |   |-- tty2 -> /dev/ttyIFM_RSx_0_2
|   |   `-- tty3 -> /dev/ttyIFM_RSx_0_3
|   `-- type.RS485

Use /run/iotdin-imx8p/stack/frontplane/C/access/ttyX to access port #X

IFM-RS232

IFM-RS232 I/O module provides four 2-wire RS232 ports.
During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Example

For an IFM-RS232 module installed in slot D the configurator script will create the following access files:

/run/iotdin-imx8p/stack/frontplane/
|-- D
|   |-- access
|   |   |-- tty0 -> /dev/ttyIFM_RSx_1_0
|   |   |-- tty1 -> /dev/ttyIFM_RSx_1_1
|   |   |-- tty2 -> /dev/ttyIFM_RSx_1_2
|   |   `-- tty3 -> /dev/ttyIFM_RSx_1_3
|   `-- type.RS232

Use /run/iotdin-imx8p/stack/frontplane/D/access/ttyX to access port #X

IFM-NVME

IFM-NVME provides an additional storage implemented with NVME solid-state drive.

During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Admolition note.png IFM-NVME module can only be installed in position A (next to main gateway)

For an IFM-NVME module installed in slot A the configurator script will create the following access files:

/run/iotdin-imx8p/stack/frontplane/
|-- A
|   |-- access
|   |   `-- blkdev -> /dev/nvme0n1
|   `-- type.NVME

IFM-WB

IFM-WB I/O module features one 802.11ax WiFi and one Bluetooth 5.3 BLE interfaces.
During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Admolition note.png IFM-WB module can only be installed in position A (next to main gateway)

For an IFM-WB module installed in slot A the configurator script will create the following access files:

/run/iotdin-imx8p/stack/frontplane/
|-- A
|   |-- access
|   |   |-- bluetooth -> /sys/class/bluetooth/hci0
|   |   `-- wlan -> /sys/class/net/wlan0
|   `-- type.WB

Example

  • Display WiFi network interface info
compulab@compulab-imx8mp:~$ wlan=$(basename $(readlink -f /run/iotdin-imx8p/stack/frontplane/A/access/wlan))
compulab@compulab-imx8mp:~$ sudo ifconfig ${wlan}
compulab@compulab-imx8mp:~$ sudo iwconfig ${wlan}
  • Display Bluetooth interface info
compulab@compulab-imx8mp:~$ bt=$(basename $(readlink -f /run/iotdin-imx8p/stack/frontplane/A/access/bluetooth))
compulab@compulab-imx8mp:~$ hciconfig ${bt}

WiFi

Enable/Disable WiFi Interface

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

Network Scanning

  • Sample WiFi scanning:
compulab@compulab-imx8mp:~$ nmcli dev wifi list ifname ${wlan}
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@compulab-imx8mp:~$ sudo nmcli device wifi connect <SSID> password <PASSWORD> name WifiCon-${wlan} ifname ${wlan}
  • Disconnect wireless network:
compulab@compulab-imx8mp:~$ sudo nmcli connection down WifiCon-${wlan}
  • Connect wireless network again:
compulab@compulab-imx8mp:~$ sudo nmcli connection up WifiCon-${wlan}

Creating Access Point

Admolition note.png Debian 12
ipv4 forwarding must be turned on manually
  • Enable port forwarding:
compulab@compulab-imx8mp:~$ sudo sed -i 's/^#\(net.ipv[4,6].*forward\)/\1/' /etc/sysctl.conf
  • Enable wireless AP (replace <SSID> and <PASSWORD> with desired access point parameters):
sudo nmcli device wifi hotspot ssid <SSID> password <PASSWORD> con-name HotspotCon-${wlan} ifname ${wlan}
  • Disable wireless AP:
compulab@compulab-imx8mp:~$ sudo nmcli connection down HotspotCon-${wlan}
  • Enable wireless AP again:
compulab@compulab-imx8mp:~$ sudo nmcli connection up HotspotCon-${wlan}