openwrt移植openthread

导语

使用openwrt作为thread协议布网中的边界路由。

移植openthread

假设OPENWRT_TOP_SRCDIR为openwrt根目录
移植步骤如下:

git clone https://github.com/openthread/ot-br-posix.git		 #不要放到openwrt目录下,请另找一个工作目录
cd ot-br-posix
git submodule update --init --recursive 			#拉取子库
echo src-link openthread "$(pwd)/etc/openwrt" >> ${OPENWRT_TOP_SRCDIR}/feeds.conf 		#更新feeds源
cd "${OPENWRT_TOP_SRCDIR}"
./scripts/feeds update -f openthread 			#更新openthread
./scripts/feeds install -f openthread-br 		#下载openthread
make menuconfig #选择openthread
make package/feeds/openthread/opthread-br/{clean,compile} V=s

报错问题解决

问题一

报错:too many initializers for 'ubus_method'

解决方法:uci ubox ubus等更新到1806版本或以上,可从openwrt的github上找

问题二

报错:-Werror=implicit-function-declaration

解决方法:修改ot-br-posix/CMakeLists.txt文件

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,7 +48,7 @@ if (OTBR_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
     add_link_options(--coverage)
 endif()
 
-add_compile_options(-Wall -Wextra -Werror -Wfatal-errors -Wno-missing-braces)
+add_compile_options(-Wall -Wextra -Wfatal-errors -Wno-missing-braces)

问题三

报错:缺少libncurses.so.5 libreadline.so.6依赖库

解决方法:ot-br-posix/etc/openwrt/openthread-br/Makefile

--- a/etc/openwrt/openthread-br/Makefile
+++ b/etc/openwrt/openthread-br/Makefile
@@ -50,7 +50,7 @@ define Package/openthread-br
        SECTION := base
        CATEGORY := Network
        TITLE := OpenThread Border Router
-       DEPENDS := +libstdcpp +libjson-c +libubus +libblobmsg-json
+       DEPENDS := +libstdcpp +libjson-c +libubus +libblobmsg-json +libncurses +libreadline
 endef

问题四

运行报错:Enable multithreading to use std::thread: Operation not permitted

解决方法:修改ot-br-posix/src/agent/CMakeLists.txt

--- a/src/agent/CMakeLists.txt
+++ b/src/agent/CMakeLists.txt
@@ -26,6 +26,8 @@
 #  POSSIBILITY OF SUCH DAMAGE.
 #
 
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++11")
+
 add_executable(otbr-agent
     agent_instance.cpp
     agent_instance.hpp

问题五

编译报错:error: 'fd_set' was not declared in this scope

修改方法:在报错文添加

+#include <sys/types.h>

如果遇到其他报错,可尝试回退到博主所移植的ot-br-posix commit版本经行验证
移植commit 版本

commit 0a18ff04240020f2cfc9cb776bd3162ddb40c8d8
Author: Yakun Xu <xyk@google.com>
Date:   Fri May 29 22:59:15 2020 +0800

    [openthread] update OpenThread to fix ot-ctl reset (#442)

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值