关注+星号公众号,不容错过精彩
作者:HywelStar
Hi, 遗留之前的GNSS 内容还没有完成,今天发布关于编译GPSD以及出现问题的解决方法,我相信极大可能在是使用上才会仔细去看这个内容,当一个了解,如果真是遇到什么问题,可以后台私信。往期关联内容:
当前环境Ubuntu 18.04
CPU:i.MX8MM
参考:https://gitlab.com/gpsd/gpsd/-/blob/master/build.adoc?ref_type=heads
1. 编译GPSD[Ubuntu]
https://download-mirror.savannah.gnu.org/releases/gpsd/?C=M&O=A
Necessary components for any build:
C compiler | gpsd and client library are written in C |
---|---|
scons | for executing the build recipe |
Python2.x(x>=6) or 3.y(y>=2) | for scons and some helper scripts |
sudo apt-get install scons
下载源码:
wget https://download-mirror.savannah.gnu.org/releases/gpsd/gpsd-3.25.zip
unzip gpsd-3.25.zip
cd gpsd-3.25
开始编译:
scons && scons check
# if that passes, and you want udev support, not recommended:
scons udev-install
正常来说Ubuntu 下的基本不会有什么错误的!
2. 交叉编译
编译完毕后目录结构记录:
nxp/GNSS$ tree -L 1
.
├── gpsd-3.25
├── gpsd-3.25.zip
├── libusb-1.0.22
├── libusb-1.0.22.tar.bz2
├── ncurses-6.1
└── ncurses-6.1.tar.gz
3 directories, 3 files
从官方来说,支持的平台还是比较丰富的,比如OpenWRT, FreeBSD, NetBSD, Android等等。
Cross-building
依赖:libusb, libncurses, 【这两个是需要交叉编译!!】
2.1 解决依赖库编译
以下是在ubuntu 18.04 环境下编译,在什么版本上编译,问题不大;
2.1.1 libusb 编译
打开 下载libusb
https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.22/
wget https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.22/libusb-1.0.22.tar.bz2
tar -xvf libusb-1.0.22.tar.bz2
cd libusb-1.0.22
configure
指定交叉编译器GCC ,安装目录
./configure CC=你的交叉编译GCC --host=arm-linux --prefix=$PWD/arm_install --disable-udev
make
make install
# 由于这里使用i.mx8mm 交叉编译环境[以下根据自身情况]
source ../../toolchain_sdk/sysroots/armv8a-poky-linux
./configure --host=arm-linux --prefix=$PWD/arm_install --disable-udev
安装成功:
2.1.2 libncurses 编译
下载源码libncurses
https://ftp.gnu.org/pub/gnu/ncurses/
这里采用6.1 版本
wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
tar zxvf ncurses-6.1.tar.gz
cd ncurses-6.1
配置& 编译& 安装
./configure CC=你的交叉编译GCC --host=arm-linux --prefix=$PWD/arm_install --with-shared
make
make install
# 由于这里使用i.mx8mm 交叉编译环境,会设置CC[以下根据自身情况]
source ../../toolchain_sdk/sysroots/armv8a-poky-linux
./configure --host=arm-linux --prefix=$PWD/arm_install --with-shared
make
make install
安装成功:
2.3 编译gpsd
wget https://download-mirror.savannah.gnu.org/releases/gpsd/gpsd-3.25.zip
unzip gpsd-3.25.zip
cd gpsd-3.25
将刚刚编译的libusb, libcurese 的库放在当前目录下:
打包libusb 库
GNSS/libusb-1.0.22/arm_install$ tar czvf libusb_so.tar.gz ./lib/*
./lib/libusb-1.0.a
./lib/libusb-1.0.la
./lib/libusb-1.0.so
./lib/libusb-1.0.so.0
./lib/libusb-1.0.so.0.1.0
./lib/pkgconfig/
./lib/pkgconfig/libusb-1.0.pc
# 打包libncurses 库
GNSS/ncurses-6.1/arm_install$ tar czvf libncurses-6.1_so.tar.gz ./lib/*
./lib/libform.a
./lib/libform_g.a
./lib/libform.so
./lib/libform.so.6
./lib/libform.so.6.1
./lib/libmenu.a
./lib/libmenu_g.a
./lib/libmenu.so
./lib/libmenu.so.6
./lib/libmenu.so.6.1
./lib/libncurses.a
./lib/libncurses++.a
./lib/libncurses_g.a
./lib/libncurses++_g.a
./lib/libncurses.so
./lib/libncurses.so.6
./lib/libncurses.so.6.1
./lib/libpanel.a
./lib/libpanel_g.a
./lib/libpanel.so
./lib/libpanel.so.6
./lib/libpanel.so.6.1
./lib/terminfo
# 将上面两个库拷贝至gpsd 目录,并解压
编译【指定安装目录】:
scons timeservice=yes nmea0183=yes fixed_port_speed=9600 fixed_stop_bits=1 prefix=$PWD/arm_install
安装:
scons install
可以看到各个需要使用的东西,将这些可执行文件,库文件放入板子中运行既可。
2.4 板子上运行
简单运行,没有问题,后续添加GNSS 设备测试。
3. 问题记录
3.1 stack level too deep
cd gpsd-3.25/www; (cat hardware-head.html && PYTHONIOENCODING=utf-8 /usr/bin/python gpscap.py && cat hardware-tail.html) > hardware.html
/usr/bin/asciidoctor -b html5 -v -a gpsdweb=https://gpsd.io/ -a gpsdver=3.25 -a docinfo=shared -o gpsd-3.25/www/building.html gpsd-3.25/build.adoc
/usr/bin/asciidoctor -b html5 -v -a gpsdweb=https://gpsd.io/ -a gpsdver=3.25 -a docinfo=shared -o gpsd-3.25/www/installation.html gpsd-3.25/INSTALL.adoc
/usr/bin/asciidoctor -b html5 -v -a gpsdweb=https://gpsd.io/ -a gpsdver=3.25 -a docinfo=shared -o gpsd-3.25/www/README.html gpsd-3.25/README.adoc
/usr/bin/asciidoctor -b html5 -v -a gpsdweb=https://gpsd.io/ -a gpsdver=3.25 -a docinfo=shared -o gpsd-3.25/www/SUPPORT.html gpsd-3.25/SUPPORT.adoc
/usr/bin/asciidoctor -b html5 -v -a gpsdweb=https://gpsd.io/ -a gpsdver=3.25 -a docinfo=shared -o gpsd-3.25/www/AIVDM.html gpsd-3.25/www/AIVDM.adoc
/usr/bin/asciidoctor -b html5 -v -a gpsdweb=https://gpsd.io/ -a gpsdver=3.25 -a docinfo=shared -o gpsd-3.25/www/client-howto.html gpsd-3.25/www/client-howto.adoc
/usr/bin/asciidoctor -b html5 -v -a gpsdweb=https://gpsd.io/ -a gpsdver=3.25 -a docinfo=shared -o gpsd-3.25/www/gpsd-numbers-matter.html gpsd-3.25/www/gpsd-numbers-matter.adoc
/usr/bin/asciidoctor -b html5 -v -a gpsdweb=https://gpsd.io/ -a gpsdver=3.25 -a docinfo=shared -o gpsd-3.25/www/gpsd-client-example-code.html gpsd-3.25/www/gpsd-client-example-code.adoc
stack level too deep
Use --trace for backtrace
scons: *** [gpsd-3.25/www/gpsd-client-example-code.html] Error 1
scons: building terminated because of errors.
解决办法:
sudo gem update asciidoctor
3.2 libncurses 错误:Unable to recognise the format of the input file
由于使用./progs/中的bin文件都是arm 需要修改
解决办法[将系统的那些文件拷贝至./progs/]:
ls ./progs/
capconvert clear_cmd.h infocmp MKtermsort.sh reset_cmd.h tic tparm_type.c transform.c tty_settings.c
clear clear.sh infocmp.c modules tabs tic.c tparm_type.h transform.h tty_settings.h
clear.c dump_entry.c Makefile progs.priv.h tabs.c toe tput tset
clear_cmd.c dump_entry.h Makefile.in reset_cmd.c termsort.h toe.c tput.c tset.c
# 系统的文件拷贝至./progs/
cp /usr/bin/infocmp /usr/bin/tic /usr/bin/clear /usr/bin/tabs /usr/bin/toe /usr/bin/tput /usr/bin/tset ./progs/
4. 总结
本章主要对GPSD 的交叉编译进行操作,中间涉及一些库的编译,期间可能出现的一些问题记录,有些在对于自动驾驶授时方面可能会用上这个gpsd 外加授时功能的程序进行时间的统一,有空后续操作并在视频号发布,记得关注!
参考:
https://blog.csdn.net/yiyu20180729/article/details/136340493
其他玩法:
https://gpswebshop.com/blogs/tech-support-by-os-linux/how-to-connect-an-usb-gps-receiver-with-a-linux-computer
往期推荐