./scripts/feeds update -a
Updating feed 'packages' from 'https://github.com/openwrt/packages.git' ...
Initialized empty Git repository in /home/openwrt/trunk/feeds/packages/.git/
remote: Counting objects: 3771, done.
remote: Compressing objects: 100% (3014/3014), done.
remote: Total 3771 (delta 472), reused 3132 (delta 257), pack-reused 0
Receiving objects: 100% (3771/3771), 2.11 MiB | 537 KiB/s, done.
Resolving deltas: 100% (472/472), done.
Create index file './feeds/packages.index'
Collecting package info: done
Collecting target info: done
Updating feed 'luci' from 'https://github.com/openwrt/luci.git' ...
Initialized empty Git repository in /home/openwrt/trunk/feeds/luci/.git/
remote: Counting objects: 11944, done.
remote: Compressing objects: 100% (6342/6342), done.
remote: Total 11944 (delta 3975), reused 10006 (delta 2524), pack-reused 0
Receiving objects: 100% (11944/11944), 8.85 MiB | 1.16 MiB/s, done.
Resolving deltas: 100% (3975/3975), done.
Create index file './feeds/luci.index'
Collecting package info: done
Collecting target info: done
Updating feed 'routing' from 'https://github.com/openwrt-routing/packages.git' . ..
Initialized empty Git repository in /home/openwrt/trunk/feeds/routing/.git/
remote: Counting objects: 484, done.
remote: Compressing objects: 100% (378/378), done.
remote: Total 484 (delta 88), reused 362 (delta 39), pack-reused 0
Receiving objects: 100% (484/484), 260.39 KiB | 185 KiB/s, done.
Resolving deltas: 100% (88/88), done.
Create index file './feeds/routing.index'
Collecting package info: done
Collecting target info: done
Updating feed 'telephony' from 'https://github.com/openwrt/telephony.git' ...
Initialized empty Git repository in /home/openwrt/trunk/feeds/telephony/.git/
remote: Counting objects: 307, done.
remote: Compressing objects: 100% (256/256), done.
remote: Total 307 (delta 71), reused 227 (delta 26), pack-reused 0
Receiving objects: 100% (307/307), 145.64 KiB | 167 KiB/s, done.
Resolving deltas: 100% (71/71), done.
Create index file './feeds/telephony.index'
Collecting package info: done
Collecting target info: done
Updating feed 'management' from 'https://github.com/openwrt-management/packages. git' ...
Initialized empty Git repository in /home/openwrt/trunk/feeds/management/.git/
remote: Counting objects: 39, done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 39 (delta 8), reused 26 (delta 3), pack-reused 0
Unpacking objects: 100% (39/39), done.
Create index file './feeds/management.index'
Collecting package info: done
Collecting target info: done
Updating feed 'targets' from 'https://github.com/openwrt/targets.git' ...
Initialized empty Git repository in /home/openwrt/trunk/feeds/targets/.git/
remote: Counting objects: 137, done.
remote: Compressing objects: 100% (95/95), done.
remote: Total 137 (delta 17), reused 122 (delta 16), pack-reused 0
Receiving objects: 100% (137/137), 130.80 KiB | 66 KiB/s, done.
Resolving deltas: 100% (17/17), done.
Create index file './feeds/targets.index'
Collecting package info: done
Collecting target info: done
./scripts/feeds update packages luci
./scrippts/feeds update -a
Build dependency: Please install the openssl library (with development headers)
for ubuntu
sudo apt-get install lissl
for centos
yum -y install openssl-devel
xzcat: command not found
沒裝xz,解壓縮xz格式。
sudo yum -y install xz;
OpenWrt 開發環境搭建--編譯調試--

OpenWrt是一個高度模塊化、高度自動化的嵌入式linux發行版,其編譯和安裝過程比普通的linux發行版而言,要簡單太多了。如果您是新手,您那恐懼的心大可放到肚子里,呵呵。對於新手來說最麻煩的恐怕是安裝開發環境需要的軟件了。 最基本條件: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1.PC一台,性能強點,性能好編譯得就快。linux推薦安裝ubuntu 8.04中文版(或者suse)和fedora 11(對於初學者而言,最好是裝在虛擬機如VM里,可省去很多麻煩。如何在VM里安裝linux,您可多google或者baidu) 2.寬帶一條,需要速度好點,因為有很多軟件包是網絡下載后安裝。 3.耐心和時間。 編譯環境准備(安裝linux發行版和軟件包): +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1.安裝好ubuntu8.04中文版本或者fedora 9或者11,搞定網絡連接。 以非root用戶登陸,打開“應用程序—-附件—-終端”。如果您已經安裝好linux, 那么此步驟請略去。 2.如果您選擇ubuntu, 那么ubuntu開發環境需要的軟件有 sudo apt-get install gcc g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils subversion libncurses5-dev ncurses-term zlib1g-dev 然后 sudo apt-get update 如您選擇安裝fedora11或者fedora9 Fedora 11 or 9: # yum install autoconf binutils bison bzip2 flex gawk gcc gcc-c++ gettext make ncurses-devel patch unzip wget zlib-devel 由於fedora 安裝包本來就很全面,所以需另外安裝的東西較少。所以一般情況下,推薦安裝fedora 11。對於初學者而言,最方便的方法是在VM上安裝linux。 由於ubuntu本來就是基於suse, 所以如果您要以suse為開發環境,那么您參考ubuntu的安裝步驟即可。 如果你能閱讀英文,那么請參考 http://wiki.openwrt.org/doc/howto/buildroot, OpenWrt英文論壇2006年文章:Building OpenWrt Kamikaze from source https://forum.openwrt.org/viewtopic.php?id=9180 這里有更詳細權威的說明。 1.獲取OpenWrt源代碼和安裝包,更新 svn checkout svn://svn.openwrt.org/openwrt/trunk (開發版本,不穩定,不建議下載) PS:wgethttp://downloads.openwrt.org/backfire/10.03/backfire_10.03_source.tar.bz2(目前穩定版本,建議) 2. 檢查配置環境 必須使用非root用戶進行操作,添加一個普通用戶。(注意:如果使用root進行操作的話,會提示檢查失敗:Checking 'non-root'... failed.) [root@localhost trunk]# adduser openwrt [root@localhost trunk]# su openwrt 為了防止文件讀寫權限造成問題,需要將源碼copy到openwet的根目錄下進行所有操作。 [openwrt@localhost openwrt]$ cd ~ [openwrt@localhost ~]$ cp -r /usr/src/test/trunk ./ [openwrt@localhost ~]$ cd trunk/ [openwrt@localhost trunk]$ ls BSDmakefile LICENSE README feeds.conf.default package scripts toolchain Config.in Makefile docs include rules.mk target tools 3.下載feeds Feeds是OpenWrt環境所需要的軟件包套件。最重要的feeds有: ‘packages’一些額外的基礎路由器特性軟件 ‘LuCI’OpenWrt默認的GUI ‘Xwrt’另一種可選的GUI界面, 需要能夠連接互聯網。 在下載之前可以通過查看’feeds.conf.default’文件,來檢查哪些文件需要包含在環境中。 開始下載,使用: [openwrt@localhost trunk]$ ./scripts/feeds update -a 安裝feeds包,只有安裝之后,在后面的make menuconfig時,才可以對相關配置進行勾選。 [openwrt@localhost trunk]$ ./scripts/feeds install -a 如果更新了feeds的配置文件,需要添加新的軟件包用於生成系統。只需進行重復操作: [openwrt@localhost trunk]$ ./scripts/feeds update -a [openwrt@localhost trunk]$ ./scripts/feeds install -a 4.進行配置 編譯過程使用的交叉編譯,交叉編譯生成的SDK以及image等文件的類型取決於開發環境、應用硬件、以及源碼版本。所以要對自己的環境進行了解,才能進行正確的配置。我在配置過程中,就遇到了這個問題,我的硬件是brcm47xx,在第一次編譯的時候,選擇地是Target System (Broadcom BCM947xx/953xx),最后生成的包無法在router上安裝,版本不匹配。第二次安裝時,選擇了Target System (Broadcom BCM947xx/953xx[2.4]),安裝成功,我的板子可能只支持linux2.4的內核。(設備型號是Linksys Wrt54gs v3.0) (2011.05.01添加:其實Linksys Wrt54gs v3.0是支持Linux 2.6版本的,Target System 選擇 Broadcom BCM947xx/953xx,編譯后也是可以用的,這周末由於項目需要改某個軟件,每次修改代碼后,都得重新編譯一下固件,經過來回編譯了十來次,都可以使用。另外。內核版本升級之后,無線驅動改成了mac802.11,而非以前的wl,以為wl.o這個專門的庫只在linux2.4中才用到。) [openwrt@localhost trunk]$ make defconfig [openwrt@localhost trunk]$ make prereq [openwrt@localhost trunk]$ make menuconfig 通過文本對話框進行選項配置,最主要的配置項有: Target system(目標系統類型) Package selection(軟件包選擇) Build system settings (編譯系統設置) Kernel modules (內核模塊) [*]表示:這個包裹選中編譯,並安裝在firmware中; [M]表示:這個軟件包選中編譯,但並不安裝在firmware中。 在退出Menuconfig的時,會提示是否保存配置。 在此我只對target system進行了選擇;勾選了Advanced configuration option和Build the OpenWrt SDK選項。 5. 編譯 (1)一般情況,使用一個簡單的命令: [openwrt@localhost trunk]$ make (2)在多核處理器系統上為提高速度,可使用(例如用3核處理器): [openwrt@localhost trunk]$ make –j 3 (3)在后台進行編譯,使用空閑的I/O資源和CPU性能,可使用(例如使用雙核處理器) [openwrt@localhost trunk]$ onice -c 3 nice -n 20 make -j 2 (4)編譯一個單獨的軟件包(例如在cups軟件包): [openwrt@localhost trunk]$ make package/cups/compile V=99 (5)如果特殊原因需要分析編譯報錯信息: [openwrt@localhost trunk]$ make V=99 2>&1 |tee build.log |grep -i error 說明:將編譯的所有輸出信息保存在build.log中,將error信息打印在屏幕上。 (6)一個復雜指令的應用 [openwrt@localhost trunk]$ ionice -c 3 nice -n 20 make -j 2 V=99 CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 \|tee build.log |egrep -i '(warn|error)' 說明:將編譯的所有輸出信息保存在build.log中,將error和warning信息打印在屏幕上。編譯過程使用雙核CPU,占用后台資源。 6.生成鏡像(Image)位置 新生成的鏡像會默認放在新建的一個bin目錄下。例如:/bin/brcm-2.4/packages [openwrt@localhost trunk]$ ls bin/* 將編譯好的鏡像做個備份,例如備份到/目錄下: [openwrt@localhost trunk]$ cp bin / 7.清理工作 建議現在清理編譯產生的文件,以免下次編譯時造成沖突,(文件如果存在的話,將不會被替換),執行make clean 注意:在執行clean命令,確保已經將編譯好的image進行了備份。清理工作會清楚bin目錄。 [openwrt@localhost trunk]$ make clean 除了清除生成的目錄,還想清除交叉編譯工具(以及工具鏈目錄) [openwrt@localhost trunk]$ make dirclean 清除所有相關的東西,包括下載的軟件包,配置文件,feed內容等:(不建議使用) [openwrt@localhost trunk]$ make distclean 對於更新feeds后出現的錯誤: ERROR:please fix package/feeds/packages/mc/Makefile 等類似的問題,需要執行這條語句進行系統的清理 更詳細的信息建議您參考 http://downloads.openwrt.org/kamikaze/docs/openwrt.html 應該是當前最新最權威的文檔 編譯過程中需要通過官網下載很多相關的軟件包,所以必須保證能夠順利連上外網。由於下載速度的限制,編譯過程大概需要數小時。編譯結束后,所有的產品都會放在編譯根目錄下的bin/yourtarget/. 例如:我所編譯的產物都放在./bin/brcm47xx/下,其中文件主要有幾類: (1). bin/.trx 文件: 這些都是在我們所選的target-system的類別之下,針對不同路由器型號、版本編譯的路由器固件。這些不同路由器的型號和版本是openwrt預先設置好的,我們不需要更改。至於.bin和.trx的區別,一種說法是,第一次刷路由器的時候,需要用.bin文件,如果需要再升級,則不能再使用. bin文件,而需要用.trx文件。原因是,.bin是將路由器的相關配置信息和.trx封裝在一起而生成的封包,也就是說是包含路由器版本信息的. trx。在第一次刷固件的時候,我們需要提供這樣的信息,而在后續升級時,則不再需要,用.trx文件即可。 (2)packages文件夾: 里面包含了我們在配置文件里設定的所有編譯好的軟件包。默認情況下,會有默認選擇的軟件包。 (3) OpenWrt-SDK.**.tar.bz2: 這個也就是我們定制編譯好的OpenWRT SDK環境。我們將用這個來進行OpenWrt軟件包的開發。例如,我所編譯好的SDK環境包為:/bin/brcm47xx/OpenWrt-SDK- brcm47xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.30.1.tar.bz2 可以從名稱上看出,target system是brcm47xx,host system是Linux-x86_64,使用的編譯工具以及庫是4.3.3+cs_uClibc-0.9.30.1。 (4)md5sums 文件: 這個文件記錄了所有我們編譯好的文件的MD5值,來保證文件的完整性。因為文件的不完整,很容易將路由器變成“磚頭”。 需要主要的是,編譯完成后,一定要將編譯好的bin目錄進行備份(如果里面東西對你很重要的話),因為在下次編譯之前,執行make clean 會將bin目錄下的所有文件給清除掉!! 2、 更改原有packages 在編譯根目錄下會有一個dl的目錄,這個目錄其實是“download”的簡寫,在編譯前期,需要從網絡下載的數據包都會放在這個目錄下,這些軟件包的一個特點就是,會自動安裝在所編譯的固件中,也就是我們make menuconfig的時候,為固件配置的一些軟件包。如果我們需要更改這些源碼包,只需要將更改好的源碼包打包成相同的名字放在這個目錄下,然后開始編譯即可。編譯時,會將軟件包解壓到build_dir目錄下。 當然,你也可以自己在dl里面創建自己的軟件包,然后更改相關的配置文件,讓openwrt可以識別這個文件包。 由於我的項目更改的內容是底層的,需要跟固件一起安裝。所以,我使用的方法就是直接更改dl目錄下軟件包,然后重新進行固件編譯。感覺類似於Linux的內核編譯。反復編過十多次,沒有任何問題。 第一次編譯由於要下載大量的軟件包,慢慢的等吧,快則半小時,慢則2,3小時. 如果下載過慢,建議您中斷編譯過程,然后用迅雷去主動下載,放到./dl目錄下。一個加快速度的小技巧: 本站小編已經將將一些常用的軟件包打包成dl.tar,放在http://ul.to/2y8a2w, 下載后用tar xvf dl.tar(在windows下用winrar打開即可,然后你用ftp或者samba之類傳到Linux PC上),將解包出來的東東直接放到./dl目錄下,相必會大大加快初次安裝、編譯的速度。同樣在http://ul.to/fasgus上可下載linux-2.36.30.10.tar.bz2,當然您也可以用迅雷之類的工具來下。 8. 編譯好的文件在當前目錄的bin文件夾下。 如果是brcm-2.4 ls bin/brcm-2.4/ 就可以看到很多熟悉的文件了。 9、 安裝OpenWrt 找到對應的固件,進行固件升級。網上方法很多,這里不再贅述。 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 下面我們編寫自己的package: 新建自己的packages 對於自己新建的package,而這個package又不需要隨固件一起安裝,換句話說,就是可以當做一個可選軟件包的話。我們可以利用我們的SDK環境來單獨編譯,編譯后會生成一個ipk的文件包。然后利用 opkg install xxx.ipk 來安裝這個軟件。 下面具體說下,如何編譯一個helloword的軟件包。 (1)首先,編寫helloworld程序 編寫helloworld.c /**************** * Helloworld.c * The most simplistic C program ever written. * An epileptic monkey on crack could write this code. *****************/ #include <stdio.h> #include <unistd.h> int main(void) { printf("Hell! O' world, why won't my code compile?\n\n"); return 0; } 編寫Makefile文件 # build helloworld executable when user executes "make" helloworld: helloworld.o $(CC) $(LDFLAGS) helloworld.o -o helloworld helloworld.o: helloworld.c $(CC) $(CFLAGS) -c helloworld.c # remove object files and executable when user executes "make clean" clean: rm *.o helloworld 在這兩個文件的目錄下,執行make 應該可以生成helloworld的可執行文件。執行helloworld后,能夠打印出“Hell! O' world, why won't my code compile?”。 這一步,主要保證我們的源程序是可以正常編譯的。下面我們將其移植到OpenWRT上。 (2)將OpenWrt-SDK-brcm47xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.30.1.tar.bz2解壓 tar –xvf OpenWrt-SDK-brcm47xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.30.1.tar.bz2 (3)進入SDK cd OpenWrt-SDK-brcm47xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.30.1 可以看到里面的目錄結構跟我們之前source的目錄結構基本相同,所需要編譯的軟件包,需要放置在package目錄下 (4)在package目錄下創建helloworld目錄 cd package mkdir helloworld cd helloworld (5)創建src目錄,拷貝 helloworld文件 mkdir src cp /home/wrt/test/helloworld.c src cp /home/wrt/test/Makefile src (6)在helloworld目錄下創建Makefile文件 這個Makefile文件是給OpenWRT讀的,而之前寫的那個Makefile文件是針對helloworld給編譯其讀的。兩個Makefile不在同一層目錄下。 touch Makefile vim Makefile Makefile文件模板內容如下: ############################################## # OpenWrt Makefile for helloworld program # # # Most of the variables used here are defined in # the include directives below. We just need to # specify a basic description of the package, # where to build our program, where to find # the source files, and where to install the # compiled program on the router. # # Be very careful of spacing in this file. # Indents should be tabs, not spaces, and # there should be no trailing whitespace in # lines that are not commented. # ############################################## include $(TOPDIR)/rules.mk # Name and release number of this package PKG_NAME:=helloworld PKG_RELEASE:=1 # This specifies the directory where we're going to build the program. # The root build directory, $(BUILD_DIR), is by default the build_mipsel # directory in your OpenWrt SDK directory PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) include $(INCLUDE_DIR)/package.mk # Specify package information for this program. # The variables defined here should be self explanatory. # If you are running Kamikaze, delete the DESCRIPTION # variable below and uncomment the Kamikaze define # directive for the description below define Package/helloworld SECTION:=utils CATEGORY:=Utilities TITLE:=Helloworld -- prints a snarky message endef # Uncomment portion below for Kamikaze and delete DESCRIPTION variable above define Package/helloworld/description If you can't figure out what this program does, you're probably brain-dead and need immediate medical attention. endef # Specify what needs to be done to prepare for building the package. # In our case, we need to copy the source files to the build directory. # This is NOT the default. The default uses the PKG_SOURCE_URL and the # PKG_SOURCE which is not defined here to download the source from the web. # In order to just build a simple program that we have just written, it is # much easier to do it this way. define Build/Prepare mkdir -p $(PKG_BUILD_DIR) $(CP) ./src/* $(PKG_BUILD_DIR)/ endef # We do not need to define Build/Configure or Build/Compile directives # The defaults are appropriate for compiling a simple program such as this one # Specify where and how to install the program. Since we only have one file, # the helloworld executable, install it by copying it to the /bin directory on # the router. The $(1) variable represents the root directory on the router running # OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install # directory if it does not already exist. Likewise $(INSTALL_BIN) contains the # command to copy the binary file from its current location (in our case the build # directory) to the install directory. define Package/helloworld/install $(INSTALL_DIR) $(1)/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/ endef # This line executes the necessary commands to compile our program. # The above define directives specify all the information needed, but this # line calls BuildPackage which in turn actually uses this information to # build a package. $(eval $(call BuildPackage,helloworld)) (7)返回到SDK的根目錄 執行make進行編譯 編譯過程會在build_dir目錄下完成 編譯結果會放在 bin/[yourtarget]/package目錄下helloworld_1_bcm47xx.ipk (8)上傳helloworld_1_bcm47xx.ipk 使用sftp軟件上傳helloworld_1_bcm47xx.ipk至路由器 執行 opkg install helloworld_1_bcm47xx.ipk 輸入hello然后按Tab鍵,發現openwrt中已經有helloworld可執行命令。 執行 helloworld 查看程序的效果。 Hell! O' world, why won't my code compile?
防止ssh 暴力破擊
http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece763105392230e54f7257b8c8148228a8448e435061e5a35a3fd7c734e5392d8793301d01d0b99e4732f77552fecdddf893acacd903f598a3044710bf730&p=8b2a97108f871cb134bd9b7d0f12c9&newp=882a9647d2815af006be9b7c4c5dcb231615d70e3cd7d0143dcfcc16&user=baidu&fm=sc&query=it%D0%D0%B3%CC&qid=b3f2f28c00008295&p1=5
版權聲明:本文內容由互聯網用戶自發貢獻,版權歸作者所有,本社區不擁有所有權,也不承擔相關法律責任。如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至:
yqgroup@service.aliyun.com 進行舉報,並提供相關證據,一經查實,本社區將立刻刪除涉嫌侵權內容。