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

相关文章
相关标签/搜索