SAMA5D2 Xplained running Yocto 6.1 release, sysfs gpio problems?

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

bcouture
Posts: 1
Joined: Mon Sep 30, 2019 10:53 pm

SAMA5D2 Xplained running Yocto 6.1 release, sysfs gpio problems?

Mon Sep 30, 2019 11:23 pm

Yes, I realize that sysfs is depreciated, but it's still useful for ease of testing.

I'm trying to access some of the GPIO on the board from the command line, and I'm having a problem.

I'm trying to access the onboard green LED on PB5 via "echo 37 >/sys/class/gpio/export" , but this returns a
"write error: Device or resource busy".

However, "echo 4 >/sys/class/gpio/export" works, giving access to PA4.

It seems like /sys/class/gpio/export will only accept a single character. If so, how do you access the additional GPIO?
Or do I have the syntax wrong?

I've tried browsing https://github.com/linux4sam/linux-at91 ... r-api/gpio, but haven't
found anything useful.

Thanks!
blue_z
Location: USA
Posts: 1974
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D2 Xplained running Yocto 6.1 release, sysfs gpio problems?

Tue Oct 01, 2019 2:26 am

bcouture wrote: Yes, I realize that sysfs is depreciated, ...
No, and you probably mean deprecated, but that is also an inaccurate statement.
Only a few (meaning not all) features of sysfs have been deprecated (not "depreciated"). You're probably thinking of the sysfs GPIO interface.
But other sysfs interfaces are still supported (see Documentation/ABI/stable/), as well as apparently the LED (gpio) sysfs interface (although there is also the userspace character LED interface).

bcouture wrote: I'm trying to access the onboard green LED on PB5 via "echo 37 >/sys/class/gpio/export" , but this returns a "write error: Device or resource busy".
The GPIO pin is "busy" because it is already owned by a device driver.
You can only export a pin that is free, that is, not multiplexed to a peripheral or acquired by a device driver or already exported.
That's how the resource management of pins works (the pinctrl and gpio subsystems).

bcouture wrote: It seems like /sys/class/gpio/export will only accept a single character.
That's a hasty and erroneous assertion based on flimsy experimentation.
Instead of assuming that the software is deficient or broken when you obtain unsuccessful results, consider the more-likely possibility that you are misusing this unfamiliar software.


bcouture wrote: I've tried browsing https://github.com/linux4sam/linux-at91 ... r-api/gpio, but haven't found anything useful.
The salient documentation to study (not just browse) is Documentation/driver-api/gpio/drivers-on-gpio.rst and Documentation/leds/leds-class.txt.

The demo code that you booted your board with configures pin PB5 as a LED gpio, which can be controlled using the LED sysfs interface.

LED handling under Linux
========================

In its simplest form, the LED class just allows control of LEDs from userspace.
LEDs appear in /sys/class/leds/.
The maximum brightness of the LED is defined in max_brightness file.
The brightness file will set the brightness of the LED (taking a value 0-max_brightness).
Most LEDs don't have hardware brightness support so will just be turned on for non-zero brightness settings.

Regards

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 4 guests