GPIO Pins Control - HummingBoard Pulse/Mate & i.MX8M Plus SOM

To control on the GPIO pins:

  • The external GPIOs are available under the /sys/class/gpio folder in Linux.

  • To control on the GPIO pins you need to calculate the GPIO number XX (*) and run the commands below:

=================================================== # Export GPIO XX =================================================== XX=<GPIO-Linux-Number> echo ${XX} > /sys/class/gpio/export # Set GPIO pin Direction Output/Input =================================================== # 1- Output -> =================================================== echo "out" > /sys/class/gpio/gpio${XX}/direction # Set the output value # High echo 1 > /sys/class/gpio/gpio${XX}/value # or LOW echo 0 > /sys/class/gpio/gpio${XX}/value =================================================== # 2- Input -> =================================================== echo "in" > /sys/class/gpio/gpio${XX}/direction # Get the input value cat /sys/class/gpio/gpio${XX}/value =================================================== # Unexport GPIO XX =================================================== echo ${XX} > /sys/class/gpio/unexport

(*) from the schematics you can find the name of the pin/pad (find the pad name of the imx8mp processor side) and from here pins-imx8mp.h can find the GPIO define name of the pin/pad with the GPIO option like (MX8MP_IOMUXC_SAI2_RXD0__GPIO4_IO23), then you can calculate the GPIO number XX


XX = linux gpio number = (gpio_bank - 1) * 32 + gpio_bit

Example: to calculate the GPIO number of mikroBus J8 [pin 2] 
Pad Name: SAI2_RXD

Pin Define: MX8MP_IOMUXC_SAI2_RXD0___GPIO4_IO23
GPIO Bank= 4

GPIO bit = 23


XX = ( 4 - 1) * 32 + 23 = 119


Attached here the MikroBus schematics:

MikroBus Pin

Pad Name (SOM side)

GPIO name

Linux GPIO number

J8 [pin 2]

SAI3_RXD

GPIO4_IO30

126

J8 [pin 3]

ECSPI2_SS0

GPIO5_IO13

141

J8 [pin 4]

ECSPI2_SCLK

GPIO5_IO10

138

J8 [pin 5]

ECSPI2_MISO

GPIO5_IO12

140

J8 [pin 6]

ECSPI2_MOSI

GPIO5_IO11

139

J10 [pin 1]

UART3_CTS -> ECSPI1_MISO

GPIO5_IO08

136

J10 [pin 2]

UART3_RTS -> ECSPI1_SS0

GPIO5_IO09

137

J10 [pin 3]

UART3_RXD -> ECSPI1_SCLK

GPIO5_IO06

134

J10 [pin 4]

UART3_TXD -> ECSPI1_MOSI

GPIO5_IO07

135

J10 [pin 5]

I2C3_SCL (reserved)

GPIO5_IO18

146

J10 [pin 6]

I2C3_SDA (reserved)

GPIO5_IO19

147



Note: from here pins-imx8mp.h can find the all supported functions of the pin (IOMUX options), from the Define names of same PAD name
for example, this pad ECSPI2_SS0 can support 5 functions (UART RTC, UART CTS, SPI SS, GPIO, TPSMP_HDATA) 

Define format MX8MM_IOMUX (for more information can see NXP documentations)

 

To use the SPI of the MikroBus you need to configure the SPI signals in the device tree & generate new Linux kernel + device tree

  • You can use this repo to generate the kerenl - 

https://github.com/SolidRun/linux-stable/tree/lf-5.15-sr-imx8

 

SolidRun Ltd.