20240502给NanoPi的NEO core开发板编译移远的4G模块的上网程序quectel-CM
2024/5/2 16:29
1、默认编译为AMD64/INTEL的x64架构的可执行文件:
rootroot@rootroot-ThinkBook-16-G5-IRH:~$
rootroot@rootroot-ThinkBook-16-G5-IRH:~$ unzip Quectel_QConnectManager_Linux_V1.6.5.1.zip
Archive: Quectel_QConnectManager_Linux_V1.6.5.1.zip
rootroot@rootroot-ThinkBook-16-G5-IRH:~$
rootroot@rootroot-ThinkBook-16-G5-IRH:~$
rootroot@rootroot-ThinkBook-16-G5-IRH:~$ cd quectel-CM/
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ ll
total 896
drwxrwxr-x 4 rootroot rootroot 4096 1月 22 11:06 ./
drwxr-xr-x 40 rootroot rootroot 4096 5月 2 16:02 ../
-rw-rw-r-- 1 rootroot rootroot 33837 1月 15 10:21 atc.c
-rw-rw-r-- 1 rootroot rootroot 25544 1月 15 10:21 atchannel.c
-rw-rw-r-- 1 rootroot rootroot 5124 1月 15 10:21 atchannel.h
-rw-rw-r-- 1 rootroot rootroot 5612 1月 15 10:21 at_tok.c
-rw-rw-r-- 1 rootroot rootroot 1072 1月 15 10:21 at_tok.h
-rw-rw-r-- 1 rootroot rootroot 1237 1月 15 10:21 CMakeLists.txt
-rw-rw-r-- 1 rootroot rootroot 1408 1月 15 10:21 configure.ac
-rw-rw-r-- 1 rootroot rootroot 1293 1月 15 10:21 default.script
-rw-rw-r-- 1 rootroot rootroot 1221 1月 15 10:21 default.script_ip
-rw-rw-r-- 1 rootroot rootroot 22875 1月 15 10:21 device.c
-rw-rw-r-- 1 rootroot rootroot 40995 1月 15 10:21 ethtool-copy.h
-rw-rw-r-- 1 rootroot rootroot 8678 1月 15 10:21 GobiNetCM.c
drwxrwxr-x 3 rootroot rootroot 4096 1月 15 10:21 log/
-rw-rw-r-- 1 rootroot rootroot 36466 1月 22 11:00 main.c
-rw-rw-r-- 1 rootroot rootroot 1706 1月 22 11:06 Makefile
-rw-rw-r-- 1 rootroot rootroot 639 1月 15 10:21 Makefile.am
-rw-rw-r-- 1 rootroot rootroot 90446 1月 15 10:21 mbim-cm.c
-rw-rw-r-- 1 rootroot rootroot 449 1月 15 10:21 NOTICE
drwxrwxr-x 2 rootroot rootroot 4096 1月 22 11:07 out/
-rw-rw-r-- 1 rootroot rootroot 14221 1月 15 10:21 QCQCTL.h
-rw-rw-r-- 1 rootroot rootroot 9495 1月 15 10:21 QCQMI.h
-rw-rw-r-- 1 rootroot rootroot 22506 1月 15 10:21 QCQMUX.c
-rw-rw-r-- 1 rootroot rootroot 140524 1月 15 10:21 QCQMUX.h
-rw-rw-r-- 1 rootroot rootroot 1498 1月 15 10:21 qendian.h
-rw-rw-r-- 1 rootroot rootroot 896 1月 15 10:21 qlist.h
-rw-rw-r-- 1 rootroot rootroot 15291 1月 15 10:21 qmap_bridge_mode.c
-rw-rw-r-- 1 rootroot rootroot 121844 1月 15 10:21 QMIThread.c
-rw-rw-r-- 1 rootroot rootroot 13521 1月 15 10:21 QMIThread.h
-rw-rw-r-- 1 rootroot rootroot 16988 1月 15 10:21 QmiWwanCM.c
-rw-rw-r-- 1 rootroot rootroot 19416 1月 15 10:21 qrtr.c
-rw-rw-r-- 1 rootroot rootroot 1256 1月 15 10:21 qrtr.h
-rw-rw-r-- 1 rootroot rootroot 15971 1月 15 10:21 quectel-atc-proxy.c
-rw-rw-r-- 1 rootroot rootroot 13989 1月 15 10:21 quectel-mbim-proxy.c
-rw-rw-r-- 1 rootroot rootroot 24012 1月 15 10:21 quectel-qmi-proxy.c
-rw-rw-r-- 1 rootroot rootroot 30664 1月 15 10:21 quectel-qrtr-proxy.c
-rw-rw-r-- 1 rootroot rootroot 9350 1月 22 11:06 ReleaseNote.txt
-rw-rw-r-- 1 rootroot rootroot 9974 1月 15 10:21 rmnetctl.c
-rw-rw-r-- 1 rootroot rootroot 23841 1月 15 10:21 udhcpc.c
-rw-rw-r-- 1 rootroot rootroot 5472 1月 15 10:21 udhcpc_netlink.c
-rw-rw-r-- 1 rootroot rootroot 4065 1月 15 10:21 udhcpc_script.c
-rw-rw-r-- 1 rootroot rootroot 10201 1月 15 10:21 util.c
-rw-rw-r-- 1 rootroot rootroot 1285 1月 15 10:21 util.h
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ cd out/
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ ll
total 8
drwxrwxr-x 2 rootroot rootroot 4096 1月 22 11:07 ./
drwxrwxr-x 4 rootroot rootroot 4096 1月 22 11:06 ../
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ cd ..
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ ll
total 896
drwxrwxr-x 4 rootroot rootroot 4096 1月 22 11:06 ./
drwxr-xr-x 40 rootroot rootroot 4096 5月 2 16:02 ../
-rw-rw-r-- 1 rootroot rootroot 33837 1月 15 10:21 atc.c
-rw-rw-r-- 1 rootroot rootroot 25544 1月 15 10:21 atchannel.c
-rw-rw-r-- 1 rootroot rootroot 5124 1月 15 10:21 atchannel.h
-rw-rw-r-- 1 rootroot rootroot 5612 1月 15 10:21 at_tok.c
-rw-rw-r-- 1 rootroot rootroot 1072 1月 15 10:21 at_tok.h
-rw-rw-r-- 1 rootroot rootroot 1237 1月 15 10:21 CMakeLists.txt
-rw-rw-r-- 1 rootroot rootroot 1408 1月 15 10:21 configure.ac
-rw-rw-r-- 1 rootroot rootroot 1293 1月 15 10:21 default.script
-rw-rw-r-- 1 rootroot rootroot 1221 1月 15 10:21 default.script_ip
-rw-rw-r-- 1 rootroot rootroot 22875 1月 15 10:21 device.c
-rw-rw-r-- 1 rootroot rootroot 40995 1月 15 10:21 ethtool-copy.h
-rw-rw-r-- 1 rootroot rootroot 8678 1月 15 10:21 GobiNetCM.c
drwxrwxr-x 3 rootroot rootroot 4096 1月 15 10:21 log/
-rw-rw-r-- 1 rootroot rootroot 36466 1月 22 11:00 main.c
-rw-rw-r-- 1 rootroot rootroot 1706 1月 22 11:06 Makefile
-rw-rw-r-- 1 rootroot rootroot 639 1月 15 10:21 Makefile.am
-rw-rw-r-- 1 rootroot rootroot 90446 1月 15 10:21 mbim-cm.c
-rw-rw-r-- 1 rootroot rootroot 449 1月 15 10:21 NOTICE
drwxrwxr-x 2 rootroot rootroot 4096 1月 22 11:07 out/
-rw-rw-r-- 1 rootroot rootroot 14221 1月 15 10:21 QCQCTL.h
-rw-rw-r-- 1 rootroot rootroot 9495 1月 15 10:21 QCQMI.h
-rw-rw-r-- 1 rootroot rootroot 22506 1月 15 10:21 QCQMUX.c
-rw-rw-r-- 1 rootroot rootroot 140524 1月 15 10:21 QCQMUX.h
-rw-rw-r-- 1 rootroot rootroot 1498 1月 15 10:21 qendian.h
-rw-rw-r-- 1 rootroot rootroot 896 1月 15 10:21 qlist.h
-rw-rw-r-- 1 rootroot rootroot 15291 1月 15 10:21 qmap_bridge_mode.c
-rw-rw-r-- 1 rootroot rootroot 121844 1月 15 10:21 QMIThread.c
-rw-rw-r-- 1 rootroot rootroot 13521 1月 15 10:21 QMIThread.h
-rw-rw-r-- 1 rootroot rootroot 16988 1月 15 10:21 QmiWwanCM.c
-rw-rw-r-- 1 rootroot rootroot 19416 1月 15 10:21 qrtr.c
-rw-rw-r-- 1 rootroot rootroot 1256 1月 15 10:21 qrtr.h
-rw-rw-r-- 1 rootroot rootroot 15971 1月 15 10:21 quectel-atc-proxy.c
-rw-rw-r-- 1 rootroot rootroot 13989 1月 15 10:21 quectel-mbim-proxy.c
-rw-rw-r-- 1 rootroot rootroot 24012 1月 15 10:21 quectel-qmi-proxy.c
-rw-rw-r-- 1 rootroot rootroot 30664 1月 15 10:21 quectel-qrtr-proxy.c
-rw-rw-r-- 1 rootroot rootroot 9350 1月 22 11:06 ReleaseNote.txt
-rw-rw-r-- 1 rootroot rootroot 9974 1月 15 10:21 rmnetctl.c
-rw-rw-r-- 1 rootroot rootroot 23841 1月 15 10:21 udhcpc.c
-rw-rw-r-- 1 rootroot rootroot 5472 1月 15 10:21 udhcpc_netlink.c
-rw-rw-r-- 1 rootroot rootroot 4065 1月 15 10:21 udhcpc_script.c
-rw-rw-r-- 1 rootroot rootroot 10201 1月 15 10:21 util.c
-rw-rw-r-- 1 rootroot rootroot 1285 1月 15 10:21 util.h
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ make -j8
cd out/; rm -rf *.o libmnl/*.o quectel-CM quectel-qmi-proxy quectel-mbim-proxy quectel-atc-proxy
gcc -Wall -Wextra -Werror -O1 quectel-qmi-proxy.c -o out/quectel-qmi-proxy -lpthread -ldl -lrt
gcc -Wall -Wextra -Werror -O1 quectel-mbim-proxy.c -o out/quectel-mbim-proxy -lpthread -ldl -lrt
gcc -Wall -Wextra -Werror -O1 quectel-atc-proxy.c atchannel.c at_tok.c util.c -o out/quectel-atc-proxy -lpthread -ldl -lrt
gcc -Wall -Wextra -Werror -O1 QmiWwanCM.c GobiNetCM.c main.c QCQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c atc.c atchannel.c at_tok.c udhcpc.c -o out/quectel-CM -lpthread -ldl -lrt
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ ll
total 896
drwxrwxr-x 4 rootroot rootroot 4096 1月 22 11:06 ./
drwxr-xr-x 40 rootroot rootroot 4096 5月 2 16:02 ../
-rw-rw-r-- 1 rootroot rootroot 33837 1月 15 10:21 atc.c
-rw-rw-r-- 1 rootroot rootroot 25544 1月 15 10:21 atchannel.c
-rw-rw-r-- 1 rootroot rootroot 5124 1月 15 10:21 atchannel.h
-rw-rw-r-- 1 rootroot rootroot 5612 1月 15 10:21 at_tok.c
-rw-rw-r-- 1 rootroot rootroot 1072 1月 15 10:21 at_tok.h
-rw-rw-r-- 1 rootroot rootroot 1237 1月 15 10:21 CMakeLists.txt
-rw-rw-r-- 1 rootroot rootroot 1408 1月 15 10:21 configure.ac
-rw-rw-r-- 1 rootroot rootroot 1293 1月 15 10:21 default.script
-rw-rw-r-- 1 rootroot rootroot 1221 1月 15 10:21 default.script_ip
-rw-rw-r-- 1 rootroot rootroot 22875 1月 15 10:21 device.c
-rw-rw-r-- 1 rootroot rootroot 40995 1月 15 10:21 ethtool-copy.h
-rw-rw-r-- 1 rootroot rootroot 8678 1月 15 10:21 GobiNetCM.c
drwxrwxr-x 3 rootroot rootroot 4096 1月 15 10:21 log/
-rw-rw-r-- 1 rootroot rootroot 36466 1月 22 11:00 main.c
-rw-rw-r-- 1 rootroot rootroot 1706 1月 22 11:06 Makefile
-rw-rw-r-- 1 rootroot rootroot 639 1月 15 10:21 Makefile.am
-rw-rw-r-- 1 rootroot rootroot 90446 1月 15 10:21 mbim-cm.c
-rw-rw-r-- 1 rootroot rootroot 449 1月 15 10:21 NOTICE
drwxrwxr-x 2 rootroot rootroot 4096 5月 2 16:02 out/
-rw-rw-r-- 1 rootroot rootroot 14221 1月 15 10:21 QCQCTL.h
-rw-rw-r-- 1 rootroot rootroot 9495 1月 15 10:21 QCQMI.h
-rw-rw-r-- 1 rootroot rootroot 22506 1月 15 10:21 QCQMUX.c
-rw-rw-r-- 1 rootroot rootroot 140524 1月 15 10:21 QCQMUX.h
-rw-rw-r-- 1 rootroot rootroot 1498 1月 15 10:21 qendian.h
-rw-rw-r-- 1 rootroot rootroot 896 1月 15 10:21 qlist.h
-rw-rw-r-- 1 rootroot rootroot 15291 1月 15 10:21 qmap_bridge_mode.c
-rw-rw-r-- 1 rootroot rootroot 121844 1月 15 10:21 QMIThread.c
-rw-rw-r-- 1 rootroot rootroot 13521 1月 15 10:21 QMIThread.h
-rw-rw-r-- 1 rootroot rootroot 16988 1月 15 10:21 QmiWwanCM.c
-rw-rw-r-- 1 rootroot rootroot 19416 1月 15 10:21 qrtr.c
-rw-rw-r-- 1 rootroot rootroot 1256 1月 15 10:21 qrtr.h
-rw-rw-r-- 1 rootroot rootroot 15971 1月 15 10:21 quectel-atc-proxy.c
-rw-rw-r-- 1 rootroot rootroot 13989 1月 15 10:21 quectel-mbim-proxy.c
-rw-rw-r-- 1 rootroot rootroot 24012 1月 15 10:21 quectel-qmi-proxy.c
-rw-rw-r-- 1 rootroot rootroot 30664 1月 15 10:21 quectel-qrtr-proxy.c
-rw-rw-r-- 1 rootroot rootroot 9350 1月 22 11:06 ReleaseNote.txt
-rw-rw-r-- 1 rootroot rootroot 9974 1月 15 10:21 rmnetctl.c
-rw-rw-r-- 1 rootroot rootroot 23841 1月 15 10:21 udhcpc.c
-rw-rw-r-- 1 rootroot rootroot 5472 1月 15 10:21 udhcpc_netlink.c
-rw-rw-r-- 1 rootroot rootroot 4065 1月 15 10:21 udhcpc_script.c
-rw-rw-r-- 1 rootroot rootroot 10201 1月 15 10:21 util.c
-rw-rw-r-- 1 rootroot rootroot 1285 1月 15 10:21 util.h
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ cd out/
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ ll
total 328
drwxrwxr-x 2 rootroot rootroot 4096 5月 2 16:02 ./
drwxrwxr-x 4 rootroot rootroot 4096 1月 22 11:06 ../
-rwxrwxr-x 1 rootroot rootroot 48320 5月 2 16:02 quectel-atc-proxy*
-rwxrwxr-x 1 rootroot rootroot 228816 5月 2 16:02 quectel-CM*
-rwxrwxr-x 1 rootroot rootroot 22368 5月 2 16:02 quectel-mbim-proxy*
-rwxrwxr-x 1 rootroot rootroot 23336 5月 2 16:02 quectel-qmi-proxy*
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ file quectel-CM
quectel-CM: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=89b0fca80e86f63fb1ee4f9d807584499c0a1aca, for GNU/Linux 3.2.0, not stripped
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ ll
total 328
drwxrwxr-x 2 rootroot rootroot 4096 5月 2 16:02 ./
drwxrwxr-x 4 rootroot rootroot 4096 1月 22 11:06 ../
-rwxrwxr-x 1 rootroot rootroot 48320 5月 2 16:02 quectel-atc-proxy*
-rwxrwxr-x 1 rootroot rootroot 228816 5月 2 16:02 quectel-CM*
-rwxrwxr-x 1 rootroot rootroot 22368 5月 2 16:02 quectel-mbim-proxy*
-rwxrwxr-x 1 rootroot rootroot 23336 5月 2 16:02 quectel-qmi-proxy*
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ cd ..
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ mv out/ x64_out/
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
2、修改Makefile为ARM32架构:
Z:\quectel-CM\Makefile
ifneq ($(CROSS_COMPILE),)
CROSS-COMPILE:=$(CROSS_COMPILE)
endif
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_mips_malta_defconfig/output/host/usr/bin/mips-buildroot-linux-uclibc-
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_arm_vexpress_defconfig/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-
#CROSS-COMPILE:=/workspace/buildroot-git/qemu_mips64_malta/output/host/usr/bin/mips-gnu-linux-
ifeq ($(CC),cc)
CC:=$(CROSS-COMPILE)gcc
endif
LD:=$(CROSS-COMPILE)ld
修改为:
ifneq ($(CROSS_COMPILE),)
CROSS-COMPILE:=$(CROSS_COMPILE)
endif
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_mips_malta_defconfig/output/host/usr/bin/mips-buildroot-linux-uclibc-
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_arm_vexpress_defconfig/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-
#CROSS-COMPILE:=/workspace/buildroot-git/qemu_mips64_malta/output/host/usr/bin/mips-gnu-linux-
CROSS-COMPILE:=/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-
##ifeq ($(CC),cc)
##CC:=$(CROSS-COMPILE)gcc
##endif
CC:=/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc
LD:=$(CROSS-COMPILE)ld
ifneq ($(CROSS_COMPILE),)
CROSS-COMPILE:=$(CROSS_COMPILE)
endif
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_mips_malta_defconfig/output/host/usr/bin/mips-buildroot-linux-uclibc-
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_arm_vexpress_defconfig/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-
#CROSS-COMPILE:=/workspace/buildroot-git/qemu_mips64_malta/output/host/usr/bin/mips-gnu-linux-
CROSS-COMPILE:=/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-
##ifeq ($(CC),cc)
##CC:=$(CROSS-COMPILE)gcc
##endif
CC:=/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc
LD:=$(CROSS-COMPILE)ld
QL_CM_SRC=QmiWwanCM.c GobiNetCM.c main.c QCQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c
QL_CM_SRC+=atc.c atchannel.c at_tok.c
#QL_CM_SRC+=qrtr.c rmnetctl.c
ifeq (1,1)
QL_CM_DHCP=udhcpc.c
else
LIBMNL=libmnl/ifutils.c libmnl/attr.c libmnl/callback.c libmnl/nlmsg.c libmnl/socket.c
DHCP=libmnl/dhcp/dhcpclient.c libmnl/dhcp/dhcpmsg.c libmnl/dhcp/packet.c
QL_CM_DHCP=udhcpc_netlink.c
QL_CM_DHCP+=${LIBMNL}
endif
CFLAGS += -Wall -Wextra -Werror -O1 #-s
LDFLAGS += -lpthread -ldl -lrt
release: clean qmi-proxy mbim-proxy atc-proxy #qrtr-proxy
$(CC) ${CFLAGS} ${QL_CM_SRC} ${QL_CM_DHCP} -o out/quectel-CM ${LDFLAGS}
debug: clean
$(CC) ${CFLAGS} -g -DCM_DEBUG ${QL_CM_SRC} ${QL_CM_DHCP} -o out/quectel-CM -lpthread -ldl -lrt
qmi-proxy:
$(CC) ${CFLAGS} quectel-qmi-proxy.c -o out/quectel-qmi-proxy ${LDFLAGS}
mbim-proxy:
$(CC) ${CFLAGS} quectel-mbim-proxy.c -o out/quectel-mbim-proxy ${LDFLAGS}
qrtr-proxy:
$(CC) ${CFLAGS} quectel-qrtr-proxy.c -o out/quectel-qrtr-proxy ${LDFLAGS}
atc-proxy:
$(CC) ${CFLAGS} quectel-atc-proxy.c atchannel.c at_tok.c util.c -o out/quectel-atc-proxy ${LDFLAGS}
clean:
cd out/; rm -rf *.o libmnl/*.o quectel-CM quectel-qmi-proxy quectel-mbim-proxy quectel-atc-proxy
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ make -j8
cd out/; rm -rf *.o libmnl/*.o quectel-CM quectel-qmi-proxy quectel-mbim-proxy quectel-atc-proxy
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1 quectel-qmi-proxy.c -o out/quectel-qmi-proxy -lpthread -ldl -lrt
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1 quectel-mbim-proxy.c -o out/quectel-mbim-proxy -lpthread -ldl -lrt
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1 quectel-atc-proxy.c atchannel.c at_tok.c util.c -o out/quectel-atc-proxy -lpthread -ldl -lrt
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1 QmiWwanCM.c GobiNetCM.c main.c QCQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c atc.c atchannel.c at_tok.c udhcpc.c -o out/quectel-CM -lpthread -ldl -lrt
QMIThread.c: In function ‘requestGetProfile’:
QMIThread.c:2100:9: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for(int i=0; i<profile_num; i++)
^
QMIThread.c:2100:9: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
QMIThread.c:2111:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for(int i=0; i<profile_num; i++)
^
make: *** [Makefile:32: release] Error 1
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
Z:\quectel-CM\QMIThread.c
static int requestGetProfile(PROFILE_T *profile) {
PQCQMIMSG pRequest;
PQCQMIMSG pResponse;
PQMUX_MSG pMUXMsg;
int err;
PQMIWDS_APNNAME pApnName;
PQMIWDS_USERNAME pUserName;
PQMIWDS_PASSWD pPassWd;
PQMIWDS_AUTH_PREFERENCE pAuthPref;
PQMIWDS_IPTYPE pIpType;
PQMIWDS_PDPCONTEXT pPdpContext;
PQMIWDS_PROFILELIST pProfileList;
const char *ipStr[] = {"IPV4", "NULL", "IPV6", "IPV4V6"};
profile->old_apn[0] = profile->old_user[0] = profile->old_password[0] = '\0';
profile->old_auth = 0;
profile->old_iptype = 0;
if (profile->enable_ipv4 && profile->enable_ipv6)
profile->iptype = 3;
else if (profile->enable_ipv6)
profile->iptype = 2;
else
profile->iptype = 0;
if (!profile->pdp)
return 0;
_re_check:
pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_LIST_REQ, WdsGetProfileListReqSend, profile);
err = QmiThreadSendQMI(pRequest, &pResponse);s_pResponse = malloc(le16_to_cpu(pResponse->QMIHdr.Length) + 1);
qmi_rsp_check_and_return();
pProfileList = (PQMIWDS_PROFILELIST)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01);
uint8 profile_indexs[42] = {0};
uint8 profile_num = pProfileList->ProfileList[0];
if(profile_num >= 1)
{
uint8 j = 0;
uint8 k = 2;
for(int i=0; i<profile_num; i++)
{
profile_indexs[j++] = pProfileList->ProfileList[k];
if(pProfileList->ProfileList[++k] == 0)
k+=2;
else
k+=2+pProfileList->ProfileList[k];
}
}
free(pResponse);
for(int i=0; i<profile_num; i++)
{
profile->profile_index = profile_indexs[i];
pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_SETTINGS_REQ, WdsGetProfileSettingsReqSend, profile);
err = QmiThreadSendQMI(pRequest, &pResponse);
qmi_rsp_check_and_return();
pPdpContext = (PQMIWDS_PDPCONTEXT)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x25);
if(pPdpContext->pdp_context == profile->pdp)
break;
else
free(pResponse);
if(i == profile_num-1)
{
pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_CREATE_PROFILE_REQ, WdsCreateProfileSettingsReqSend, profile);
err = QmiThreadSendQMI(pRequest, &pResponse);
qmi_rsp_check_and_return();
free(pResponse);
goto _re_check;
}
}
pApnName = (PQMIWDS_APNNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x14);
pUserName = (PQMIWDS_USERNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1B);
pPassWd = (PQMIWDS_PASSWD)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1C);
pAuthPref = (PQMIWDS_AUTH_PREFERENCE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1D);
pIpType = (PQMIWDS_IPTYPE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11);
if (pApnName/* && le16_to_cpu(pApnName->TLVLength)*/)
uchar2char(profile->old_apn, sizeof(profile->old_apn), &pApnName->ApnName, le16_to_cpu(pApnName->TLVLength));
if (pUserName/* && pUserName->UserName*/)
uchar2char(profile->old_user, sizeof(profile->old_user), &pUserName->UserName, le16_to_cpu(pUserName->TLVLength));
if (pPassWd/* && le16_to_cpu(pPassWd->TLVLength)*/)
uchar2char(profile->old_password, sizeof(profile->old_password), &pPassWd->Passwd, le16_to_cpu(pPassWd->TLVLength));
if (pAuthPref/* && le16_to_cpu(pAuthPref->TLVLength)*/) {
profile->old_auth = pAuthPref->AuthPreference;
}
if (pIpType) {
profile->old_iptype = pIpType->IPType;
}
dbg_time("%s[pdp:%d index:%d] %s/%s/%s/%d/%s", __func__, profile->pdp, profile->profile_index, profile->old_apn, profile->old_user, profile->old_password, profile->old_auth, ipStr[profile->old_iptype]);
free(pResponse);
return 0;
}
#endif
修改为:
static int requestGetProfile(PROFILE_T *profile) {
PQCQMIMSG pRequest;
PQCQMIMSG pResponse;
PQMUX_MSG pMUXMsg;
int err;
PQMIWDS_APNNAME pApnName;
PQMIWDS_USERNAME pUserName;
PQMIWDS_PASSWD pPassWd;
PQMIWDS_AUTH_PREFERENCE pAuthPref;
PQMIWDS_IPTYPE pIpType;
PQMIWDS_PDPCONTEXT pPdpContext;
PQMIWDS_PROFILELIST pProfileList;
const char *ipStr[] = {"IPV4", "NULL", "IPV6", "IPV4V6"};
profile->old_apn[0] = profile->old_user[0] = profile->old_password[0] = '\0';
profile->old_auth = 0;
profile->old_iptype = 0;
if (profile->enable_ipv4 && profile->enable_ipv6)
profile->iptype = 3;
else if (profile->enable_ipv6)
profile->iptype = 2;
else
profile->iptype = 0;
if (!profile->pdp)
return 0;
_re_check:
pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_LIST_REQ, WdsGetProfileListReqSend, profile);
err = QmiThreadSendQMI(pRequest, &pResponse);s_pResponse = malloc(le16_to_cpu(pResponse->QMIHdr.Length) + 1);
qmi_rsp_check_and_return();
pProfileList = (PQMIWDS_PROFILELIST)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01);
uint8 profile_indexs[42] = {0};
uint8 profile_num = pProfileList->ProfileList[0];
if(profile_num >= 1)
{
uint8 j = 0;
uint8 k = 2;
//for(int i=0; i<profile_num; i++)
int i;
for(i=0; i<profile_num; i++)
{
profile_indexs[j++] = pProfileList->ProfileList[k];
if(pProfileList->ProfileList[++k] == 0)
k+=2;
else
k+=2+pProfileList->ProfileList[k];
}
}
free(pResponse);
//for(int i=0; i<profile_num; i++)
int i;
for(i=0; i<profile_num; i++)
{
profile->profile_index = profile_indexs[i];
pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_SETTINGS_REQ, WdsGetProfileSettingsReqSend, profile);
err = QmiThreadSendQMI(pRequest, &pResponse);
qmi_rsp_check_and_return();
pPdpContext = (PQMIWDS_PDPCONTEXT)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x25);
if(pPdpContext->pdp_context == profile->pdp)
break;
else
free(pResponse);
if(i == profile_num-1)
{
pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_CREATE_PROFILE_REQ, WdsCreateProfileSettingsReqSend, profile);
err = QmiThreadSendQMI(pRequest, &pResponse);
qmi_rsp_check_and_return();
free(pResponse);
goto _re_check;
}
}
pApnName = (PQMIWDS_APNNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x14);
pUserName = (PQMIWDS_USERNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1B);
pPassWd = (PQMIWDS_PASSWD)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1C);
pAuthPref = (PQMIWDS_AUTH_PREFERENCE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1D);
pIpType = (PQMIWDS_IPTYPE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11);
if (pApnName/* && le16_to_cpu(pApnName->TLVLength)*/)
uchar2char(profile->old_apn, sizeof(profile->old_apn), &pApnName->ApnName, le16_to_cpu(pApnName->TLVLength));
if (pUserName/* && pUserName->UserName*/)
uchar2char(profile->old_user, sizeof(profile->old_user), &pUserName->UserName, le16_to_cpu(pUserName->TLVLength));
if (pPassWd/* && le16_to_cpu(pPassWd->TLVLength)*/)
uchar2char(profile->old_password, sizeof(profile->old_password), &pPassWd->Passwd, le16_to_cpu(pPassWd->TLVLength));
if (pAuthPref/* && le16_to_cpu(pAuthPref->TLVLength)*/) {
profile->old_auth = pAuthPref->AuthPreference;
}
if (pIpType) {
profile->old_iptype = pIpType->IPType;
}
dbg_time("%s[pdp:%d index:%d] %s/%s/%s/%d/%s", __func__, profile->pdp, profile->profile_index, profile->old_apn, profile->old_user, profile->old_password, profile->old_auth, ipStr[profile->old_iptype]);
free(pResponse);
return 0;
}
#endif
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ make -j8
cd out/; rm -rf *.o libmnl/*.o quectel-CM quectel-qmi-proxy quectel-mbim-proxy quectel-atc-proxy
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1 quectel-qmi-proxy.c -o out/quectel-qmi-proxy -lpthread -ldl -lrt
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1 quectel-mbim-proxy.c -o out/quectel-mbim-proxy -lpthread -ldl -lrt
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1 quectel-atc-proxy.c atchannel.c at_tok.c util.c -o out/quectel-atc-proxy -lpthread -ldl -lrt
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1 QmiWwanCM.c GobiNetCM.c main.c QCQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c atc.c atchannel.c at_tok.c udhcpc.c -o out/quectel-CM -lpthread -ldl -lrt
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ cd out/
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ ll
total 272
drwxrwxr-x 2 rootroot rootroot 4096 5月 2 16:29 ./
drwxrwxr-x 5 rootroot rootroot 4096 5月 2 16:29 ../
-rwxrwxr-x 1 rootroot rootroot 45844 5月 2 16:29 quectel-atc-proxy*
-rwxrwxr-x 1 rootroot rootroot 183564 5月 2 16:29 quectel-CM*
-rwxrwxr-x 1 rootroot rootroot 16336 5月 2 16:29 quectel-mbim-proxy*
-rwxrwxr-x 1 rootroot rootroot 20296 5月 2 16:29 quectel-qmi-proxy*
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ file quectel-CM
quectel-CM: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.0.8, BuildID[sha1]=df17be612cd8840b562e01885b0a84d9afa96d78, with debug_info, not stripped
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$
参考资料:
百度:QMIThread.c:2100:9: error: ‘for’ loop initial declarations are only allowe
https://blog.csdn.net/qq_53381910/article/details/131819714
error: ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
https://blog.csdn.net/lei2014lei/article/details/134590485
error: ‘for‘ loop initial declarations are only allowed in C99 or C11 mode