小米路由器Openwrt固件修改代码超频至1100MHZ

William
2020-09-02 / 0 评论 / 146 阅读 / 正在检测是否收录...

推荐4.14内核,v2瑞性能是最好的,比新内核5.4强40%

更换内核方法:打开LEDE目录/target/linux/ramips/Makefile
KERNEL_PATCHVER:=4.14
KERNEL_TESTING_PATCHVER:=4.14

Lean的内核4.14的源码包下载在openwrt目录,设置在ledetargetlinuxramipspatches-4.14102-mt7621-fix-cpu-clk-add-clkdev.patch文件,通过设置CPU频率寄存器,可以提升MT7621的频率

修改一: 第68行,即下方第4行高亮代码

#define MT7621_GPIO_MODE_UART1              1
#define MT7621_GPIO_MODE_I2C                2
#define MT7621_GPIO_MODE_UART3_MASK         0x3
@@ -113,49 +113,93 @@ static struct rt2880_pmx_group mt7621_pi
         { 0 }
};

修改二,第113和156-160行

+void __init ralink_clk_init(void)
+{
+        u32 syscfg, xtal_sel, clkcfg, clk_sel, curclk, ffiv, ffrac;
+        u32 pll, prediv, fbdiv;
// 下面一行,后面加了 i
+        u32 xtal_clk, cpu_clk, bus_clk,i;
+        const static u32 prediv_tbl[] = {0, 1, 2, 2};
+
+        syscfg = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG0);
+        xtal_sel = (syscfg >> XTAL_MODE_SEL_SHIFT) & XTAL_MODE_SEL_MASK;
+
+        clkcfg = rt_sysc_r32(SYSC_REG_CLKCFG0);
+        clk_sel = (clkcfg >> CPU_CLK_SEL_SHIFT) & CPU_CLK_SEL_MASK;
+
+        curclk = rt_sysc_r32(SYSC_REG_CUR_CLK_STS);
+        ffiv = (curclk >> CUR_CPU_FDIV_SHIFT) & CUR_CPU_FDIV_MASK;
+        ffrac = (curclk >> CUR_CPU_FFRAC_SHIFT) & CUR_CPU_FFRAC_MASK;
+
+        if (xtal_sel <= 2)
+                xtal_clk = 20 * 1000 * 1000;
+        else if (xtal_sel <= 5)
+                xtal_clk = 40 * 1000 * 1000;
+        else
+                xtal_clk = 25 * 1000 * 1000;

         switch (clk_sel) {
         case 0:
-                clk_sts = rt_sysc_r32(SYSC_REG_CUR_CLK_STS);
-                cpu_fdiv = ((clk_sts >> 8) & 0x1F);
-                cpu_ffrac = (clk_sts & 0x1F);
-                cpu_clk = (500 * cpu_ffrac / cpu_fdiv) * 1000 * 1000;
+                cpu_clk = 500 * 1000 * 1000;
                 break;
-
         case 1:
-                fbdiv = ((rt_sysc_r32(0x648) >> 4) & 0x7F) + 1;
-                syscfg = rt_sysc_r32(SYSC_REG_SYSCFG);
-                xtal_mode = (syscfg >> 6) & 0x7;
-                if (xtal_mode >= 6) {
-                        /* 25Mhz Xtal */
-                        cpu_clk = 25 * fbdiv * 1000 * 1000;
-                } else if (xtal_mode >= 3) {
-                        /* 40Mhz Xtal */
-                        cpu_clk = 40 * fbdiv * 1000 * 1000;
-                } else {
-                        /* 20Mhz Xtal */
-                        cpu_clk = 20 * fbdiv * 1000 * 1000;
-                }
+                pll = rt_memc_r32(MEMC_REG_CPU_PLL);
// 加了下面4行
+               pll &= ~(0x7ff);
+               pll |=  (0x362);
+               rt_memc_w32(pll,MEMC_REG_CPU_PLL);
+               for(i=0;i<1024;i++);
+                fbdiv = (pll >> CPU_PLL_FBDIV_SHIFT) & CPU_PLL_FBDIV_MASK;
+                prediv = (pll >> CPU_PLL_PREDIV_SHIFT) & CPU_PLL_PREDIV_MASK;
+                cpu_clk = ((fbdiv + 1) * xtal_clk) >> prediv_tbl[prediv];
                 break;

将原代码改为上面红色字体三行代码,其中"0x362"这个位置的值,对应的是1100Mhz的频率设置
频率设置值的换算如下,
0x362 =
1100Mhz/20Mhz -1 = 54
54*16+2 = 866
866转为十六进制就是0x362
相应的,
1000Mhz--0x312
1200Mhz--0x3B2

保存文件,重新编译,之前最好是能编译成功一次
make clean(一定要这个清除命令否则改动不会编译进去)
make -j1 V=s (如果之前已经成功编译过,可以用多线程编译)

openssl加解密性能测试
进入ssh,输入下面命令测试
openssl speed -evp aes-128-gcm
测试结果
Openwrt超频1100Mhz,以1024字节为例是8887k

880Mhz1100Mhz
Openwrt7112k8887k
Pandavan6217k7768k

aes-128-gcm测试成绩从原来的6209k/s提升到7768k/s,性能提升25%
Openwrt用的4.14内核,效能比Padavan3.4内核好很多

油管,Trojan能跑到50mpbs,强烈推荐MT7621跑trojan

油管性能测试对比

880Mhz1100Mhz
Openwrt18mbps22mbps
Pandavan13mbps16mbps

此方法不光对小米路由AC2100有效,对MT7621的路由器应该都有效。

0

评论 (0)

取消