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-优快云博客

其他玩法:

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

在构建 Maven 项目时,如果遇到 `com.magus.cloud:framework-parent:4.1.5-SNAPSHOT` 依赖无法解析的问题,通常可能由以下几个原因导致: ### 1. 依赖未发布到远程仓库 如果该依赖是公司内部或特定组织开发的私有库,它可能并未发布到公共的 Maven 仓库(如 Maven Central 或 JCenter)。此时需要确认是否在 `settings.xml` 中配置了正确的私有仓库地址,并且该仓库中确实存在该版本的依赖包 [^4]。 ### 2. SNAPSHOT 版本问题 SNAPSHOT 版本是 Maven 中用于表示“开发中版本”的特殊标识。如果本地或 CI/CD 环境未正确配置 SNAPSHOT 更新策略,可能会导致无法拉取最新的 SNAPSHOT 包。可以在 `settings.xml` 中配置如下策略以确保 SNAPSHOT 被及时更新: ```xml <profiles> <profile> <repositories> <repository> <id>your-repo</id> <url>http://your.repo.url</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> </profiles> ``` ### 3. IDE 缓存问题 有时候 IDE(如 IntelliJ IDEA)可能会因为缓存问题导致依赖无法正确加载。可以尝试清理 Maven 缓存并重启 IDE: ```bash rm -rf ~/.m2/repository/com/magus/cloud mvn clean install -U ``` 之后重新导入项目或刷新 Maven 依赖 [^3]。 ### 4. 项目配置错误 检查 `pom.xml` 文件中是否正确引用了该 parent 项目,确保其 `groupId`、`artifactId` 和 `version` 都无误。例如: ```xml <parent> <groupId>com.magus.cloud</groupId> <artifactId>framework-parent</artifactId> <version>4.1.5-SNAPSHOT</version> <relativePath/> </parent> ``` 同时,确认是否设置了正确的 `relativePath`,如果不设置,Maven 将默认从本地或远程仓库查找该 parent 项目 [^1]。 ### 5. 网络或代理问题 如果公司网络需要通过代理访问外部仓库,或者存在网络不稳定情况,也可能导致依赖下载失败。请检查 `settings.xml` 中是否配置了正确的代理设置: ```xml <proxies> <proxy> <id>example-proxy</id> <active>true</active> <protocol>http</protocol> <host>proxy.example.com</host> <port>8080</port> <username>user</username> <password>pass</password> <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts> </proxy> </proxies> ``` ### 6. 手动安装依赖 如果上述方法均无效,可以尝试手动下载该依赖的 JAR 文件,并使用以下命令将其安装到本地仓库: ```bash mvn install:install-file -Dfile=path/to/framework-parent-4.1.5-SNAPSHOT.jar \ -DgroupId=com.magus.cloud \ -DartifactId=framework-parent \ -Dversion=4.1.5-SNAPSHOT \ -Dpackaging=jar ``` 安装完成后,再次刷新 Maven 项目即可 [^5]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

码思途远

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

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

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

打赏作者

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

抵扣说明:

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

余额充值