LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 09-17-2022, 07:55 AM   #1
bthomas
LQ Newbie
 
Registered: Sep 2022
Posts: 3

Rep: Reputation: 0
Configuring GPIO pin mapping for libgpiod


Hi

I installed a bare minimal Debian 11 (Bullseye) distribution on a Nano Pi M1 single board computer. I would like to use it to control external devices using its GPIO pins. I was not able to find a suitable port of Python packages such RPi.GPIO for this purpose. Besides I understand the current best practice for controlling gpio pins is to use libgpiod. The gpio device is detected by the kernel as shown below

Code:
$ sudo gpiodetect 
gpiochip0 [1c20800.pinctrl] (224 lines)
gpiochip1 [1f02c00.pinctrl] (32 lines)
However the pins are not named and so it is not obvious how the libgpiod pin numbers map to pins on the Nano Pi M1 board as shown below

Code:
$ sudo gpioinfo gpiochip0
gpiochip0 - 224 lines:
	line   0:      unnamed       unused   input  active-high 
	line   1:      unnamed       unused   input  active-high 
	line   2:      unnamed       unused   input  active-high 
	line   3:      unnamed       unused   input  active-high 
	line   4:      unnamed       unused   input  active-high 
	line   5:      unnamed       unused   input  active-high 
	line   6:      unnamed       unused   input  active-high 
	line   7:      unnamed       unused   input  active-high 
	line   8:      unnamed       unused   input  active-high 
	line   9:      unnamed       unused   input  active-high 
	line  10:      unnamed "nanopi:blue:status" output active-high [used]
How do I find out what libgpiod pin numbers map to what pins on the Nano Pi M1 board ? As I understand this may require a Device Tree Overlay. If this is indeed what is required, how do I understand how to write the Device Tree Overlay file to give me the required pin mapping. I have familiarised myself the device tree source file format but even to write the DTS file I need to know the pin mapping in the first place.

Thank you
 
Old 09-19-2022, 12:27 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,147

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
Maybe not needed. Do you have a /sys/class/gpio directory?
 
Old 09-21-2022, 03:39 PM   #3
bthomas
LQ Newbie
 
Registered: Sep 2022
Posts: 3

Original Poster
Rep: Reputation: 0
As I understand libgpiod was created to avoid use of /sys/class/gpio.
 
Old 09-21-2022, 04:00 PM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
You searched thoroughly their documentation and it all was useless? You could use a voltmeter and find out mapping by switching pins one by one, time consuming though.
 
Old 09-22-2022, 05:00 AM   #5
bthomas
LQ Newbie
 
Registered: Sep 2022
Posts: 3

Original Poster
Rep: Reputation: 0
That is a good idea indeed. I was thinking along the lines of setting up a gpiod event to monitor and then set a 3.3v volt pull up or down resistor on each pin with a switch and see which gpio lines detect it. Apart from being tedious I am not sure if this will work for all the pins though it may be enough to give me an idea of the pin layout.

The problem with their documentation is that they list the pin numbers which are (I think) "logical" pin numbers and may not correspond to the numbering that is used by the gpiod driver. There is a circuit diagram available and I am trying to figure out how the gpiod numbering corresponds with the pin numbers in the circuit diagram.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
libgpiod in -current? xor_ebx_ebx Slackware - ARM 9 03-18-2021 05:04 AM
Interface 1-wire DS18B20 over GPIO pin using AM3359 backbencher Linux - Embedded & Single-board computer 0 06-26-2013 06:44 PM
GPIO access on a Fujitsu Mini-ITX Industrial Mainboard, PCI Driver for GPIO mechatrix Linux - Embedded & Single-board computer 3 11-20-2011 03:57 PM
Receive IRQ from a GPIO pin maus Linux - Embedded & Single-board computer 1 06-22-2009 10:02 AM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 08:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration