max. pico relay control

  • cttelegram wrote: 2024-03-16 6:08 hi, I can control two relays via gpio 55 and 54 from bash commands, they work fine.
    I want to use two more relays for a total of 4 but I can't find them.
    many pins give me this error:
    echo 68 > /sys/class/gpio/export
    -bash: echo: write error: Invalid argument

    only these two pins work:
    echo 55 > /sys/class/gpio/export
    echo 54 > /sys/class/gpio/export
    What could be the problem? thank you all for your help
    Hello, I am sorry to say that I did not repeat your problem here, and such errors will not occur in normal operation of reused pins, but only when entering illegal commands. If you can suggest testing under various shell environments (bash or sh)

    Code: Select all

    bash
    root@luckfox:/# echo 68 > /sys/class/gpio/export
    
  • I did a lot of tests but the only pins to control a relay are only 55 and 54, only these work correctly.
    do you know any other pins ?
  • cttelegram wrote: 2024-03-16 16:33 I did a lot of tests but the only pins to control a relay are only 55 and 54, only these work correctly.
    do you know any other pins ?

    I tried to control gpio68 on luckfox-pico pro ubuntu, and the output high and low levels can be controlled normally. You can refer to whether the command line is executed correctly

    Code: Select all

    echo 68 > /sys/class/gpio/export
    echo out > /sys/class/gpio/gpio68/direction
    echo 1 > /sys/class/gpio/gpio68/value  # high level
    echo 0 > /sys/class/gpio/gpio68/value  # low level
    
  • I'm using Alpine Linux installed on Nand Luckyfox Pico Max.. the command is correct but I can only control pins 54 and 55.. I have no idea where the problem is..
  • cttelegram wrote: 2024-03-18 12:39 I'm using Alpine Linux installed on Nand Luckyfox Pico Max.. the command is correct but I can only control pins 54 and 55.. I have no idea where the problem is..
    I have previously tested it in buildroot and ubuntu environments, and it can be controlled normally when the device tree is set up properly. Alpine Linux is provided by the community and we do not maintain it. I have tested and found that most of the GPIOs are reused. The pins provided on the luckfox-pico pro are reused for functions such as UART SPI IIC PWM except for UART4's flow control pin (54 55) which is not used.
    gpiochip2_03.jpg
    gpiochip2_04.jpg
    It would be ideal to use pin 66 67, but I found in /proc/device-tree/pinctrl that gpiochip2 is not enabled (pins 64 through 95) and therefore cannot be controlled
    gpiochip2_02.jpg
    gpiochip2.jpg
    Alpine Linux's original image may not be suitable for your use case, You need to reference [url] https://wiki.luckfox.com/Luckfox-Pico/L ... e-Linux-2/ [/ url] modify the device tree to liberate more pins.
    I hope you found this helpful.
  • ok thanks, at the moment I'm happy with 4 inputs and 2 outputs... I just wanted to understand if I could midify the current system... but now I'm keeping alpinelinux because it works well in NAND
  • cttelegram wrote: 2024-03-19 13:10 ok thanks, at the moment I'm happy with 4 inputs and 2 outputs... I just wanted to understand if I could midify the current system... but now I'm keeping alpinelinux because it works well in NAND


    Alpine Linux adaptation is provided by community members. In the https://wiki.luckfox.com/Luckfox-Pico/L ... e-Linux-2/, it mentions building rootfs.img and modifying the contents of build.sh. As for the device tree and drivers, the boot.img is built using Luckfox SDK. Therefore, you can customize your desired peripheral configuration by replacing boot.img during the burning phase.

    The boot.img in the luckfox-pico pro max image on the cloud drive has been tested and can control gpiochip2 (64 ~ 95).
    boot.7z (2.63 MiB)
    Downloaded 504 times
  • I have the same problem. Also checked, and realized that there is a few more pins that can be used. I checked only outputs (not inputs!) and stability of high/low values. Is there any way to disable SPI, I2C or UART programatically and free more pins in Alpine Linux?

    These pins might be used as output in Alpine:

    gpio4
    gpio34
    gpio54
    gpio55
    gpio97
    gpio98
    gpio99
    gpio100
    gpio101
    gpio102
    gpio103
  • Alpine only replaces the root filesystem. If you need to configure external devices, you can modify the device tree in the traditional way, compile it, and generate a new boot.img. You can then flash the boot.img separately.