arduino / avrdude-packing

This repository contains the release pipeline to build statically avrdude
6 stars 1 forks source link

Avrdude 7.3 #31

Open MCUdude opened 7 months ago

MCUdude commented 7 months ago

Describe the problem

Hi @umbynos!
You're probably aware of it, but Avrdude 7.3 was recently released, with lots of new and exciting features, but also lots of under-the-hood changes.

One of the new key features is "automatic serial port discovery", which means that you can do -c ch340, -c ft232rl:[optional s/n] or even -P usb:[vid]:[pid]:[optional s/n] instead of having to find the correct COM port number or /dev path. New serial adapters can easily be added to avrdude.conf, which means that -c arduino_uno or -c arduino_mega world work just fine as long as their USB VID and PID are present in avrdude.conf. Neat!

Another neat feature is support for the famous "1200bps touch" functionality the Arduino Leonardo, Micro/Pro Micro and the Nano Every rely on. We put lots of development into this, and it works flawlessly with devices that gets a new PID and/or VID after issuing a "1200bps touch". Use the -r flag to issue a 1200bps touch.

However, Avrdude needs to be compiled with libserialport. I hope you're able to update the build procedure to add this dependency. It makes the entire experience a lot better for Arduino users!

Thanks and best!

To reproduce

N/A

Expected behavior

N/A

avrdude version

Avrdude 7.3

Operating system

N/A

Operating system version

N/A

Additional context

No response

Issue checklist

mcuee commented 6 months ago

To get libserialport, the other possibility is to upgrade the crossbuild container.

Reference:

mcuee commented 6 months ago

Related issue from avdude project.

As of now, the action is only executed upon git push to git main, but not release tagging. https://github.com/avrdudes/avrdude/blob/main/.github/workflows/arduino_packing.yml

mcuee commented 6 months ago

@umbynos

BTW, I think 0007-Cmake-fix-build-not-working-with-mingw-toolchain.patch is no longer needed with avrdude 7.3.

mcuee commented 6 months ago

One experiment to cross build libserialport and avrdude under the cross-build container using the mingw cross compiler.

mcuee@debian12vmn100:~$ docker pull ghcr.io/arduino/crossbuild:0.2.2
0.2.2: Pulling from arduino/crossbuild
5d3b2c2d21bb: Pull complete
3fc2062ea667: Pull complete
75adf526d75b: Pull complete
4606fda479ee: Pull complete
deebe817e5f3: Pull complete
4227963d6e29: Pull complete
6d5b4c83c7da: Pull complete
Digest: sha256:dbacb8b6851fdc3b82e53ee3a3d1126d1f6f2d545e0f7b33398ceb9df8915310
Status: Downloaded newer image for ghcr.io/arduino/crossbuild:0.2.2
ghcr.io/arduino/crossbuild:0.2.2
mcuee@debian12vmn100:~$ docker run -it --name crossbuild -v $PWD:/workdir ghcr.io/arduino/crossbuild:0.2.2
root@c44bc932da28:/workdir# ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  build
root@c44bc932da28:/workdir# gcc-
gcc-9         gcc-ar        gcc-ar-9      gcc-nm        gcc-nm-9      gcc-ranlib    gcc-ranlib-9
root@c44bc932da28:/workdir# cd /opt/
root@c44bc932da28:/opt# ls
gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu    i686-ubuntu16.04-linux-gnu  osxcross
gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf  lib                         x86_64-ubuntu16.04-linux-gnu-gcc
root@c44bc932da28:/workdir# cd
...
   14  mkdir build
   15  cd build/
   16  git clone https://github.com/sigrokproject/libserialport.git
   17  cd libserialport/
   24  apt update
   25  apt install nano
   27  nano macosx.c
   28  git diff
   31  ./autogen.sh
   49  ./configure --disable-shared --enable-static --host=i686-w64-mingw32 --prefix=/opt/lib/i686-w64-mingw32
   50  make
   51  make install
   52  cd ..
   54  git clone https://github.com/avrdudes/avrdude.git
   55  cd avrdude/
   56  git checkout v7.3
   59  cmake -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-I/opt/lib/i686-w64-mingw32/include/libusb-1.0/ -I/opt/lib/i686-w64-mingw32/include -pthread" -DCMAKE_PREFIX_PATH=/opt/lib/i686-w64-mingw32/ -DHAVE_LIBFTDI="NO" -B build/
   60  cmake --build build

root@c44bc932da28:~/build/avrdude# ls -la ./build/src/avrdude.*
-rw-r--r-- 1 root root  913423 Feb 17 05:52 ./build/src/avrdude.conf
-rw-r--r-- 1 root root  913488 Feb 17 05:52 ./build/src/avrdude.conf.in
-rwxr-xr-x 1 root root 6163017 Feb 17 05:52 ./build/src/avrdude.exe
-rw-r--r-- 1 root root    2652 Feb 17 05:52 ./build/src/avrdude.spec

You can see that libserialport is included from the below run log.

root@c44bc932da28:~/build/libserialport# git diff
diff --git a/macosx.c b/macosx.c
index 0d22bb6..0b03981 100644
--- a/macosx.c
+++ b/macosx.c
@@ -36,7 +36,7 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port)
        io_object_t ioport, ioparent;
        CFTypeRef cf_property, cf_bus, cf_address, cf_vendor, cf_product;
        Boolean result;
-       char path[PATH_MAX], class[16];
+       char path[PATH_MAX], class[64];

        DEBUG("Getting serial port list");
        if (!(classes = IOServiceMatching(kIOSerialBSDServiceValue)))

root@c44bc932da28:~/build/libserialport# make install
 /usr/bin/mkdir -p '/opt/lib/i686-w64-mingw32/lib'
 /bin/bash ./libtool --silent  --mode=install /usr/bin/install -c   libserialport.la '/opt/lib/i686-w64-mingw32/lib'
 /usr/bin/mkdir -p '/opt/lib/i686-w64-mingw32/include'
 /usr/bin/install -c -m 644 libserialport.h '/opt/lib/i686-w64-mingw32/include'
 /usr/bin/mkdir -p '/opt/lib/i686-w64-mingw32/lib/pkgconfig'
 /usr/bin/install -c -m 644 libserialport.pc '/opt/lib/i686-w64-mingw32/lib/pkgconfig'

root@c44bc932da28:~/build/avrdude# cmake -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-I/opt/lib/i686-w64-mingw32/include/libusb-1.0/ -I/opt/lib/i686-w64-mingw32/include -pthread" -DCMAKE_PREFIX_PATH=/opt/lib/i686-w64-mingw32/ -DHAVE_LIBFTDI="NO" -B build/
-- The C compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/i686-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/i686-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- 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 - 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 - 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
-- Configuration summary:
-- ----------------------
-- DO HAVE    libelf
-- DO HAVE    libusb
-- DO HAVE    libusb_1_0
-- DO HAVE    libhidapi
-- DON'T HAVE libftdi
-- DO HAVE    libftdi1
-- DO HAVE    libreadline
-- DO HAVE    libserialport
-- DISABLED   doc
-- DISABLED   parport
-- DISABLED   linuxgpio
-- DISABLED   linuxspi
-- ----------------------
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_CXX_COMPILER

-- Build files have been written to: /root/build/avrdude/build
root@c44bc932da28:~/build/avrdude# cmake --build build
[  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
[  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
[ 12%] 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
[ 16%] 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
[ 20%] 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
[ 24%] Building C object src/CMakeFiles/libavrdude.dir/dryrun.c.o
[ 25%] 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
[ 29%] 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
[ 33%] Building C object src/CMakeFiles/libavrdude.dir/jtag3.c.o
/root/build/avrdude/src/jtag3.c: In function 'jtag3_parseextparms':
/root/build/avrdude/src/jtag3.c:1556:47: warning: unknown conversion type character 'h' in format [-Wformat=]
 1556 |           if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
      |                                               ^
/root/build/avrdude/src/jtag3.c:1556:37: warning: too many arguments for format [-Wformat-extra-args]
 1556 |           if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
      |                                     ^~~~~~~~~~~~~
/root/build/avrdude/src/jtag3.c:1556:47: warning: unknown conversion type character 'h' in format [-Wformat=]
 1556 |           if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
      |                                               ^
/root/build/avrdude/src/jtag3.c:1556:37: warning: too many arguments for format [-Wformat-extra-args]
 1556 |           if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
      |                                     ^~~~~~~~~~~~~
/root/build/avrdude/src/jtag3.c:1584:71: warning: unknown conversion type character 'h' in format [-Wformat=]
 1584 |           int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
      |                                                                       ^
/root/build/avrdude/src/jtag3.c:1584:55: warning: too many arguments for format [-Wformat-extra-args]
 1584 |           int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
      |                                                       ^~~~~~~~~~~~~~~~~~~
/root/build/avrdude/src/jtag3.c:1584:71: warning: unknown conversion type character 'h' in format [-Wformat=]
 1584 |           int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
      |                                                                       ^
/root/build/avrdude/src/jtag3.c:1584:55: warning: too many arguments for format [-Wformat-extra-args]
 1584 |           int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
      |                                                       ^~~~~~~~~~~~~~~~~~~
[ 35%] Building C object src/CMakeFiles/libavrdude.dir/leds.c.o
[ 36%] Building C object src/CMakeFiles/libavrdude.dir/linuxgpio.c.o
[ 37%] Building C object src/CMakeFiles/libavrdude.dir/linuxspi.c.o
[ 38%] Building C object src/CMakeFiles/libavrdude.dir/lists.c.o
[ 40%] Building C object src/CMakeFiles/libavrdude.dir/micronucleus.c.o
[ 41%] Building C object src/CMakeFiles/libavrdude.dir/par.c.o
[ 42%] Building C object src/CMakeFiles/libavrdude.dir/pgm.c.o
[ 44%] Building C object src/CMakeFiles/libavrdude.dir/pgm_type.c.o
[ 45%] Building C object src/CMakeFiles/libavrdude.dir/pickit2.c.o
[ 46%] Building C object src/CMakeFiles/libavrdude.dir/pindefs.c.o
[ 48%] Building C object src/CMakeFiles/libavrdude.dir/ppi.c.o
[ 49%] Building C object src/CMakeFiles/libavrdude.dir/ppiwin.c.o
[ 50%] Building C object src/CMakeFiles/libavrdude.dir/serbb_posix.c.o
[ 51%] Building C object src/CMakeFiles/libavrdude.dir/serbb_win32.c.o
[ 53%] Building C object src/CMakeFiles/libavrdude.dir/ser_avrdoper.c.o
[ 54%] Building C object src/CMakeFiles/libavrdude.dir/ser_posix.c.o
[ 55%] Building C object src/CMakeFiles/libavrdude.dir/ser_win32.c.o
[ 57%] Building C object src/CMakeFiles/libavrdude.dir/serialadapter.c.o
[ 58%] Building C object src/CMakeFiles/libavrdude.dir/serialupdi.c.o
[ 59%] Building C object src/CMakeFiles/libavrdude.dir/stk500.c.o
[ 61%] Building C object src/CMakeFiles/libavrdude.dir/stk500v2.c.o
/root/build/avrdude/src/stk500v2.c: In function 'stk500v2_jtag3_parseextparms':
/root/build/avrdude/src/stk500v2.c:2010:47: warning: unknown conversion type character 'h' in format [-Wformat=]
 2010 |           if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
      |                                               ^
/root/build/avrdude/src/stk500v2.c:2010:37: warning: too many arguments for format [-Wformat-extra-args]
 2010 |           if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
      |                                     ^~~~~~~~~~~~~
/root/build/avrdude/src/stk500v2.c:2010:47: warning: unknown conversion type character 'h' in format [-Wformat=]
 2010 |           if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
      |                                               ^
/root/build/avrdude/src/stk500v2.c:2010:37: warning: too many arguments for format [-Wformat-extra-args]
 2010 |           if(sscanf(extended_param, "suffer=%hhi", PDATA(pgm)->suffer_data+1) < 1) {
      |                                     ^~~~~~~~~~~~~
/root/build/avrdude/src/stk500v2.c:2038:71: warning: unknown conversion type character 'h' in format [-Wformat=]
 2038 |           int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
      |                                                                       ^
/root/build/avrdude/src/stk500v2.c:2038:55: warning: too many arguments for format [-Wformat-extra-args]
 2038 |           int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
      |                                                       ^~~~~~~~~~~~~~~~~~~
/root/build/avrdude/src/stk500v2.c:2038:71: warning: unknown conversion type character 'h' in format [-Wformat=]
 2038 |           int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
      |                                                                       ^
/root/build/avrdude/src/stk500v2.c:2038:55: warning: too many arguments for format [-Wformat-extra-args]
 2038 |           int sscanf_success = sscanf(extended_param, "vtarg_switch=%hhi", PDATA(pgm)->vtarg_switch_data+1);
      |                                                       ^~~~~~~~~~~~~~~~~~~
[ 62%] Building C object src/CMakeFiles/libavrdude.dir/stk500generic.c.o
[ 63%] Building C object src/CMakeFiles/libavrdude.dir/strutil.c.o
[ 64%] Building C object src/CMakeFiles/libavrdude.dir/teensy.c.o
[ 66%] Building C object src/CMakeFiles/libavrdude.dir/term.c.o
[ 67%] Building C object src/CMakeFiles/libavrdude.dir/updi_link.c.o
[ 68%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm.c.o
[ 70%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v0.c.o
[ 71%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v2.c.o
[ 72%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v3.c.o
[ 74%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v4.c.o
[ 75%] Building C object src/CMakeFiles/libavrdude.dir/updi_nvm_v5.c.o
[ 76%] Building C object src/CMakeFiles/libavrdude.dir/updi_readwrite.c.o
[ 77%] Building C object src/CMakeFiles/libavrdude.dir/updi_state.c.o
[ 79%] Building C object src/CMakeFiles/libavrdude.dir/urclock.c.o
[ 80%] Building C object src/CMakeFiles/libavrdude.dir/usbasp.c.o
[ 81%] Building C object src/CMakeFiles/libavrdude.dir/usb_hidapi.c.o
[ 83%] Building C object src/CMakeFiles/libavrdude.dir/usb_libusb.c.o
[ 84%] Building C object src/CMakeFiles/libavrdude.dir/usbtiny.c.o
[ 85%] Building C object src/CMakeFiles/libavrdude.dir/update.c.o
[ 87%] Building C object src/CMakeFiles/libavrdude.dir/wiring.c.o
[ 88%] Building C object src/CMakeFiles/libavrdude.dir/xbee.c.o
[ 89%] Building C object src/CMakeFiles/libavrdude.dir/__/lexer.c.o
[ 90%] Building C object src/CMakeFiles/libavrdude.dir/__/config_gram.c.o
[ 92%] Linking C static library libavrdude.a
[ 92%] Built target libavrdude
Scanning dependencies of target avrdude
[ 93%] Building C object src/CMakeFiles/avrdude.dir/main.c.o
/root/build/avrdude/src/main.c: In function 'main':
/root/build/avrdude/src/main.c:953:26: warning: unknown conversion type character 'z' in format [-Wformat=]
  953 |   if(1 != sscanf("42", "%zi", &ztest) || ztest != 42)
      |                          ^
/root/build/avrdude/src/main.c:953:24: warning: too many arguments for format [-Wformat-extra-args]
  953 |   if(1 != sscanf("42", "%zi", &ztest) || ztest != 42)
      |                        ^~~~~
/root/build/avrdude/src/main.c:953:26: warning: unknown conversion type character 'z' in format [-Wformat=]
  953 |   if(1 != sscanf("42", "%zi", &ztest) || ztest != 42)
      |                          ^
/root/build/avrdude/src/main.c:953:24: warning: too many arguments for format [-Wformat-extra-args]
  953 |   if(1 != sscanf("42", "%zi", &ztest) || ztest != 42)
      |                        ^~~~~
[ 94%] Building C object src/CMakeFiles/avrdude.dir/developer_opts.c.o
[ 96%] Building C object src/CMakeFiles/avrdude.dir/whereami.c.o
[ 97%] Linking C executable avrdude
[ 98%] Built target avrdude
Scanning dependencies of target conf
[100%] Generating avrdude.conf
[100%] Built target conf

And the binary works fine.

PS C:\work\avr\avrdude_test\avrdude_bin\avrdude_mingw32> .\avrdude.exe -c jtag2updi -P ch340 -p m4808 -t -v

avrdude: Version 7.3
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\work\avr\avrdude_test\avrdude_bin\avrdude_mingw32\avrdude.conf

         Using port            : COM10
         Using programmer      : jtag2updi
         Programmer baud rate  : 115200
         AVR Part              : ATmega4808
         Programming modes     : UPDI, SPM
         Programmer Type       : JTAGMKII_UPDI
         Description           : JTAGv2 to UPDI bridge
         Main MCU HW version   : 1
         Main MCU FW version   : 6.00
         Sec. MCU HW version   : 1
         Sec. MCU FW version   : 6.00
         Serial number         : 0a:0b:0c:0d:0e:0f
avrdude: silicon revision: 0.1
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9650 (probably m4808)

avrdude: processing -t interactive terminal
avrdude> dump fuses
>>> dump fuses 0x0 0xa
Reading | ################################################## | 100% 0.05 s
0000  00 54 01 ff 00 c8 06 00  02 ff                    |.T........      |
avrdude> quit

avrdude done.  Thank you.
mcuee commented 6 months ago

However I have issues with Linux cross-build.

It also works under Linux.

root@c44bc932da28:~/build/libserialport# make distclean
...
root@c44bc932da28:~/build/libserialport# ./configure --disable-shared --enable-static --host=x86_64-ubuntu16.04-linux-gnu --prefix=/opt/lib/x86_64-ubuntu16.04-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-ubuntu16.04-linux-gnu-strip... x86_64-ubuntu16.04-linux-gnu-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for x86_64-ubuntu16.04-linux-gnu-gcc... x86_64-ubuntu16.04-linux-gnu-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether x86_64-ubuntu16.04-linux-gnu-gcc accepts -g... yes
checking for x86_64-ubuntu16.04-linux-gnu-gcc option to accept ISO C89... none needed
checking whether x86_64-ubuntu16.04-linux-gnu-gcc understands -c and -o together... yes
checking dependency style of x86_64-ubuntu16.04-linux-gnu-gcc... gcc3
checking for x86_64-ubuntu16.04-linux-gnu-ar... x86_64-ubuntu16.04-linux-gnu-ar
checking the archiver (x86_64-ubuntu16.04-linux-gnu-ar) interface... ar
checking for x86_64-ubuntu16.04-linux-gnu-gcc... (cached) x86_64-ubuntu16.04-linux-gnu-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether x86_64-ubuntu16.04-linux-gnu-gcc accepts -g... (cached) yes
checking for x86_64-ubuntu16.04-linux-gnu-gcc option to accept ISO C89... (cached) none needed
checking whether x86_64-ubuntu16.04-linux-gnu-gcc understands -c and -o together... (cached) yes
checking dependency style of x86_64-ubuntu16.04-linux-gnu-gcc... (cached) gcc3
checking whether ln -s works... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-ubuntu16.04-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by x86_64-ubuntu16.04-linux-gnu-gcc... /opt/x86_64-ubuntu16.04-linux-gnu-gcc/x86_64-ubuntu16.04-linux-gnu/bin/ld
checking if the linker (/opt/x86_64-ubuntu16.04-linux-gnu-gcc/x86_64-ubuntu16.04-linux-gnu/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin//x86_64-ubuntu16.04-linux-gnu-nm -B
checking the name lister (/opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin//x86_64-ubuntu16.04-linux-gnu-nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-ubuntu16.04-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /opt/x86_64-ubuntu16.04-linux-gnu-gcc/x86_64-ubuntu16.04-linux-gnu/bin/ld option to reload object files... -r
checking for x86_64-ubuntu16.04-linux-gnu-objdump... x86_64-ubuntu16.04-linux-gnu-objdump
checking how to recognize dependent libraries... pass_all
checking for x86_64-ubuntu16.04-linux-gnu-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for x86_64-ubuntu16.04-linux-gnu-ar... (cached) x86_64-ubuntu16.04-linux-gnu-ar
checking for archiver @FILE support... @
checking for x86_64-ubuntu16.04-linux-gnu-strip... (cached) x86_64-ubuntu16.04-linux-gnu-strip
checking for x86_64-ubuntu16.04-linux-gnu-ranlib... x86_64-ubuntu16.04-linux-gnu-ranlib
checking command to parse /opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin//x86_64-ubuntu16.04-linux-gnu-nm -B output from x86_64-ubuntu16.04-linux-gnu-gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for x86_64-ubuntu16.04-linux-gnu-mt... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... x86_64-ubuntu16.04-linux-gnu-gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if x86_64-ubuntu16.04-linux-gnu-gcc supports -fno-rtti -fno-exceptions... no
checking for x86_64-ubuntu16.04-linux-gnu-gcc option to produce PIC... -fPIC -DPIC
checking if x86_64-ubuntu16.04-linux-gnu-gcc PIC flag -fPIC -DPIC works... yes
checking if x86_64-ubuntu16.04-linux-gnu-gcc static flag -static works... yes
checking if x86_64-ubuntu16.04-linux-gnu-gcc supports -c -o file.o... yes
checking if x86_64-ubuntu16.04-linux-gnu-gcc supports -c -o file.o... (cached) yes
checking whether the x86_64-ubuntu16.04-linux-gnu-gcc linker (/opt/x86_64-ubuntu16.04-linux-gnu-gcc/x86_64-ubuntu16.04-linux-gnu/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for size_t... yes
checking for struct termios2... yes
checking for struct termios.c_ispeed... no
checking for struct termios.c_ospeed... no
checking for struct termios2.c_ispeed... yes
checking for struct termios2.c_ospeed... yes
checking whether BOTHER is declared... yes
checking for struct serial_struct... yes
checking for realpath... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking for flock... yes
checking for clock_gettime... yes
checking for visibility control... attribute
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libserialport.pc
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

libserialport configuration summary:

 - Package version................. 0.1.1
 - Library ABI version............. 1:0:1
 - Prefix.......................... /opt/lib/x86_64-ubuntu16.04-linux-gnu
 - Building on..................... x86_64-pc-linux-gnu
 - Building for.................... x86_64-ubuntu16.04-linux-gnu
 - Building shared / static........ no / yes

Compile configuration:
 - C compiler...................... x86_64-ubuntu16.04-linux-gnu-gcc
 - C compiler version.............. x86_64-ubuntu16.04-linux-gnu-gcc (crosstool-NG crosstool-ng-1.23.0-242-g521d6c17) 7.2.0
 - C compiler flags................ -g -O2
 - Linker flags....................

root@c44bc932da28:~/build/libserialport# make
make  all-am
  CC       serialport.lo
  CC       timing.lo
  CC       linux.lo
  CC       linux_termios.lo
  CCLD     libserialport.la
root@c44bc932da28:~/build/libserialport# make install
 /usr/bin/mkdir -p '/opt/lib/x86_64-ubuntu16.04-linux-gnu/lib'
 /bin/bash ./libtool --silent  --mode=install /usr/bin/install -c   libserialport.la '/opt/lib/x86_64-ubuntu16.04-linux-gnu/lib'
 /usr/bin/mkdir -p '/opt/lib/x86_64-ubuntu16.04-linux-gnu/include'
 /usr/bin/install -c -m 644 libserialport.h '/opt/lib/x86_64-ubuntu16.04-linux-gnu/include'
 /usr/bin/mkdir -p '/opt/lib/x86_64-ubuntu16.04-linux-gnu/lib/pkgconfig'
 /usr/bin/install -c -m 644 libserialport.pc '/opt/lib/x86_64-ubuntu16.04-linux-gnu/lib/pkgconfig'
root@c44bc932da28:~/build/libserialport# cd ..
root@c44bc932da28:~/build# cd avrdude/
root@c44bc932da28:~/build/avrdude# rm -rf build_linux/
root@c44bc932da28:~/build/avrdude# cmake -DCMAKE_C_COMPILER=x86_64-ubuntu16.04-linux-gnu-gcc -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-I/opt/lib/x86_64-ubuntu16.04-linux-gnu/include/libusb-1.0/ -I/opt/lib/x86_64-ubuntu16.04-linux-gnu/include -pthread" -DCMAKE_PREFIX_PATH=/opt/lib/x86_64-ubuntu16.04-linux-gnu/ -DHAVE_LIBFTDI="NO" -B build_linux/
-- The C compiler identification is GNU 7.2.0
-- Check for working C compiler: /opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin/x86_64-ubuntu16.04-linux-gnu-gcc
-- Check for working C compiler: /opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin/x86_64-ubuntu16.04-linux-gnu-gcc -- 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 - 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 - 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
-- Configuration summary:
-- ----------------------
-- DO HAVE    libelf
-- DO HAVE    libusb
-- DO HAVE    libusb_1_0
-- DO HAVE    libhidapi
-- DON'T HAVE libftdi
-- DO HAVE    libftdi1
-- DO HAVE    libreadline
-- DO HAVE    libserialport
-- DISABLED   doc
-- DISABLED   parport
-- DISABLED   linuxgpio
-- DISABLED   linuxspi
-- ----------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /root/build/avrdude/build_linux
root@c44bc932da28:~/build/avrdude# cmake --build 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
[  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
[ 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
/root/build/avrdude/src/strutil.c: In function 'str_sprintf':
/root/build/avrdude/src/strutil.c:237:8: warning: null destination pointer [-Wformat-truncation=]
   size = vsnprintf(NULL, size, fmt, ap);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 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
[ 93%] Built target libavrdude
Scanning dependencies of target avrdude
[ 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
[ 98%] Built target avrdude
Scanning dependencies of target conf
[100%] Generating avrdude.conf
[100%] Built target conf
mcuee commented 6 months ago

Just attach my avrdude 7.3 release cross-build binaries in case people want to test under Windows and Linux. All binaries are built with libserialport support.

avrdude_mingw32.zip avrdude_linux_x86.zip avrdude_linux_x64.zip avrdude_linux_arm64.zip avrdude_linux_arm32.zip

Edit: renamed and archived here as well. https://github.com/mcuee/avrdude/releases/tag/v7.3

mcuee commented 6 months ago

libserialport needs more work for cross build as well for macOS.

root@c44bc932da28:~/build/libserialport# ./configure --disable-shared --enable-static --host=x86_64-apple-darwin13 --prefix=/opt/lib/x86_64-apple-darwin13
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-apple-darwin13-strip... x86_64-apple-darwin13-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for x86_64-apple-darwin13-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for x86_64-apple-darwin13-ar... x86_64-apple-darwin13-ar
checking the archiver (x86_64-apple-darwin13-ar) interface... ar
checking for x86_64-apple-darwin13-gcc... gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking whether ln -s works... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-apple-darwin13
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /opt/osxcross/target/bin//x86_64-apple-darwin13-nm
checking the name lister (/opt/osxcross/target/bin//x86_64-apple-darwin13-nm) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-apple-darwin13 format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for x86_64-apple-darwin13-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for x86_64-apple-darwin13-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for x86_64-apple-darwin13-ar... (cached) x86_64-apple-darwin13-ar
checking for archiver @FILE support... no
checking for x86_64-apple-darwin13-strip... (cached) x86_64-apple-darwin13-strip
checking for x86_64-apple-darwin13-ranlib... x86_64-apple-darwin13-ranlib
checking command to parse /opt/osxcross/target/bin//x86_64-apple-darwin13-nm output from gcc object... failed
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for x86_64-apple-darwin13-mt... no
checking for mt... no
checking if : is a manifest tool... no
checking for x86_64-apple-darwin13-dsymutil... x86_64-apple-darwin13-dsymutil
checking for x86_64-apple-darwin13-nmedit... x86_64-apple-darwin13-nmedit
checking for x86_64-apple-darwin13-lipo... x86_64-apple-darwin13-lipo
checking for x86_64-apple-darwin13-otool... x86_64-apple-darwin13-otool
checking for x86_64-apple-darwin13-otool64... no
checking for otool64... no
checking for -single_module linker flag... /usr/bin/ld: unrecognised option: -single_module
no
checking for -exported_symbols_list linker flag... no
checking for -force_load linker flag... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin13 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking IOKit/IOKitLib.h usability... no
checking IOKit/IOKitLib.h presence... no
checking for IOKit/IOKitLib.h... no
configure: error: IOKit/IOKitLib.h not found
umbynos commented 5 months ago

Hello @mcuee have you tried to use -framework IOKit I remember using something like this in the command line for avrdude building https://github.com/arduino/avrdude-packing/blob/b85bd88665fa3761ca197c1866e3cfe2d509c00b/.github/workflows/release.yml#L91

mcuee commented 5 months ago

@umbynos

Thanks for the tip. I will try this over the weekend.

mcuee commented 5 months ago

@umbynos

Sorry I can not figure out how to do it.

I tried things like the following and it did not work.

root@c44bc932da28:~/build/libserialport# CFLAGS="-I/opt/lib/x86_64-apple-darwin13/include -pthread -framework Foundation -framework IOKit -framework Cocoa -framework Security" LDFLAGS="-L/opt/lib/x86_64-apple-darwin13/lib" ./configure --dis
able-shared --enable-static --host=x86_64-apple-darwin13 --prefix=/opt/lib/x86_64-apple-darwin13
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-apple-darwin13-strip... x86_64-apple-darwin13-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for x86_64-apple-darwin13-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/root/build/libserialport':
configure: error: C compiler cannot create executables
See `config.log' for more details
mcuee commented 5 months ago

Then I also tried the fork here. https://github.com/avrdudes/libserialport/pull/3 https://github.com/ndim/libserialport/tree/add-version-suffix

But apparently it is also not working -- looks like the CMake script is not yet ready for cross-compiler.

``` root@c44bc932da28:~/build/libserialport_cmake# cmake -B build_darwin -DCMAKE_C_COMPILER=o64-clang -DCMAKE_EXE_LINKER_FLAGS="-L/opt/lib/x86_64-apple-darwin13/lib" -DCMAKE_C_FLAGS="-I/opt/lib/x86_64-apple-darwin13/include -pthread -framework Foundation -framework IOKit -framework Cocoa -framework Security" -DCMAKE_PREFIX_PATH=/opt/lib/x86_64-apple-darwin13 -- The C compiler identification is Clang 10.0.0 -- Check for working C compiler: /opt/osxcross/target/bin/o64-clang -- Check for working C compiler: /opt/osxcross/target/bin/o64-clang -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Configuring done -- Generating done -- Build files have been written to: /root/build/libserialport_cmake/build_darwin root@c44bc932da28:~/build/libserialport_cmake# cmake -build build_darwin -- Configuring done -- Generating done -- Build files have been written to: /root/build/libserialport_cmake/build_darwin root@c44bc932da28:~/build/libserialport_cmake# cmake -B build_darwin -DCMAKE_C_COMPILER=o64-clang -DCMAKE_EXE_LINKER_FLAGS="-L/opt/lib/x86_64-apple-darwin13/lib" -DCMAKE_C_FLAGS="-I/opt/lib/x86_64-apple-darwin13/include -pthread -framework Foundation -framework IOKit -framework Cocoa -framework Security" -DCMAKE_PREFIX_PATH=/opt/lib/x86_64-apple-darwin13 -- Configuring done -- Generating done -- Build files have been written to: /root/build/libserialport_cmake/build_darwin root@c44bc932da28:~/build/libserialport_cmake# cmake --build build_darwin Scanning dependencies of target libserialport [ 20%] Building C object CMakeFiles/libserialport.dir/serialport.c.o clang: warning: -framework Foundation: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework Cocoa: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework Security: 'linker' input unused [-Wunused-command-line-argument] [ 40%] Building C object CMakeFiles/libserialport.dir/timing.c.o clang: warning: -framework Foundation: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework Cocoa: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework Security: 'linker' input unused [-Wunused-command-line-argument] [ 60%] Building C object CMakeFiles/libserialport.dir/linux.c.o clang: warning: -framework Foundation: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework Cocoa: 'linker' input unused [-Wunused-command-line-argument] clang: warning: -framework Security: 'linker' input unused [-Wunused-command-line-argument] /root/build/libserialport_cmake/linux.c:198:23: error: incomplete definition of type 'struct dirent' char buf[sizeof(entry->d_name) + 23]; ~~~~~^ /root/build/libserialport_cmake/linux.c:193:9: note: forward declaration of 'struct dirent' struct dirent *entry; ^ /root/build/libserialport_cmake/linux.c:200:2: error: use of undeclared identifier 'DIR' DIR *dir; ^ /root/build/libserialport_cmake/linux.c:200:7: error: use of undeclared identifier 'dir'; did you mean 'div'? DIR *dir; ^~~ div /opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/stdlib.h:144:8: note: 'div' declared here div_t div(int, int) __pure2; ^ /root/build/libserialport_cmake/linux.c:205:14: warning: implicit declaration of function 'opendir' is invalid in C99 [-Wimplicit-function-declaration] if (!(dir = opendir("/sys/class/tty"))) ^ /root/build/libserialport_cmake/linux.c:205:8: error: use of undeclared identifier 'dir' if (!(dir = opendir("/sys/class/tty"))) ^ /root/build/libserialport_cmake/linux.c:209:18: warning: implicit declaration of function 'readdir' is invalid in C99 [-Wimplicit-function-declaration] while ((entry = readdir(dir))) { ^ /root/build/libserialport_cmake/linux.c:209:26: error: use of undeclared identifier 'dir'; did you mean 'div'? while ((entry = readdir(dir))) { ^~~ div /opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/stdlib.h:144:8: note: 'div' declared here div_t div(int, int) __pure2; ^ /root/build/libserialport_cmake/linux.c:209:16: warning: incompatible integer to pointer conversion assigning to 'struct dirent *' from 'int' [-Wint-conversion] while ((entry = readdir(dir))) { ^ ~~~~~~~~~~~~ /root/build/libserialport_cmake/linux.c:210:56: error: incomplete definition of type 'struct dirent' snprintf(buf, sizeof(buf), "/sys/class/tty/%s", entry->d_name); ~~~~~^ /opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf' __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__) ^~~~~~~~~~~ /root/build/libserialport_cmake/linux.c:193:9: note: forward declaration of 'struct dirent' struct dirent *entry; ^ /root/build/libserialport_cmake/linux.c:214:64: error: incomplete definition of type 'struct dirent' snprintf(buf, sizeof(buf), "/sys/class/tty/%s/device", entry->d_name); ~~~~~^ /opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf' __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__) ^~~~~~~~~~~ /root/build/libserialport_cmake/linux.c:193:9: note: forward declaration of 'struct dirent' struct dirent *entry; ^ /root/build/libserialport_cmake/linux.c:221:48: error: incomplete definition of type 'struct dirent' snprintf(name, sizeof(name), "/dev/%s", entry->d_name); ~~~~~^ /opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf' __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__) ^~~~~~~~~~~ /root/build/libserialport_cmake/linux.c:193:9: note: forward declaration of 'struct dirent' struct dirent *entry; ^ /root/build/libserialport_cmake/linux.c:256:2: warning: implicit declaration of function 'closedir' is invalid in C99 [-Wimplicit-function-declaration] closedir(dir); ^ /root/build/libserialport_cmake/linux.c:256:11: error: use of undeclared identifier 'dir'; did you mean 'div'? closedir(dir); ^~~ div /opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/stdlib.h:144:8: note: 'div' declared here div_t div(int, int) __pure2; ^ 4 warnings and 9 errors generated. make[2]: *** [CMakeFiles/libserialport.dir/build.make:89: CMakeFiles/libserialport.dir/linux.c.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/libserialport.dir/all] Error 2 make: *** [Makefile:130: all] Error 2 ```
mcuee commented 1 week ago

FYI, avrdude 8.0 has been released.

As of now the static linking build binaries are missing libserialport support.

mcuee commented 1 week ago

avrdude 8.0 mingw32 cross build log. build_log.txt

Initial run log under Ubuntu 24.04.

mcuee@PCRyzen5600G:~/build/docker$ docker pull ghcr.io/arduino/crossbuild:0.2.2
0.2.2: Pulling from arduino/crossbuild
5d3b2c2d21bb: Pull complete 
3fc2062ea667: Pull complete 
75adf526d75b: Pull complete 
4606fda479ee: Pull complete 
deebe817e5f3: Pull complete 
4227963d6e29: Pull complete 
6d5b4c83c7da: Pull complete 
Digest: sha256:dbacb8b6851fdc3b82e53ee3a3d1126d1f6f2d545e0f7b33398ceb9df8915310
Status: Downloaded newer image for ghcr.io/arduino/crossbuild:0.2.2
ghcr.io/arduino/crossbuild:0.2.2
mcuee@PCRyzen5600G:~/build/docker$ docker run -it --name crossbuild -v $PWD:/workdir ghcr.io/arduino/crossbuild:0.2.2

Within cross-build docker.

root@fe01b20fdc99:/workdir/build# history
    1  ls
    2  mkdir build
    3  cd build/
    4  git clone https://github.com/sigrokproject/libserialport.git
    5  cd libserialport/
    6  ./autogen.sh 
    7  ./configure --disable-shared --enable-static --host=i686-w64-mingw32 --prefix=/opt/lib/i686-w64-mingw32
    8  make
    9  make install
   10  cd ..
   11  ls
   12  git clone https://github.com/avrdudes/avrdude.git
   13  cd avrdude/
   14  git checkout v8.0
   15  cmake -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-I/opt/lib/i686-w64-mingw32/include/libusb-1.0/ -I/opt/lib/i686-w64-mingw32/include -pthread" -DCMAKE_PREFIX_PATH=/opt/lib/i686-w64-mingw32/ -DHAVE_LIBFTDI="NO" -B build/
   16  cmake --build build
   17  ls -la ./build/src/avrdude.*
   18  ls
   19  cd ..
   20  ls
   21  cd build/
   22  ls
   23  nano build_log.txt
   24  apt install nano
   25  apt update
   26  apt install nano
   27  nano build_log.txt
   28  history
mcuee commented 1 week ago

avrdude 8.0 Linux x64 cross build.

   30  cd libserialport/
   31  make distclean
   32  ./configure --disable-shared --enable-static --host=x86_64-ubuntu16.04-linux-gnu --prefix=/opt/lib/x86_64-ubuntu16.04-linux-gnu
   33  make
   34  make install
   35  cd ..
   36  ls
   37  cd avrdude/
   38  ls
   39  cmake -DCMAKE_C_COMPILER=x86_64-ubuntu16.04-linux-gnu-gcc -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-I/opt/lib/x86_64-ubuntu16.04-linux-gnu/include/libusb-1.0/ -I/opt/lib/x86_64-ubuntu16.04-linux-gnu/include -pthread" -DCMAKE_PREFIX_PATH=/opt/lib/x86_64-ubuntu16.04-linux-gnu/ -DHAVE_LIBFTDI="NO" -B build_linux/
   40  cmake --build build_linux/
   41  ls ./build_linux/src/avrdude*
   42  ldd ./build_linux/src/avrdude
   43  ./build_linux/src/avrdude
   44  cd ..
   45  ls
   46  nano build_log_linux_x64.txt 
   47  history

build_log_linux_x64.txt

mcuee commented 1 week ago

libserialport needs more work for cross build as well for macOS.

Same issue now.

root@fe01b20fdc99:/workdir/build/libserialport# ./configure --disable-shared --enable-static --host=x86_64-apple-darwin13 --prefix=/opt/lib/x86_64-apple-darwin13
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-apple-darwin13-strip... x86_64-apple-darwin13-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for x86_64-apple-darwin13-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for x86_64-apple-darwin13-ar... x86_64-apple-darwin13-ar
checking the archiver (x86_64-apple-darwin13-ar) interface... ar
checking for x86_64-apple-darwin13-gcc... gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking whether ln -s works... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-apple-darwin13
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /opt/osxcross/target/bin//x86_64-apple-darwin13-nm
checking the name lister (/opt/osxcross/target/bin//x86_64-apple-darwin13-nm) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-apple-darwin13 format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for x86_64-apple-darwin13-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for x86_64-apple-darwin13-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for x86_64-apple-darwin13-ar... (cached) x86_64-apple-darwin13-ar
checking for archiver @FILE support... no
checking for x86_64-apple-darwin13-strip... (cached) x86_64-apple-darwin13-strip
checking for x86_64-apple-darwin13-ranlib... x86_64-apple-darwin13-ranlib
checking command to parse /opt/osxcross/target/bin//x86_64-apple-darwin13-nm output from gcc object... failed
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for x86_64-apple-darwin13-mt... no
checking for mt... no
checking if : is a manifest tool... no
checking for x86_64-apple-darwin13-dsymutil... x86_64-apple-darwin13-dsymutil
checking for x86_64-apple-darwin13-nmedit... x86_64-apple-darwin13-nmedit
checking for x86_64-apple-darwin13-lipo... x86_64-apple-darwin13-lipo
checking for x86_64-apple-darwin13-otool... x86_64-apple-darwin13-otool
checking for x86_64-apple-darwin13-otool64... no
checking for otool64... no
checking for -single_module linker flag... /usr/bin/ld: unrecognised option: -single_module
no
checking for -exported_symbols_list linker flag... no
checking for -force_load linker flag... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin13 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking IOKit/IOKitLib.h usability... no
checking IOKit/IOKitLib.h presence... no
checking for IOKit/IOKitLib.h... no
configure: error: IOKit/IOKitLib.h not found