openwrt编译+openvswitch功能添加

来源:互联网 发布:工地扬尘监测仪数据 编辑:程序博客网 时间:2024/06/09 18:18

这篇文章主要介绍openwrt的编译烧录工作,主要是想在openwrt上添加openvswitch的功能(使用的openwrt版本是attitude adjustment(12.09)),废话不多说,直接开始安装流程。
1、环境准备

  • Ubuntu 14.04 LTS x86_32
    sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-peri unzip
    建议在一般用户权限下进行编译,如果用root权限编译的话,可能会出现build dependency:please do not compile as root的错误提示。
  • 下载openwrt的源码
    openwrt的几个版本选择:
    1.backfire(stable version)git clone git://git.openwrt.org/10.03/openwrt.git
    2.attitude adjustment(stable version)git clone git://git.openwrt.org/12.09/openwrt.git
    3.trunk(develop version)git clone git://git.openwrt.org/openwrt.git
    4.barrier breaker(stable version)git clone git://git.openwrt.org/14.07/openwrt.git
    当然你也可以使用svn代码管理工具下载各个版本:
    svn co svn://svn.openwrt.org/openwrt/branches/backfire
    svn co svn://svn.openwrt.org/openwrt/branches/attitude_adjustment
    svn co svn://svn.openwrt.org/openwrt/branches/trunk
    svn co scn://scn.openwrt.org/openwrt/branches/barrier_breaker
    我这里编译了attitude adjustment和trunk两个版本的openwrt。一般建议采用stable version,避免在develop version里碰到一些奇怪的问题。为了添加openvswitch的功能,在attitude adjustment和trunk两个版本中的处理是不同的,先说下attitude adjustment下的编译过程。
    在attitude adjustment版本的官方软件包套件(也就是feeds.conf.default里列出的那些软件源)是没有包含openvswitch的,因此需要我们自己来添加相应的软件源。
    cd $TOPDIR
    echo “src-git openvswitch git://github.com/schuza/openvswitch.git” > feeds.conf.default
    同时为了编译完之后管理的方便,选择了将luci组件编译上,但是在编译的过程中发现使用官方软件包套件中的Luci源:src-svn luci http://svn.luci.subsignal.org/luci/branches/luci-0.11/contrib/package在执行更新的时候出现No address associated with hostname的错误,上网查询之后感觉是软件源出了问题,于是从github上找了个attitude adjustment下的luci添加到feeds.conf.default中去:
    echo “src-git luci git://github.com/gwlim/attitude_adjustment_luci.git” > feeds.conf.default
    添加完这些源之后,接下来开始编译。
    cd openwrt
    ./scripts/feeds update -a
    ./scripts/feeds install -a
    make menuconfig
    这一步选择与你的硬件相匹配的型号以及你想要安装到你的openwrt上的软件。硬件匹配部分每台AP都不一样,根据你自己的设备进行选择,接下来我只选择了一些我认为我这里必要的部分,包括:
    添加openvswitch:select Network -> openvswitch-switch,openwrt-brcompat,openvswitch-controller
    添加Luci:select LuCi -> collectiections -> <*>luci
    添加luci的中文语言包:select LuCi -> Translations -> <*>luci-i18n-chinese
    添加中文语言包的时候有的编译版本里在LuCi的modules里面:LuCi -> Modules -> Translations -> <*>luci-i18n-chinese
    添加ddns:select LuCi -> Applications -> <*>luci-app-ddns
    保存退出。
    在添加openvswitch里,执行完make menuconfig之后,需要在.config这个文件里添加一句命令:
    echo “# CONFIG_KERNEL_BRIDGE is not set” > .config
    接下来就是make了,make的过程是需要联网的,而且如果你是第一次从源码编译的话,那么make将会耗费很长一段时间,如果再加上你的网速不够给力的话,那就更加耗费时间了,(博主甚至因为网速太不给力导致好几次出现No more mirrors to download进而导致编译终端的现象,不得不吐槽一下学校的坑爹网速。。)
    编译完成之后,会出现一个bin的文件夹,编译得到的固件也就存放在openwrt/bin//下面,这里你会发现有好几个和你的设备对应的固件,就烧录固件到你的设备里而言,有两种方式:
    (1)对于从未安装过openwrt的AP,从原厂固件更新到openwrt系统时使用*-factory.bin这个固件;
    (2)对于已经安装过openwrt的AP,从第三方软件更新到openwrt系统时使用“*-sysupgrade.bin”这个固件。
    接下来就可以将生成的固件拷贝到你的设备里进行更新了。

对于trunk版本的openwrt,官方给定软件套件里已经包含了openvswitch这个软件,你只需要执行feeds更新,再选择openvswitch后执行编译即可。

主要参考链接:
https://github.com/pichuang/openvwrt
https://github.com/gwlim/attitude_adjustment_luci
http://roan.logdown.com/posts/165911-compiled-openwrt
http://roan.logdown.com/posts/191801-set-openvswitch

0 0
原创粉丝点击