0%

在 ARMv8 架构设备上编译 csdr

放假惹…..博主最近在并夕夕上剁手了 PHICOMM N1 盒子,PHICOMM N1 的 CPU 采用的是更新的 ARMv8 架构,在把 RTL-SDR 服务器从 Orange Pi Lite 转移到 N1 时遇到了一些麻烦。

为了不让有类似需求的其他人踩坑,特此水一文章……

话说回来,编译就是踩坑呢!(这段划去)

略去降级固件、刷入系统系统的过程,直接步入正题……

Debian 9 系统,为了方便,博主直接使用了之前文章中提到的一建脚本……

1
2
3
root@yukiho:~# apt update && apt install git -y
root@yukiho:~# cd /home
root@yukiho:/home# wget --no-check-certificate https://raw.githubusercontent.com/bclswl0827/openwebrx-installer/master/rtl-sdr_installer.sh && chmod +x rtl-sdr_installer.sh && bash rtl-sdr_installer.sh

编译 rtl-sdr 时一切顺利。心中想着有着更强的设备运行 SDR 而满心欢喜时,这时却报错了。

仔细一看,是 csdr…

1
2
3
root@yukiho:/home# git clone https://github.com/simonyiszk/csdr.git
root@yukiho:/home# cd csdr
root@yukiho:/home# make install

报错内容如下:

1
2
3
4
5
6
7
8
9
NOTE: you may have to manually edit Makefile to optimize for your CPU (especially if you compile on ARM, please edit PARAMS_NEON).
Auto-detected optimization parameters: -mfloat-abi=hard -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mvectorize-with-neon-quad -funsafe-math-optimizations -Wformat=0 -DNEON_OPTS

rm -f dumpvect*.vect
gcc -std=gnu99 -O3 -ffast-math -fdump-tree-vect-details -dumpbase dumpvect -mfloat-abi=hard -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mvectorize-with-neon-quad -funsafe-math-optimizations -Wformat=0 -DNEON_OPTS fft_fftw.c libcsdr_wrapper.c -g -lm -lrt -lfftw3f -DUSE_FFTW -DLIBCSDR_GPL -DUSE_IMA_ADPCM -Wno-unused-result -fpic -shared -Wl,-soname,libcsdr.so.0.15 -o libcsdr.so.0.15
Makefile:52: recipe for target 'libcsdr.so' failed
gcc: error: unrecognized command line option '-mfloat-abi=hard'
gcc: error: unrecognized command line option '-mfpu=neon'
gcc: error: unrecognized command line option '-mvectorize-with-neon-quad'

从报错来看,应该是架构不兼容的问题,Google 一圈发现在 csdr 和 OpenWebRX 的 GitHub Issues 页面也有相关讨论。

  • https://github.com/simonyiszk/openwebrx/issues/101
  • https://github.com/simonyiszk/csdr/issues/11

解决方案很简单,只需修改 csdr 编译用的 Makefile,再重新编译即可。

在 Makefile 的第 33 行,将 PARAMS_NEON 字段:

1
PARAMS_NEON = -mfloat-abi=hard -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mvectorize-with-neon-quad -funsafe-math-optimizations -Wformat=0 -DNEON_OPTS

修改为:

1
PARAMS_NEON = -march=armv8-a+crc+crypto -mtune=cortex-a53

重新编译,问题解决。