java openwrt_使用OpenWrt的SDK

为什么要使用SDK:

Reasons forusing the SDK are:

Compile custom softwarefor a specific release whileensuring binary and feature compatibility

Compile newer versions of certain packages

Recompile existing packages with custom patches or different features

如何获得OpenWrt的SDK,有两种方法:

-----------------------------------

BTW, 看上面的图,这里ImageBuilder/SDK/Toolchain都分别作什么用途的呢?

ImageBuilder,现改名为Image Generator了。你想要获得的路由器固件有许多种途径获得(直接从官方下载编译好了的bin文件;你自己下载源码编译;使用ImageGenerator生成),这个工具的使用成本介于下载bin文件与源码编译两者之间。参考http://wiki.openwrt.org/doc/howto/obtain.firmware.generate看看它能做什么事情:

Reasons forusing 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.forexample 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里头):

b730bbbaa4daa723cda7ef3328a58b11.png

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

04af9af891d34fab95d303ac01f3061b.png

上图在编译过程中出现了许多WARNING

WARNING: skipping --package not selected

Runmake menuconfig and enable compilation for your package. It should be labeled with or to work correctly. Read image.configuration further up in this article.

意思就是在make menuconfig中没有选中这些包,所以它不编译!我是直接修改.config的,在里面搜索相应的WARNING指出的名字,然后改为=y就可以了。

734c45aa41f1994598ead4107e5e5bc1.png

输入编译命令(上图)

make package/nano/compile

结果已经在~/openwrt/bin/ar71xx中看到有这个ipk包了

c19ba39118efeb3383aeef0558af1b95.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值