How to use SPI on Colibri IMX6ULL

Dear @jaski.tx,

I need to change the value of SPI output gpio on sometime while the my application is running.
If I use the Toradex GPIO tool the value is changed right.
I saw the change value using the command: cat /sys/kernel/debug/gpio and with the oscilloscope.

Before:
gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
gpio-2 ( |VCC_USB[1-4] ) out lo
gpio-11 ( |enable ) out hi
gpio-20 ( |spi_imx ) out hi
gpio-21 ( |spi_imx ) out hi
gpio-22 ( |spi_imx ) out hi
gpio-23 ( |spi_imx ) out hi
After:
gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
gpio-2 ( |VCC_USB[1-4] ) out lo
gpio-11 ( |enable ) out hi
gpio-20 ( |spi_imx ) out hi
gpio-21 ( |spi_imx ) out lo
gpio-22 ( |spi_imx ) out hi
gpio-23 ( |spi_imx ) out hi

I tried to use the following lines:

                     // export GPIO
                     fd = open("/sys/class/gpio/export", O_WRONLY);
                    write(fd, "21", 2);
                    close(fd);

                      // configure as output
                      fd = open("/sys/class/gpio/gpio21/direction", O_WRONLY);
                      write(fd, "out", 3);
                      close(fd);

                     fd = open("/sys/class/gpio/gpio21/value", O_WRONLY | O_SYNC);
                     write(fd, "0", 1);

I used these commands on the VF61 and they run right.
Then I tried to export gpio21 on IMX6ULL it’s give me a error message and the folder gpio21 is not created.
I tried the following command line: echo 21 > /sys/class/gpio/export

and obtained this error: write error: Device or resource busy

How could I change the status of SPI GPIO output?

Thank you,

Best regards

Matteo

hi @Matte

Could you ask a new question? This will help us to keep the Community clean.

Thanks and best regards,
Jaski