Echo: write error: Invalid argument


I am trying to access the GPIO from Linux (Ubuntu 22.04 with kernel 5.15.0-48-generic). I am following the steps from the Wiki: Accessing 40-pin GPIO - Seeed Wiki

When I try to write to export I get an error “echo: write error: Invalid argument”

sudo -i
cd /sys/class/gpio
echo 337 > export
-bash: echo: write error: Invalid argument

Any suggestions?

Thanks. Gary.

Hello @garysims,

Could you please try this on Ubuntu 18.04?

Thank you.

Yes, it works on 18.04, I reverted to the older version just after I posted the message, however my question isn’t about 18.04, it is about 22.04.

Hello @garysims,

I have tested this further with Ubuntu 18.04, 19.04, 20.04 and 22.04 and it seems that it works only for 18.04, 19.04.

When I checked the kernel version, the corresponding versions were as follows:

  • 18.04 - 5.4.0
  • 19.04 - 5.0.0
  • 20.04 - 5.15.0
  • 22.04 - 5.15.0

It seems that it is related with the kernel. For 5.15, it does not work.

Unfortunately, we do not have the resources to debug this further. We might need to conclude that it is only compatible with 18.04 and 19.04.

I wonder if it is because since Linux 4.8 the GPIO sysfs interface is DEPRECATED. Maybe Linux 5.15 has removed it completely.