|
本帖最后由 yumeimm 于 2019-4-11 20:38 编辑
1. 前言
OpenWrt以开源,支持设备多,第三方package多而闻名。想要什么功能,找个*.ipk, 然后 opkg install *.ipk就好。
国内的很多做路由的公司,都是基于openwrt修改而来(按道理,这些公司的系统应该也开源,然而没有)。
QCA9558之类的路由,例如:MW450R V1 =FW450R V1 = 880N V1= 881N V1 = 941N V7 = 2041N V2 等等,很早就有Gabor Juhos / hackpascal (感谢hackpascal )等写的驱动程序,以及后续lean等修改。
使用lean的代码(感谢lean),或者集成进OpenWrt官方的代码,然后编译出相应的固件,都不是很困难。
具体可看看我写的这两贴:
lean的源代码编译的2041N v2固件: https://www.right.com.cn/forum/f ... 51934&highlight=941
OpenWrt官方master分支编译固件: https://www.right.com.cn/forum/f ... 54267&highlight=941
但是OpenWrt官方的代码为什么没有集成进去呢? 我在网上搜了一下,找到了一些内容,特写出来供网友看看~~
2. 向OpenWrt的官方提交
其实向官方提交支持的pull request已经有了两次,一次是#1444, 一次是#1481。
第一次提交:#1444: https://github.com/openwrt/openwrt/pull/1444
第二次提交 #1481: https://github.com/openwrt/openwrt/pull/1481
提交者都是 imbrolla (感谢辛苦付出), 没有通过的原因,可以由上述链接看到原因。这里简单说一下:
第一次提交未通过,是因为需要按照Openwrt提交的格式进行提交,具体可看这里Submitting Patches。简单说,就是把所有的多次commit合并为一次commit, 然后commit 需要signoff。另外需要详细的描述提交的内容,包括适应的体系结构,等等。
第二次提交,这些问题应该都没有了。但是有两个主要问题:
1) 对源代码(mach-tl-wr941n-v7.c)的操作有疑义,英文如下:
The factory U-boot of this device (In fact, on all QCA device with an FE switch) will set MDIO_MASTER_EN bit to 1, which enabled the on-switch mdio master but also disallow the direct access to switch PHYs, resulting in the inability to read PHY ID from GMAC MDIO on SoC.
ar8216 on OpenWrt is introduced long time ago when there is no mdio device framework in kernel. It's probed using the PHY framework and current probing method requires an available PHY ID, which in this case isn't possible before setting MDIO_MASTER_EN to 0.
A proper way of solving this problem is writing a new probing procedure using the mdio-device framework currently available in kernel, which registers a device directly without needing the access to an PHY ID and we can do a switch reset after that in the switch driver.
As for the dirty way here, the machine initialization code alter a switch soft reset by directly accessing mdio registers of GMAC0 and send mdio instructions before the probing of mdio driver, doing what shouldn't be done by machine initialization code and introducing a piece of messy and duplicated code into the target.
它的意思大概是说:
a) 提交的代码中,重启/启动ar8236交换机的方法,采用直接访问mdio寄存器的方式
涉及到的主要是这两个函数:
static unsigned int __init athrs27_reg_read(unsigned int s27_addr)
{...}
static void __init ar8236_reset(void)
{...}
b) 这种方式,在新的内核模式下,不应该出现了。现在内核已经有了mdio框架支持
c) 使用内核提供的mdio框架,写一个探测模块然后再初始化ar8236就可以。
2) ar71xx/ath79架构,太久了,估计很难再接受新设备加入。(可能而已)
如果上述源代码问题解决,应该还是有可能合并入官方代码。
3. 总结
官方已经加入941n-v7:https://github.com/openwrt/openwrt/pull/1755/files
经过上述分析,可以看到,要加入官方代码,估计有点困难了。综合起来有很多原因:
首先 架构太老,旧路由性能不行,而且flash存储太小,基本是2M/4M居多, 合并入现在的官方代码,编译出的固件往往超过4M。导致需要硬改flash才能刷入。
其次,驱动尽管hackpascal 已经写了,但是openwrt已经往前发展,旧有的代码不太适合,而且没有大神继续维护。(当然对我们普通人,能用就行,代码规不规范不是关注点)。
最后,要这些旧路由发挥余热,那就用别人编译的吧,或者lean维护的代码,或者维护一个和openwrt同步的官方代码,但是加入这些老路由的支持也可以。
|
|