Custom Kernel with GPIO iMX7

Dear Community;

I am trying to build a custom kernel image from source code. I am doing this because I need to control some GPIO via sys. For example GPIOs 58, 112 and 118 are available to use via sys, but GPIO 1 is not. Using cat /sys/kernel/debug/gpio I can see that GPIO 1 is already exported or preassigned to another function in the system:

gpio-1 (Wake-Up ) in lo

With the Colibri T30 I had the same problem because some GPIOs were preassigned in the kernel to CONFIG_KEYBOARD_GPIO . Toradex recommended to disable that and build again the kernel. Everything worked perfectly. Now I have tried to do the same but I don’t know in which file and how I need to modify.

Any help is appreciated and if more information is needed ask please.

Thanks, Ander.

hi @Andermutu

The Tegra DownStream Kernels are not using Device tree Blob, so you have to change everything in Kernel. For imx7, you can change the DTB files in order to change the Function of the Pins and export them as GPIO. Please read for this the instructions written about device tree customization on the following Site.

Hi @Andermutu
You can try to disable it by disabling the gpio-keys entry in your devicetree by doing something like:

{
    gpio-keys {
        status = "disabled";
    };
};

To find out how to compile the devicetree follow Jaskis link.

Regards,
Stefan

Thanks you for help. That lines that you have shared were need to be added? If I have understood well they must be added in the module level… but I am not sure. Besides in the module level I have to files, the imx7d-colibri.dtsi and imx7d-colibri-emmc.dtsi. I suppose that I need to edit the second file. Can you confirm please?

Thanks a lot.

Hi @Andermutu

The best thing would be if you create your own dts file. But for testing you can modify imx7d-colibri-emmc-eval-v3.dts or imx7d-colibri-emmc-aster.dts depending on what you load in u-boot.

Regards,
Stefan

Hi @stefan_e.tx

Thank you, that’s clear. I am adding the lines of code you have given me, but when I try to compile the device tree I get a syntax error. I don’t know where do I have to add that lines, so I added it at the bottom of the file. I will upload the file.

DTC
arch/arm/boot/dts/imx7d-colibri-emmc-eval-v3.dtb
Error:
arch/arm/boot/dts/imx7d-colibri-emmc-eval-v3.dts:26.1-2
syntax error FATAL ERROR: Unable to
parse input tree
scripts/Makefile.lib:293: fallo en las
instrucciones para el objetivo
‘arch/arm/boot/dts/imx7d-colibri-emmc-eval-v3.dtb’
make1: ***
[arch/arm/boot/dts/imx7d-colibri-emmc-eval-v3.dtb]
Error 1 arch/arm/Makefile:327: fallo
en las instrucciones para el objetivo
‘dtbs’ make: *** [dtbs] Error 2

Sorry and thanks for your patience.

Please try this file.

Regards,
Stefan

Finally worked! Now I can use all the GPIOs I need.

Thank both @stefan_e.tx and @jaski.tx for your incredibly fast help and support.

Thanks for the feedback. You are welcome.