Skip to content

Instantly share code, notes, and snippets.

@wen-long
Last active November 14, 2019 16:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wen-long/8839717 to your computer and use it in GitHub Desktop.
Save wen-long/8839717 to your computer and use it in GitHub Desktop.

##1.准备linux下编译环境

sudo apt-get install gcc g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils git libncurses5-dev ncurses-term zlib1g-dev gawk libssl-dev python wget subversion xz-utils

64位系统还需

sudo apt-get install lib32gcc1 libc6-dev-i386

##2.下载源码

  • trunk (开发版):
git clone git://git.openwrt.org/openwrt.git trunk
cd trunk 
./scripts/feeds update -a 
./scripts/feeds install -a 

##3.检查编译环境

make defconfig

若提示缺少软件包或编译库等依赖,则按提示安装所缺软件包或库等即可 ##4.选择组件

make menuconfig

注意: *号是编译进固件,M 是编译但是不编译进固件,生成 ipkg 文件,路由器 flash 不够大的话要考虑尽量编译成模块

  1. 选择Target System
  2. 选择Target Profile
  3. LuCI->Collections->luci(可以通过网页设置路由器)
  4. LuCI->Translations->luci-i18n-chinese(中文界面)
  5. 其余设置自行决定 #####界面说明:
  • luci:WEB界面
  • LuCI ->Applications:应用软件的WEB界面、
  • Base system:系统基础,里面有USB挂载 block-mount
  • Kernel modules:内核模块,内容很多,不如文件系统等等按照自己需要的选吧
  • Utilities:一些实用工具,比如自动挂载选项,无线开关等

##5.编译

make V=99 j=处理器数目+1

也可以直接

make V=99

##6.生成的固件在bin目录下 ###Fin

##以下杂记

1.参考链接

2. make -j 10 download预先用10连接数下载源码

3. 只编译某个软件 make package/cups/compile V=99

4. usb需要的包

 - Kernel modules -> USB Support -> <*>  kmod-usb-ohci   SUB1.1驱动
 - Kernel modules -> USB Support -> <*> kmod-usb2  USB2.0驱动根据硬件选择
 - Base system -> <*>block-mount
 - Kernel modules -> Filesystems -> <*> kmod-fs-ext4
 - Kernel modules -> USB Support -> <*> kmod-usb-storage-extras.
 - Utilities -> Filesystem -> <*> badblocks

5. 加入新软件重新编译时最好 make clean删除.o文件和.bin文件

  1. 选择CPU型号 Target System—–Atheros AR71xx/AR7240/AR913x/AR934x
  2. 选择路由型号 Target Profile—-TP-LINK TL-MR3420 v1
  3. 添加luci LuCI—>Collections—– <*> luci
  4. 添加luci的中文语言包 LuCI—>Translations—- <*> luci-i18n-chinese
  5. 添加DDNS LuCI—>Applications —> <*>luci-app-ddns.
  6. 添加USB挂载 Base system —> <*>block-mount
  7. 添加硬盘格式支持 Kernel modules —> Filesystems —> <*> kmod-fs-ext4
  8. 添加UTF8编码 Kernel modules —> Native Language Support —> <*> kmod-nls-utf8
  9. 添加USB扩展支持 Kernel modules —> USB Support —> <*> kmod-usb-storage-extras.
  10. 添加自动挂载工具 Utilities —> Filesystem —> <*> badblocks
  11. 添加复位键支持 Utilities —> <*> restorefactory
  12. 添加一键开关无线 Utilities —> <*> wifitoggle

openwrt修改出厂默认语言 http://www.right.com.cn/forum/thread-100338-1-1.html

make 命令简单说明   make V=99   V=99表示输出详细的debug信息

  make world   表示编译所有

  make j=2 V=99   如是多核CPU,加j=2 选项理论上能加快编译速度   make -j 2 V=99可加快编译速度(不推荐使用)

  只清除某个模块   make package/qos/clean

  只编译某个模块   make package/qos/clean   make package/qos/compile   make package/qos/install

  make V=99 | tee compile_v1.0.0.log   混合 tee 命令将编译信息放到compile_v1.0.0.log文件中方便查看。

留几个链接

  1. http://blog.sunshine-wang.info/?p=177
  2. https://code.google.com/p/wallproxy/wiki/OpenWRT
  3. http://www.right.com.cn/forum/forum.php?mod=viewthread&tid=129186&extra=page%3D1&page=1&
  4. https://forum.openwrt.org/viewtopic.php?id=39860
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment