Nossiac / mtk-openwrt-feeds

mtk-openwrt-feeds
429 stars 204 forks source link

drivers for mt7613 #127

Open bricco1981 opened 1 year ago

bricco1981 commented 1 year ago

hi, thanks a lot for your help with this drivers. I'm try to understand how get drivers for mt7613be chipset, I cannot find any info. I'm talking about mtk and not mt76.should this card work with mt7615 drivers?

vikingloudmouth commented 9 months ago

any updates on this? Did you end up working this out @bricco1981

bricco1981 commented 9 months ago

@vikingloudmouth no, i get alot of errors, i stopped now. maybe i''ll start again when i 'll have free time. have you dome progress?

vikingloudmouth commented 9 months ago

@bricco1981 I have tried to use the mt7515 driver. I was able to build the driver with openwrt 22.03.5 and running modprobeon the .ko runs without errors. I can't bring it up though. Using Luci I get the message "Please restart manually to create this interface." when selecting enable - this doesn't change after rebooting the router or pressing the reload button. Looking in the log I have errors

daemon.err uhttpd[1488]: cat: can't open '/tmp/mtk/if-save': No such file or directory cat: can't open '/tmp/mtk/vifup-save': No such file or directory

I then tried the command line tool /sbin/mtkwifi, first I got a permission error trying to run it. After fixing that with chmod, I can see the same errors that the luci interface generates.

I also tried manually bringing the interface up with ifconfig rai0 up but that gives me the error ifconfig: SIOCGIFFLAGS: No such device

From a quick look at the code for the luci app, it appears to me to all start from the what is returned when running ls /sys/class/net

For me, I can see ra0 in the output of that command ( I was also trying - without issues - the mt7603 driver), but no rai0 is listed. This is where I got stuck though.

bricco1981 commented 9 months ago

No,mt7615 are not the driver you Need . You Need mt7663.

vikingloudmouth commented 9 months ago

@bricco1981 Do you know where they are available? I thought the mt7615 driver covered that? (or is that just with the opensource mt76 driver version)

vikingloudmouth commented 8 months ago

I have been using the mt7663 driver on my mt7613 without any issues for the last week. It was built based on "MT7663_LinuxAP_6.0.3.0_20200106-775e6a.tar" with modifications copied from the mt7615d driver in https://github.com/Azexios/openwrt-r3p-mtk to get it to compile for openwrt 22.03.5.

Does anyone know what need to be changed to use these mtk drivers for use with openwrt 23.05?

bricco1981 commented 8 months ago

so can you share the driver on github? or explain neded modification?

ravichaudhary133 commented 6 months ago

@vikingloudmouth Hey, could you share the process of building the mtk drivers based on mt7663 for mt7613 device. I really need to get it working for my device. The default mt76 driver in openwrt has tx power issues.

bricco1981 commented 2 months ago

@vikingloudmouth can you please share the code, i'm not able to make this work.

vikingloudmouth commented 2 months ago

I'll share what I have when I have a chance, should find time to dig it back up gain and work out what I did in the next few weeks.

I've been using it since I first posted with only one issue: intermittent reconnection problems when using clients only capable of WPA2 if the router is set to WPA2/WPA3 mixed mode. No issues with clients capable of WPA3, and no issues with WPA2 clients if I don't use the mixed mode and instead only set WPA2 mode. I also have tested it on openwrt 23.05 and the wireless worked fine - the config page wouldn't load though. Hopefully someone else can fix that after I share the code

ravichaudhary133 commented 2 months ago

Thank you man, eagerly waiting for your code!

On Wed, 8 May 2024, 15:40 vikingloudmouth, @.***> wrote:

I'll share what I have a chance, should find time to dig it back up gain and work out what I did in the next few weeks.

I've been using it since I first posted with only one issue: intermittent reconnection problems when using clients only capable of WPA2 if the router is set to WPA2/WPA3 mixed mode. No issues with clients capable of WPA3, and no issues with WPA2 clients if I don't use the mixed mode and instead only set WPA2 mode. I also have tested it on openwrt 23.05 and the wireless worked fine - the config page wouldn't load though. Hopefully someone else can fix that after I share the code

— Reply to this email directly, view it on GitHub https://github.com/Nossiac/mtk-openwrt-feeds/issues/127#issuecomment-2100232666, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL2VLFSEDZO2N2S3YGXYA33ZBH2ZFAVCNFSM6AAAAAATMNL7TGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBQGIZTENRWGY . You are receiving this because you commented.Message ID: @.***>

bricco1981 commented 2 months ago

ok do not worry about config page i can make that easy. i'll make luci app mtk custom for this.

bricco1981 commented 1 month ago

FATAL: modpost: GPL-incompatible module mt_wifi.ko uses GPL-only symbol '__kernel_write' how solve this? what does this error mean

bricco1981 commented 1 month ago

ping @vikingloudmouth

bricco1981 commented 1 week ago

well as i said i did a custom luci app for this, i do not know if you will share this drivers. Schermata da 2024-07-02 10-24-48 Schermata da 2024-07-02 10-26-42

vikingloudmouth commented 1 week ago

Sorry for the lack of response. Left all the code in a mess and haven't got around to working out which of them actually works. Give mt7663.ko with OpenWrt 23.05 a go. I think it should work with

modprobe mt7663
ifconfig rai0 up
brctl addif br-lan rai0

and looks for a /etc/wireless/mt7663/mt7663.2.dat for the config file. Let me know how it goes. It may give only give very slows speeds though, I may need to work out again how I pointed it at the right data for the radio config.

I'll try to find the code that that actually can from. I really should have done this properly from the start...

bricco1981 commented 1 week ago

this is crazy i made the driver work but very low signal, so calibration is not correct. i'll try your mt7663.ko

vikingloudmouth commented 1 week ago

From memory the part of the code that looks for the firmware .bin file was kinda broken when the radio config was for two cards w.r.t. to using/not using a offset into the calibration area for the second radio in a .bin file was used. Think I ended up working around it be pointing it to a .bin file that contained the calibration data for both radios, setting a offset somewhere in the menuconfig, and making sure that I had it set as the second card with the first card selected as a 7603 (even though I wasn't using the mtk driver for the first card)

Think I also had speed issues at one point if I was running with a default .dat without encryption (or something along those lines) even I using no password on the network

vikingloudmouth commented 1 week ago

If helpful, this is the relevant part of my config

CONFIG_PACKAGE_kmod-mt7603=y
# CONFIG_PACKAGE_kmod-mt7603e is not set
# CONFIG_PACKAGE_kmod-mt7615-firmware is not set
# CONFIG_PACKAGE_kmod-mt7615d is not set
# CONFIG_PACKAGE_kmod-mt7615e is not set
# CONFIG_PACKAGE_kmod-mt7663-firmware-ap is not set
# CONFIG_PACKAGE_kmod-mt7663-firmware-sta is not set
CONFIG_PACKAGE_kmod-mt7663e=y
CONFIG_MTK_MT7663E_SUPPORT_OPENWRT=y
CONFIG_MTK_MT7663E_WIFI_DRIVER=y
# CONFIG_MTK_MT7663E_FIRST_IF_NONE is not set
CONFIG_MTK_MT7663E_FIRST_IF_MT7603E=y
# CONFIG_MTK_MT7663E_FIRST_IF_MT7615E is not set
# CONFIG_MTK_MT7663E_FIRST_IF_MT7622 is not set
# CONFIG_MTK_MT7663E_SECOND_IF_NONE is not set
CONFIG_MTK_MT7663E_SECOND_IF_MT7663E=y
# CONFIG_MTK_MT7663E_SECOND_IF_MT7615E is not set
# CONFIG_MTK_MT7663E_SECOND_IF_MTTEST is not set
CONFIG_MTK_MT7663E_THIRD_IF_NONE=y
# CONFIG_MTK_MT7663E_THIRD_IF_MT7615E is not set
CONFIG_MTK_MT7663E_RT_FIRST_CARD=7603
CONFIG_MTK_MT7663E_RT_SECOND_CARD=7663
CONFIG_MTK_MT7663E_RT_FIRST_IF_RF_OFFSET=0x0
CONFIG_MTK_MT7663E_RT_SECOND_IF_RF_OFFSET=0x8000
CONFIG_MTK_MT7663E_MT_WIFI=y
CONFIG_MTK_MT7663E_MT_WIFI_PATH="mt_wifi"

#
# WiFi Generic Feature Options
#
CONFIG_MTK_MT7663E_FIRST_IF_EEPROM_FLASH=y
# CONFIG_MTK_MT7663E_FIRST_IF_EEPROM_EFUSE is not set
CONFIG_MTK_MT7663E_RT_FIRST_CARD_EEPROM="flash"
CONFIG_MTK_MT7663E_SECOND_IF_EEPROM_FLASH=y
# CONFIG_MTK_MT7663E_SECOND_IF_EEPROM_PROM is not set
# CONFIG_MTK_MT7663E_SECOND_IF_EEPROM_EFUSE is not set
CONFIG_MTK_MT7663E_RT_SECOND_CARD_EEPROM="flash"
CONFIG_MTK_MT7663E_MULTI_INF_SUPPORT=y
CONFIG_MTK_MT7663E_WIFI_BASIC_FUNC=y
CONFIG_MTK_MT7663E_DOT11_N_SUPPORT=y
CONFIG_MTK_MT7663E_DOT11_VHT_AC=y
CONFIG_MTK_MT7663E_G_BAND_256QAM_SUPPORT=y
CONFIG_MTK_MT7663E_TPC_SUPPORT=y
# CONFIG_MTK_MT7663E_THERMAL_PROTECT_SUPPORT is not set
CONFIG_MTK_MT7663E_ICAP_SUPPORT=y
CONFIG_MTK_MT7663E_SPECTRUM_SUPPORT=y
CONFIG_MTK_MT7663E_BACKGROUND_SCAN_SUPPORT=y
CONFIG_MTK_MT7663E_SMART_CARRIER_SENSE_SUPPORT=y
# CONFIG_MTK_MT7663E_SCS_FW_OFFLOAD is not set
CONFIG_MTK_MT7663E_MT_DFS_SUPPORT=y
# CONFIG_MTK_MT7663E_OFFCHANNEL_SCAN_FEATURE is not set
CONFIG_MTK_MT7663E_HDR_TRANS_TX_SUPPORT=y
CONFIG_MTK_MT7663E_HDR_TRANS_RX_SUPPORT=y
CONFIG_MTK_MT7663E_WSC_INCLUDED=y
CONFIG_MTK_MT7663E_WSC_V2_SUPPORT=y
CONFIG_MTK_MT7663E_DOT11W_PMF_SUPPORT=y
CONFIG_MTK_MT7663E_TXBF_SUPPORT=y
# CONFIG_MTK_MT7663E_FTM_SUPPORT is not set
# CONFIG_MTK_MT7663E_MBO_SUPPORT is not set
CONFIG_MTK_MT7663E_IGMP_SNOOP_SUPPORT=y
CONFIG_MTK_MT7663E_RTMP_FLASH_SUPPORT=y
CONFIG_MTK_MT7663E_CAL_BIN_FILE_SUPPORT=y
CONFIG_MTK_MT7663E_LINK_TEST_SUPPORT=y
CONFIG_MTK_MT7663E_WIFI_GPIO_CTRL=y
# CONFIG_MTK_MT7663E_MIN_PHY_RATE_SUPPORT is not set
# CONFIG_MTK_MT7663E_VENDOR_FEATURE11_SUPPORT is not set
CONFIG_MTK_MT7663E_ATE_SUPPORT=y
# CONFIG_MTK_MT7663E_MEMORY_OPTIMIZATION is not set
# CONFIG_MTK_MT7663E_PASSPOINT_R2 is not set
CONFIG_MTK_MT7663E_UAPSD=y
# CONFIG_MTK_MT7663E_TCP_RACK_SUPPORT is not set
CONFIG_MTK_MT7663E_RED_SUPPORT=y
# CONFIG_MTK_MT7663E_FDB_SUPPORT is not set
# CONFIG_MTK_MT7663E_FIRST_IF_EPAELNA is not set
CONFIG_MTK_MT7663E_FIRST_IF_IPAILNA=y
# CONFIG_MTK_MT7663E_FIRST_IF_IPAELNA is not set
# CONFIG_MTK_MT7663E_SECOND_IF_EPAELNA is not set
CONFIG_MTK_MT7663E_SECOND_IF_IPAILNA=y
# CONFIG_MTK_MT7663E_SECOND_IF_IPAELNA is not set
# CONFIG_MTK_MT7663E_RLT_MAC is not set
# CONFIG_MTK_MT7663E_RTMP_MAC is not set
# end of WiFi Generic Feature Options

I am using a .bin file I extracted from by device. not sure exactly what I did to extract it, but the radio calibration data is at offset 0x8000 that matches the above config. You can tell by the first two bytes at that offset being 0x63 0x76 which matches 7663. The first part of my .bin file is for the 7603 radio, so at offset 0 the first two bytes are 0x03 0x76 for 7603.

Hopefully, this help you getting it to find the calibration data


edit: the .bin I'm using comes from saving my radio mtdblock

bricco1981 commented 1 week ago

so when you first fixed the compilation, did the driver worked fine? good speed and signal? or always week?

vikingloudmouth commented 1 week ago

No I had speed issues initially. Don't think I needed to change the code to fix it though, just the config and point the driver to a .bin file that contained the calibration data at the offset rather than at the start.

From memory, the driver was putting out some messages in one of openwrt logs (think it was the kernel log) about not finding firmware/eeprom/bin data and using a default one.

Also pretty sure I've found the code that works. I'll give it a quick test from a clean start and put it up if it works.

vikingloudmouth commented 1 week ago

FATAL: modpost: GPL-incompatible module mt_wifi.ko uses GPL-only symbol '__kernel_write' how solve this? what does this error mean

You probably already worked this out, but I got around this by changing the mt_wifi code to say it was GPL...

bricco1981 commented 1 week ago

yes i i fixed that. the problem that now i have is wrong macaddress and weak signal in ap mode, in sta mode i get good speed like 300 down 50 up.

vikingloudmouth commented 1 week ago

If your getting good speeds in sta mode that means you now have it finding the calibration data right?

Try checking your config in AP mode, think I made have also had slows speeds until I setup the .dat file to use encryption (or something along those lines) for the network mode. From memory it wasn't really a problem with the driver, just that devices would only use a slow rate in the outdated default mode without any

bricco1981 commented 1 week ago

well the signal is too weak in ap mode and why i have wrong mac address?

vikingloudmouth commented 1 week ago

I have no idea about the mac address, I didn't check what it was before and don't know if it is wrong or not for me

bricco1981 commented 1 week ago

for the low signal could be that the antennas are not used the right way. my device is a comfast ew72 v2

vikingloudmouth commented 1 week ago

Doesn't the good speed in STA mode rule that out?

bricco1981 commented 1 week ago

yes that's very strange. also i do not see about ANTENNA STAFF in bin folder, if you check the bin folder mt7615 you can see antenna things.

vikingloudmouth commented 1 week ago

you mean the .bin files?

bricco1981 commented 1 week ago

yes IPAELNA ect

vikingloudmouth commented 1 week ago

Pretty sure I'm just running with one .bin file. I extracted it from openwrt using the button to save the radio mtdblock, Not sure if it's needed in both places, but I called the file mt7663_7603.bin and put a copy into /lib/firmware/mt7663_7603.bin and /etc/wireless/mt7663/mt7663_7603.bin . Pretty sure that is what the .ko I uploaded looks for

bricco1981 commented 1 week ago

strange for me it look in etc/wireless/mt7663e/mt7663.2.eeprom.bin

vikingloudmouth commented 1 week ago

I may have changed that in the menuconfig. I did initially have issues with it not finding the right file / offset into the file.

Can you see error messages in the log about it?

bricco1981 commented 1 week ago

but you have weak signal? or normal?

vikingloudmouth commented 1 week ago

Signal strength looks fine, laptop says 5 bars. No issues with speed

bricco1981 commented 1 week ago

do you get this in log? get_wdev_by_idx: invalid idx(0)

bricco1981 commented 1 week ago

well i'll wait for your code so i can test if i have same weak signal.

bricco1981 commented 1 week ago

that's the app custom, to make the clients show right, make a folder in etc/wireless/mt7612 luci-app-mtwifi.zip also i think is good if you edit the name of your .ko mt_wifi.ko in the first makefile and in makefile ap so driver will load and you can enable the radio in luci.

vikingloudmouth commented 1 week ago

get_wdev_by_idx: invalid idx(0)

Seem familiar, think I had that when it wasn't finding the .bin file.

bricco1981 commented 1 week ago

well i'm not sure why you .ko is so big, anyway it killed my device.

bricco1981 commented 1 week ago

are you going to share this working code?

vikingloudmouth commented 1 week ago

I've rebuilt it with v23.05.3, I'll give it a test and upload over the weekend

bricco1981 commented 1 week ago

Well i hope so, i'm working on 23 too,kernel 5.15.x

vikingloudmouth commented 1 week ago

@bricco1981 https://github.com/vikingloudmouth/mt7663 The correct firmware file needs to exists for a good signal. By default, it looks for /lib/firmware/mt7663.bin, you can change the file it looks for in the l1 profile options. Alternatively dd if=/dev/$(grep -i '"factory"' /proc/mtd | cut -c 1-4) of=/lib/firmware/mt7663.bin bs=1 count=1536 skip=32768 should give you the right file for your device.

I've renamed the .ko to mt_wifi.ko as you suggested, but couldn't get your luci app to work - won't compile. Getting a warning has a dependency on 'luci-lib-jquery-1-4', which does not exist. Tried removing that dependency, it then builds but then I just get a blank page in luci for that page.


edit: forget to add the 992-add-ndo-do-ioctl.patch to that repo. Same as from your other drivers, I just put it under hack-5.15 instead of hack-5.10.

bricco1981 commented 1 week ago

hi, same as my code weak signal === pAd = (ptrval), size = 7149568 === Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.947059] Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.957808] <-- RTMPAllocAdapterBlock, Status=0 Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.962351] pAd->PciHif.CSRBaseAddress =0xc0d00000, csr_addr=0xc0d00000! Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.969110] RTMPInitPCIeDevice():device_id=0x7663 Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.973807] mt_pci_chip_cfg(): HWVer=0x8b10, FWVer=0x8a01, pAd->ChipID=0x7663 Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.980936] mt7663_init()--> Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.983822] <--mt7663_init() Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.991662] <-- RTMPAllocTxRxRingMemory, Status=0 Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 11.996386] get_wdev_by_idx: invalid idx(0) Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 12.000701] get_wdev_by_idx: invalid idx(0) Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 12.004969] get_wdev_by_idx: invalid idx(0) Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 12.009165] get_wdev_by_idx: invalid idx(0) Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 12.013338] get_wdev_by_idx: invalid idx(0) Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 12.017519] get_wdev_by_idx: invalid idx(0) Fri Mar 22 22:11:03 2024 kern.warn kernel: [ 12.022997] get_wdev_by_idx: invalid idx(0)

bricco1981 commented 1 week ago

that's for luci mtk luci-lib-jquery-1-4_6_mipsel_24kc.zip ok signal is better now, but still weak, we need fix this

bricco1981 commented 1 week ago

i cannot go from one room to another is to weak, if signal is good for you, share mt7663.bin

vikingloudmouth commented 1 week ago

but still weak, we need fix this

Don't know how to help there. All my issues with low signal strength disappeared as some as I put the .bin in the /lib/firmware/ folder with a name that matches the setting in the l1 profile.

Just checked my log, I'm getting a bunch of get_wdev_by_idx: invalid idx(0), everthing seems to be working fine though...

vikingloudmouth commented 1 week ago

share mt7663.bin

No need, just run dd if=/dev/$(grep -i '"factory"' /proc/mtd | cut -c 1-4) of=/lib/firmware/mt7663.bin bs=1 count=1536 skip=32768

To check it is right, then run hexdump /lib/firmware/mt7663.bin The first 2 bytes should be 0x7663.