OpenWrt Forum Archive

Topic: RT5350 WiFI terrible performance for CC and newer.

The content of this topic has been archived on 25 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello All,

Has anyone else experienced issues with WiFi performance on RT5350 using CC stable 15.05 and latest trunk(r47806)?

here is my experience...

get latest trunk.
configured rt5350 generic build for Poray M4-8M (the unit I happen to be working with)
build using all defaults to create a generic system for testing wifi
enable wifi by editing /etc/config/wireless
scp a file...

the file transfer starts but after about 150K stops.  ssh to the box works but very sluggish.

If I go back to r36813 (pre mt7620 support).  And follow the above procedure the WiFi works great.   I can transfer files with scp without issue and login via SSH is snappy.

I suspect that adding support for the MT7620 has broken something in the RT5350 WiFi.   

Has anyone else experienced any issues similar to these?  Any idea how to go about fixing this? all hints are appreciated.

Thanks,

--luis

here is more...

don't ask me how i discovered this but deleting this patch
target/linux/ramips/patches-3.18/0011-MIPS-ralink-add-rt2880-wmac-clock.patch

fixes the wifi on my rt5350 system.  Rebuilding the system I get very nice wifi performance
root@OpenWrt:/tmp# scp axcel@192.168.0.101:latest.d/exp-m4.bin .
Login for axcel@192.168.0.101
Password:
exp-m4.bin                                    100% 5888KB   1.2MB/s   00:05   

this same file will NOT transfer when the patch is present.  I only get 150K before the transfer halts.

So the $64K question is... why does this

From bf4f5250117cd65a78903b8ce302499806416ed1 Mon Sep 17 00:00:00 2001
From: John Crispin <blogic@openwrt.org>
Date: Mon, 4 Aug 2014 09:52:22 +0200
Subject: [PATCH 11/57] MIPS: ralink: add rt2880 wmac clock

Signed-off-by: John Crispin <blogic@openwrt.org>
---
arch/mips/ralink/rt288x.c |    3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--- a/arch/mips/ralink/rt288x.c
+++ b/arch/mips/ralink/rt288x.c
@@ -76,7 +76,7 @@ struct ralink_pinmux rt_gpio_pinmux = {

void __init ralink_clk_init(void)
{
-    unsigned long cpu_rate;
+    unsigned long cpu_rate, wmac_rate = 40000000;
    u32 t = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG);
    t = ((t >> SYSTEM_CONFIG_CPUCLK_SHIFT) & SYSTEM_CONFIG_CPUCLK_MASK);

@@ -101,6 +101,7 @@ void __init ralink_clk_init(void)
    ralink_clk_add("300500.uart", cpu_rate / 2);
    ralink_clk_add("300c00.uartlite", cpu_rate / 2);
    ralink_clk_add("400000.ethernet", cpu_rate / 2);
+    ralink_clk_add("480000.wmac", wmac_rate);
}

void __init ralink_of_remap(void)


break RT5350 WiFi?

So interestingly, the file rt288x.c which is the basis of that patch doesnt even get built for rt5350.  rt5350 uses rt305x.c as the basis for its build so I suspect that is not the actual problem.

In my case, when wireless reception is flawless, I get excellent performance but as the RF environment degrades, the performance suffers considerably.  The performance degradation is not in line with the environment.

Furthermore, when rt5350 is connected as a station, I NEVER see bitrates above 54 mbps in 802.11n HT mode.
The same is not true for running the chip as a wireless access point.

I am experiencing a similar issue and I am rolling back to Openwrt BB to verify your observations.   Do you have any other information that might be helpful?

Thanks for replying... We would like to get this fixed so that we can move to CC... in the mean time we just rolled back to an early version of BB (r36813) which has been working fine for a long time.

What is the significance of 36813?  is that the commit hash?

Please let me know how I can specifically build r36813.  Thanks

(Last edited by mskeff on 17 May 2017, 23:09)

r36813 is the svn commit version number...  it corresponds to git

commit 2dfa092d52ab24ba1e432b5b0a5d61ed2472531b
Author: nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date:   Fri May 31 15:42:23 2013 +0000


    usbmode: fix hotplug script name
   
    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
   
    git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36813 3c298f89-4303-0410-b956-a3cf2f4a3e73

Soooo. I don't know from where to start, but I will try. I have a bunch of garbage D-link go-rt-n150 (rt5350f) radios and out of curiosity I've decided to upgrade the stock 8MB RAM and 2MB flash. So far so good. I ended up with 32MB RAM and 4MB flash (at that moment I did not mange to find 8 or 16). For openwrt I choose DIR-300 B7 which is the same as the above one and everything went fine, until now...I Used to play with 3G USB modem. On top of 3g I run PPTP client which also run flawlessly and overall result was perfect, except Wi-IF. N was not there at all, just 54Mbps max, but working as expected. Today I've replaced 4MB flash with 16MB and the wireless seems dead to me, and I don't know why?!? With 4MB flash, at some point during bootup, kernel throws me some kind of error and prints the affected stack, but everything working normally. The problem is I want more flash storage to be able to install more things (I'm new to openwrt) and replace flash. That message is missing from kernel log today, as Wifi behave strangely. After client supply WPA psk, connection stops at "receiving DHCP address". On 10 attempts -  2 or 3 was successful, but non the less - ping from router to wifi client is horrible and also no traffic actually get passed. I don't know what to think. Is it issues with CC or somehow I've managed to screw the wifi chip itself? Tomorrow I will put old 4MB flash back (with kernel complaining about something) and see what's going on...

19.05.17
In the end I actually copied whole 4MB flash into 16MB, and not the u-boot only. The error in kernel is back, and everything is working normal. if someone is interested in, I can provide ssh login to router itself...

(Last edited by bfka on 19 May 2017, 13:14)

Not much help (yet) but I can definitely confirm this works a heck of a lot better.  This revision gives < 20% retx packets with one antenna versus roughly 50% retx packets with antenna diversity on my newer kernel.  Additionally (or causally,) the transmit bitrate from the router is lower in CC HEAD than BB r36813.

I'm determining the difference and I'll post a patch here once I fix the issue.

lsoltero wrote:

r36813 is the svn commit version number...  it corresponds to git

commit 2dfa092d52ab24ba1e432b5b0a5d61ed2472531b
Author: nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date:   Fri May 31 15:42:23 2013 +0000


    usbmode: fix hotplug script name
   
    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
   
    git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36813 3c298f89-4303-0410-b956-a3cf2f4a3e73

I look forward to your findings... It would be nice to move to CC for this one router...

I'm not sure how to post patches here..... so heres a kind of kludgy go at this.  I've attached several patches inline.  You wont need the antenna diversity patch specifically but i think its required as a series of patches as the following patch relies on it.

./package/kernel/mac80211/patches/628-rt2x00-rt5350_calibration_fixup.patch

Index: compat-wireless-2016-01-10/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
===================================================================
--- compat-wireless-2016-01-10.orig/drivers/net/wireless/ralink/rt2x00/rt2800lib.c      2017-05-24 12:19:13.404718115 -0400
+++ compat-wireless-2016-01-10/drivers/net/wireless/ralink/rt2x00/rt2800lib.c   2017-05-24 12:24:00.672438416 -0400
@@ -4491,6 +4491,7 @@
        case RT3071:
        case RT3090:
        case RT3572:
+       case RT5350:
                delta += rt2800_get_gain_calibration_delta(rt2x00dev);
                break;
        default:
@@ -5107,6 +5108,8 @@
                rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
        } else if (rt2x00_rt(rt2x00dev, RT5350)) {
                rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404);
+               rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606);
+               rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
        } else {
                rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000000);
                rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606);
@@ -5785,6 +5788,8 @@
        if (rt2x00_rt(rt2x00dev, RT5350)) {
                rt2800_bbp_write(rt2x00dev, 105, 0x3c);
                rt2800_bbp_write(rt2x00dev, 106, 0x03);
+
+               rt2800_bbp_write(rt2x00dev, 128, 0x12);
        } else {
                rt2800_bbp_write(rt2x00dev, 105, 0x34);
                rt2800_bbp_write(rt2x00dev, 106, 0x05);
@@ -7115,6 +7120,8 @@
 
 static void rt2800_init_rfcsr_5350(struct rt2x00_dev *rt2x00dev)
 {
+       rt2800_rf_init_calibration(rt2x00dev, 30);
+
        rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
        rt2800_rfcsr_write(rt2x00dev, 1, 0x23);
        rt2800_rfcsr_write(rt2x00dev, 2, 0x50);
@@ -7181,6 +7188,8 @@
        rt2800_rfcsr_write(rt2x00dev, 61, 0xd1);
        rt2800_rfcsr_write(rt2x00dev, 62, 0x00);
        rt2800_rfcsr_write(rt2x00dev, 63, 0x00);
+
+       rt2800_led_open_drain_enable(rt2x00dev);
 }
 
 static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)

./package/kernel/mac80211/patches/629-rt2x00-rt5350_antenna_diversity.patch

Index: compat-wireless-2016-01-10/drivers/net/wireless/ralink/rt2x00/rt2800.h
===================================================================
--- compat-wireless-2016-01-10.orig/drivers/net/wireless/ralink/rt2x00/rt2800.h 2017-05-24 12:34:45.335781051 -0400
+++ compat-wireless-2016-01-10/drivers/net/wireless/ralink/rt2x00/rt2800.h      2017-05-24 12:36:08.618888626 -0400
@@ -94,6 +94,7 @@
 #define REV_RT3090E                    0x0211
 #define REV_RT3390E                    0x0211
 #define REV_RT3593E                    0x0211
+#define REV_RT5350F                    0x0105
 #define REV_RT5390F                    0x0502
 #define REV_RT5390R                    0x1502
 #define REV_RT5592C                    0x0221
Index: compat-wireless-2016-01-10/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
===================================================================
--- compat-wireless-2016-01-10.orig/drivers/net/wireless/ralink/rt2x00/rt2800lib.c      2017-05-24 12:34:45.367780719 -0400
+++ compat-wireless-2016-01-10/drivers/net/wireless/ralink/rt2x00/rt2800lib.c   2017-05-24 12:40:31.939288380 -0400
@@ -3583,6 +3583,10 @@
                        rt2800_bbp_write(rt2x00dev, 86, 0x46);
                else
                        rt2800_bbp_write(rt2x00dev, 86, 0);
+       } else if (rt2x00_rt(rt2x00dev, RT5350)) {
+               rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
+               rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
+               rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
        } else {
                rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
                rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
@@ -5738,6 +5742,10 @@
 
 static void rt2800_init_bbp_3352(struct rt2x00_dev *rt2x00dev)
 {
+       int ant, div_mode;
+       u16 eeprom;
+       u8 value;
+
        rt2800_bbp_write(rt2x00dev, 3, 0x00);
        rt2800_bbp_write(rt2x00dev, 4, 0x50);
 
@@ -5820,10 +5828,31 @@
        rt2800_bbp_write(rt2x00dev, 148, 0xc8);
 
        if (rt2x00_rt(rt2x00dev, RT5350)) {
-               rt2800_bbp_write(rt2x00dev, 150, 0x40); /* Antenna Software OFDM */
-               rt2800_bbp_write(rt2x00dev, 151, 0x30); /* Antenna Software CCK */
-               rt2800_bbp_write(rt2x00dev, 152, 0xa3);
+               rt2800_disable_unused_dac_adc(rt2x00dev);
+
+               rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+               div_mode = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_ANT_DIVERSITY);
+               ant = (div_mode == 3 || div_mode == 0) ? 1 : 0;
+
+               /* This chip has hardware antenna diversity*/
+               if (rt2x00_rt_rev_gte(rt2x00dev, RT5350, REV_RT5350F) && div_mode == 1) {
+                       rt2800_bbp_write(rt2x00dev, 150, 0); /* Disable Antenna Software OFDM */
+                       rt2800_bbp_write(rt2x00dev, 151, 0); /* Disable Antenna Software CCK */
+               } else {
+                       rt2800_bbp_write(rt2x00dev, 150, 0x40); /* Antenna Software OFDM */
+                       rt2800_bbp_write(rt2x00dev, 151, 0x30); /* Antenna Software CCK */
+               }
+
                rt2800_bbp_write(rt2x00dev, 154, 0); /* Clear previously selected antenna */
+
+               value = 0xa3; //rt2800_bbp_read(rt2x00dev, 152, &value);
+               if (ant == 0)
+                       rt2x00_set_field8(&value, BBP152_RX_DEFAULT_ANT, 1);
+               else
+                       rt2x00_set_field8(&value, BBP152_RX_DEFAULT_ANT, 0);
+               rt2800_bbp_write(rt2x00dev, 152, value);
+
+               rt2800_init_freq_calibration(rt2x00dev);
        }
 }
 
@@ -7890,12 +7919,18 @@
        if (rt2x00_rt(rt2x00dev, RT3070) ||
            rt2x00_rt(rt2x00dev, RT3090) ||
            rt2x00_rt(rt2x00dev, RT3352) ||
-           rt2x00_rt(rt2x00dev, RT3390)) {
+           rt2x00_rt(rt2x00dev, RT3390) ||
+           rt2x00_rt(rt2x00dev, RT5350)) {
                value = rt2x00_get_field16(eeprom,
                                EEPROM_NIC_CONF1_ANT_DIVERSITY);
                switch (value) {
                case 0:
                case 1:
+                       if (rt2x00_rt_rev_gte(rt2x00dev, RT5350, REV_RT5350F)) {
+                               rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY; /* Unused */
+                               rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY; /* Unused */
+                               break;
+                       }
                case 2:
                        rt2x00dev->default_ant.tx = ANTENNA_A;
                        rt2x00dev->default_ant.rx = ANTENNA_A;


./package/kernel/mac80211/patches/631-rt2x00-Fix_mmic_countermeasures.patch

Index: compat-wireless-2016-01-10/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
===================================================================
--- compat-wireless-2016-01-10.orig/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c     2017-05-15 02:40:10.486150947 +0000
+++ compat-wireless-2016-01-10/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c  2017-05-15 02:42:57.630150947 +0000
@@ -139,7 +139,7 @@
                if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
                        rxdesc->flags |= RX_FLAG_DECRYPTED;
                else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
-                       rxdesc->flags |= RX_FLAG_MMIC_ERROR;
+                       rxdesc->flags |= RX_FLAG_DECRYPTED | RX_FLAG_MMIC_ERROR;
        }
 
        if (rt2x00_get_field32(word, RXD_W3_MY_BSS))

(Last edited by mskeff on 21 Jun 2017, 20:17)

wow! you go the wifi working well for the 5350 on CC?  good job.

Normally patches are posted to the developers mailing list.  You need to subscribe to that and then post the patches.

I will manually apply these to my cc distribution to see how they work on my device.

Thank you very much for looking into this.

--luis

I want a sanity check from someone else before i start posting them to the mailing list tongue

The discussion might have continued from here.