How to operate GPIO on and off in sysfs.Please help me

I have an UP2 Intel N4200 evaluation board.I use Ubilinux sysfs shell can operate GPIO on and off,reference up-community.But after I installed Ubuntu 18.04, in the same way, no error was reported on the shell command, but in fact GPIO did not work.

root@test-UP-APL01:/sys/class/gpio# echo 432 > export 
root@test-UP-APL01:/sys/class/gpio# cd gpio432
root@test-UP-APL01:/sys/class/gpio/gpio432# echo "out" > direction               
root@test-UP-APL01:/sys/class/gpio/gpio432# cat value
0
root@test-UP-APL01:/sys/class/gpio/gpio432# cat value
1
root@test-UP-APL01:/sys/class/gpio/gpio432# echo 1 > value
root@test-UP-APL01:/sys/class/gpio/gpio432# cat /sys/kernel/debug/gpio
gpiochip3: GPIOs 267-309, parent: platform/INT3452:03, INT3452:03:
gpiochip2: GPIOs 310-356, parent: platform/INT3452:02, INT3452:02:
gpiochip1: GPIOs 357-433, parent: platform/INT3452:01, INT3452:01:
gpio-432 (                    |sysfs               ) out hi
gpiochip0: GPIOs 434-511, parent: platform/INT3452:00, INT3452:00:
root@test-UP-APL01:/sys/class/gpio/gpio432#


I really can’t find the problem point, how to operate GPIO on and off in sysfs.Please help me,Thank you

I just realized that I copied a wrong command line, which is correct:

root@test-UP-APL01:/sys/class/gpio# echo 432 > export
root@test-UP-APL01:/sys/class/gpio# cd gpio432
root@test-UP-APL01:/sys/class/gpio/gpio432# echo "out" > direction
root@test-UP-APL01:/sys/class/gpio/gpio432# cat value
0
root@test-UP-APL01:/sys/class/gpio/gpio432# echo 1 > value
root@test-UP-APL01:/sys/class/gpio/gpio432# cat value
1
root@test-UP-APL01:/sys/class/gpio/gpio432# cat /sys/kernel/debug/gpio
gpiochip3: GPIOs 267-309, parent: platform/INT3452:03, INT3452:03:
gpiochip3: GPIOs 267-309, parent: platfor52:03, INT3452:03m/INT34:
gpiochip2: GPIOs 310-356, parent: platform/INT3452:02, INT3452:02:
gpiochip1: GPIOs 357-433, parent: platform/INT3452:01, INT3452:01:
gpio-432 (                    |sysfs               ) out hi
gpiochip0: GPIOs 434-511, parent: platform/INT3452:00, INT3452:00:
root@test-UP-APL01:/sys/class/gpio/gpio432#

When switching switch, pin voltage does not change.So please help me!

Hi Zhyg,

It’s hard to tell what the problem can be, your commands seem correct. Can you control the other devices, or none of them?

I consulted this websit (wiki.up-community.org->Pinout_UP2 ) to do, pin462 and pin432 test, the result is the same.
I have two questions now. I don’t know if you can help me.

  1. According to the content of the reference website, Linux kernel is used, but different versions and customizations are different. Ubilinux kernel is customized, and Ubuntu kernel is the standard Ubuntu kernel.According to this understanding, the virtual GPIO address mapped on sysfs should be the same, only the kernel is different.
  2. Whether GPIO operation under sysfs is related to kernel configuration

Thank you

Hi Zhyg,

I searched a bit for this issue, and could only find a clue that simply tells us if your system has gpio support. Not much, but (a bit) more than nothing.

This is how you can check if your gpio is enabled on your system:

# grep GPIOLIB /boot/config-5.4.0-62-generic

This is an example from one of my machines, change the kernel version to the one you are running on.

If supported, you’ll get a line like this one:

CONFIG_GPIOLIB=y

You can do the same with sysfs:

# grep SYSFS /boot/config-5.4.0-62-generic

With the output of:

CONFIG_SYSFS=y

I would guess both are enabled on your system, or you couldn’t export anything. So I can only answer to your last answer with confidence for now, yes it is related to kernel configuration. It seems I’ll have to test this on some unfortunate device.