温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何编译HG255D的openwrt固件

发布时间:2021-12-18 11:32:08 来源:亿速云 阅读:410 作者:小新 栏目:互联网科技

小编给大家分享一下如何编译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固件。

看完了这篇文章,相信你对“如何编译HG255D的openwrt固件”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI