Failed to cross compile Asterisk voice channel for OpenWRT [Solved]

Hi everyone,

I recently got into OpenWRT and compiled a working image of the snapshot version for the R64. I was planing on creating a VoIP GSM gateway with the Quectel EC25-E modem. I found this fork of the chan_donge Asterisk channel driver: asterisk-chan-quectel I tried cross compiling it with the generated toolchain from the OpenWRT build with this command:

./configure --with-astversion=18.5.1 --build=x86_64-pc-linux-gnu --host=aarch64-openwrt-linux

Output:

checking build system type… x86_64-pc-linux-gnu checking host system type… aarch64-openwrt-linux-gnu checking target system type… aarch64-openwrt-linux-gnu checking for a BSD-compatible install… /usr/bin/install -c checking whether build environment is sane… yes checking for aarch64-openwrt-linux-strip… aarch64-openwrt-linux-strip checking for a thread-safe mkdir -p… /usr/bin/mkdir -p checking for gawk… gawk checking whether make sets $(MAKE)… yes checking whether make supports nested variables… yes checking for aarch64-openwrt-linux-gcc… aarch64-openwrt-linux-gcc checking whether the C compiler works… no configure: error: in /home/matej/toolchain/asterisk-chan-quectel': configure: error: C compiler cannot create executables Seeconfig.log’ for more details

Content of config.log:

This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake.

It was created by chan_quectel configure 1.1, which was generated by GNU Autoconf 2.69. Invocation command line was

$ ./configure --with-astversion=18.5.1 --build=x86_64-pc-linux-gnu --host=aarch64-openwrt-linux

---------

Platform.

---------

hostname = ubuntu uname -m = x86_64 uname -r = 5.11.0-27-generic uname -s = Linux uname -v = #29~20.04.1-Ubuntu SMP Wed Aug 11 15:58:17 UTC 2021

/usr/bin/uname -p = x86_64 /bin/uname -X = unknown

/bin/arch = x86_64 /usr/bin/arch -k = unknown /usr/convex/getsysinfo = unknown /usr/bin/hostinfo = unknown /bin/machine = unknown /usr/bin/oslevel = unknown /bin/universe = unknown

PATH: /home/matej/.local/bin PATH: /usr/local/sbin PATH: /usr/local/bin PATH: /usr/sbin PATH: /usr/bin PATH: /sbin PATH: /bin PATH: /usr/games PATH: /usr/local/games PATH: /snap/bin PATH: /home/matej/toolchain/bin

-----------

Core tests.

-----------

configure:2334: checking build system type configure:2348: result: x86_64-pc-linux-gnu configure:2368: checking host system type configure:2381: result: aarch64-openwrt-linux-gnu configure:2401: checking target system type configure:2414: result: aarch64-openwrt-linux-gnu configure:2456: checking for a BSD-compatible install configure:2524: result: /usr/bin/install -c configure:2535: checking whether build environment is sane configure:2590: result: yes configure:2647: checking for aarch64-openwrt-linux-strip configure:2663: found /home/matej/toolchain/bin/aarch64-openwrt-linux-strip configure:2674: result: aarch64-openwrt-linux-strip configure:2739: checking for a thread-safe mkdir -p configure:2778: result: /usr/bin/mkdir -p configure:2785: checking for gawk configure:2801: found /usr/bin/gawk configure:2812: result: gawk configure:2823: checking whether make sets $(MAKE) configure:2845: result: yes configure:2874: checking whether make supports nested variables configure:2891: result: yes configure:3102: checking for aarch64-openwrt-linux-gcc configure:3118: found /home/matej/toolchain/bin/aarch64-openwrt-linux-gcc configure:3129: result: aarch64-openwrt-linux-gcc configure:3204: checking for C compiler version configure:3213: aarch64-openwrt-linux-gcc --version >&5 /home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/…/…/host/lib/ld-linux-x86-64.so.2: No such file or directory configure:3224: $? = 127 configure:3213: aarch64-openwrt-linux-gcc -v >&5 /home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/…/…/host/lib/ld-linux-x86-64.so.2: No such file or directory configure:3224: $? = 127 configure:3213: aarch64-openwrt-linux-gcc -V >&5 /home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/…/…/host/lib/ld-linux-x86-64.so.2: No such file or directory configure:3224: $? = 127 configure:3213: aarch64-openwrt-linux-gcc -qversion >&5 /home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/…/…/host/lib/ld-linux-x86-64.so.2: No such file or directory configure:3224: $? = 127 configure:3244: checking whether the C compiler works configure:3266: aarch64-openwrt-linux-gcc -D_GNU_SOURCE conftest.c >&5 /home/matej/toolchain/bin/aarch64-openwrt-linux-gcc: line 5: /home/matej/toolchain/bin/…/…/host/lib/ld-linux-x86-64.so.2: No such file or directory configure:3270: $? = 127 configure:3308: result: no configure: failed program was: | /* confdefs.h / | #define PACKAGE_NAME “chan_quectel” | #define PACKAGE_TARNAME “chan_quectel” | #define PACKAGE_VERSION “1.1” | #define PACKAGE_STRING “chan_quectel 1.1” | #define PACKAGE_BUGREPORT “https://github.com/bg111/asterisk-chan-quectel/issues” | #define PACKAGE_URL “https://github.com/bg111/asterisk-chan-quectel/” | #define PACKAGE “chan_quectel” | #define VERSION “1.1” | #define ASTERISK_VERSION_NUM 180501 | / end confdefs.h. */ | | int | main () | { | | ; | return 0; | } configure:3313: error: in /home/matej/toolchain/asterisk-chan-quectel': configure:3315: error: C compiler cannot create executables Seeconfig.log’ for more details

----------------

Cache variables.

----------------

ac_cv_build=x86_64-pc-linux-gnu ac_cv_env_CC_set= ac_cv_env_CC_value= ac_cv_env_CFLAGS_set= ac_cv_env_CFLAGS_value= ac_cv_env_CPPFLAGS_set= ac_cv_env_CPPFLAGS_value= ac_cv_env_CPP_set= ac_cv_env_CPP_value= ac_cv_env_LDFLAGS_set= ac_cv_env_LDFLAGS_value= ac_cv_env_LIBS_set= ac_cv_env_LIBS_value= ac_cv_env_build_alias_set=set ac_cv_env_build_alias_value=x86_64-pc-linux-gnu ac_cv_env_host_alias_set=set ac_cv_env_host_alias_value=aarch64-openwrt-linux ac_cv_env_target_alias_set= ac_cv_env_target_alias_value= ac_cv_host=aarch64-openwrt-linux-gnu ac_cv_path_install=’/usr/bin/install -c’ ac_cv_path_mkdir=/usr/bin/mkdir ac_cv_prog_AWK=gawk ac_cv_prog_CC=aarch64-openwrt-linux-gcc ac_cv_prog_STRIP=aarch64-openwrt-linux-strip ac_cv_prog_make_make_set=yes ac_cv_target=aarch64-openwrt-linux-gnu am_cv_make_support_nested_variables=yes

-----------------

Output variables.

-----------------

ACLOCAL=’${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing aclocal-1.16’ AC_CFLAGS=’’ AMDEPBACKSLASH=’’ AMDEP_FALSE=’’ AMDEP_TRUE=’’ AMTAR=’$${TAR-tar}’ AM_BACKSLASH=’’ AM_DEFAULT_V=’$(AM_DEFAULT_VERBOSITY)’ AM_DEFAULT_VERBOSITY=‘1’ AM_V=’$(V)’ AUTOCONF=’${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing autoconf’ AUTOHEADER=’${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing autoheader’ AUTOMAKE=’${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing automake-1.16’ AWK=‘gawk’ CC=‘aarch64-openwrt-linux-gcc’ CCDEPMODE=’’ CFLAGS=’’ CPP=’’ CPPFLAGS=’ -D_GNU_SOURCE’ CYGPATH_W=‘echo’ DEFS=’’ DEPDIR=’’ DESTDIR=’’ ECHO_C=’’ ECHO_N=’-n’ ECHO_T=’’ EGREP=’’ EXEEXT=’’ GREP=’’ INSTALL_DATA=’${INSTALL} -m 644’ INSTALL_PROGRAM=’${INSTALL}’ INSTALL_SCRIPT=’${INSTALL}’ INSTALL_STRIP_PROGRAM=’$(install_sh) -c -s’ LDFLAGS=’’ LIBOBJS=’’ LIBS=’’ LTLIBOBJS=’’ MAKEINFO=’${SHELL} /home/matej/toolchain/asterisk-chan-quectel/missing makeinfo’ MKDIR_P=’/usr/bin/mkdir -p’ OBJEXT=’’ PACKAGE=‘chan_quectel’ PACKAGE_BUGREPORT=‘https://github.com/bg111/asterisk-chan-quectel/issues’ PACKAGE_NAME=‘chan_quectel’ PACKAGE_REVISION=‘43gh=47cg’ PACKAGE_STRING=‘chan_quectel 1.1’ PACKAGE_TARNAME=‘chan_quectel’ PACKAGE_URL=‘https://github.com/bg111/asterisk-chan-quectel/’ PACKAGE_VERSION=‘1.1’ PATH_SEPARATOR=’:’ RM=’’ SET_MAKE=’’ SHELL=’/bin/bash’ SOLINK=’’ STRIP=‘aarch64-openwrt-linux-strip’ TARGET=’’ VERSION=‘1.1’ ac_ct_CC=’’ am__EXEEXT_FALSE=’’ am__EXEEXT_TRUE=’’ am__fastdepCC_FALSE=’’ am__fastdepCC_TRUE=’’ am__include=’’ am__isrc=’’ am__leading_dot=’.’ am__nodep=’’ am__quote=’’ am__tar=’$${TAR-tar} chof - “$$tardir”’ am__untar=’$${TAR-tar} xf -’ bindir=’${exec_prefix}/bin’ build=‘x86_64-pc-linux-gnu’ build_alias=‘x86_64-pc-linux-gnu’ build_cpu=‘x86_64’ build_os=‘linux-gnu’ build_vendor=‘pc’ datadir=’${datarootdir}’ datarootdir=’${prefix}/share’ docdir=’${datarootdir}/doc/${PACKAGE_TARNAME}’ dvidir=’${docdir}’ exec_prefix=‘NONE’ host=‘aarch64-openwrt-linux-gnu’ host_alias=‘aarch64-openwrt-linux’ host_cpu=‘aarch64’ host_os=‘linux-gnu’ host_vendor=‘openwrt’ htmldir=’${docdir}’ includedir=’${prefix}/include’ infodir=’${datarootdir}/info’ install_sh=’${SHELL} /home/matej/toolchain/asterisk-chan-quectel/install-sh’ libdir=’${exec_prefix}/lib’ libexecdir=’${exec_prefix}/libexec’ localedir=’${datarootdir}/locale’ localstatedir=’${prefix}/var’ mandir=’${datarootdir}/man’ mkdir_p=’$(MKDIR_P)’ oldincludedir=’/usr/include’ pdfdir=’${docdir}’ prefix=‘NONE’ program_transform_name=‘s,x,x,’ psdir=’${docdir}’ runstatedir=’${localstatedir}/run’ sbindir=’${exec_prefix}/sbin’ sharedstatedir=’${prefix}/com’ sysconfdir=’${prefix}/etc’ target=‘aarch64-openwrt-linux-gnu’ target_alias=’’ target_cpu=‘aarch64’ target_os=‘linux-gnu’ target_vendor=‘openwrt’

-----------

confdefs.h.

-----------

/* confdefs.h */ #define PACKAGE_NAME “chan_quectel” #define PACKAGE_TARNAME “chan_quectel” #define PACKAGE_VERSION “1.1” #define PACKAGE_STRING “chan_quectel 1.1” #define PACKAGE_BUGREPORT “https://github.com/bg111/asterisk-chan-quectel/issues#define PACKAGE_URL “https://github.com/bg111/asterisk-chan-quectel/#define PACKAGE “chan_quectel” #define VERSION “1.1” #define ASTERISK_VERSION_NUM 180501

configure: exit 77

If someone would help that would be awesome :smile:

I guess the best way to build this is to use the package build script for asterisk-chan-dongle and do it within the build system (instead of just using the toolchain).

cd feeds/telephony/net
cp -vr asterisk-chan-dongle asterisk-chan-quectel
 # you may need to make similar patches, but remove them for now
rm -r asterisk-chan-quectel/patches
# now edit asterisk-chan-quectel/Makefile
1 Like

Thank you so much!

I followed your instructions along with those in this tutorial and eventualy got it working. The patch files needed to stay the same

If anyone is interested in this here is a pkg file for glibc (my musl configuration needs some more work): asterisk-chan-quectel_2020-05-28-ad17cff6-1_aarch64_cortex-a53.ipk (92.4 KB)

Here is the musl one:

asterisk-chan-quectel_2020-05-28-ad17cff6-1_aarch64_cortex-a53.ipk (87.3 KB)

Please also share the package source Makefile so people can build this for all platforms. If can you make a PR to have it added to https://www.github.com/openwrt/telephony that would be ideal.

Thank you! I’m sure this work will be useful for many people!

Will do when I get the time today or tommorow. It’s worth noting that the source code for the channel driver needs some working. I get segmentation faults while testing calls in Asterisk CLI. I’m not that experienced with gdb, but I will try to get the debugging symbols and analyze the dump file I created with asterisk. I receive the call on my phone but after ending it the segmentation fault occurs:

For reference the AT^DDSETEX is not even a Quectel supported AT command and is left in source code from chan_dongle. The CREG command is a Quectel supported command but it seems that parsing is not implemented correctly. I would love to fork and modify the source code but unfortunately I’m pretty busy the next few weeks.

Also can you help me how to reslove this issue without having to use chown command every time I reboot:

Is this topic better suited for the OpenWRT forum (I also created a topic there but it got not traction)