Setting GPIO pin not working


We are currently using the Verdin IMX8MM DL 1GB WB IT with a custom board with some GPIO assignments.
I cannot seem to control the GPIO output pins. We have buttons system and that works perfectly fine. But setting the GPIO programmatically does not work.

I am using the gpiod library for python, like this:

    def __init__(self, hw_chip, offset, direction, default=0):
        Initiates HW GPIO.
        GPIO pins HW mapping can be seen by running "gpioinfo" command in the Docker Container of the system.
        By running "gpioinfo 1" you will se the mapping of the GPIO pins on GPIO chip 1.
        Available GPIO chips are 0-9.
        :param HWChip: What HW Chip gpio is located on
        :param offset: Pin number of GPIO pin
        :param direction: input/output/edge/rising
        :param default: default state of pin (1/0)
        chip = gpiod.chip(hw_chip)
        self.gpio = chip.get_line(offset)
        self.config = gpiod.line_request()

        if direction == "output":
            self.config.request_type = gpiod.line_request.DIRECTION_OUTPUT
            self.gpio.request(self.config, default)
        elif direction == "input":
            self.config.request_type = gpiod.line_request.DIRECTION_INPUT
        elif direction == "edge":
            self.config.request_type = gpiod.line_request.EVENT_BOTH_EDGES
        elif direction == "rising":
            self.config.request_type = gpiod.line_request.EVENT_RISING_EDGE
            print("wrong input")  # placeholder for real error handling
        self.prev_val = 0
        self.counter = 0

    def set_gpio(self, state):
        Set GPIO pin
        :param state: 1/0

Using gpioset from the terminal also does not work. The pin never goes high as it seems to think that the pin is 0 (after doing gpioget). Although the LEDs that are connected to the pin are always on after we connect the Toradex module to the board. We have checked the electronics and it seems to be fine on that end.

Any ideas? If more information is needed, feel free to say so.

You should dfin pin as a GPIO in a Device tree. Then you can use a “gpioinfo” command to verify pin availability. Please check for more details:

We have a custom device tree where all the pins have been configured to GPIOs (not done by myself).
These are the pins: The comment refers to the SODIMM pin.

            led_1 = GPIO(4, 6, "output")  # pin 137 
            led_2 = GPIO(4, 7, "output")  # pin 139 
            led_3 = GPIO(4, 8, "output")  # pin 141 
            led_4 = GPIO(4, 9, "output")  # pin 143 
            led_5 = GPIO(2, 4, "output")  # pin 206 
            led_6 = GPIO(4, 5, "output")  # pin 208 
            led_7 = GPIO(4, 26, "output")  # pin 210
            led_8 = GPIO(4, 27, "output")  # pin 212

Here is the gpioinfo on chip 4 results (we use one line as well from chip 2 but you get the idea):

        line   0: "SODIMM_131"       unused   input  active-high 
        line   1:      unnamed "CTRL_SLEEP_MOCI#" output active-high [used]
        line   2:  "SODIMM_91"       unused   input  active-high 
        line   3:  "SODIMM_16"       unused   input  active-high 
        line   4:  "SODIMM_15"       unused   input  active-high 
        line   5: "SODIMM_208"       unused   input  active-high 
        line   6: "SODIMM_137"       unused   input  active-high 
        line   7: "SODIMM_139"       unused   input  active-high 
        line   8: "SODIMM_141"       unused   input  active-high 
        line   9: "SODIMM_143"       unused   input  active-high 
        line  10: "SODIMM_196"       unused   input  active-high 
        line  11: "SODIMM_200"       unused   input  active-high 
        line  12: "SODIMM_198"       unused   input  active-high 
        line  13: "SODIMM_202"    "spi_imx"  output  active-high [used]
        line  14:      unnamed        "scl"  output  active-high [used open-drain]
        line  15:      unnamed        "sda"  output  active-high [used open-drain]
        line  16:  "SODIMM_55"       unused   input  active-high 
        line  17:  "SODIMM_53"       unused   input  active-high 
        line  18:  "SODIMM_95"        "scl"  output  active-high [used open-drain]
        line  19:  "SODIMM_93"        "sda"  output  active-high [used open-drain]
        line  20:  "SODIMM_14"        "scl"  output  active-high [used open-drain]
        line  21:  "SODIMM_12"        "sda"  output  active-high [used open-drain]
        line  22:      unnamed       unused   input  active-high 
        line  23:      unnamed       unused   input  active-high 
        line  24:      unnamed       unused   input  active-high 
        line  25:      unnamed    "spi_imx"  output  active-high [used]
        line  26: "SODIMM_210"       unused   input  active-high 
        line  27: "SODIMM_212"       unused   input  active-high 

I interpret this as they are available, right?

Now that I look at them I can see that they are labeled as “input”, should that be changed?
If they should be changed in the device tree, how do you change it? If we take this block as an example (taken from our device tree):

			gpio@30230000 {
				compatible = "fsl,imx8mm-gpio\0fsl,imx35-gpio";
				reg = <0x30230000 0x10000>;
				interrupts = <0x00 0x46 0x04 0x00 0x47 0x04>;
				clocks = <0x02 0xe2>;
				#gpio-cells = <0x02>;
				#interrupt-cells = <0x02>;
				gpio-ranges = <0x14 0x00 0x57 0x20>;
				gpio-line-names = "SODIMM_102\0SODIMM_90\0SODIMM_92\0SODIMM_94\0SODIMM_96\0SODIMM_100\0\0\0\0SODIMM_174\0SODIMM_120\0SODIMM_104\0SODIMM_106\0SODIMM_108\0SODIMM_112\0SODIMM_114\0SODIMM_116\0\0SODIMM_118\0\0SODIMM_88\0SODIMM_149\0SODIMM_147\0SODIMM_36\0SODIMM_32\0SODIMM_30\0SODIMM_34\0SODIMM_38\0SODIMM_252\0SODIMM_133\0SODIMM_135\0SODIMM_129";
				phandle = <0x7b>;

What variables should be changed?

Please check this article Device Tree Customization Examples | Toradex Developer Center

Hi @edmirsuljicOIM !

Were you able to solve your issue?

Best regards,


I haven’t yet actually. I’m waiting for a co-worker to do it since he has better knowledge of device trees, although I might to it myself just to learn it. I have a feeling that it’s not very hard to change a pin from input to output.

Hi @edmirsuljicOIM !


I explained a little bit about device trees in this other thread of yours: Issues with pin mapping - #7 by henrique.tx

Was it helpful? Did you manage to go forward with your project?

Let us know :slight_smile:

Best regards,

Hi @edmirsuljicOIM !

Were you able to solve your issue?

If yes, please share the solution and mark it as the solution as well.

Best regards,


Yes we needed to disable an UART node in the overlay and it worked.