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
self.gpio.request(self.config)
elif direction == "edge":
self.config.request_type = gpiod.line_request.EVENT_BOTH_EDGES
self.gpio.request(self.config)
elif direction == "rising":
self.config.request_type = gpiod.line_request.EVENT_RISING_EDGE
self.gpio.request(self.config)
else:
print("wrong input") # placeholder for real error handling
self.gpio.release()
self.prev_val = 0
self.counter = 0
def set_gpio(self, state):
"""
Set GPIO pin
:param state: 1/0
"""
self.gpio.request(self.config)
self.gpio.set_value(state)
self.gpio.release()
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.
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.
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):
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.