使用OpenWrt的SDK


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

為什么要使用SDK:

 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,有兩種方法:

  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都分別作什么用途的呢?

  • 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去下載真正的源碼,后面我們會在例子中看到)。

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

然后我們在~/openwrt根目錄下,執行下面命令就把源碼下載下來了:

make package/nano/download

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

然后輸入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包了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM