openwrt编译修改固件
转载自:http://blog.chinaunix.net/uid-25631578-id-4009228.html
(1)-编译703_8M固件
1. target/linux/ar71xx/image/Makefile
- $(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
- .id = “TL-WR703Nv1″,
- .hw_id = HWID_TL_WR703N_V1,
- .hw_rev = 1,
- .layout_id = “4Mlzma”,
(2)-修改默认WIFI,添加WIFI配置,WIFI名为MAC后六位
修改package/kernel/mac80211/files/lib/wifi/mac80211.sh
option disabled 1改成0,默认开启wifi。
option disabled 0下添加
- option htmode HT40+
- option channel 1
- option country CN
- option noscan 1
- option txpower 17
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:
- config wifi-iface
- option device radio$devidx
- option network lan
- option mode ap
- option ssid OpenWrt_$(cat /sys/class/ieee80211/${dev}/macaddress|awk -F ":" '{print $4""$5""$6 }'| tr a-z A-Z)option encryption none
- 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
- root:$1$wEehtjxj$YBu4quNfVUjzfv8p/PBo5.:0:0:99999:7:::
(4)-修改路由连接数,优化网络参数
修改路由连接数,优化网络参数
连接数默认情况下是1.6万多吧。可以选择性修改。
修改sysctl.conf文件,位于package/base-files/files/etc/
- net.netfilter.nf_conntrack_max=65535
(5)-默认中文,修改主机名,添加并修改默认主题,设定时区
默认中文,添加并默认主题
修改feeds/luci/libs/web/root/etc/config
- option lang auto
改为
- option lang zh_cn
- config internal languages
- option en 'English'
- option zh_cn 'chinese'
添加主题
1.首先打开trunk/feeds/luci/themes这个目录,你会发现里面有很多主题(除了base为基础包外)每一个文件夹就
是一个主题
2.我们得修改makefile文件,使其制定编译的时候能找到openwrtcn这个主题
找到路径为trunk/feeds/luci/contrib/package/luci下面的makefile文件双击打开
搜索OpenWrt.org这样很快就定位到添加主题的地方了,在下面空白处增加一句
效果如下
- $(eval $(call theme,base,Common base for all themes))
- $(eval $(call theme,openwrt,OpenWrt.org ))
- $(eval $(call theme,bootstrap,Bootstrap Theme))
- $(eval $(call theme,openwrtcn,openwrtcn Theme (default),,,1))
-
- $(eval $(call theme,freifunk-bno,Freifunk Berlin Nordost Theme,\
- Stefan Pirwitz <stefan-at-freifunk-bno-dot-de>))
-
- $(eval $(call theme,freifunk-generic,Freifunk Generic Theme,\
- Manuel Munz <freifunk-at-somakoma-dot-de>))
保存退出即可。
修改默认主题
修改feeds/luci/libs/web/root/etc/config
- option mediaurlbase /luci-static/openwrt.org
可根据需要将openwrt.org修改为Bootstap、openwrtcn、freifunk-bno、freifunk-generic
修改主机名,设定时区
修改package/base-files/files/etc/config/system
- config system
- option conloglevel 8
- option cronloglevel 8
- option hostname Openwrt
- option timezone Asia/Shanghai
- option timezone CST-8
- config timeserver ntp
- list server 0.openwrt.pool.ntp.org
- list server 1.openwrt.pool.ntp.org
- list server 2.openwrt.pool.ntp.org
- list server 3.openwrt.pool.ntp.org
- option enable_server 0
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
- sudo apt-get update
- sudo apt-get install autoconf automake libcppunit-dev autopoint openssl libtool sphinx-common sphinxsearch libgcrypt11-dev libxml2-dev pkg-config
- md5sum /……/……/trunk/dl/aria2-1.17.1.tar.bz2 省略好代表openwrt的源码的路径补全,回车就能获取md5码,记住用用的
- #
- # Copyright (C) 2012 OpenWrt.org
- #
- # This is free software, licensed under the GNU General Public License v2.
- # See /LICENSE for more information.
- #
- include $(TOPDIR)/rules.mk
-
- PKG_NAME:=aria2 名字
- PKG_VERSION:=1.17.1
- PKG_RELEASE:=1
-
- PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
- PKG_SOURCE_URL:=
- PKG_MD5SUM:=86229ef8d289893934cb3af25c8fddf6
- PKG_INSTALL:=1
-
- include $(INCLUDE_DIR)/package.mk
-
- define Package/aria2
- SECTION:=net
- CATEGORY:=Network
- SUBMENU:=File Transfer
- TITLE:=lightweight download utility
- URL:=http://aria2.sourceforge.net/
- DEPENDS:=+libopenssl +zlib +libxml2 +libstdcpp \
- $(INTL_DEPENDS) $(ICONV_DEPENDS)
- endef
-
- define Package/aria2/description
- aria2 is a lightweight multi-protocol & multi-source command-line download
- utility
- endef
-
- define Package/aria2/conffiles
- /etc/config/aria2
- endef
-
- CONFIGURE_ARGS += \
- --disable-nls \
- --without-gnutls \
- --without-libnettle \
- --without-libgmp \
- --without-libgcrypt \
- --without-libexpat \
- --without-libcares \
- --without-sqlite3 \
- --with-openssl \
- --with-libxml2 \
- --with-libz
-
- CONFIGURE_VARS += \
- ZLIB_CFLAGS="-I$(STAGING_DIR)/usr/include" \
- ZLIB_LIBS="-L$(STAGING_DIR)/usr/lib"
-
- define Package/aria2/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aria2c $(1)/usr/bin
- endef
-
- $(eval $(call BuildPackage,aria2))
双击打开packages.index,在任意位置添加如下代码
- Source-Makefile: feeds/packages/net/aria2/Makefile
- Package: aria2
- Submenu: File Transfer
- Version: 1.17.1-1
- Depends: +libc +USE_EGLIBC:librt +USE_EGLIBC:libpthread +libopenssl +zlib +libxml2 +libstdcpp
- Menu-Depends:
- Provides:
- Section: net
- Category: Network
- Title: lightweight download utility
- Maintainer: OpenWrt Developers Team <openwrt-devel@openwrt.org>
- Source: aria2-1.17.1.tar.bz2
- Type: ipkg
- Description: aria2 is a lightweight multi-protocol & multi-source command-line download
- utility
- http://aria2.sourceforge.net/
- OpenWrt Developers Team <openwrt-devel@openwrt.org>
- @@
文章末有我上传的luci-aria2的源码文件,下载下来后放到你的luci响应的目录,版本不宜样目录可能不宜样
- Package: luci-app-aria2
- Submenu: 3. Applications
- Version: 0.11+svk-1
- Depends: +libc +USE_EGLIBC:librt +USE_EGLIBC:libpthread +PACKAGE_luci-app-aria2:aria2
- Menu-Depends:
- Provides:
- Build-Depends: lua/host
- Section: luci
- Category: LuCI
- Title: aria2 configuration module
- Maintainer: LuCI Development Team <luci@lists.subsignal.org>
- Source:
- Type: ipkg
- Description: aria2 configuration module http://luci.subsignal.org/ LuCI Development Team <luci@lists.subsignal.org>
-
- @@
- ./scripts/feeds install -a
- make menuconfig
make menuconfig
就可以在luci>3. Applications 找到 luci-app-aria2了(7)-添加fullflash分区,uboot、art分区可写
修改target/linux/ar71xx/files/drivers/mtd/tplinkpart.c
- #define TPLINK_NUM_PARTS 5
- #define TPLINK_NUM_PARTS 6
(即在原有的数值上加1)
然后在文件中找到以下内容
- parts[0].name = "u-boot";
- parts[0].offset = 0;
- parts[0].size = offset;
- parts[0].mask_flags = MTD_WRITEABLE;
- parts[1].name = "kernel";
- parts[1].offset = offset;
- parts[1].size = rootfs_offset - offset;
- parts[2].name = "rootfs";
- parts[2].offset = rootfs_offset;
- parts[2].size = art_offset - rootfs_offset;
- parts[3].name = "art";
- parts[3].offset = art_offset;
- parts[3].size = TPLINK_ART_LEN;
- parts[3].mask_flags = MTD_WRITEABLE;
- parts[4].name = "firmware";
- parts[4].offset = offset;
- parts[4].size = art_offset - offset
- parts[5].name = "fullflash";
- parts[5].offset = 0;
- 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)