openwrt 编译进阶

来源:互联网 发布:淘宝虚假交易申诉场景 编辑:程序博客网 时间:2024/05/16 19:43

(1)-编译703_8M固件

1.    target/linux/ar71xx/image/Makefile

  1. $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLWR703,tl-wr703n-v1,TL-WR703N,ttyATH0,115200,0×07030101,1,8Mlzma))

2.    tools/firmware-utils/src/mktplinkfw.c

  1. .id = “TL-WR703Nv1″,
  2. .hw_id = HWID_TL_WR703N_V1,
  3. .hw_rev = 1,
  4. .layout_id = “4Mlzma”,
将其中的4Mlzma替换成8Mlzma

(2)-修改默认WIFI,添加WIFI配置,WIFI名为MAC后六位

修改package/kernel/mac80211/files/lib/wifi/mac80211.sh

option disabled 1改成0,默认开启wifi。

option disabled 0下添加

  1. option htmode HT40+
  2. option channel 1
  3. option country CN
  4. option noscan 1
  5. option txpower 17
option htmode HT40+ 使用40MHz频宽,但只支持1-7信道。HT40-,支持5-13信道。HT20 支持1-13信道,20MHz频宽
option channel 1使用信道1,1-13之间。若有限定频宽,信道参考如上。
option country CN 设定wifi标准为中国 CN、JP、HK均可开启13信道,默认的US只有1-12信道
option noscan 1 强制使用40MHz的频宽
option txpower 17 发射功率为17dBm,大约50mW。不可设定过大,否则有烧毁PA的危险。

修改默认SSD:
  1. config wifi-iface
  2. option device radio$devidx
  3. option network lan
  4. option mode ap
  5. option ssid OpenWrt_$(cat /sys/class/ieee80211/${dev}/macaddress|awk -":" '{print $4""$5""$6 }'| tr a-z A-Z)option encryption none
  6. option encryption none

option mode ap,配置模式为AP。例如WDS之类。

option ssid     OpenWrt_$(cat /sys/class/ieee80211/${dev}/macaddress|awk -F ":" '{print $4""$5""$6 }'| tr a-z A-Z)  默认SSID为Openwrt_MAC后六位

option encryption none 是否开启加密,可以是psk、psk2、psk2-ccmp等
option network  lan 位于哪个接口的管理之下,默认lan。一般无需修改


(3)-修改root密码

默认情况下root是没有密码的,需设定密码才能开启ssh。
修改shadow文件,位于package/base-files/files/etc
  1. root:$1$wEehtjxj$YBu4quNfVUjzfv8p/PBo5.:0:0:99999:7:::
密码经过加密,将密码修改成admin。

(4)-修改路由连接数,优化网络参数

修改路由连接数,优化网络参数

连接数默认情况下是1.6万多吧。可以选择性修改。
修改sysctl.conf文件,位于package/base-files/files/etc/

  1. net.netfilter.nf_conntrack_max=65535
65535自行替换。

(5)-默认中文,修改主机名,添加并修改默认主题,设定时区

默认中文,添加并默认主题

修改feeds/luci/libs/web/root/etc/config

  1. option lang auto

改为


  1. option lang zh_cn
 并添加
  1. config internal languages
  2.         option en 'English'
  3.         option zh_cn 'chinese'

添加主题

1.首先打开trunk/feeds/luci/themes这个目录,你会发现里面有很多主题(除了base为基础包外)每一个文件夹就

是一个主题

2.我们得修改makefile文件,使其制定编译的时候能找到openwrtcn这个主题

找到路径为trunk/feeds/luci/contrib/package/luci下面的makefile文件双击打开

搜索OpenWrt.org这样很快就定位到添加主题的地方了,在下面空白处增加一句

效果如下

  1. $(eval $(call theme,base,Common base for all themes))
  2. $(eval $(call theme,openwrt,OpenWrt.org ))
  3. $(eval $(call theme,bootstrap,Bootstrap Theme))
  4. $(eval $(call theme,openwrtcn,openwrtcn Theme (default),,,1))
  5.   
  6. $(eval $(call theme,freifunk-bno,Freifunk Berlin Nordost Theme,\
  7.     Stefan Pirwitz <stefan-at-freifunk-bno-dot-de>))
  8.   
  9. $(eval $(call theme,freifunk-generic,Freifunk Generic Theme,\
  10.     Manuel Munz <freifunk-at-somakoma-dot-de>))

保存退出即可。

修改默认主题

修改feeds/luci/libs/web/root/etc/config

  1. option mediaurlbase /luci-static/openwrt.org

可根据需要将openwrt.org修改为Bootstap、openwrtcn、freifunk-bno、freifunk-generic

修改主机名,设定时区
修改package/base-files/files/etc/config/system

  1. config system
  2. option conloglevel 8
  3. option cronloglevel 8
  4. option hostname Openwrt
  5. option timezone Asia/Shanghai
  6. option timezone CST-8
  7. config timeserver ntp
  8. list server 0.openwrt.pool.ntp.org
  9. list server 1.openwrt.pool.ntp.org
  10. list server 2.openwrt.pool.ntp.org
  11. list server 3.openwrt.pool.ntp.org
  12. option enable_server 0
option hostname Openwrt 设定主机名


option timezone Asia/Shanghai 时区设置为亚洲/上海
option timezone CST-8 正8区
list server 就是ntp服务器了。


(6)-添加aria2,luci添加,web管理界面添加

aria2的源码来自于 

http://sourceforge.net/projects/aria2/files/stable/

我们这里以aria2-1.17.1版本为例下载的源码格式为aria2-1.17.1.tar.bz2

aria2的依赖安装
很多人没安装这依赖编译时会报错的
  1. sudo apt-get update 
  2. sudo apt-get install autoconf automake libcppunit-dev autopoint openssl libtool sphinx-common sphinxsearch libgcrypt11-dev libxml2-dev pkg-config
开始集成aria2c
首先把下载下来的aria2-1.17.1.tar.bz2放进openwrt源码根目录的dl目录
获取md5码
ctrl+alt+T弹出终端输入
  1. md5sum /……/……/trunk/dl/aria2-1.17.1.tar.bz2 省略好代表openwrt的源码的路径补全,回车就能获取md5码,记住用用的
在/feeds/packages/net/aria2/路径下创建aria2c源码的makefile文件内容如下 (make文件及其他本文需要文件见文章最下方)
  1. #
  2. # Copyright (C) 2012 OpenWrt.org
  3. #
  4. This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8.        
  9. PKG_NAME:=aria2 名字
  10. PKG_VERSION:=1.17.1
  11. PKG_RELEASE:=1
  12.        
  13. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 
  14. PKG_SOURCE_URL:=
  15. PKG_MD5SUM:=86229ef8d289893934cb3af25c8fddf6
  16. PKG_INSTALL:=1
  17.        
  18. include $(INCLUDE_DIR)/package.mk
  19.        
  20. define Package/aria2
  21.   SECTION:=net
  22.   CATEGORY:=Network
  23.   SUBMENU:=File Transfer
  24.   TITLE:=lightweight download utility
  25.   URL:=http://aria2.sourceforge.net/
  26.   DEPENDS:=+libopenssl +zlib +libxml2 +libstdcpp \
  27.     $(INTL_DEPENDS) $(ICONV_DEPENDS)
  28. endef
  29.        
  30. define Package/aria2/description
  31.  aria2 is a lightweight multi-protocol & multi-source command-line download
  32.  utility
  33. endef
  34.        
  35. define Package/aria2/conffiles
  36. /etc/config/aria2
  37. endef
  38.        
  39. CONFIGURE_ARGS += \
  40.     --disable-nls \
  41.     --without-gnutls \
  42.     --without-libnettle \
  43.     --without-libgmp \
  44.     --without-libgcrypt \
  45.     --without-libexpat \
  46.     --without-libcares \
  47.     --without-sqlite3 \
  48.     --with-openssl \
  49.     --with-libxml2 \
  50.     --with-libz
  51.        
  52. CONFIGURE_VARS += \
  53.     ZLIB_CFLAGS="-I$(STAGING_DIR)/usr/include" \
  54.     ZLIB_LIBS="-L$(STAGING_DIR)/usr/lib"
  55.        
  56. define Package/aria2/install
  57.     $(INSTALL_DIR) $(1)/usr/bin
  58.     $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aria2c $(1)/usr/bin
  59. endef
  60.        
  61. $(eval $(call BuildPackage,aria2))
在feeds目录下面找到packages.index索引文件,添加aria2源码索引记录
双击打开packages.index,在任意位置添加如下代码
  1. Source-Makefile: feeds/packages/net/aria2/Makefile
  2. Package: aria2
  3. Submenu: File Transfer
  4. Version: 1.17.1-1
  5. Depends: +libc +USE_EGLIBC:librt +USE_EGLIBC:libpthread +libopenssl +zlib +libxml2 +libstdcpp
  6. Menu-Depends: 
  7. Provides: 
  8. Section: net
  9. Category: Network
  10. Title: lightweight download utility
  11. Maintainer: OpenWrt Developers Team <openwrt-devel@openwrt.org>
  12. Source: aria2-1.17.1.tar.bz2
  13. Type: ipkg
  14. Description: aria2 is a lightweight multi-protocol & multi-source command-line download
  15.  utility
  16. http://aria2.sourceforge.net/
  17. OpenWrt Developers Team <openwrt-devel@openwrt.org>
  18. @@
到这里aria2算是添加完了,用命令还可以使用,没luci界面是有点不方便,下面完美来添加luci-aria2
添加luci-aria2
文章末有我上传的luci-aria2的源码文件,下载下来后放到你的luci响应的目录,版本不宜样目录可能不宜样
trunk版本为例
把luci-aria2这个文件夹放进/trunk/feeds/luci/applications/这个目录里面
然后在trunk/feeds/目录下找到luci.index 这个索引文件,打开在任意位置添加如下代
  1. Package: luci-app-aria2 
  2. Submenu: 3. Applications 
  3. Version: 0.11+svk-1
  4. Depends: +libc +USE_EGLIBC:librt +USE_EGLIBC:libpthread +PACKAGE_luci-app-aria2:aria2 
  5. Menu-Depends: 
  6. Provides: 
  7. Build-Depends: lua/host 
  8. Section: luci 
  9. Category: LuCI 
  10. Title: aria2 configuration module 
  11. Maintainer: LuCI Development Team <luci@lists.subsignal.org> 
  12. Source: 
  13. Type: ipkg 
  14. Description: aria2 configuration module http://luci.subsignal.org/ LuCI Development Team <luci@lists.subsignal.org> 
  15.   
  16. @@
保存退出即可
到这里就集成完了
最后在终端执行
  1. ./scripts/feeds install -a
  2. make menuconfig

make menuconfig

就可以在luci>3. Applications 找到luci-app-aria2了

(7)-添加fullflash分区,uboot、art分区可写

修改target/linux/ar71xx/files/drivers/mtd/tplinkpart.c

  1. #define TPLINK_NUM_PARTS      5
改为
  1. #define TPLINK_NUM_PARTS 6

(即在原有的数值上加1)

然后在文件中找到以下内容

  1. parts[0].name = "u-boot";
  2.     parts[0].offset = 0;
  3.     parts[0].size = offset;
  4.     parts[0].mask_flags = MTD_WRITEABLE;
  5.     parts[1].name = "kernel";
  6.     parts[1].offset = offset;
  7.     parts[1].size = rootfs_offset - offset;
  8.     parts[2].name = "rootfs";
  9.     parts[2].offset = rootfs_offset;
  10.     parts[2].size = art_offset - rootfs_offset;
  11.     parts[3].name = "art";
  12.     parts[3].offset = art_offset;
  13.     parts[3].size = TPLINK_ART_LEN;
  14.     parts[3].mask_flags = MTD_WRITEABLE;
  15.     parts[4].name = "firmware";
  16.     parts[4].offset = offset;
  17.     parts[4].size = art_offset - offset
在 parts[4].size = art_offset - offset 后面换一行,添加这段
  1. parts[5].name = "fullflash";
  2. parts[5].offset = 0;
  3. parts[5].size = master->size

uboot、art分区可写,目的是使用ttl刷新uboot、art

注释掉  parts[0].mask_flags = MTD_WRITEABLE;


(8)-顶部菜单添加按钮

比如在顶部菜单添加释放内存按钮


修改/modules/admin-full/luasrc/controller/admin/index.lua


+        entry({"admin", "Free_Memory"}, call("Free_Memory"), _("Free Memory"), 81)


+function Free_Memory()  

+  

+ luci.util.exec("echo 3 > /proc/sys/vm/drop_caches")  

+ luci.http.redirect(luci.dispatcher.build_url("admin", "status", "overview"))  

+end

0 0
原创粉丝点击