Skip to content

Add support for GPIO line names via libgpiod#4

Open
mhei wants to merge 16 commits into
EVerest:everestfrom
chargebyte:feature/libgpiod
Open

Add support for GPIO line names via libgpiod#4
mhei wants to merge 16 commits into
EVerest:everestfrom
chargebyte:feature/libgpiod

Conversation

@mhei

@mhei mhei commented Apr 29, 2026

Copy link
Copy Markdown

The good old sysfs based user-space interface with GPIO numbers is obsolete since several years.

This PR add support for an alternative approach: instead of plain integers, user can configure the required GPIO lines using a GPIO line name as usually defined in the Device Tree for the board. For this, this PR relys on libgpiod. Support for using libgpiod can be switched on at compile time, to keep backwards compatiblity, it is disabled by default.

The new dependency is not pulled in automatically but is expected to be provided by the environment.

The tested libgpiod version is v2.0.1 - since this is currently the version that we (chargebyte) bundle in our kirkstone builds on our targets.

Even if the library is compiled with libgpiod support, then it is still possible to use integer numbers and the older sysfs interface.

Sidenote 1: I pulled in the commit from #3 - just wanted to have it included when testing. I can remove it once there is a decision/feedback in that PR.

Sidenote 2: I tested only on our Charge SOM platform so far and fixed a 64-bit issue from an older commit in this branch.

I'm unsure regarding the ADDITIONAL_CONTENT stuff in the packaging file - this is untested and I hope someone with more expertise can comment on it.

tafilz and others added 12 commits January 24, 2026 22:30
This is not required anymore. Quoting glibc 2.30 NEWS:

> * The functions clock_gettime, clock_getres, clock_settime,
>   clock_getcpuclockid, clock_nanosleep were removed from the librt library
>   for new applications (on architectures which had them).  Instead, the
>   definitions in libc will be used automatically, which have been available
>   since glibc 2.17.

When building in a BitBake devshell as shared library and inspecting
the resulting .so file with readelf reveals that librt.so is never
linked to:

    0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
    0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
    0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
    0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
    0x0000000000000001 (NEEDED)             Shared library: [ld-linux-aarch64.so.1]
    0x000000000000000e (SONAME)             Library soname: [liblibnfc_nci.so]

This will also fix

    do_package_qa: QA Issue: File /usr/lib/cmake/libnfc-nci/libnfc-nci-targets.cmake in package libnfc-nci-dev contains reference to TMPDIR [buildpaths]

in yocto builds since it contained a full path to librt.so.

Signed-off-by: Tafil Avdyli <tafil@tafhub.de>
Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Invalid file descriptor is -1, values >= must be considered valid.

While at, get rid of the Close method is derived class since
the functionality is the same for all derived classes.

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
This uses a proprietary ioctl which will not work with default
I2C or SPI interface devices on Linux.
I guess this is left-over copy&paste garbage.
Remove it since there seems no user of this methods.

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Destination buffer must not overflow, so check size of buffer
and string length.

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
We need to pass the size of the target variable, not
the size of the pointer to it.

This is important on platforms where sizeof(pointer) != sizeof(int)

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Comment thread src/nfcandroid_nfc_hidlimpl/halimpl/tml/transport/NfccAltTransport.cc Outdated
Comment thread conf/libnfc-nxp.conf
mhei added 2 commits May 4, 2026 16:36
This should make it more clear, that mixing is undefined behavior.

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
We can re-use kernel's maximum GPIO line name length here
instead of a random hard-coded size.

While at, improve the debug messages to support users when using
the new feature.

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
@barsnick

Copy link
Copy Markdown

@cburandt Friendly ping ;-)

@mhei

mhei commented Jun 8, 2026

Copy link
Copy Markdown
Author

Any comments, positive or negative, are welcome, as is regression testing on existing platforms.

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
@mhei

mhei commented Jun 11, 2026

Copy link
Copy Markdown
Author

I had problems to cross-compile the library and the PN7160TokenProvider using Yocto kirkstone, so I added a commit here to create a shared library. This requires also a small change in the CMake file of PN7160TokenProvider, you can find it here as example: https://github.com/chargebyte/everest-core/commits/feature/pn7160-as-shared-lib/

Signed-off-by: Michael Heimpold <michael.heimpold@chargebyte.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants