IOT-GATE-RPI5: Raspberry Pi OS: How-To Guide

From Compulab Mediawiki
Revision as of 14:06, 3 June 2026 by Igor (talk | contribs) (Created page with "= Overview = IOT-GATE-RPI5 runs standard [https://www.raspberrypi.com/software/operating-systems/ Raspberry Pi OS] with an additional IOT-GATE-RPI5 OS Configuration Layer that...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

IOT-GATE-RPI5 runs standard Raspberry Pi OS with an additional IOT-GATE-RPI5 OS Configuration Layer that sets-up the gateway peripheral devices and provides useful tools for device configuration and management.

Gateway Configurator

During O/S boot, the IOT-GATE-RPI5 automatically runs the Gateway configurator script.
The script detects WiFi/Bluetooth modules, cellular modems, and other peripherals, and configures the virtual device files used to access these devices, and creates access files for all permanent and detected optional devices.

Gateway Interfaces

Gateway interfaces access directory example:

/run/iot-gate-rpi5/gateway/access/
├── blkdev
│   └── emmc -> /dev/mmcblk0
├── cmd_button
│   └── event -> /dev/input/event6
├── leds
│   ├── green_a -> /sys/class/leds/Green_A
│   └── red_a -> /sys/class/leds/Red_A
├── network
│   ├── bluetooth -> /sys/class/bluetooth/hci0
│   ├── mesh
│   ├── modem
│   │   ├── at1 -> /dev/ttyModemAT1
│   │   ├── at2 -> /dev/ttyModemAT2
│   │   └── qcdm -> /dev/ttyModemQCDM
│   └── wlan -> /sys/class/net/wlan0
└── tpm
    ├── tpm -> /sys/class/tpm/tpm0
    └── tpmrm -> /sys/class/tpmrm/tpmrm0

Cellular Modem

IOT-GATE-RPI5 cellular interface is implemented with a mini-PCIe cellular modem module and a micro-SIM socket. To set up IOT-GATE-RPI5 for cellular functionality, install an active SIM card into SIM socket located behind the side panel service bay door. Remove the service bay door to access the SIM socket.

Admolition note.png Cellular modem is present only in gateways ordered with the “JT910G” configuration option

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.
pi@raspberrypi:~$ sudo nmcli connection add type gsm ifname '*' con-name CellularCon apn ISP-APN
  • Connect cellular network
pi@raspberrypi:~$ sudo nmcli connection up CellularCon
  • Disconnect cellular network
pi@raspberrypi:~$ sudo nmcli connection down CellularCon

Ethernet

IOT-GATE-RPI5 features two Ethernet ports:

  • ETH0 – 1000Mbps port implemented with Raspberry Pi 5 module
  • ETH1 – 100Mbps port implemented with Microchip LAN9514 controller

Please refer to the Raspberry Pi OS documentation for detailed instruction about configuring network settings.

WiFi and Bluetooth

IOT-GATE-RPI5 features optional on-board 802.11ac WiFi and Bluetooth 5.0 BLE interfaces.
Please refer to the Raspberry Pi OS documentation for detailed instruction about configuring WiFi and connecting to Access Point.

CPU temperature

The CPU temperature can be read in several ways:

  • Using the vcgencmd utility, as shown below:
pi@raspberrypi:~$ vcgencmd measure_temp
  • Directly via sysfs:
pi@raspberrypi:~$ cat /sys/class/thermal/thermal_zone0/temp

Please refer to the Raspberry Pi OS documentation for more detailed information about thermal control and frequency management.

LEDs

IOT-GATE-RPI5 features a user Bi-Color (Red + Green) LED found on the main panel. The dual LED is controlled via GPIO pins and can be accessed via sysfs interface.

  • The Green and the Res LEDs are referred to as Green_A and Red_A respectively
  • Choose a LED (Red in this example):
pi@raspberrypi:~$ LED=Red_A
  • Turn the LED ON
pi@raspberrypi:~$ echo "1" | sudo tee -a /sys/class/leds/${LED}/brightness
  • Turn the LED OFF
pi@raspberrypi:~$ echo "0" | sudo tee -a /sys/class/leds/${LED}/brightness
  • Set LED's trigger
pi@raspberrypi:~$ echo "heartbeat" | sudo tee -a /sys/class/leds/${LED}/trigger

TPM

IOT-GATE-RPI5 features TPM 2.0 implemented with Infineon SLB9673.

TPM Initialization

The TPM driver is loaded gets loaded automatically

  • Make sure that the TPM kernel object is loaded:
pi@raspberrypi:~# lsmod | grep tpm_tis_i2c
  • Load the TPM kernel object manually is required:
pi@raspberrypi:~$ modprobe tpm_tis_i2c

TPM Basic Functionality

  • Install the tpm2-tools package:
pi@raspberrypi:~$ sudo apt-get update && sudo apt-get install tpm2-tools
  • Validate basic functionality
pi@raspberrypi:~$ sudo tpm2_getrandom --hex 32

The correct result will be returned generated 32-symbol key.

CMD button

The CMD button is implemented as gpio-keys device with code 171 (KEY_CONFIG).
It is exposed as a standard Linux Input Device and can be accessed from userspace via the corresponding /dev/input/eventX device file.

CMD button device tree overlay

To enable or disable the IOT-GATE-RPI5 CMD button, add or remove (comment out) the following line in the config.txt file:

dtoverlay=iotg-rpi5/iotg-rpi5-cmd-button

Input Device

During O/S boot, the IOT-GATE-RPI5 configurator script creates an access file pointing to the corresponding input event device.

Example

/run/iot-gate-rpi5/gateway/access/
...
├── cmd_button
│   └── event -> /dev/input/event6
...

CMD Button Demo

The cmd_button demo utility uses the Linux utility evtest to monitor CMD button press events and perform a user action, namely toggling the state of User LED A.


pi@raspberrypi:~$ sudo /opt/iot-gate-rpi5/shell/cmd_button 
           #######################
           #   CMD Button Demo   #
           #######################

Press CMD button and observe User LED A state change

Press 'Ctrl+C' to stop the Demo
CMD Button pressed: LED state: red
CMD Button pressed: LED state: green
CMD Button pressed: LED state: red
CMD Button pressed: LED state: green
CMD Button pressed: LED state: red
CMD Button pressed: LED state: green
CMD Button pressed: LED state: red
CMD Button pressed: LED state: green
^C

Industrial I/O Interfaces

The IOT-GATE-RPI5 features two configurable Industrial I/O ports. Each port can be individually configured to operate in either RS485 or CAN mode.
In addition, the IOT-GATE-RPI5 provides four programmable signals that can be used as either digital inputs or digital outputs.
These three interfaces are treated as a virtual I/O stack, where the RS485/CAN ports are managed as virtual slots A and B, and the Digital I/O interface is managed as virtual slot C.

I/O Configurator

During O/S boot, the IOT-GATE-RPI5 automatically runs the Industrial I/O configurator script. The script examines the user-defined I/O configuration, such as RS485, CAN, and Digital I/Os, and creates access files for all enabled interfaces.

Industrial I/O Stack access directory example:

/run/iot-gate-rpi5/io_stack/
└── frontplane
    ├── A
    │   ├── access
    │   │   └── can -> /sys/class/net/canA
    │   └── type.CAN
    ├── B
    │   ├── access
    │   │   └── tty -> /dev/ttyAMA2
    │   └── type.RS485
    └── C
        ├── access
        │   ├── di.map
        │   └── do.map
        └── type.DIO

CAN bus

The IOT-GATE-RPI5 CAN interfaces are implemented using MCP2518FD controllers interfaced with the Raspberry Pi CM5 SPI interfaces.
CAN bus key characteristics:

  • Support both the CAN 2.0B and CAN FD standards
  • The maximum supported data rate is 8 Mbps in CAN FD mode
  • Galvanic isolation from the main unit
  • Optional 120Ω termination resistors

The CAN signals are routed to the Industrial I/O connector as follows:

Pin Signal Name Description
12 PORTA_TRM PORT-A: 120Ω termination control

Connect to ISO1_GND (pin 17) to disable termination

13 PORTA_NEG PORT-A: CAN bus low
14 PORTA_POS PORT-A: CAN bus high
15 PORTB_NEG PORT-B: CAN bus low
16 PORTB_POS PORT-B: CAN bus high
17 ISO1_GND Isolated ground for CAN domain
18 PORTB_TRM PORT-B: 120Ω termination control

Connect to ISO1_GND (pin 17) to disable termination

Please refer to IOT-GATE-RPI5 reference guide for Industrial I/O Connector full pin-out.

Enable/Disable CAN Interface

To enable/disable CAN Interface on a specific Industrial I/O port (aka virtual slot) please use iotg-rpi5-config utility.

Access CAN Interface

During O/S boot, the I/O configurator automatically creates access files for all enabled CAN interfaces.

  • Detect a CAN interface on the slot A:
pi@raspberrypi:~$ canA=$(basename $(readlink -e /run/iot-gate-rpi5/io_stack/frontplane/A/access/can))
  • Detect a CAN interface on the slot B:
pi@raspberrypi:~$ canB=$(basename $(readlink -e /run/iot-gate-rpi5/io_stack/frontplane/B/access/can))


Admolition tip.png Use ${canA} and ${canB} variables for accessing CAN interfaces.

CAN 2.0B

The following example demonstrates how to configure and use the CAN interface on the slot A

CAN interface configuration

  • Disable the CAN interface:
pi@raspberrypi:~$ sudo ip link set ${canA} down
  • Configure the CAN interface bit-rate to 1 Mbits/sec:
pi@raspberrypi:~$ sudo ip link set ${canA} type can bitrate 1000000
  • Enable the CAN interface:
pi@raspberrypi:~$ sudo ip link set ${canA} up

Send/Receive packets

Use cansend utility to send packets via the CAN interface:

  • Send standard CAN frame
pi@raspberrypi:~$ sudo cansend ${canA} 111#1122334455667788
  • Send extended CAN frame
pi@raspberrypi:~$ sudo cansend ${canA} 11111111#1122334455667788

Use cangen utility to generate continuous traffic on the CAN interface:

  • CAN frames (extended mode) generator, random payload, interval between two successive frames 50 msec:
pi@raspberrypi:~$ sudo cangen -g 50 -e -D r -v ${canA}
...
  canA  062732AC#
  canA  0F5E0A2E#FC
  canA  0F7E7A24#A6.8F.AD.6E
  canA  1D64ADFC#0E.66.77
  canA  0322F5FD#9B.1F.EC.4A.01.1F
  canA  098A5C8F#
  canA  151EBD68#8F.B1.A7.70.53.7A.F4.26
  canA  0EDB6A60#A7.47.82.6A.0C.9D.02.75
  canA  02C007EB#4C.D2.66.14.1A.12.1E.72
  canA  1C06246D#DD.65.A8.0D.92.9E.84.2B
  canA  1CE351BD#CE.5D.25
  canA  0F843F27#49.89.5D.51.24.35.A7.12
...

Use candump utility to capture, display, filter, and log real-time CAN (Controller Area Network) bus traffic

  • Dump all received data frames as well as error frames:
...
pi@raspberrypi:~ $ sudo candump any,0:0,#FFFFFFFF
  canA  0DC514CB   [8]  55 56 36 7C 7A 0A 30 24
  canA  0825720E   [8]  6D 9C B6 0F D6 30 A4 00
  canA  02E8D437   [7]  9E 18 08 19 50 92 A3
  canA  06F860CD   [3]  27 11 38
  canA  08FC1CA5   [8]  6E 03 72 7E 45 76 A3 41
  canA  1026292B   [8]  13 0C 80 60 0B 73 AA 49
  canA  090079D8   [0] 
  canA  1AC761C8   [5]  E9 55 A7 04 93
  canA  0771D951   [8]  0D 81 BC 6C 60 4B 97 0F
  canA  03C3FA5A   [8]  36 7C 3B 10 91 CE AC 06
  canA  0CA0F9E2   [4]  E2 60 50 2A
  canA  05062028   [8]  8C 7D F8 38 CD 3C 02 0E
...

CAN FD

The following example demonstrates how to configure and use the CAN interface on the slot B

CAN interface configuration

  • Disable the CAN interface:
pi@raspberrypi:~$ sudo ip link set ${canB} down
  • Set the CAN FD interface arbitration bitrate to 1 Mbits/sec and the data bitrate to 8 Mbits/sec:
pi@raspberrypi:~$ sudo ip link set dev ${canB} type can bitrate 1000000 fd on dbitrate 8000000
  • Enable the CAN interface:
pi@raspberrypi:~$ sudo ip link set ${canB} up

Send/Receive packets

Use cansend utility to send packets via the CAN interface:

  • Send standard CAN frame without switching bitrate:
pi@raspberrypi:~$ sudo cansend ${canB} 111##0.1122334455667788
  • Send standard CAN frame with bitrate switch (BRS):
pi@raspberrypi:~$ sudo cansend ${canB} 111##1.1122334455667788
  • Send extended CAN frame (on the first device) without switching bitrate:
pi@raspberrypi:~$ sudo cansend ${canB} 11111111##0.111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000
  • Send extended CAN frame (on the first device) with bitrate switch (BRS):
pi@raspberrypi:~$ sudo cansend ${canB} 11111111##1.111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000

Use cangen utility to generate continuous traffic on the CAN interface:

  • CAN FD frames (extended mode) generator, bitrate switch (BRS), random payload, interval between two successive frames 50 msec:
pi@raspberrypi:~$ sudo cangen -g 50 -e -b -D r -v ${canB}
...
  canB  0493FE58##1.55.E9.C1
  canB  0B895EB8##1.DE.F6.05.40.04.3F.E4.50.DE.F6.05.40.04.3F.E4.50.DE.F6.05.40.04.3F.E4.50
  canB  1696CDF4##1.E4.7B.28.24.5D.05.59.27.E4.7B.28.24.5D.05.59.27
  canB  133AE826##1.CC.89.BD.16
  canB  0BDF5FC9##1.02.E8.17.30.53.DF.AF.4E.02.E8.17.30
  canB  104E7D14##1.90.13.C5.01
  canB  0C27407A##1.68.D4.11.7B.65.B2.DA
  canB  04B0FCC9##1.CD.47
  canB  036DDD96##1.A2.39
  canB  0A8BF78F##1.53
...

Use candump utility to capture, display, filter, and log real-time CAN (Controller Area Network) bus traffic:

  • Dump all received data frames as well as error frames:
pi@raspberrypi:~$ sudo candump any,0:0,#FFFFFFFF
...
  canB  03BD5B31  [16]  61 01 C1 38 48 BE E5 25 61 01 C1 38 48 BE E5 25
  canB  0C01AF9E  [05]  3D 08 81 72 BE
  canB  11E9FCF7  [16]  66 79 82 4E CE CF B8 76 66 79 82 4E CE CF B8 76
  canB  1BE347A5  [04]  48 7E 84 58
  canB  1D0D9DA5  [16]  4F AB D2 11 24 EF 98 4F 4F AB D2 11 24 EF 98 4F
  canB  0F648B7F  [32]  92 D7 A7 1F 79 57 CB 35 92 D7 A7 1F 79 57 CB 35 92 D7 A7 1F 79 57 CB 35 92 D7 A7 1F 79 57 CB 35
  canB  1E57BDAE  [04]  DD E3 26 69
  canB  0FD3942B  [04]  A2 75 E1 09
  canB  1E67C67E  [03]  A4 AD 76
  canB  116DD0E8  [01]  DA
...

RS485

The IOT-GATE-RPI5 RS485 interfaces are implemented using MAX13488 (or compatible) transceiver interfaced with the Raspberry Pi CM5 UARTs.
RS485 key characteristics:

  • 2-wire, half-duplex
  • Programmable baud rate of up to 1Mbps
  • Galvanic isolation from the main unit
  • Optional 120Ω termination resistors controlled by shorting between PORTA-TRM and PORTB-TRM pins to ISO1_GND pin

The RS485 signals are routed to the Industrial I/O connector as follows:

Pin Signal Name Description
12 PORTA_TRM PORT-A: 120Ω termination control

Connect to ISO1_GND (pin 17) to disable termination

13 PORTA_NEG PORT-A: RS485 negative
14 PORTA_POS PORT-A: RS485 positive
15 PORTB_NEG PORT-B: RS485 negative
16 PORTB_POS PORT-B: RS485 positive
17 ISO1_GND Isolated ground for RS485 domain
18 PORTB_TRM PORT-B: 120Ω termination control

Connect to ISO1_GND (pin 17) to disable termination

Please refer to IOT-GATE-RPI5 reference guide for Industrial I/O Connector full pin-out.

Enable/Disable RS485 Interface

To enable/disable RS485 Interface on a specific Industrial I/O port (aka virtual slot) please use iotg-rpi5-config utility.

Access RS485 Interface

During O/S boot, the I/O configurator automatically creates access files for all enabled RS485 interfaces.

  • Detect an RS485 interface on the slot A:
pi@raspberrypi:~$ ttyRS485_A=$(basename $(readlink -e /run/iot-gate-rpi5/io_stack/frontplane/A/access/tty))
  • Detect an RS485 interface on the slot B:
pi@raspberrypi:~$ ttyRS485_B=$(basename $(readlink -e /run/iot-gate-rpi5/io_stack/frontplane/B/access/tty))


Admolition tip.png Use ${ttyRS485_A} and ${ttyRS485_B} variables for accessing RS485 interfaces
pi@raspberrypi:~$ stty -F ${ttyRS485_B}

Digital I/O

The IOT-GATE-RPI5 IOT-GATE-RPI5 provides four programmable signals which can be used as either digital inputs or outputs.
DIO key characteristics:

  • Designed for 24V PLC applications
  • Digital outputs maximal output current 1A per channel
  • Digital inputs self-powered with current limit

The DIO signals are routed to the Industrial I/O connector as follows:

Pin Signal Name Description
6 ISO2_GND Isolated ground for DIO domain
7 DIO_VIN Digital I/O external DC power input
8 DIO1 Digital input / output 1
9 DIO0 Digital input / output 0
10 DIO3 Digital input / output 3
11 DIO2 Digital input / output 2


Admolition important.png External voltage supply in the range 6-24V DC must be supplied via DIO_VIN pin for correct operation of digital inputs and outputs

Please refer to IOT-GATE-RPI5 reference guide for Industrial I/O Connector full pin-out.

Enable Digital Inputs and Outputs

The IOT-GATE-RPI5 provides four programmable signals that can be configured as either digital inputs or digital outputs.
The Digital I/O interface is managed as virtual slot C.
To configure the direction of a specific signal, use the iotg-rpi5-config utility.

Access DIO Interface

During O/S boot, the I/O configurator automatically creates access files for the DIO signals according to trhe user-defined configuration.
DIO signals can be accessed either through the DIO utilities developed by Compulab and included in the IOT-GATE-RPI5 Raspberry Pi OS image, or through the GPIO utilities provided by the gpiod package.

In the following example, digital signals 0 and 3 are configured as inputs (DI0 and DI3), while signals 1 and 2 are configured as outputs (DO1 and DO2).

Show DIO to GPIO chip/line mapping

Use dioinfo to show Digital Input and Output GPIO chip/line mapping.

pi@raspberrypi:~$ /opt/iot-gate-rpi5/shell/dioinfo 
Stack Slot C:   DIO     (4x DI; 4x DO)
        ~~~~~~~~~~~~~~~~~
        Digital GPIO GPIO
        Signal  Chip Line
        ~~~~~~~~~~~~~~~~~
        DI 0:   0    6 
        DI 1:   -1   -1
        DI 2:   -1   -1
        DI 3:   0    27
        ~~~~~~~~~~~~~~~~~
        DO 0:   -1   -1
        DO 1:   14   1 
        DO 2:   14   2 
        DO 3:   -1   -1
        ~~~~~~~~~~~~~~~~~

Note that the table above contains valid GPIO chip/line information only for the DI0, DO1, DO2, and DI3 signals.
The remaining entries are not valid because the corresponding signals are not accessible.

Reading Digital Inputs

Example
Read state of input pin DI0:

  • Use dioget to access digital inputs.
pi@raspberrypi:~$ dioget=/opt/iot-gate-rpi5/shell/dioget
pi@raspberrypi:~$ sudo ${dioget} 0
  • Alternatively, use gpioget to access the underlying GPIO:
pi@raspberrypi:~$ sudo gpioget --numeric -c 0 6

Setting Digital Outputs

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

  • Use dioset to access digital outputs.
pi@raspberrypi:~$ dioset=/opt/iot-gate-rpi5/shell/dioset
pi@raspberrypi:~$ sudo ${dioset} 2 1
  • Alternatively, use gpioset to access the underlying GPIO:
pi@raspberrypi:~$ sudo gpioset --toggle 0 -c 14 2=1