使用OpenWrt的SDK

原文:http://wiki.openwrt.org/doc/howto/obtain.firmware.sdklinux

爲何要使用SDK:git

 Reasons for using the SDK are:
    Compile custom software for a specific release while ensuring binary and feature compatibility
    Compile newer versions of certain packages
    Recompile existing packages with custom patches or different features

如何得到OpenWrt的SDK,有兩種方法:web

  1. 在編譯路由器固件的時候,選中[*] Build the OpenWrt SDK;
  2. http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/這裏去下載,若是你使用不一樣的OpenWrt版本或者不同的路由器,請自行選擇,入口地址http://downloads.openwrt.org/

-----------------------------------編輯器

BTW, 看上面的圖,這裏ImageBuilder/SDK/Toolchain都分別做什麼用途的呢?svn

  • ImageBuilder,現更名爲Image Generator了。你想要得到的路由器固件有許多種途徑得到(直接從官方下載編譯好了的bin文件;你本身下載源碼編譯;使用ImageGenerator生成),這個工具的使用成本介於下載bin文件與源碼編譯二者之間。參考http://wiki.openwrt.org/doc/howto/obtain.firmware.generate看看它能作什麼事情:
     Reasons for using Image Generator are:
    
        Embedding packages directly into the SquashFS to reduce space requirements on the target
        Preconfigure images by embedding packages and configuration files directly into SquashFS, and save manpower when flashing many devices
        Building minimal images. for example without the web interface
        Learning
  • SDK就上面有介紹了,The SDK is a relocatable, precompiled OpenWrt toolchain suitable to cross compile single userspace packages for a specific target without compiling the whole system from scratch.;看看SDK裏機的內容就明白了,它是Toolchain+各類腳本組成的(Toolchain就在staing_dir裏頭):
  • Toolchain,工具鏈,像mips-openwrt-linux-uclibc-ld/mips-openwrt-linux-cpp這樣子的東西,位於staging_dir/toolchain-mips~中;

----------------------------------- 工具

默認狀況下,下載得的SDK裏面沒有包含任何的包。你須要安裝的包要到openwrt官方源中下載,可使用svn或者git方式下載包(其實是下載包的Makefile文件,這個Makefile文件中指定了某個網址,可讓SDK去下載真正的源碼,後面咱們會在例子中看到)。ui

不過惋惜的是,我使用svn和git試過了許多源,都沒有辦法下載到任何包的Makefile文件,因此只能使用暴露一點的方法了:去TracBrowser下載,例如https://dev.openwrt.org/browser/packages/utils/nano下載nano編輯器的Makefile文件,將它們放到~/openwrt/package/nano/中。this

而後咱們在~/openwrt根目錄下,執行下面命令就把源碼下載下來了:spa

make package/nano/download

源碼會下載到~/openwrt/dl中3d

而後輸入prepare準備命令(解壓源碼到~/openwrt/build_dir/target-ips_r2~中,並執行打包patch文件,若是還有依賴沒有下載的話也會自動下載,如nano須要ncurses庫)

make package/nano/prepare

上圖在編譯過程當中出現了許多WARNING

WARNING: skipping <package> -- package not selected
Run make menuconfig and enable compilation for your package. It should be labeled with <*> or <M> to work correctly. Read image.configuration further up in this article.

意思就是在make menuconfig中沒有選中這些包,因此它不編譯!我是直接修改.config的,在裏面搜索相應的WARNING指出的名字,而後改成=y就能夠了。

輸入編譯命令(上圖)

make package/nano/compile

結果已經在~/openwrt/bin/ar71xx中看到有這個ipk包了

相關文章
相關標籤/搜索