Custom GPIO on Colibri imx7-1G

Hello,
we develop a custom schematics for the Colibri IMX7-1G

we used the following pin as gpio

while on the other 46 48 50 (the pin i tried) are always 0

I just recompiler the minimal yocto image provided by Toradex. This is the output of gpioinfo
gpiochip2 - 32 lines:
line 0: “SODIMM_56” unused input active-high
line 1: “SODIMM_44” unused output active-high
line 2: “SODIMM_68” unused input active-high
line 3: “SODIMM_82” unused input active-high
line 4: “SODIMM_93” unused input active-high
line 5: “SODIMM_76” unused input active-high
line 6: “SODIMM_70” unused input active-high
line 7: “SODIMM_60” unused input active-high
line 8: “SODIMM_58” unused input active-high
line 9: “SODIMM_78” unused input active-high
line 10: “SODIMM_72” unused input active-high
line 11: “SODIMM_80” unused input active-high
line 12: “SODIMM_46” unused output active-high
line 13: “SODIMM_62” unused input active-high
line 14: “SODIMM_48” unused output active-high
line 15: “SODIMM_74” unused input active-high
line 16: “SODIMM_50” unused output active-high
line 17: “SODIMM_52” unused input active-high
line 18: “SODIMM_54” unused input active-high
line 19: “SODIMM_66” unused input active-high
line 20: “SODIMM_64” unused input active-high
line 21: “SODIMM_57” unused input active-high
line 22: “SODIMM_61” unused input active-high
line 23: “SODIMM_136” unused input active-high
line 24: “SODIMM_138” unused input active-high
line 25: “SODIMM_140” unused input active-high
line 26: “SODIMM_142” unused input active-high
line 27: “SODIMM_144” unused input active-high
line 28: “SODIMM_146” unused input active-high
line 29: unnamed unused input active-high
line 30: unnamed unused input active-high
line 31: unnamed unused input active-high

after i executed the gpioset on all the four GPIO

I suspect i should edit some configuration file or the devicetree but i don’t know how to do it

Thank you
Andrea

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

For configuring GPIOs on the Colibri iMX7-1G, indeed, adjustments in the device tree are necessary to ensure the pins are set up correctly for your application. Given the pins you’re interested in (SODIMM 46, 48, 50), you’ll need to modify the device tree to change their functionality to GPIO and set their direction and default state if needed.

Here’s a general approach to achieve this:

  1. Locate the Device Tree Source (DTS) file: For the Colibri iMX7-1G, the relevant DTS files are typically found within the Linux kernel source tree under arch/arm/boot/dts/. The exact file depends on your specific carrier board and configuration. You might be looking for a file named similar to imx7d-colibri-eval-v3.dtsi or another variant that matches your carrier board.

  2. Modify the Pin Configuration: Within the DTS file, locate the pinmux settings for the pins you wish to use as GPIO. You will need to ensure that the pins are not assigned to another peripheral function. The pin configuration is defined using the pinctrl nodes. You would define your GPIOs within a pinctrl node, specifying the pin function, direction, and any other required properties.

  3. Example Device Tree Modification:

    &iomuxc {
        pinctrl_additional_gpios: additionalgpios {
            fsl,pins = <
                MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO20 0x14 /* SODIMM 46 */
                MX7D_PAD_SAI1_TX_SYNC__GPIO6_IO21 0x14 /* SODIMM 48 */
                MX7D_PAD_SAI1_RX_DATA__GPIO6_IO22 0x14 /* SODIMM 50 */
            >;
        };
    };
    
    &gpio6 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_additional_gpios>;
        status = "okay";
    };
    

    This is a hypothetical example. You’ll need to replace MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO20, MX7D_PAD_SAI1_TX_SYNC__GPIO6_IO21, and MX7D_PAD_SAI1_RX_DATA__GPIO6_IO22 with the correct pad names for the pins

Please, also check if these links can help you solve your problem:

GPIO (Linux) | Toradex Developer Center.

I tried to set clear from uboot and the GPIO is working

The pin 44 seams to be used to something else because it continue to switch at fixed frequency. I suspect i need to disable the lcd controller that looks like it is using it.

More over, is there any tutorial to learn how to edit the device tree and build with the image compatible with the toradex easy installer?

In there the possibility to add a recipe in yocto to do this?

Hi @abbani !

After checking Colibri iMX7D 1GB eMMC Evalboard’s device tree, we can see on imx7-colibri.dtsi that the pins SODIMM 46, 48 and 50 are not configured as GPIOs, which is what you need. They could be configured as LCD_DATA* if &lcdif was enabled.

You can check for the &lcdif (disabled) and the strings SODIMM 46, SODIMM 48 and SODIMM 50 in the file below.

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/boot/dts/imx7-colibri.dtsi?id=v6.1.83#n

As instructed by @ToradexAI above, you will need to customize your device tree to assure those pins are configured in the way you need.

You can refer to our documentation to learn how to deal with device trees: Device Tree Documentation Overview | Toradex Developer Center.

Best regards,

I found an easy way to free the goio

touch /boot/overlays.txt

This empty the overlays and the lcd dtbo in no more loaded.
In this way, today I was able to control all the gpio

Thank you

Hi @abbani !

Nice! It makes sense if one of the device tree overlays was enabling the &lcdif node.

Keep in mind that if you need to perform changes the documentation I shared above will certainly help you :slight_smile:

Thanks for the feedback and please don’t forget to mark your solution as the Solution :wink:

Best regards,

Thank you Henrique

I read the document regarding the device tree modification and it is clear to me.
We use Zynq on tens of our product and I’m used to make custom device tree.
Is there any easy way to apply a modification in device tree form yocto recipe? Like that I put a dtsi file in a layer and than I build everything with bitbake

The device tree costumization procedure explained by Toradex requires a two step generation of the tar deploy image. I generate the image with bitbake with default device tree and than I replace it with the custom one.

This make more complex the generation of the image in cicd pipeline.

Xilinx has in Petalinux an elegant solution. There is a custom dtsi in bsp layer. You can edit that and you will get a final images with updated device tree.

Is there any way to make something similar?

Thank you

Andrea

Hi @abbani!

That’s great :slight_smile:

This is a possible approach during development. For production, for sure you will want a streamlined way to have your customized device tree on your image. This is more related to Yocto itself than to the Device Tree. So you need to go to Yocto-related documentation. On Toradex Developer we have some articles about Yocto, for example:

Feel free search for more Yocto-related documentation in Toradex Developer, but please keep in mind that the complete Yocto documentation is in their own website (be sure to always access the documentation for the Yocto version you are using - BSP 6 is Kirkstone):

https://docs.yoctoproject.org/4.0.19/

Related to this: I am not sure if you have taken a look at Torizon OS. Such device tree modification is way easier to do on Torizon OS, by using our TorizonCore Builder tool. Also the image customization process is way less computing intensive.

Here are some overview pages on Torizon OS:

And about TorizonCore Builder specifically:

https://developer.toradex.com/torizon/os-customization/

Best regards,