Toggle pin on i.MX 8M Mini Applications Processor Evaluation Kit (EVKB).

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Toggle pin on i.MX 8M Mini Applications Processor Evaluation Kit (EVKB).

Toggle pin on i.MX 8M Mini Applications Processor Evaluation Kit (EVKB).

     The following steps allow you to toggle a pin on i.MX 8M Mini EVK, you can use the EVK as not gate, trigger a wake up signal, etc. With an script and modifying the device tree you can read an input and get as output the invert input.

 

On the Host.

 

Cloning the Linux kernel repository.

 

Clone the i.MX Linux Kernel repo to the home directory.

cd ~
git clone -b lf-5.10.72-2.2.0 https://source.codeaurora.org/external/imx/linux-imx
cd linux-imx/

 

Patching the device tree.

 

Open the imx8mm-evk.dtsi file:

vim arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi

For the purpose of this example, uart3 has to be "disabled" in order to avoid pins conflict, so change "okay" to "disabled":

&uart3 {
       pinctrl-names = "default";
       pinctrl-0 = <&pinctrl_uart3>;
       assigned-clocks = <&clk IMX8MM_CLK_UART3>;
       assigned-clock-parents = <&clk IMX8MM_SYS_PLL1_80M>;
       fsl,uart-has-rtscts;
       status = "disabled";
};

Add the following lines in the iomuxc node:

 &iomuxc {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_hog>;

      pinctrl_hog: hoggrp {
              fsl,pins = <
                      MX8MM_IOMUXC_ECSPI1_SS0_GPIO5_IO9               0x19
                      MX8MM_IOMUXC_ECSPI1_MISO_GPIO5_IO8              0x19
              >;
      };

 

Build the device tree.

 

Setup your toolchain, for example:

source /opt/fsl-imx-wayland/5.10-hardknott/environment-setup-cortexa53-crypto-poky-linux

Generate config file.

make imx_v8_defconfig

Compile the device tree.

make freescale/imx8mm-evk.dtb

Copy the .dtb file to the EVK, for example with scp:

scp imx8mm-evk.dtb root@<EVK_IP>:/home/root

Alternatively, you may copy the .dtb file directly to the FAT32 partition where the Kernel and Device Tree files are located.

 

On the EVK Board.

 

Switching the device tree.

 

To copy the updated device tree to the corresponding partition, first create a directory.

mkdir Partition_1

Mount the partition one.

mount /dev/mmcblk1p1 Partition_1/

Copy or move the device tree into partition one.

cp imx8mm-evk.dtb Partition_1/

Reboot the board.

reboot

 

Create an script.

 

Use vi:

vi toggle.sh

Add the following lines:

#!/bin/bash

echo 136 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio136/direction

echo 137 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio137/direction
echo 0 > /sys/class/gpio/gpio137/value

while :
do

if [[($(cat /sys/class/gpio/gpio136/value) == "0")]]; then
        echo 1 > /sys/class/gpio/gpio137/value
else
        echo 0 > /sys/class/gpio/gpio137/value       
fi

done

Save the file:

:wq

Change file permissions:

chmod +x toggle.sh

 

Toggling a pin.

 

In this example we are using the pin "UART3_CTS" like an input and "UART3_RTS" like an output.

40 pin.png

To toggle the pin, run the script:

./toggle.sh
No ratings
Version history
Last update:
‎02-23-2022 03:10 PM
Updated by: