突然有兴致想玩一下LimeSDR,所以找了下资料,感觉这个博主写的比较靠谱,所以赶紧动手。我是使用的16.04 如下内容部分是转自“默默的点滴”。并根据自己的系统解了一些bug。http://www.mobibrw.com/2018/10729/comment-page-1#comment-3451s
- 操作系统调整
参考ubuntu 16.04低延迟内核安装低延时内核CPU
调整为最大性能模式,并且不允许降低频率,如果有执行失败也没关系,只是性能不能全利用而已
1 2 3 4 5 |
sudo apt-get install cpufrequtils sudo touch /etc/default/cpufrequtils sudo sed -i "/GOVERNOR.*/d" /etc/default/cpufrequtils test -s /etc/default/cpufrequtils && sudo sed -i '$a\GOVERNOR=\"performance\"' /etc/default/cpufrequtils || echo "GOVERNOR=\"performance\"" | sudo tee /etc/default/cpufrequtils sudo update-rc.d ondemand disable |
- 安装依赖包
1 |
sudo apt-get install cmake g++ libpython-dev python-numpy swig git libsqlite3-dev libi2c-dev libusb-1.0-0-dev libwxgtk3.0-dev freeglut3-dev |
- 编译安装SoapySDR
1 2 3 4 5 6 7 8 9 |
cd ~ git clone https://github.com/pothosware/SoapySDR.git cd SoapySDR git pull origin master mkdir build && cd build cmake .. make -j4 sudo make install sudo ldconfig |
- 编译安装LimeSDR
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
cd ~ git clone https://github.com/myriadrf/LimeSuite.git cd LimeSuite #目前的测试发现,超过这个版本的代码无法正常的发出信号, #也就是手机搜索不到我们创建好的基站, #反复研究,确认是“Commit 9883bb97 by ignasj, 2017-06-30 下午04:20” #对于“lms7_device.cpp”的修改导致的问题,原因为天线发射增益设置不正确 #解决方法参考 https://www.mobibrw.com/?p=11957 #截止目前2018.09.03版本的代码貌似已经修正这个问题了,应该已经可以正常使用了。 #测试来说,还是使用这个版本吧 git checkout v17.06.0 # 不可删除build目录,清理build目录后要还原被误删除的文件, # 原因在于build目录下存在mcu程序,默认应用启动后从这个目录提取mcu程序刷新到设备 cd build # cmake -DCMAKE_BUILD_TYPE=Debug .. cmake .. make -j4 sudo make install sudo ldconfig cd ../udev-rules/ sudo bash install.sh # Download board firmware sudo LimeUtil --update #固件下载地址 http://downloads.myriadrf.org/project/limesuite/ #如果上述的固件无法下载,可以从此处下载一份拷贝 #https://www.mobibrw.com/wp-content/uploads/2018/03/17.06-LimeUtils-fpga-fw.zip |
-
- 编译安装USRP驱动
-
123456789101112131415sudo apt-get install libboost-all-dev libusb-1.0-0-dev python-mako doxygen python-docutils python-requests cmake build-essentialcd ~git clone git://github.com/EttusResearch/uhd.gitcd uhd; mkdir host/build; cd host/buildcmake -DCMAKE_INSTALL_PREFIX=/usr ..make -j4sudo make installsudo ldconfig#下面脚本的作用是到http://files.ettus.com/binaries/images/下载最新的镜像文件,并解压缩到 /usr/share/uhd/images目录下sudo /usr/lib/uhd/utils/uhd_images_downloader.py#如果上面的镜像下载失败,可以尝试执行如下命令从本站下载# cd ~ ; wget https://www.mobibrw.com/wp-content/uploads/2018/03/uhd-images_003.010.003.000-release.zip# sudo unzip uhd-images_003.010.003.000-release.zip -d /user
编译的时候出现如下错误:
12345678910Traceback (most recent call last):File "/home/bellnet/uhd/host/build/python/setup.py", line 9, in <module>from setuptools import setupImportError: No module named setuptoolspython/CMakeFiles/pyuhd_library.dir/build.make:64: recipe for target 'python/build/timestamp' failedmake[2]: *** [python/build/timestamp] Error 1CMakeFiles/Makefile2:3976: recipe for target 'python/CMakeFiles/pyuhd_library.dir/all' failedmake[1]: *** [python/CMakeFiles/pyuhd_library.dir/all] Error 2Makefile:162: recipe for target 'all' failedmake: *** [all] Error 2主要原因是没有安装setuptools,如下方法安装
12sudo apt install python-pippip install setuptools==40.6.2重新编译make -j4。 通过。。。。。
- 下载并解压缩需要的补丁
123cd ~wget http://open-cells.com/d5138782a8739209ec5760865b1e53b0/opencells-mods-20170710.tgztar xf opencells-mods-20170710.tgz
-
1234567891011121314151617cd ~git clone https://gitlab.eurecom.fr/oai/openairinterface5g.gitcd openairinterface5g#git checkout developgit checkout 08b8b3142df16831396a5283a015564ff56bf91c -b ubuntugit apply ../opencells-mods/eNB.patch#如果网络环境不好(国内很多https访问git会有问题,那么加入下面的更改文件源的操作。source oaienv./cmake_targets/build_oai -I # install SW packages from internet# ./cmake_targets/build_oai -w USRP --eNB # compile eNB# 注意如果后续重新编译过limesdr的驱动,这部分也需要重新编译$ ./cmake_targets/build_oai -c -w LMSSDR --eNB
如下步骤可有可无,看你的网络环境
1234567891011121314151617#对于国内的用户来说,国外的几个代码地址需要修改一下,否则会出现无法下载或者下载非常慢的情况sed -i "s/git clone https:\/\/gist.github.com\/2190472.git \/opt\/ssh/wget https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/ssh.tar.gz \&\& sudo tar -zxvf ssh.tar.gz -C \/opt/g" cmake_targets/tools/build_helpersed -i "s/git clone https:\/\/gitlab.eurecom.fr\/oai\/asn1c.git \/tmp\/asn1c/wget https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/asn1c.tar.gz \&\& tar -zxvf asn1c.tar.gz -C \/tmp/g" cmake_targets/tools/build_helpersed -i "s/https:\/\/pypi.python.org\/packages\/18\/fa\/dd13d4910aea339c0bb87d2b3838d8fd923c11869b1f6e741dbd0ff3bc00\/netifaces-0.10.4.tar.gz/https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/netifaces-0.10.4.tar.gz/g" cmake_targets/tools/build_helpersed -i "s/https:\/\/github.com\/google\/protobuf\/releases\/download\/v2.6.1\/protobuf-2.6.1.tar.gz/https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/protobuf-2.6.1.tar.gz/g" cmake_targets/tools/build_helpersed -i "s/git clone https:\/\/github.com\/protobuf-c\/protobuf-c.git/wget https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/protobuf-c.tar.gz \&\& tar -zxvf protobuf-c.tar.gz/g" cmake_targets/tools/build_helpersed -i "s/http:\/\/mirrors.dotsrc.org\/gcrypt\/gnutls\/v3.1\/gnutls-3.1.23.tar.xz/https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/gnutls-3.1.23.tar.xz/g" cmake_targets/tools/build_helpersed -i "s/https:\/\/ftp.gnu.org\/gnu\/nettle\/nettle-2.5.tar.gz/https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/nettle-2.5.tar.gz/g" cmake_targets/tools/build_helper#修正兼容问题,更高版本的protobuf-c跟我们上面安装的版本不匹配,会导致编译错误sed -i "s/cd protobuf-c/cd protobuf-c \&\& git checkout 2a46af42784abf86804d536f6e0122d47cfeea45/g" cmake_targets/tools/build_helper - 编译出错(如果编译没有错误,请跳过)
123Log file for compilation has been written to: /home/bellnet/openairinterface5g/cmake_targets/log/oai_lmssdrdevif.Rel14.txtoai_lmssdrdevif compilation failedbuild have failed
具体查询log
123456789101112131415161718Scanning dependencies of target oai_lmssdrdevifBuilding CXX object CMakeFiles/oai_lmssdrdevif.dir/home/bellnet/openairinterface5g/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp.o/home/bellnet/openairinterface5g/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp: In function ‘int trx_lms_start(openair0_device*)’:/home/bellnet/openairinterface5g/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp:196:35: error: too few arguments to function ‘int LMS_VCTCXOWrite(lms_device_t*, uint16_t, bool)’LMS_VCTCXOWrite(lms_device,129);^In file included from /home/bellnet/openairinterface5g/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp:39:0:/usr/local/include/lime/LimeSuite.h:982:26: note: declared hereAPI_EXPORT int CALL_CONV LMS_VCTCXOWrite(lms_device_t * dev, uint16_t val, bool memoty);^CMakeFiles/oai_lmssdrdevif.dir/build.make:62: recipe for target 'CMakeFiles/oai_lmssdrdevif.dir/home/bellnet/openairinterface5g/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp.o' failedmake[3]: *** [CMakeFiles/oai_lmssdrdevif.dir/home/bellnet/openairinterface5g/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp.o] Error 1CMakeFiles/Makefile2:815: recipe for target 'CMakeFiles/oai_lmssdrdevif.dir/all' failedmake[2]: *** [CMakeFiles/oai_lmssdrdevif.dir/all] Error 2CMakeFiles/Makefile2:827: recipe for target 'CMakeFiles/oai_lmssdrdevif.dir/rule' failedmake[1]: *** [CMakeFiles/oai_lmssdrdevif.dir/rule] Error 2Makefile:378: recipe for target 'oai_lmssdrdevif' failedmake: *** [oai_lmssdrdevif] Error 2除错
1vim targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp原来文件
123456789#196行LMS_VCTCXOWrite(lms_device,129);if (LMS_SetSampleRate(lms_device,device->openair0_cfg->sample_rate,2)!=0){fprintf(stderr, "Failed to set sample rate %s\n",LMS_GetLastErrorMessage());return -1;}printf("Set sample rate %f MHz\n",device->openair0_cfg->sample_rate/1e6);修改LMS_VCTCXOWrite(lms_device,129成LMS_VCTCXOWrite(lms_device,129,true),再编译,通过。
- 下载并编译EPC(核心网)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455cd ~git clone https://gitlab.eurecom.fr/oai/openair-cn.gitcd openair-cngit checkout developgit checkout 724542d0b59797b010af8c5df15af7f669c1e838 -b ubuntu16#应用补丁git apply ../opencells-mods/EPC.patch#(我没有使用,如果网络不好建议执行这一条)对于国内的用户来说,国外的几个代码地址需要修改一下,否则会出现无法下载或者下载非常慢的情况sed -i "s/git clone https:\/\/gitlab.eurecom.fr\/oai\/freediameter.git -b eurecom-1.2.0/wget https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/freediameter.tar.gz \&\& tar -zxvf freediameter.tar.gz \&\& cd freediameter \&\& git checkout eurecom-1.2.0 \&\& cd ../g" build/tools/build_helpersource oaienv; cd scripts#安装依赖的软件,库./build_hss -i# Do you want to install freeDiameter 1.2.0 ?<y/N>: yes# 其他具体情况自行处理#对于国内的用户来说,国外的几个代码地址需要修改一下,否则会出现无法下载或者下载非常慢的情况sed -i "s/git clone git:\/\/git.osmocom.org\/libgtpnl/wget https:\/\/www.mobibrw.com\/wp-content\/uploads\/2018\/03\/libgtpnl.tar.gz \&\& tar -zxvf libgtpnl.tar.gz/g" ../build/tools/build_helper#Install 3PP SW for mme and spgw./build_mme -i# Do you want to install freeDiameter 1.2.0 ?<y/N>: no# Do you want to install asn1c rev 1516 patched? <y/N>: no# Do you want to install libgtpnl ? <y/N>: yes# 其他具体情况自行处理./build_spgw -i# Do you want to install libgtpnl ? <y/N>: no#调整mme的编译模板,默认情况下mme编译出来的是Debug版本,#但是这会触发"src/gtpv2-c/nwgtpv2c-0.11/src/NwGtpv2c.c"的断言异常#”mme: ~/openair-cn/src/gtpv2-c/nwgtpv2c-0.11/src/NwGtpv2c.c:487: nwGtpv2cCreateLocalTunnel: Assertion `0' failed.“#这个断言异常并不是大问题,直接无视即可#因此我们把此处的编译调整为RelWithDebInfosed -i "s/\"Debug\"/\"RelWithDebInfo\"/g" ../build/mme/CMakeLists.template#修正代码里面的几处问题sed -i "s/while 0/while (0)/g" ../src/utils/log.hsed -i 's/char[ \t]*pid_dec\[32]/char pid_dec\[128]/g' ../src/utils/pid_file.c#正式进行编译操作./build_hss -c -v./build_mme -v./build_spgw -v
- 配置EPC
123456789101112131415161718192021# 拷贝配置文件cd ~sudo mkdir -p /usr/local/etc/oaisudo cp -rp opencells-mods/config_epc/* /usr/local/etc/oai# 生成证书文件cd openair-cn; source oaienv; cd scripts./check_hss_s6a_certificate /usr/local/etc/oai/freeDiameter hss.OpenAir5G.Alliance./check_mme_s6a_certificate /usr/local/etc/oai/freeDiameter mme.OpenAir5G.Alliance# 配置出口网卡的名字,这个网卡用于访问互联网的时候使用# 如果只有一块有线网卡,并且用这块有线网卡上网,则使用如下命令即可拿到网卡名# `ifconfig | grep "Link" | awk '{print $1}' | grep "en"`# 其他情况请根据实际情况配置网卡sudo sed -i "s/PGW_INTERFACE_NAME_FOR_SGI.*/PGW_INTERFACE_NAME_FOR_SGI = \"`ifconfig | grep "Link" | awk '{print $1}' | grep "en"`\";/g" /usr/local/etc/oai/spgw.conf# 配置访问MySQL时候的密码,"/usr/local/etc/oai/hss.conf",此处假定MySQL的密码为"123"sudo sed -i "s/^MYSQL_pass.*/MYSQL_pass = \"123\"/g" /usr/local/etc/oai/hss.conf#导入数据库,建立表结构./hss_db_import 127.0.0.1 root 123 oai_db ~/opencells-mods/opencells_db.sql
- 修改我们
UE
需要使用的配置文件123456cd ~cd openairinterface5g; source oaienv#配置文件为"targets/PROJECTS/GENERIC-LTE-EPC/CONF/"目录下的包含lmssdr的配置文件sed -i "s/mobile_network_code.*/mobile_network_code = \"92\";/g" ./targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.25PRB.lmssdr.confvim ./targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.25PRB.lmssdr.conf找到
1234567891011121314151617////////// MME parameters:mme_ip_address = ( { ipv4 = "192.168.12.148";ipv6 = "192:168:30::17";active = "yes";preference = "ipv4";});NETWORK_INTERFACES :{ENB_INTERFACE_NAME_FOR_S1_MME = "eth0";ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.150/24";ENB_INTERFACE_NAME_FOR_S1U = "eth0";ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.150/24";ENB_PORT_FOR_S1U = 2152; # Spec 2152};替换为:
1234567891011121314151617///////// MME parameters:mme_ip_address = ( { ipv4 = "127.0.0.20";ipv6 = "192:168:30::17";active = "yes";preference = "ipv4";});NETWORK_INTERFACES :{ENB_INTERFACE_NAME_FOR_S1_MME = "lo";ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.10/8";ENB_INTERFACE_NAME_FOR_S1U = "lo";ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.10/8";ENB_PORT_FOR_S1U = 2152; # Spec 2152};测试功能,按照顺序打开四个独立
Shell
1234567echo -ne "\033]0;HSS\007"cd ~cd openair-cn; source oaienv; cd scripts;#貌似需要运行之前先清理一下数据库才行,否则可能导致设备无法入网,应该是个BUG./hss_db_import 127.0.0.1 root 123 oai_db ~/opencells-mods/opencells_db.sql./run_hssrun_mme.sh
1234echo -ne "\033]0;MME\007"cd ~cd openair-cn; source oaienv; cd scripts;./run_mmerun_spgw.sh
1234echo -ne "\033]0;SPGW\007"cd ~cd openair-cn; source oaienv; cd scripts;sudo -E ./run_spgwrun_eue.sh
1234567891011echo -ne "\033]0;EUE\007"cd ~cd openairinterface5g; source oaienv#配置文件为"targets/PROJECTS/GENERIC-LTE-EPC/CONF/"目录下的包含lmssdr的配置文件#这个配置文件跟天线的接入方式直接相关,天线接入的是主板上的RX1_H,TX1_2这两个天线接口#最后的-d 参数是启动图形界面分析流量sudo -E ./cmake_targets/lte_build_oai/build/lte-softmodem -O ./targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.25PRB.lmssdr.conf --rf-config-file ./targets/ARCH/LMSSDR/LimeSDR_above_1p8GHz_1v4.ini -d#如果启动之后,出现 “[PHY][E]TX : Timeout (sent 6800/7680)” 这样的红色内容,然后退出,可以多尝试几次,一般就可以恢复正常了正常启动之后,用手机(比如华为荣耀7)搜索运营型,可以找到一个名为
20892
的运营商,或者有些欧洲制式的手机可以正确的显示Eurecom
这个法国电信运营商的名字。设备使用的
SIM
卡建议从淘宝购买可以重复写入的LTE
测试卡(大约30
元每张的样子),卡内的内容请严格遵守下图的信息进行写入,包括灰色区域,看似不可写而无效,但是如果不设置成下图的样子,就会无法联网:
-
上述的代码如果下载困难,可以从本站下载一份拷贝。
SoapySDR源代码下载
LimeSuite源代码下载
USRP源代码下载
openairinterface5g源代码下载
openair-cn源代码下载
推荐使用LimeUtil刷新的固件
有需要上述的写卡软件的(SIM Personnalize tools),可以点击这里下载如果发生手机等设备无法连接到我们自己搭建的基站,在确定测试卡信息填写完全正确的前提下,如果
lte-softmodem
窗口出现下图的红色错误信息: -
1[PHY][E]ERROR: Format 1A: rb_alloc (1ff) > RIV_max (144)
优先检查设备的
MTU
,如果设备的MTU
大小超过1500
,则会导致这种问题,/usr/local/etc/oai/spgw.conf
里面配置的MTU
大小就是1500
,这个大小可以设置为1536
,但是貌似会导致应用异常。
目前已知的是小米Note1
会记录上次联网时候设备的MTU
大小,如果恰好连接过MTU
是1536
的基站,貌似会使用这个数字,导致问题。
一般建议Android
手机执行adb shell ifconfig
观察一下手机的输出。手机如果要实现上网,需要手工创建一个APN,如下图,名字任意填写即可
主要的设置为下图,APN协议,APN漫游协议,承载系统,这三个要设置,否则MME会崩溃(src/nas/emm/sap/emm_cn.c:358 空指针异常),主要是协议不支持,导致处理异常。正常情况下,已经自动设置了MCC,MNC,如果没有自动设置,请手工修改成MCC 208,MNC 92。
手机实验的时候有个小技巧,可以解决频繁插拔SIM卡的问题,就是把手机设置成飞行模式,再取消飞行模式,可以强制手机重新搜索基站并建立连接,因而减少对于SIM卡的插拔操作。
参考链接
- OpenAir, single machine Ubuntu 17.04, after major EPC update
- LimeSDR installation
- protobuf-c no longer compiles against protobuf-2.6.1
- OpenAirInterface安装说明
- OpenAirInterface安装教程
- How I can disable CPU frequency scaling and set the system to performance?
- OAI 完全搭建手册
- OpenAirInterface OAI 入门教程 1
- 「完全用软件实现 4G LTE 基站」的原理是什么?
- 怎样建设LTE专网?
- Program SIM Cards
- OpenAirInterface Community Q&A
- How to Connect OAI eNB (USRP B210) with COTS UE
- OpenAirInterface configuration
- How to Install LimeSDR on OpenInterface eNodeB
- Towards Open Cellular EcosystemOpenAirInterfaceTM (OAI): Towards Open Cellular EcosystemTable of Contents
- OpenAirInterface 面向开放式蜂窝生态系统
- Tutorial on how to setup OAI with Lime LMSDR
4 条评论
C7sky · 2019-01-19 19:31
./build_spgw -i后libgtpnl选择不按照,提示“SPGW not compiled, to compile it, re-run build_spgw without -i option”这样是正常的吗?
wangping · 2019-01-19 22:46
我没出现你的提示啊
利用Limesdr Mini搭建OAI核心网 – 小离的博客 · 2019-02-04 16:49
[…] http://www.aumoc.com/index.php/2018/12/27/ubuntu-18-04-limesdr/ […]
ubuntu 16.04系统LimeSDR MINi使用OpenAirInterface搭建LTE实验环境 – bughuang · 2019-03-21 19:06
[…] http://www.aumoc.com/index.php/2018/12/27/ubuntu-18-04-limesdr/ […]