NXP i.MX8系列平台开发讲解 - 4.1.5 GNSS篇(五) - GPSD 编译(包含交叉编译)详解

专栏文章目录传送门返回专栏目录

Hi, 我是你们的老朋友,主要专注于嵌入式软件开发,有兴趣不要忘记点击关注【码思途远】


文章目录

目录

1. 编译GPSD[Ubuntu]

2. 交叉编译

2.1 解决依赖库编译

2.1.1 libusb 编译

2.1.2 libncurses 编译

2.3 编译gpsd

2.4 板子上运行

3. 问题记录

3.1 stack level too deep

3.2 libncurses 错误:Unable to recognise the format of the input file

4. 总结


当前环境Ubuntu 18.04

CPU:i.MX8MM

参考:build.adoc · master · gpsd / gpsd · GitLab

1. 编译GPSD[Ubuntu]

Index of /releases/gpsd/

Necessary components for any build:

C compilergpsd and client library are written in C
sconsfor 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

正常来说基本不会有什么错误的!

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=你的交叉编译 --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

Index of /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 符合外加授时功能的程序进行时间的统一,有空后续操作并在视频号发布。

参考:

Linux 使用 gpsd 获取 GPS 数据_linux gpsd-CSDN博客

其他玩法:

How to connect an usb GPS receiver with a Linux computer? jack wu ...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码思途远

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值