戴維營教育《物聯網/智能家居開發》課程系列node
OpenWRT是一個專用於無線路由器設備的Linux發行版。支持衆多的芯片方案的路由器設備,由x86到ARM,MIPS等等。linux
目前穩定版本是: BARRIER BREAKER (14.07)git
目前開發版本是: Chaos Calmer (trunk)github
詳細信息參看官方網址: https://openwrt.org安全
咱們能夠去項目的官方網站獲取其源代碼,經過SVN或者GIT的方式,官方開發者網站:https://dev.openwrt.org/wiki/GetSourcebash
trunk (main development tree)網絡
git clone git://git.openwrt.org/openwrt.git
14.07 branch (Barrier Breaker) - Main repository網站
git clone git://git.openwrt.org/14.07/openwrt.git
固然,在咱們正式開始編譯前咱們須要把前提依賴環境和源碼準備好,ui
打開虛擬終端,執行以下命令:es5
openwrt@cheetah-desktop:~$ sudo apt-get install git build-essential libncurses5-dev gawk libssl-dev subversion; openwrt@cheetah-desktop:~$ mkdir -p $HOME/opensource; openwrt@cheetah-desktop:~$ cd $HOME/opensource; openwrt@cheetah-desktop:~/opensource$ git clone git://git.openwrt.org/openwrt.git ##上面命令會克隆遠程倉庫到本地,根據網絡環境狀況須要較長時間。
待源代碼克隆下來以後,咱們的源碼和編譯環境基本就OK了。
進入源碼目錄下面進行軟件包的更新與「安裝」。
openwrt@cheetah-desktop:~/opensource$ cd openwrt; openwrt@cheetah-desktop:~/opensource/openwrt$ ./scripts/feeds update -a; openwrt@cheetah-desktop:~/opensource/openwrt$ ./scripts/feeds install -a;
執行上面的腳本以後就能夠對咱們中意的設備類型進行編譯設置。以下命令進入終端下面的buildroot編譯配置界面:
make menuconfig;
咱們教程所採用的設備的CPU芯片是MT7620系列(MT7620A/N),下面就開始爲MT7620系列的設備進行最基本的配置,步驟以下:
Target System (Atheros AR7xxx/AR9xxx) --->
回車進入下翻後空格選擇Ralink RT288x/RT3xxx
而後再回車後退,這時編譯目標就是: Target System (Ralink RT288x/RT3xxx) --->
了。
Subtarget (RT3x5x/RT5350 based boards) --->
回車進入下翻按空格選擇(X) MT7620 based boards
而後回車後退,這時編譯的子目標就是:Subtarget (MT7620 based boards) --->
了。
LuCI --->
回車進去 1. Collections --->
再回車進去再空格選擇第一個<*> luci(new)
,而後在Exit一路後退到主菜單。
在主菜單Exit退出配置並保存。
That's All. 基本配置就是這麼簡單。下面開始咱們人生的「第一次」路由器固件編譯了,是否是很緊張阿? What Ever. 第一次老是要經歷的,那就積極面對吧。
咱們用下面這個命令來進行編譯固件:
make V=s
就這麼一個命令就會開啓整個編譯構建系統,全自動的去爲咱們編譯咱們須要的固件。因此的因此,這個過程將會是一個漫長的等待。若是互聯網網絡比較通暢,那麼我們這第一次編譯的時間大約要花2~3小時。由於構建系統須要去互聯網上下載各類程序庫源代碼,而後再逐個編譯,最後集成並組建出咱們須要的固件。
這段時間裏,咱們大能夠出去湘江邊溜達一圈,隔江望望毛主席,再回來我們戴維營裏看結果。
溜達回來後,編譯也許結束,等結束的這個時候,咱們的固件會乖乖的躺在當前目錄下的bin/ramips/
這個路徑下.
openwrt@cheetah-desktop:~/opensource/openwrt$ ls bin/ramips/ md5sums openwrt-ramips-mt7620-rp_n53-squashfs-sysupgrade.bin openwrt-ramips-mt7620-ai-br100-squashfs-sysupgrade.bin openwrt-ramips-mt7620-rt-n14u-squashfs-sysupgrade.bin openwrt-ramips-mt7620-ArcherC20i-squashfs-sysupgrade.bin openwrt-ramips-mt7620-uImage.bin openwrt-ramips-mt7620-dir-810l-squashfs-sysupgrade.bin openwrt-ramips-mt7620-vmlinux.bin openwrt-ramips-mt7620-e1700-squashfs-factory.bin openwrt-ramips-mt7620-vmlinux.elf openwrt-ramips-mt7620-e1700-squashfs-sysupgrade.bin openwrt-ramips-mt7620-whr-1166d-squashfs-sysupgrade.bin openwrt-ramips-mt7620-Lenovo-y1-squashfs-sysupgrade.bin openwrt-ramips-mt7620-whr-300hp2-squashfs-sysupgrade.bin openwrt-ramips-mt7620-Lenovo-y1s-squashfs-sysupgrade.bin openwrt-ramips-mt7620-whr-600d-squashfs-sysupgrade.bin openwrt-ramips-mt7620-mlw221-squashfs-sysupgrade.bin openwrt-ramips-mt7620-wmr-300-squashfs-sysupgrade.bin openwrt-ramips-mt7620-mlwg2-squashfs-sysupgrade.bin openwrt-ramips-mt7620-wr8305rt-squashfs-sysupgrade.bin openwrt-ramips-mt7620-mt7620a_mt7530-squashfs-sysupgrade.bin openwrt-ramips-mt7620-wrtnode-squashfs-sysupgrade.bin openwrt-ramips-mt7620-mt7620a_mt7610e-squashfs-sysupgrade.bin openwrt-ramips-mt7620-wt3020-8M-squashfs-factory.bin openwrt-ramips-mt7620-mt7620a-squashfs-sysupgrade.bin openwrt-ramips-mt7620-wt3020-8M-squashfs-sysupgrade.bin openwrt-ramips-mt7620-mt7620a_v22sg-squashfs-sysupgrade.bin openwrt-ramips-mt7620-xiaomi-miwifi-mini-squashfs-sysupgrade.bin openwrt-ramips-mt7620-mzk-750dhp-squashfs-sysupgrade.bin openwrt-ramips-mt7620-zbt-wa05-squashfs-sysupgrade.bin openwrt-ramips-mt7620-na930-squashfs-sysupgrade.bin packages openwrt-ramips-mt7620-root.squashfs
到了這一步,咱們的MT7620系列芯片的路由器固件就都已經編譯好了。咱們能夠選擇咱們合適型號的固件進行刷機了。 部分營員拿到的北京豌豆機器人小組的開發板WRTNode對應的固件文件是:openwrt-ramips-mt7620-wrtnode-squashfs-sysupgrade.bin
部分營員們拿到的鐵盒子路由器是中性包裝的工程產品,雖然和其餘知名品牌的在外觀上有差別,可是大能夠不要在乎這些區別。他們的配置都是差很少的。鐵盒子型號WR8305RT對應的固件文件就是: openwrt-ramips-mt7620-wr8305rt-squashfs-sysupgrade.bin
謝謝各位,歡迎交流並指正。
---- 大茶園丁@戴維營教育