Nossiac / mtk-openwrt-feeds

mtk-openwrt-feeds
428 stars 204 forks source link

mt7612 does not work with 17.01.4 #29

Open wrtcoder opened 6 years ago

wrtcoder commented 6 years ago

Hi All,

We tried to test the mtk driver on WG3526 router with tag 17.01.4. Below is the status we get

Please see the log of mt7612 when it is loaded and the ifconfig output

root@LEDE:/# modprobe mt7612
[  169.156447] register rt2860
[  169.167564] 
[  169.167564] 
[  169.167564] === pAd = c0c81000, size = 2104664 ===
[  169.167564] 
[  169.177392] <-- RTMPAllocTxRxRingMemory, Status=0
[  169.182917] <-- RTMPAllocAdapterBlock, Status=0
[  169.187433] pAd->CSRBaseAddress =0xc0b80000, csr_addr=0xc0b80000!
[  169.193529] device_id =0x7662
[  169.196491] ==>rlt_wlan_chip_onoff(): OnOff:1, Reset= 1, pAd->WlanFunCtrl:0x0, Reg-WlanFunCtrl=0x20a
[  169.206143] chip_id1=, chip_id2=, pAd->MACVersion=0x76623000
[  169.211796] chip_id1=0x0, chip_id2=0x0, pAd->MACVersion=0x76623000
[  169.217971] RtmpChipOpsEepromHook::e2p_type=0, inf_Type=5
[  169.223342] RtmpEepromGetDefault::e2p_dafault=1
[  169.227877] NVM is EFUSE mode
[  169.230839] get_dev_name_prefix(): dev_idx = 1, dev_name_prefix=rai
root@LEDE:/# ifconfig ra0 up
[  267.363746] TX_BCN DESC ae967000 size = 320
[  267.368063] RX[0] DESC ae969000 size = 2048
[  267.372634] RX[1] DESC ae96a000 size = 2048
[  267.429269] E2pAccessMode=2
[  267.432487] cfg_mode=9
[  267.434831] cfg_mode=9
[  267.437231] wmode_band_equal(): Band Equal!
[  267.443121] APSDCapable[0]=0
[  267.445983] APSDCapable[1]=0
[  267.448865] APSDCapable[2]=0
[  267.451729] APSDCapable[3]=0
[  267.454590] APSDCapable[4]=0
[  267.457476] APSDCapable[5]=0
[  267.460341] APSDCapable[6]=0
[  267.463202] APSDCapable[7]=0
[  267.466063] APSDCapable[8]=0
[  267.468942] APSDCapable[9]=0
[  267.471806] APSDCapable[10]=0
[  267.474754] APSDCapable[11]=0
[  267.477753] APSDCapable[12]=0
[  267.480708] APSDCapable[13]=0
[  267.483655] APSDCapable[14]=0
[  267.486603] APSDCapable[15]=0
[  267.489571] default ApCliAPSDCapable[0]=0
[  267.621472] Key1Str is Invalid key length(0) or Type(0)
[  267.626856] Key2Str is Invalid key length(0) or Type(0)
[  267.632220] Key3Str is Invalid key length(0) or Type(0)
[  267.637618] Key4Str is Invalid key length(0) or Type(0)
[  267.668688] [PMF]Set_PMFMFPC_Proc:: apidx=0, Desired MFPC=0
[  267.674333] [PMF]Set_PMFMFPR_Proc:: apidx=0, Desired MFPR=0
[  267.680027] [PMF]Set_PMFSHA256_Proc:: apidx=0, Desired PMFSHA256=0
[  267.686679] FW Version:CL173766-A
[  267.690020] FW Build Date:20170925114906
[  267.694255] CmdAddressLenReq:(ret = 0)
[  267.698696] CmdFwStartReq: override = 1, address = 1048576
[  267.704263] CmdStartDLRsp: WiFI FW Download Success
[  267.724204] AsicDMASchedulerInit(): DMA Scheduler Mode=0(LMAC)
[  267.730044] efuse_probe: efuse = 10000002
[  267.734033] RtmpChipOpsEepromHook::e2p_type=2, inf_Type=5
[  267.739421] RtmpEepromGetDefault::e2p_dafault=1
[  267.743930] RtmpChipOpsEepromHook: E2P type(2), E2pAccessMode = 2, E2P default = 1
[  267.751478] RtmpChipOpsEepromHook: Do not support E2P type(2), change to BIN mode
[  267.758940] NVM is BIN mode
[  267.761774] 1. Phy Mode = 14
[  267.764641] rtmp_get_default_bin_file_by_chip(): Found E2P bin file name:mt7603/mt7603.eeprom.bin
[  267.773485] rtmp_get_default_bin_file_by_chip::Found E2P bin file name=mt7603/mt7603.eeprom.bin
[  267.782274] RtmpOSFileOpen(): Error 2 opening /etc/wireless/mt7603/mt7603.eeprom.bin
[  267.790030] rtmp_ee_load_from_bin::Error opening /etc/wireless/mt7603/mt7603.eeprom.bin
[  267.798140] Cal Free IC!!
[  267.800870] @@@  NICReadEEPROMParameters : pAd->FWLoad=0
[  267.966992] Country Region from e2p = ffff
[  267.971092] tssi_1_target_pwr_g_band = 12
[  267.975093] 2. Phy Mode = 14
[  267.978102] 3. Phy Mode = 14
[  267.980973] NICInitPwrPinCfg(14): Not support for HIF_MT yet!
[  267.986716] NICInitializeAsic(584): Not support rtmp_mac_sys_reset () for HIF_MT yet!
[  267.994505] mt_mac_init()-->
[  267.997392] mt7603_init_mac_cr()-->
[  268.001113] AsicSetMacMaxLen(1831): Set the Max RxPktLen=1024!
[  268.006947] <--mt_mac_init()
[  268.009960]  WTBL Segment 1 info:
[  268.013254]          MemBaseAddr/FID:0x28000/0
[  268.017091]          EntrySize/Cnt:32/128
[  268.020473]  WTBL Segment 2 info:
[  268.023766]          MemBaseAddr/FID:0x40000/0
[  268.027628]          EntrySize/Cnt:64/128
[  268.031016]  WTBL Segment 3 info:
[  268.034310]          MemBaseAddr/FID:0x42000/64
[  268.038240]          EntrySize/Cnt:64/128
[  268.041622]  WTBL Segment 4 info:
[  268.044915]          MemBaseAddr/FID:0x44000/128
[  268.048925]          EntrySize/Cnt:32/128
[  268.052322] MtAsicACQueue: Write CR:21510, Value=10421
[  268.057463] MtAsicACQueue: Write CR:21500, Value=10421
[  268.062643] AntCfgInit(2641): Not support for HIF_MT yet!
[  268.068161] MCS Set = ff ff 00 00 01
[  268.071764] [PMF]ap_pmf_init:: apidx=0, MFPC=0, MFPR=0, SHA256=0
[  268.077819] AsicSetRalinkBurstMode(4166): Not support for HIF_MT yet!
[  268.084227] RTMPSetPiggyBack(883): Not support for HIF_MT yet!
[  268.115674] AsicSetTxPreamble(4153): Not support for HIF_MT yet!
[  268.121836] AsicSetPreTbtt(): bss_idx=0, PreTBTT timeout = 0xa0
[  268.127758] ap_ftkd> Initialize FT KDP Module...
[  268.132359] Main bssid = 00:0c:43:26:60:40
[  268.136517] <==== rt28xx_init, Status=0
[  268.142106] @@@ ed_monitor_init : ===>
[  268.145876] @@@ ed_monitor_init : <===
[  268.149674] mt7603_set_ed_cca: NON-CE Region,60200618=d7c8340f,ed_th=34
[  268.156299] mt7603_set_ed_cca: TURN ON EDCCA mac 0x10618 = 0xd7c8340f, EDCCA_Status=1
[  268.164205] WiFi Startup Cost (ra0): 0.800s
root@LEDE:/# ifconfig rai0 up
[  339.073562] build time =
[  339.076248] 20141115060606a
[  339.079085] rom patch for E3 IC
[  339.082207]
[  339.083684] platform =
[  339.086151] ALPS
[  339.087993] hw/sw version =
[  339.090853]
[  339.092691] patch version =
[  339.095573]
[  339.108906] FW Version:0.0.00 Build:1
[  339.112550] Build Time:201706151016____
[  339.116441] fw for E3 IC
[  339.134413] RX[0] DESC ae990000 size = 4096
[  339.139383] RX[1] DESC ae991000 size = 4096
[  339.149564] E2pAccessMode=2
[  339.152835] cfg_mode=14
[  339.155416] cfg_mode=14
[  339.157865] wmode_band_equal(): Band Not Equal!
[  339.164291] APSDCapable[0]=0
[  339.167193] APSDCapable[1]=0
[  339.170071] APSDCapable[2]=0
[  339.172933] APSDCapable[3]=0
[  339.175831] APSDCapable[4]=0
[  339.178702] APSDCapable[5]=0
[  339.181565] APSDCapable[6]=0
[  339.184426] APSDCapable[7]=0
[  339.187318] APSDCapable[8]=0
[  339.190187] APSDCapable[9]=0
[  339.193050] APSDCapable[10]=0
[  339.196020] APSDCapable[11]=0
[  339.198970] APSDCapable[12]=0
[  339.201918] APSDCapable[13]=0
[  339.204865] APSDCapable[14]=0
[  339.207831] APSDCapable[15]=0
[  339.210782] default ApCliAPSDCapable[0]=0
[  339.343336] Key1Str is Invalid key length(0) or Type(0)
[  339.348741] Key2Str is Invalid key length(0) or Type(0)
[  339.354122] Key3Str is Invalid key length(0) or Type(0)
[  339.359524] Key4Str is Invalid key length(0) or Type(0)
[  339.380571] 1. Phy Mode = 49
[  339.383442] NVM is Efuse and its size =1d[1e0-1fc]
[  339.389552] NVM is efuse and the information is too less to bring up the interface
[  339.397100] Load EEPROM buffer from BIN, and force to use BIN buffer mode
[  339.403983] RtmpOSFileOpen(): Error 2 opening /tmp/RT30xxEEPROM.bin
[  339.410250] rtmp_ee_load_from_bin::Error opening /tmp/RT30xxEEPROM.bin
[  339.416768] RtmpChipOpsEepromHook::e2p_type=4, inf_Type=5
[  339.422137] NVM is BIN mode
[  339.433644] get_chl_grp:illegal channel (167)
[  339.437997] get_chl_grp:illegal channel (167)
[  339.442330] get_chl_grp:illegal channel (169)
[  339.446679] get_chl_grp:illegal channel (169)
[  339.451012] get_chl_grp:illegal channel (171)
[  339.455365] get_chl_grp:illegal channel (171)
[  339.459702] /home/simpletask/workspace/oss/lede-17.01/build_dir/target-mipsel_24kc_musl-1.1.16/linux-ramips_mt7621/tm7612/src/rlt_wifi_ap/../rd
[  339.479207] Country Region from e2p = ffff
[  339.483295] mt76x2_read_temp_info_from_eeprom:: is_temp_tx_alc=0, temp_tx_alc_enable=0
[  339.491191] mt76x2_read_tx_alc_info_from_eeprom:: is_ePA_mode=0, ePA_type=3
[  339.498137] mt76x2_read_tx_alc_info_from_eeprom:: [5G band] high_temp_slope=0, low_temp_slope=0
[  339.506805] mt76x2_read_tx_alc_info_from_eeprom:: [2G band] high_temp_slope=0, low_temp_slope=0
[  339.515477] mt76x2_read_tx_alc_info_from_eeprom:: [5G band] tc_lower_bound=0, tc_upper_bound=0
[  339.524046] mt76x2_read_tx_alc_info_from_eeprom:: [2G band] tc_lower_bound=0, tc_upper_bound=0
[  339.532656] mt76x2_get_external_lna_gain::LNA type=0x11, BLNAGain=0x0, ALNAGain0=0x0, ALNAGain1=0x0, ALNAGain2=0x0
[  339.542971] 2. Phy Mode = 49
[  339.545902] 3. Phy Mode = 49
[  339.548784] andes_pci_fw_init
[  339.551790] 0x1300 = 00073200
[  339.580105] AntCfgInit: primary/secondary ant 0/1
[  339.584789] andes_load_cr:cr_type(2)
[  339.598437] @@@ BuildChannel # 36 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 40 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 44 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 48 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 52 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 56 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 60 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 64 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 100 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 104 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 108 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 112 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 116 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 120 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 124 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 128 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 132 :: Pwr0 = 26, Pwr1 =26, Flags = 40, RemainingTimeForUse=0
 @@@ BuildChannel # 136 :: Pwr0 = 26, Pwr1 =26, Flags = 40, RemainingTimeForUse=0
 @@@ BuildChannel # 140 :: Pwr0 = 26, Pwr1 =26, Flags = 0, RemainingTimeForUse=0
 @@@ BuildChannel # 149 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 153 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 157 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 161 :: Pwr0 = 26, Pwr1 =26, Flags = c0, RemainingTimeForUse=0
 @@@ BuildChannel # 165 :: Pwr0 = 26, Pwr1 =26, Flags = 0, RemainingTimeForUse=0
 MCS Set = ff ff 00 00 01
[  339.773971] mt76x2_bbp_adjust():rf_bw=2, ext_ch=1, PrimCh=157, HT-CentCh=159, VHT-CentCh=155
[  339.880465] TX0 power compensation = 0x38
[  339.884459] TX1 power compensation = 0x38
[  339.888483] APStartUp(): AP Set CentralFreq at 155(Prim=157, HT-CentCh=159, VHT-CentCh=155, BBP_BW=2)
[  339.897798] mt76x2_calibration(channel = 155)
[  340.283180] Main bssid = 00:00:00:00:00:00
[  340.287298] mt76x2_reinit_agc_gain:original agc_vga0 = 0x5c, agc_vga1 = 0x5c
[  340.294312] mt76x2_reinit_agc_gain:updated agc_vga0 = 0x5c, agc_vga1 = 0x5c
[  340.301261] mt76x2_reinit_hi_lna_gain:original hi_lna0 = 0x27, hi_lna1 = 0x27
[  340.308382] mt76x2_reinit_hi_lna_gain:updated hi_lna0 = 0x27, hi_lna1 = 0x27
[  340.315416] original vga value(chain0) = 5c
[  340.319578] original vga value(chain1) = 5c
[  340.328760] <==== rt28xx_init, Status=0
[  340.332586] get_dev_name_prefix(): dev_idx = 1, dev_name_prefix=apclii
[  340.340742] RTMPDrvOpen(1):Check if PDMA is idle!
[  340.345509] RTMPDrvOpen(2):Check if PDMA is idle!

root@LEDE:/# iwconfig
eth0.1    no wireless extensions.
lo        no wireless extensions.
ra0       RTWIFI SoftAP  ESSID:"wifi-mt7603"  
          Mode:Managed  Channel=6  Access Point: 00:0C:43:26:60:40   
          Bit Rate=300 Mb/s   

eth0      no wireless extensions.
rai0      RTWIFI SoftAP  ESSID:"wifi-mt7612"  
          Mode:Managed  Channel=157  Access Point: Not-Associated   
          Bit Rate:867 Mb/s   

apcli0    RTWIFI SoftAP  ESSID:""  
          Mode:Managed  Channel=6  Access Point: Not-Associated   
          Bit Rate:300 Mb/s   

br-lan    no wireless extensions.
eth0.2    no wireless extensions.
apclii0   RTWIFI SoftAP  ESSID:""  
          Mode:Managed  Channel=157  Access Point: Not-Associated   
          Bit Rate:300 Mb/s 

root@LEDE:/#  ifconfig rai0
rai0      Link encap:Ethernet  HWaddr 00:00:00:00:00:00  
          inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:31 

Another strange thing we observed on the UI page is that ra0 appears as the interface for mt7612 instead of rai0 mt7612_mtk

ZiqiangYu commented 6 years ago

in order to let 7612 work normally,you should have /lib/firmware/mt7612e.eeprom.bin . if not,driver can't find correct rf parameter and mac address

Nossiac commented 6 years ago

I'm writing a wiki on how to retrieve the eeprom.bin, that may help solve the issue.

wrtcoder commented 6 years ago

Hi @ZiqiangYu and @Nossiac,

Thank you for your reply, I tried to copy the mt7612e.eeprom.bin from witi repo to /lib/firmware/mt7612e.eeprom.bin, but it does not solve the issue. The MAC address of rai0 interface is still all zeros. May you please help to point me to the correct firmware binary.

Nossiac commented 6 years ago

First of all, you need to locate the factory data partition on your device.

For example, this is the partition table of your device:

root@LEDE:/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00010000 00010000 "factory"
mtd3: 00fb0000 00010000 "firmware"
mtd4: 001748fb 00010000 "kernel"
mtd5: 00e3b705 00010000 "rootfs"
mtd6: 00be0000 00010000 "rootfs_data"

the eeprom data resides in the "factory" partition. You can check the data hexdump -C -n 128 /dev/mtd2, you will get something like this:

root@LEDE:/# hexdump -C -n 256 /dev/mtd2
00000000  63 76 00 00 00 0c 43 26  60 d0 63 76 c3 14 00 80  |cv....C&`.cv....|
00000010  02 00 63 76 c3 14 00 00  00 00 00 00 00 00 00 00  |..cv............|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

If the data is correct, dump it into the file required by driver:

dd if=/dev/mtd2 of=/lib/firmware/mt7612e.eeprom.bin bs=1 count=512

Here's the openwrt's script to do the same thing, FYI:

https://github.com/openwrt/openwrt/blob/master/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom#L8

kennylam777 commented 6 years ago

In my case (XiaoMi Mini), the path of eeprom seems defined as "/etc/wireless/mt7612/mt7612e.eeprom.bin" As I can find these message from dmesg after "modprobe mt7612"

[  300.265319] rtmp_get_default_bin_file_by_chip::chip version=0x7612
[  300.271641] rtmp_get_default_bin_file_by_chip(): Found E2P bin file name:mt7612/mt7612e.eeprom.bin
[  300.280798] rtmp_get_default_bin_file_by_chip::Found E2P bin file name=mt7612/mt7612e.eeprom.bin
[  300.289783] rtmp_ee_load_from_bin::FileName=/etc/wireless/mt7612/mt7612e.eeprom.bin
[  300.297692] RtmpOSFileOpen(): Error 2 opening /etc/wireless/mt7612/mt7612e.eeprom.bin
[  300.305686] rtmp_ee_load_from_bin::Error opening /etc/wireless/mt7612/mt7612e.eeprom.bin

The line 'rtmp_ee_load_from_bin' of indicates the path of eeprom

/dev/mtd2 is my "factory" mtd partition

As the MAC address can be modified by "Breed" or other tools on eeprom, I didn't copy a file but link to /dev/mtd2

ln -s /dev/mtd2 /etc/wireless/mt7612/mt7612e.eeprom.bin

And then my mt7612 can finally work with valid BSSID.

Thanks Nossiac for making this great project!

ezzeldinadel commented 5 years ago

why is this still not closed?