Apalis i.MX6 GPIO control

Hi @Svetoslav ,

Yes, adding all the banks to the docker-compose worked. I can read all the pins except one.
The only issue right now is with GPIO bank 1, offset 2 (MXM3 pin 15). For some reason I get an error trying to read or write information on it in the following way gpiod_ctxless_get_value(“gpiochip0”, 2, false, “gpio-toggle”); .
For example with GPIO bank 1, offset 6 (MXM3 pin 17) I can read value with gpiod_ctxless_get_value(“gpiochip0”, 6, false, “gpio-toggle”);
I couldn’t find anything else on that pin so I think it’s not used for anything else so it should be readable.

Just checked here, and GPIO bank 1 offset 2 is being used by regulator-pcie-switch:

torizon@apalis-imx6-05064592:~$ docker run --rm -it --device /dev/gpiochip0 torizonextras/arm32v7-gpiod 
root@b6745be831e9:/# gpioinfo 
gpiochip0 - 32 lines: 
       line  0:   "MXM3_84" "regulator-usb-host-vbus" output active-high [used] 
       line  1:    "MXM3_4"      unused  input active-high 
       line  2: "MXM3_15/GPIO7" "regulator-pcie-switch" output active-high [used] 
       line  3:   "MXM3_96"      unused  input active-high 
       line  4:   "MXM3_37"      unused  input active-high 
       line  5:     unnamed      unused  input active-high 
       line  6: "MXM3_17/GPIO8" unused input active-high 
       line  7:   "MXM3_14"      unused  input active-high 
       line  8:   "MXM3_12"      unused  input active-high 
       line  9:    "MXM3_2"      unused  input active-high 
       line 10:  "MXM3_184"      unused  input active-high 
       line 11:  "MXM3_180"      unused  input active-high 
       line 12:  "MXM3_178"      unused  input active-high 
       line 13:  "MXM3_176"      unused  input active-high 
       line 14:  "MXM3_188"      unused  input active-high 
       line 15:  "MXM3_186"      unused  input active-high 
       line 16:  "MXM3_160"      unused  input active-high 
       line 17:  "MXM3_162"      unused  input active-high 
       line 18:  "MXM3_150"      unused  input active-high 
       line 19:  "MXM3_144"      unused  input active-high 
       line 20:  "MXM3_154"      unused  input active-high 
       line 21:  "MXM3_146"      unused  input active-high 
       line 22:     unnamed      unused  input active-high 
       line 23:     unnamed      unused  input active-high 
       line 24:   "MXM3_72"      unused  input active-high 
       line 25:     unnamed "phy-reset" output active-high [used] 
       line 26:     unnamed      unused  input active-high 
       line 27:     unnamed      unused  input active-high 
       line 28:     unnamed "PCIe reset" output active-high [used] 
       line 29:     unnamed      unused  input active-high 
       line 30:     unnamed      unused  input active-high 
       line 31:     unnamed      unused  input active-high

So the information I passed to you in my last message is incorrect: by default GPIO 1 pin 2 is not available out-of-the-box. Sorry for the mistake, I’ll correct my previous post.

In this case there are a few options you can do:

  • Use another GPIO pin from the list I passed before: I tested all the pins there, and with the exception of GPIO 1 pin 2 all the others should work.

  • Use a Device Tree Overlay to disable the PCIe regulator in order to use the pin. Keep in mind that this will likely disable PCIe on the module. You can use TorizonCore Builder with the ‘build’ command to create a TorizonCore image with it. Details on how to do this can be seen here:


TorizonCore Builder Details
  • On your (Linux) host machine, download the TorizonCore Builder setup script if you haven’t done so:
mkdir -p ~/tcbdir/ && cd ~/tcbdir/
wget https://raw.githubusercontent.com/toradex/tcb-env-setup/master/tcb-env-setup.sh
  • Source the script to initialize TorizonCore Builder:
cd ~/tcbdir/
source tcb-env-setup.sh
  • Inside ~/tcbdir, clone Linux and the overlay repositories for TorizonCore 6:
git clone -b linux-6.0.y git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
git clone -b master git://git.toradex.com/device-tree-overlays.git device-trees
  • Inside ~/tcbdir create a directory named images. Download TorizonCore 6.2 and put the .tar file in the images directory.

  • Inside ~/tcbdir create a file named apalis-imx6_enable_gpio1_2_overlay.dts with the following content:

/dts-v1/;
/plugin/;
/ {
	compatible = "toradex,apalis_imx6q";
};

&reg_pcie_switch {
	status = "disabled";
};
  • Inside ~/tcbdir create a file named tcbuild.yaml with the following content:
tcbuild.yaml
input:
  easy-installer:
    local: images/torizon-core-docker-apalis-imx6-Tezi_6.2.0+build.2.tar

customization:
  device-tree:
    include-dirs:
      - linux/include/
    overlays:
      clear: false
      add:
        - apalis-imx6_enable_gpio1_2_overlay.dts

output:
  easy-installer:
    local: apalis_imx6_tc6.2_enable_gpio1_2
 # >> Information used by Toradex Easy Installer:
    name: "TorizonCore (UPSTREAM)"
    description: "TorizonCore with GPIO1 pin 2 (MXM3 pin 15) enabled in Userspace"
  • Inside ~/tcbdir run torizoncore-builder build. It will generate a directory named apalis_imx6_tc6.2_enable_gpio1_2. Copy this directory to a USB stick, plug it to your module then load the latest release of Toradex Easy Installer on your module (don’t use the stable release).

Best regards,
Lucas Akira

1 Like