40-Pin I/O Headers Utility on I-Pi SAMRC IMX8M Plus

This document provides detailed instructions for utilizing the 40-Pin I/O Headers on I-Pi SMARC IMX8M Plus.

Prerequisites

  • GPIO libraries are included with our image by default.
  • Power up the targeted device with all the necessary cables such as HDMI, keyboard, mouse and ethernet cable.

Linux Host

1. Getting Started

  • Install “hexer” for editing the binary files.

    sudo apt install hexer
  • Install “i2c-tools”.

    sudo apt install i2c-tools
  • Enter into the terminal as a root user using the below command,

    su root

    Note: All the commands require administrator privileges and run as root user.

2. Utilizing the Pin Headers with Linux

2.1 Voltage Monitor

  • Open the terminal type the following command,

    cd /sys/class/regulator
  • To get the hardware monitor input voltage and get the respective voltage description

    cat <regulator index>/microvolts
    cat <regulator index>/name
  • In the example below, user is reading the voltage and description of id 1

    cat regulator.1/microvolts
    cat regulator.1/name

2.2 GPIO

  • Open the terminal type the following command,

    cd /sys/class/gpio
  • To export the GPIO pin

    echo N > export (N should replace with gpio chip base number)

    In below example 497 is the gpio chip base number for pin-7 in IMX8MP.

    Ex:

    echo 497 > export
  • To read the direction of a pin

    cat gpio497/direction
  • To write the direction of a pin

    echo in > gpio497/direction
  • To read the value of a pin

    cat gpio497/value
  • To write the value of a pin

    echo 1 > gpio497/value
2.2.1 GPIO Pin Configurations
  • On CN1001 expansion connector E_GPIO and S_GPIO is available. These GPIO pins are mapped by to following numbers:

    S_GPIO(MRAA) numbers are:

    ​ pin7 - 497

    ​ pin11 - 499

    ​ pin12 - 498

    ​ pin13 - 500

    ​ pin15 - 501

    E_GPIO(MRAA) numbers are:

    ​ pin29 - 461

    ​ pin31 - 462

    ​ pin32 - 463

    ​ pin33 - 464

    ​ pin35 - 465

    ​ pin36 - 466

    ​ pin37 - 467

    ​ pin38 - 468

    ​ pin40 - 469

2.3 Storage

  • To read the storage area,

    hexdump /sys/bus/nvmem/devices//nvmem

    For example:

    hexdump /sys/bus/nvmem/devices/imx-octp0/nvmem
  • To write the storage area

    hexer /sys/bus/nvmem/devices//nvmem

    For example:

    hexer /sys/bus/nvmem/devices/imx-octp0/nvmem

    Hexer will open a nvmem file in editor mode. To edit the data press r (replace) and enter new data then press ESC key and :wq to save. Then read the same file using hexdump to check saved changes.

2.4 Backlight

  • Open the terminal type the following command,

    cd /sys/class/backlight
  • To Set the current Backlight Enable State to either ON / OFF

    echo > lvds_backlight/bl_power

    For Example,

    • To enable the backlight,

      echo 1 > lvds_backlight/bl_power
    • To Disable the backlight,

      echo 0 > lvds_backlight/bl_power
  • To get the current Backlight Brightness level

    cat lvds_backlight/actual_brightness
  • To Set the current Backlight brightness level

    echo <level> > lvds_backlight/brightness
    • For Example, to set the brightness level of 78,

      echo 78 > lvds_backlight/brightness