编译HG255D的openwrt固件

      因trunk版本每天都有变动,所以先如下说明:openwrt源码是2014年5月21日,从svn co svn://svn.openwrt.org/openwrt/trunk/下载。版本r40804。

      去年年底从X宝JS那花100多(这也是学费,现在要是折腾就自己买个二手的自己改装)买的改装后的华为HG255D路由,flash 16M,内存32M*2,刷的是openwrt-dreambox固件。没入手CH341A编程器前一直都不敢对路由器太大折腾。虽说里面uboot是lintel不死uboot,但还是担心变砖。入手编程器以后,就决定自己为hg255d编译openwrt固件(后来拆了hg255d一看,才知道想法太天真了,hg255d用的不是普通的8、16脚flash)。

      openwrt没法直接编译出HG255D路由器的固件,虽然在make menuconfig选择HG255D路由后,make V=s编译后并没有出现openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin升级固件。找到一些资料是说:

HG255D原版的无线校正数据(“eeprom”)在flash的最后128 KiB。
eeprom除了MAC地址还有无线频率校正、每通道功率控制之类的数据,如果eeprom被擦除又没有备份的话无线就起不来了。
eeprom每个路由器都不同,从其他机器上拷贝一个过来用的话无线通信效果会劣化。
Openwrt在HG255D上启动后会到/lib/firmware下找soc_wmac.eeprom文件,
如果找不到的话就试图从Flash的factory区读取出来,如果读取失败的话wifi无法启动。
openwrt官方的版本只在lintel u-boot上测试过,如果刷在带原厂u-boot的HG255D上会擦除无线校正数据(factory),这很严重。
原版的布局是,前128k是uboot,最后128k是factory(0xfa0000开始),中间的是firmware,firmware的前1M是kernel,后面就是rootfs了。

要编译出HG255D升级固件,需要做如下改动:

1、打开对HG255D板的支持
在target/linux/ramips/image/Makefile中,去掉下面两行行首的#,增加对HG255D编译的支持(用HG255D搜索即可)

Image/Build/Profile/HG255D=$(call BuildFirmware/Default16M/$(1),$(1),hg255d,HG255D)
$(call Image/Build/Profile/HG255D,$(1))


2、使用原机的mac地址
其实源代码里面提供了对原来mac地址的读取,但是脚本有点问题
在target/linux/ramips/base-files/lib/ramips.sh中查找HG255D,能查到如下代码
*"HG255D")                                
		name="hg255d"
		;;
将其中的"HG255D"修改为"HuaWei HG255D",如下
*"HuaWei HG255D")                                
		name="hg255d"
	;;
然后在target/linux/ramips/base-files/lib/preinit/06_set_iface_mac中查找freestation5,在查找到的这行下面加入HG255D对应的代码,如下:
freestation5 |\
	hg255d |\
	hlk-rm04 |\

3、改电源指示灯不能正常工作的问题
修改target/linux/ar71xx/base-files/etc/diag.sh,找到:
hlk-rm04)
		status_led="hlk-rm04:red:power"
		;;
其下添加
hg255d)
		status_led="hg255d:power"
		;;

以上是需要修改的。下面列的是可选修改的:


4、修改缺省lan ip
修改package/base-files/files/lib/functions/uci-defaults.sh中

set network.lan.ipaddr='192.168.1.1'
中的地址为你想要的地址,我的没改。

5、打开wlan的支持,并添加无线密码12345678
修改package/kernel/mac80211/files/lib/wifi/mac80211.sh中

option disabled 1

option disabled 0
在config wifi-iface节添加wifi密码(none改成psk2,并加一条密码12345678)
option encryption 'psk2'
	option key '12345678'

如果需要加入万能桥接可再添加如下配置:
config wifi-iface
	option network 'wwan'
	option ssid 'TP-LINK_1234'		#被桥接的wifi的SSID
	option encryption 'psk2'		#被桥接的wifi的加密方式
	option device 'radio0'
	option mode 'sta'			#工作模式 客户端Client
	option bssid '11:22:33:44:55:66'	#被桥接的wifi的MAC地址
	option key '111222333'		#被桥接的wifi的密码


6、缺省使用中文(当然先要安装luci的中文模块)
修改feeds/luci/libs/web/root/etc/config/luci中(注trunk r41302发现这个文件被移动到feeds/luci/modules/base/root/etc/config/luci)
在config internal languages下增加下面两行

option zh_cn 'chinese'
	option en 'English'

并将config core main中修改为 

option lang zh_cn



7、修改默认主题
修改feeds/luci/libs/web/root/etc/config
在config core main下找到:

option mediaurlbase /luci-static/openwrt.org
可根据需要将openwrt.org修改为Bootstap、openwrtcn、freifunk-bno、freifunk-generic


8、添加root帐号密码
修改package/base-files/files/etc/shadow文件
root::0:0:99999:7:::
改成(密码是admin)
root:$1$21u5EotL$B9ebsVgEQe.C7lsk0iMf10:0:0:99999:7:::
注:生成加密的密码字段的方法:
方法一(交互式)
命令格式: openssl passwd -1 -salt $(< /dev/urandom tr -dc '[:alnum:]' | head -c 32)
Password:    # input your password here 
$1$MZrDxgEw$i2XBgmDMo0Wf1.OVvOGGQ1
 
方法二(适用于脚本)
命令格式: echo "xansun" | openssl passwd -1 -salt $(< /dev/urandom tr -dc '[:alnum:]' | head -c 32) -stdin 
$1$KsRJO8kG$M9co4G7T6.5KcITsSCRNS/

方法三
以下命令可得到加密后的字符串,zz为密码
命令格式: perl -e ’   print   crypt("zz","\$1\$acQMceF9\$"),"\n"     ’ 
$1$acQMceF9$1SaCpG2qiKKA3eGolU4Fp0

9、修改主机名,设定时区
修改package/base-files/files/etc/config/system
config system
	option hostname 'OpenWrt'
	option conloglevel '8'
	option cronloglevel '8'
	option zonename '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 hostname Openwrt 设定主机名
option zonename Asia/Shanghai 时区设置为亚洲/上海
option timezone CST-8 正8区

list server 就是ntp服务器了。


make menuconfig可选软件包(按自己需要选择):

添加USB挂载
Base system-->block-mount
添加磁盘格式支持
Kernel modules-->Filesystems-->kmod-fs-ext4
Kernel modules-->Filesystems-->kmod-fs-msdos
Kernel modules-->Filesystems-->kmod-fs-ntfs
Kernel modules-->Filesystems-->kmod-fs-vfat
语言支持
Kernel modules-->Native Language Support-->kmod-nls-utf8
网络支持
Kernel modules-->Network Support-->kmod-pppol2tp
Kernel modules-->Network Support-->kmod-pptp
USB支持
Kernel modules-->USB Support-->kmod-usb-hid
Kernel modules-->USB Support-->kmod-usb-printer
Kernel modules-->USB Support-->kmod-usb-serial  #usb转串口
Kernel modules-->USB Support-->kmod-usb-serial-cp210x
Kernel modules-->USB Support-->kmod-usb-serial-pl2303
Kernel modules-->USB Support-->kmod-usb-storage
Kernel modules-->USB Support-->kmod-usb-storage-extras
Kernel modules-->USB Support-->kmod-usb2

Video(挂载摄像头)

Kernel modules-->Video Support-->kmod-video-core
Kernel modules-->Video Support-->kmod-video-cpia2
Kernel modules-->Video Support-->kmod-video-gspca-core
Kernel modules-->Video Support-->kmod-video-pwc
Kernel modules-->Video Support-->kmod-video-sn9c102
Kernel modules-->Video Support-->kmod-video-uvc
Kernel modules-->Video Support-->kmod-video-videobuf2

无线驱动

Kernel modules-->Wireless Drivers-->kmod-rt2800-usb
Kernel modules-->Wireless Drivers-->kmod-rt73-usb
Kernel modules-->Wireless Drivers-->kmod-rtl8187
添加libffmpeg-mini支持ushare需要
Libraries-->libffmpeg-mini
LUCI
LuCI-->Collections-->luci
LuCI-->Applications-->luci-app-ddns
LuCI-->Applications-->luci-app-hd-idle
LuCI-->Applications-->luci-app-multiwan
LuCI-->Applications-->luci-app-ntpc
LuCI-->Applications-->luci-app-p910nd
LuCI-->Applications-->luci-app-qos
LuCI-->Applications-->luci-app-samba
LuCI-->Applications-->luci-app-tinyproxy
LuCI-->Applications-->luci-app-upnp
LuCI-->Applications-->luci-app-ushare
LuCI-->Applications-->luci-app-wol
LuCI-->Themes-->luci-theme-openwrt
LuCI-->Translations-->luci-i18n-chinese

Multimedia

Multimedia-->mjpg-streamer

Network 

Network-->File Transfer-->aria2
Network-->Printing-->cups-locale-zh
Network-->VPN-->pptpd
Network-->wireless-->aircrack-ng
Network-->wireless-->aircrack-ptw
Network-->wireless-->reaver
Network-->wireless-->xsupplicant
Utilities 
Utilities-->Filesystem-->badblocks	#自动挂载工具
Utilities-->Filesystem-->mkdosfs
Utilities-->Filesystem-->ntfs-3g	#ntfs读写
Utilities-->disc-->fdisk	#分区工具
Utilities-->disc-->blkid        #可以列出分区类型卷标等
Utilities-->disc-->lsblk        #列出块设备,还能显示他们之间的依赖关系
Utilities-->lrzsz		#上传下载工具
Utilities-->restorefactory	#reset键支持(长按5秒以上就可以恢复固件默认设置)
Utilities-->usbreset
Utilities-->usbutils    #lsusb支持
Utilities-->wifitoggle	#添加一键开关无线(按一下WPS键放开无线就打开或者关闭)


最后make V=s,等待编译完成生成hg255d固件。

转载于:https://my.oschina.net/osbin/blog/278782

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
华为HG255D刷机工具及固件大全,全套共计,40个固件,最新的神雕、博爱固件,内附刷机教程,亲测可用! 文件目录: ├ │ ├0508-openwrt-ramips-rt305x-hg255d-squashfs-By_shcl.bin │ ├1102-0x20000_hg255d-squashfs-tftp.checksum2.bin │ ├httpd-uboot.bin │ ├ralink.bin │ ├tftp.exe │ ├tftp2.exe │ ├Tftpd32.exe │ ├tftpd-uboot.bin │ ├u-boot-web.bin │ ├WinHex.exe │ ├不拆机更换HG255D的U-BOOT并刷OPENWRT.doc │ └固件IP.txt ├ │ ├(电信原版u-boot)h255d_tel_uboot.bin │ ├适合于电信原本的uboot的OpenWrt固件-.rar │ ├ │ │ ├新建 Microsoft Word 文档.doc │ │ ├ │ │ │ ├HG255d35.bin │ │ │ ├HG255dV100R001C01B035版本本地升级指导书.dot │ │ │ ├新建 文本文档.txt │ │ │ └中国升级页面.html ├ │ ├0219openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├0702-DreamBox-ramips-rt305x-hg255d-squashfs-tftp.bin │ ├0909-DreamBox-ramips-rt305x-hg255d-squashfs-litel.bin │ ├1019-DreamBox-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├1119-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├1123-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├1128-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├1201-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├1204-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├1226-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade (1).bin │ ├131028-石像鬼-hg255d-by可乐.bin │ ├140708-纯净版-Flash_16M_openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├20121029-Dreambox-ralink-hg255d-squashfs-Alpha.bin │ ├2013-08-03-0840-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├2013-08-04-0920-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade.bin │ ├20130822-openwrt-hg255d-PIN码专用.bin │ ├2013-10-26-1538-openwrt-ramips-rt305x-hg255d-squashfs-sysupgrade多功能版.bin │ ├20131101-1615-op-hg255d-by可乐.bin │ ├HG255D dd-wrt固件.bin │ ├HG255D博爱固件-2015.bin │ ├OP-0402-Gargoyle.zip │ ├OP-0413汉化-Gargoyle初始密码 password .zip │ ├OP-0828迷你版.bin │ ├OP-最新版0413-Gargoyle初始密码 password .zip │ ├PandoraBox-ralink-hg255d-r189-20141020(hg255d
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值