使用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包了

 

posted @ 2014-05-20 14:13  Merlin-magic  阅读(9856)  评论(0编辑  收藏  举报