Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake enabling LINUXGPIO on ubuntu 20.04 fails #1782

Closed
stefanrueger opened this issue Apr 22, 2024 · 4 comments · Fixed by #1792
Closed

cmake enabling LINUXGPIO on ubuntu 20.04 fails #1782

stefanrueger opened this issue Apr 22, 2024 · 4 comments · Fixed by #1792
Labels
bug Something isn't working

Comments

@stefanrueger
Copy link
Collaborator

After installing libgpiod-dev on ubuntu 20.04 (long-term-support until April 2030), cmake enabling LINUXGPIO fails to build: gpiod_line_set_direction_input() is missing in libgpiod. @mhei @mcuee Any ideas how to solve this?

$ sudo apt install libgpiod-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  libgpiod-doc
The following NEW packages will be installed
  libgpiod-dev
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
Need to get 49.2 kB of archives.
After this operation, 286 kB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu focal/universe amd64 libgpiod-dev amd64 1.4.1-4 [49.2 kB]
Fetched 49.2 kB in 0s (1,202 kB/s)      
Selecting previously unselected package libgpiod-dev:amd64.
(Reading database ... 401048 files and directories currently installed.)
Preparing to unpack .../libgpiod-dev_1.4.1-4_amd64.deb ...
Unpacking libgpiod-dev:amd64 (1.4.1-4) ...
Setting up libgpiod-dev:amd64 (1.4.1-4) ...

$ sudo rm -rf build_linux
$  cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -D HAVE_LINUXGPIO=1 -D HAVE_LINUXSPI=1 -D HAVE_PARPORT=1 -B build_linux
-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: /usr/bin/git (found version "2.25.1") 
-- Found FLEX: /usr/bin/flex (found version "2.6.4") 
-- Found BISON: /usr/bin/bison (found version "3.5.1")
-- Looking for libelf.h
-- Looking for libelf.h - found
-- Looking for libelf/libelf.h
-- Looking for libelf/libelf.h - not found
-- Looking for usb.h
-- Looking for usb.h - found
-- Looking for lusb0_usb.h
-- Looking for lusb0_usb.h - not found
-- Looking for libusb.h
-- Looking for libusb.h - not found
-- Looking for libusb-1.0/libusb.h
-- Looking for libusb-1.0/libusb.h - found
-- Looking for hidapi/hidapi.h
-- Looking for hidapi/hidapi.h - found
-- Looking for ftdi_tcioflush
-- Looking for ftdi_tcioflush - not found
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'libgpiod>=2.0'
--   Requested 'libgpiod >= 2.0' but version of libgpiod is 1.4.1
You may find new versions of libgpiod at
-- Checking for module 'libgpiod'
--   Found libgpiod, version 1.4.1
-- Configuration summary:
-- ----------------------
-- DO HAVE    libelf
-- DO HAVE    libusb
-- DO HAVE    libusb_1_0
-- DO HAVE    libhidapi
-- DO HAVE    libftdi (but prefer to use libftdi1)
-- DO HAVE    libftdi1
-- DO HAVE    libreadline
-- DO HAVE    libserialport
-- DISABLED   doc
-- ENABLED    parport
-- ENABLED    linuxgpio
-- DO HAVE    libgpiod
-- ENABLED    linuxspi
-- ----------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /home/srueger/etc/clock/avrdude/avrdude-main/build_linux

$ cmake --build build_linux
make[1]: Entering directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
make[2]: Entering directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
make[3]: Entering directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
[  1%] [BISON][Parser] Building parser with bison 3.5.1
[  2%] [FLEX][Parser] Building scanner with flex 2.6.4
Scanning dependencies of target libavrdude
make[3]: Leaving directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
make[3]: Entering directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
[  3%] Building C object src/CMakeFiles/libavrdude.dir/arduino.c.o
[  5%] Building C object src/CMakeFiles/libavrdude.dir/avr.c.o
[  6%] Building C object src/CMakeFiles/libavrdude.dir/avr910.c.o
[  7%] Building C object src/CMakeFiles/libavrdude.dir/avrcache.c.o
[  9%] Building C object src/CMakeFiles/libavrdude.dir/avrftdi.c.o
[ 10%] Building C object src/CMakeFiles/libavrdude.dir/avrftdi_tpi.c.o
[ 11%] Building C object src/CMakeFiles/libavrdude.dir/avrintel.c.o
[ 13%] Building C object src/CMakeFiles/libavrdude.dir/avrpart.c.o
[ 14%] Building C object src/CMakeFiles/libavrdude.dir/bitbang.c.o
[ 15%] Building C object src/CMakeFiles/libavrdude.dir/buspirate.c.o
[ 17%] Building C object src/CMakeFiles/libavrdude.dir/butterfly.c.o
[ 18%] Building C object src/CMakeFiles/libavrdude.dir/ch341a.c.o
[ 19%] Building C object src/CMakeFiles/libavrdude.dir/config.c.o
[ 21%] Building C object src/CMakeFiles/libavrdude.dir/confwin.c.o
[ 22%] Building C object src/CMakeFiles/libavrdude.dir/crc16.c.o
[ 23%] Building C object src/CMakeFiles/libavrdude.dir/dfu.c.o
[ 25%] Building C object src/CMakeFiles/libavrdude.dir/dryrun.c.o
[ 26%] Building C object src/CMakeFiles/libavrdude.dir/fileio.c.o
[ 27%] Building C object src/CMakeFiles/libavrdude.dir/flip1.c.o
[ 28%] Building C object src/CMakeFiles/libavrdude.dir/flip2.c.o
[ 30%] Building C object src/CMakeFiles/libavrdude.dir/ft245r.c.o
[ 31%] Building C object src/CMakeFiles/libavrdude.dir/jtagmkI.c.o
[ 32%] Building C object src/CMakeFiles/libavrdude.dir/jtagmkII.c.o
[ 34%] Building C object src/CMakeFiles/libavrdude.dir/jtag3.c.o
[ 35%] Building C object src/CMakeFiles/libavrdude.dir/leds.c.o
[ 36%] Building C object src/CMakeFiles/libavrdude.dir/linuxgpio.c.o
/home/srueger/etc/clock/avrdude/avrdude-main/src/linuxgpio.c: In function ‘linuxgpio_libgpiod_close’:
/home/srueger/etc/clock/avrdude/avrdude-main/src/linuxgpio.c:571:15: warning: implicit declaration of function ‘gpiod_line_set_direction_input’; did you mean ‘gpiod_line_request_input’? [-Wimplicit-function-declaration]
  571 |       int r = gpiod_line_set_direction_input(linuxgpio_libgpiod_lines[i]);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |               gpiod_line_request_input
[ 38%] Building C object src/CMakeFiles/libavrdude.dir/linuxspi.c.o
[ 39%] Building C object src/CMakeFiles/libavrdude.dir/lists.c.o
[ 40%] Building C object src/CMakeFiles/libavrdude.dir/micronucleus.c.o
[ 42%] Building C object src/CMakeFiles/libavrdude.dir/par.c.o
[ 43%] Building C object src/CMakeFiles/libavrdude.dir/pgm.c.o
[ 44%] Building C object src/CMakeFiles/libavrdude.dir/pgm_type.c.o
[ 46%] Building C object src/CMakeFiles/libavrdude.dir/pickit2.c.o
[ 47%] Building C object src/CMakeFiles/libavrdude.dir/pindefs.c.o
[ 48%] Building C object src/CMakeFiles/libavrdude.dir/ppi.c.o
[ 50%] Building C object src/CMakeFiles/libavrdude.dir/ppiwin.c.o
[ 51%] Building C object src/CMakeFiles/libavrdude.dir/serbb_posix.c.o
[ 52%] Building C object src/CMakeFiles/libavrdude.dir/serbb_win32.c.o
[ 53%] Building C object src/CMakeFiles/libavrdude.dir/ser_avrdoper.c.o
[ 55%] Building C object src/CMakeFiles/libavrdude.dir/ser_posix.c.o
[ 56%] Building C object src/CMakeFiles/libavrdude.dir/ser_win32.c.o
[ 57%] Building C object src/CMakeFiles/libavrdude.dir/serialadapter.c.o
[ 59%] Building C object src/CMakeFiles/libavrdude.dir/serialupdi.c.o
[ 60%] Building C object src/CMakeFiles/libavrdude.dir/stk500.c.o
[ 61%] Building C object src/CMakeFiles/libavrdude.dir/stk500v2.c.o
[ 63%] Building C object src/CMakeFiles/libavrdude.dir/stk500generic.c.o
[ 64%] Building C object src/CMakeFiles/libavrdude.dir/strutil.c.o
[ 65%] Building C object src/CMakeFiles/libavrdude.dir/teensy.c.o
[ 67%] Building C object src/CMakeFiles/libavrdude.dir/term.c.o
[ 68%] Building C object src/CMakeFiles/libavrdude.dir/updi_link.c.o
[ 69%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm.c.o
[ 71%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v0.c.o
[ 72%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v2.c.o
[ 73%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v3.c.o
[ 75%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v4.c.o
[ 76%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v5.c.o
[ 77%] Building C object src/CMakeFiles/libavrdude.dir/updi_readwrite.c.o
[ 78%] Building C object src/CMakeFiles/libavrdude.dir/updi_state.c.o
[ 80%] Building C object src/CMakeFiles/libavrdude.dir/urclock.c.o
[ 81%] Building C object src/CMakeFiles/libavrdude.dir/usbasp.c.o
[ 82%] Building C object src/CMakeFiles/libavrdude.dir/usb_hidapi.c.o
[ 84%] Building C object src/CMakeFiles/libavrdude.dir/usb_libusb.c.o
[ 85%] Building C object src/CMakeFiles/libavrdude.dir/usbtiny.c.o
[ 86%] Building C object src/CMakeFiles/libavrdude.dir/update.c.o
[ 88%] Building C object src/CMakeFiles/libavrdude.dir/wiring.c.o
[ 89%] Building C object src/CMakeFiles/libavrdude.dir/xbee.c.o
[ 90%] Building C object src/CMakeFiles/libavrdude.dir/__/lexer.c.o
[ 92%] Building C object src/CMakeFiles/libavrdude.dir/__/config_gram.c.o
[ 93%] Linking C static library libavrdude.a
make[3]: Leaving directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
[ 93%] Built target libavrdude
make[3]: Entering directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
Scanning dependencies of target avrdude
make[3]: Leaving directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
make[3]: Entering directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
[ 94%] Building C object src/CMakeFiles/avrdude.dir/main.c.o
[ 96%] Building C object src/CMakeFiles/avrdude.dir/developer_opts.c.o
[ 97%] Building C object src/CMakeFiles/avrdude.dir/whereami.c.o
[ 98%] Linking C executable avrdude
/usr/bin/ld: libavrdude.a(linuxgpio.c.o): in function `linuxgpio_libgpiod_close':
/home/srueger/etc/clock/avrdude/avrdude-main/src/linuxgpio.c:571: undefined reference to `gpiod_line_set_direction_input'
/usr/bin/ld: /home/srueger/etc/clock/avrdude/avrdude-main/src/linuxgpio.c:582: undefined reference to `gpiod_line_set_direction_input'
collect2: error: ld returned 1 exit status
make[3]: *** [src/CMakeFiles/avrdude.dir/build.make:125: src/avrdude] Error 1
make[3]: Leaving directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
make[2]: *** [CMakeFiles/Makefile2:98: src/CMakeFiles/avrdude.dir/all] Error 2
make[2]: Leaving directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
make[1]: *** [Makefile:130: all] Error 2
make[1]: Leaving directory '/home/srueger/etc/clock/avrdude/avrdude-main/build_linux'
make: *** [Makefile:10: new] Error 2
@stefanrueger stefanrueger added the bug Something isn't working label Apr 22, 2024
mhei added a commit to mhei/avrdude that referenced this issue Apr 22, 2024
…4 support (refs avrdudes#1782)

This ancient libgpiod version is still shipped on Ubuntu 20.04 LTS.
Add support for it by adding another helper.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
@mhei
Copy link
Contributor

mhei commented Apr 22, 2024

You could have a look at the linked branch I pushed. But this is only compile tested against libgpiod v1.4 on a recent Ubuntu 22.04.
Another option would be to require at least libgpiod v1.6 and to ignore any older version.

@mcuee
Copy link
Collaborator

mcuee commented Apr 23, 2024

@mhei

It seems to me some distros are still shipping with older version of libgpiod.
https://repology.org/project/libgpiod/versions

I am okay with bunping up the minimum libgpiod version to v1.6. But I will leave that decision to @stefanrueger.

@mhei
Copy link
Contributor

mhei commented Apr 23, 2024

The question is whether it is necessary to support libgpiod stuff on all these distros - it was not the case until now, right? From my point of view, many users are using avrdude with GPIO stuff on Raspi and similar embedded platforms - so it might make sense to focus a little bit. On the other hand, the patch is small and I think keeping it for one or two releases might help.
And this is another topic: when is the next release of avrdude scheduled? Is there a fixed/usual timeline? What distros are expected to pickup which release then?
I'll try to test the patch on a Raspi with recent Raspberry Pi OS but libgpiod v1.4 - might take some time though.

@stefanrueger
Copy link
Collaborator Author

You could have a look at the linked branch I pushed.

That looks good and works on ubuntu 20.04

The question is whether it is necessary to support libgpiod stuff on all these distros - it was not the case until now, right?

Correct. However, the project prides itself on being backwards compatible, also just in the sense of its ability to build on a wide range of distros. 20.04 sounds old, but considering it's supported until 2030, there is ample justification to make AVRDUDE build, even if an older libgpiod is installed. @mhei Could you submit a PR with your branch, please?

next release of avrdude

There isn't a fixed schedule but we aim at twice a year (early Jan, early July) if there is enough interesting innovation to share.

What distros are expected to pickup which release then?

We don't control any of that, but you could have a look at the repology.org page (https://repology.org/project/avrdude/versions):

Packaging status

mhei added a commit to mhei/avrdude that referenced this issue Apr 26, 2024
…4 support (refs avrdudes#1782)

This ancient libgpiod version is still shipped on Ubuntu 20.04 LTS.
Add support for it by adding another helper.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
@mcuee mcuee linked a pull request Apr 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants