GPIO Pins Control - HummingBoard Ripple/Pulse & i.MX8M Mini 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 echo XX > /sys/class/gpio/export # Set GPIO pin Direction echo "out" > /sys/class/gpio/gpioXX/direction or echo "in" > /sys/class/gpio/gpioXX/direction # Set the value of an output pin echo 1 > /sys/class/gpio/gpioXX/value or echo 0 > /sys/class/gpio/gpioXX/value # Get the value of an input pin cat > /sys/class/gpio/gpioXX/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 imx8mm processor side) and from here pins-imx8mm.h can find the GPIO define name of the pin/pad with the GPIO option like (MX8MM_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: MX8MM_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]

SAI2_RXD

GPIO4_IO23

119

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 -> UART3_RXD

GPIO5_IO26

154

J10 [pin 2]

UART3_RTS -> UART3_TXD

GPIO5_IO27

155

J10 [pin 3]

UART3_RXD -> UART1_RXD

GPIO5_IO22

150

J10 [pin 4]

UART3_TXD -> UART1_TXD

GPIO5_IO23

151

J10 [pin 5]

I2C3_SCL

GPIO5_IO18

146

J10 [pin 6]

I2C3_SDA

GPIO5_IO19

147



Note: from here pins-imx8mm.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 this repo to generate the kerenl - 

https://github.com/SolidRun/linux-stable/tree/linux-5.4.y-imx8

  • Here can find the imx8mm device  

https://github.com/SolidRun/linux-stable/blob/linux-5.4.y-imx8/arch/arm64/boot/dts/freescale/imx8mm-hummingboard-pulse.dts

You can see an example here - https://community.nxp.com/t5/i-MX-Processors/Problem-with-jedec-spi-nor-on-IMX8M-Mini-EVK/m-p/963020

 

SolidRun Ltd.