openwrt 工具链及 SDK 编译

主要步骤:
1. 下载源码
2. 更新 feeds
3. 配置编译项
4. 编译

主要参考:
https://wiki.openwrt.org/doc/howto/build

OS X 特殊前置步骤:

参考链接:https://wiki.openwrt.org/inbox/easy.build.macosx

创建 disk image

hdiutil create -size 20g -fs "Case-sensitive HFS+" -volname OpenWrt OpenWrt.dmg
hdiutil attach OpenWrt.dmg

安装依赖

Blah-MacBook:OpenWrt Blah$ sudo port install coreutils e2fsprogs ossp-uuid asciidoc binutils \
    bzip2 fastjar flex getopt gtk2 intltool jikes hs-zlib openssl p5-extutils-makemaker python27 \
    subversion rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses findutils \
    grep gnutar

由于 macport 已经过时,所以当时用的是 homebrew。(两者不要混用,选一个就好)

下载源码

目前 (2017/3/28) 用的是 15.05 的分支:

git clone -b chaos_calmer git://github.com/openwrt/openwrt.git

也可以考虑主分支,但可能不稳定:

git clone git://github.com/openwrt/openwrt.git

更新 feeds

更新

./scripts/feeds update -a

安装

./scripts/feeds install -a

配置

make menuconfig

也可以从既有的配置中导出

./scripts/diffconfig.sh > diffconfig # write the changes to diffconfig

配置

cp diffconfig .config # write changes to .config
# or > cat diffconfig >> .config to append changes to bottom of .config
make defconfig # expand to full config

编译

首次编译时有很多要下载的东西,最好找个好一些的网络环境

make V=s 2>&1 | tee build.log | grep -i error

工具链

交叉编译参考:https://wiki.openwrt.org/doc/devel/crosscompile

工具链路径
openwrt/staging_dir/toolchain-architecture_gcc-compilerver_uClibc-libcver/bin/

设置 STAGING_DIR 环境变量

# in profile
export STAGING_DIR = "{path}/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2"

package 编译

make package/{package_path}/{clean,compile} V=99

.ipk 目标文件路径 bin/ramips/packages/base/

Leave a Reply

Your email address will not be published. Required fields are marked *