[BPI-R64] mt7622 mac80211 WiFi driver

Thank you very much!

I make some tests if i found some time. How to load mt7615 eeprom (it is not set in dts so we need a default filename based on chip-name)

which eeprom-file have you used? is device initialized if file does not exist (with internal eeprom)?

I only added a function, this function loads the configuration file from the file system.

mt7615, and I test it. The code should be compatible original program.Should not load successfullyļ¼Ÿ

root@MT7622:~# dmesg | grep mt7615e
[  107.700196] mt7615e 0000:01:00.0: assign IRQ: got 140
[  107.842935] mt7615e 0000:01:00.0: enabling device (0000 -> 0002)
[  107.883193] mt7615e 0000:01:00.0: enabling bus mastering
[  109.119164] mt7615e 0000:01:00.0: HW/SW Version: 0x8a108a10, Build Time: 20180518100604a
[  109.194028] mt7615e 0000:01:00.0: N9 Firmware Version: _reserved_, Build Time: 20190103180756
[  109.313564] mt7615e 0000:01:00.0: CR4 Firmware Version: _reserved_, Build Time: 20181207140436
[  117.236814] mt7615e 0000:01:00.0 wlp1s0: renamed from wlan1
root@MT7622:~# 

If the configuration file does not exist, it will run the same as the original program. If the device tree exists, load /lib/firmware/xxx [xxx: eeprom device tree configuration file name]. If the eeprom configuration file is saved in mtd, the mtd configuration file is preferred.

Mt7615 have still only own eeprom as it has no reference in dtsā€¦here (and for other mt76 like mt7612) can be a default filename like mt76xx_eeprom.bin (you have mt76_devā€¦maybe there is the chipid somewhere). the eeprom (for mt7615) is needed for tx issue.

Where did i find your eeprom-files for both devices (mt7622+mt7615)?

for chip-id maybe ā€œmt76_chip(struct mt76_dev *dev)ā€ from mt76.h is useful :wink:

I donā€™t have a special eeprom. I use the eeprom mentioned in this post, save it directly in bin format, and then save all the firmware in github to /lib/firmware/mediatek/.

node run:

var data=[  
  0x22, 0x76, 0x05, 0x00, 0x00, 0x0C, 0x43, 0x26, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x44, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x20, 0x00, 0x00, 0xB3, 0x40, 0xB6, 0xC3, 0xC3, 0x26, 0x00, 0x00, 0x00, 0x41, 0xC4, 0x26, 0x00, 0x00, 0x00, 0x41, 0xC4, 0x26, 0x00, 0x00, 0x00, 0xC0, 0xC5, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC3, 0xC3, 0xC2, 0xC1, 0x00, 0xC3, 0x00, 0xC3,
  0x00, 0x81, 0x81, 0x81, 0x83, 0xC1, 0xC1, 0x82, 0x83, 0x83, 0x83, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x84, 0x00, 0x2E, 0x00, 0x90, 0x00, 0x00, 0x87, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  ];
var fs = require('fs');
fs.writeFile("mt7622_rf_conf.bin", Buffer.from(data),"binary",function(err) {
    if(err) {
        console.log(err);
    } else {
        console.log("The file was saved!");
    }
});

Thanksā€¦any idea about mt7615?

Maybe something like this

char filename[18];
sprintf(filename, "mt%d_eeprom.bin", mt76xx_chip(dev)); //mt76_chip is static and i do not know if it is available in eeprom.c

tried to set a default filename, but get this:

mt30242_eeprom.bin

ah i see the chip-id needs to be interpreted as hex :slight_smile:

Btw.

drivers/net/wireless/mediatek/mt76/eeprom.c:47:20: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'ssize_t' {aka 'int'} [-Wformat=]
      47 |  dev_info(dev->dev,"Read File OK, count %ld\n",ret);

So it should be %d instead of %ldā€¦mhm, my compiler needs %ld tooā€¦got the error from kernel-ci-bot which uses ā€œCOMPILER=gcc-9.3.0 make.cross ARCH=mipsā€

So you use basicly the same file as in first post (which is already a bin-file)

fp = filp_open(path, O_RDWR, 0); //shouldn't this O_RDONLY, as we don't want to write to the eeprom-file?

and i got a Pagefault with my modifications :wink: i got the pagefault at the strcatā€¦donā€™t know whyā€¦in my current way, i copy fname to filename and then append filename to path

 15     char filename[18];
...
 28     sprintf(filename, "mt%x_eeprom.bin", mt76_chip(dev));
 29     dev_info(dev->dev,"default filename: '%s'\n",filename);
 30     ret = of_property_read_string(np, "mediatek,rf-conf", &fname);
 31     if (!ret)
 32         strcpy(filename, fname);
...
 39     strcat(path,filename);

in your code you check again for np and return if it is not set, but np should not be modified by of_property_read_stringā€¦only the out-string if return-value is 0. your code works till this point, but not completely, but i donā€™t know why mine gets pagefault at strcat

root@bpi-r64:~# modprobe mt7615e
[   26.208449] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   26.360043] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[   26.367636] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[   26.392478] cfg80211: failed to load regulatory.db
[   26.540283] mt7622-wmac 18000000.wmac: Find 'mediatek,rf-conf' : /lib/firmware/mt7622_rf_conf.bin
[   26.550399] mt7622-wmac 18000000.wmac: Open File Faile : /lib/firmware/mt7622_rf_conf.bin
[   26.569763] mt7622-wmac 18000000.wmac: Invalid MAC address, using random address 0e:5a:a7:5b:07:36
[   26.590779] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
root@bpi-r64:~# [   27.825605] mt7622-wmac 18000000.wmac: driver own failed

i think it should be simple. no need to use the device tree. otherwise, a 7615e node is needed.

load two drivers without device tree.

eeprim.c:

// SPDX-License-Identifier: ISC
/*
 * Copyright (C) 2016 Felix Fietkau <[email protected]>
 */
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/etherdevice.h>
#include "mt76.h"

static int
mt76_get_of_file(struct mt76_dev *dev, int len)
{
char path[64]="";
struct file *fp;
loff_t pos=0;
int ret;

ret = snprintf(path,sizeof(path),"/lib/firmware/mediatek/%s_rf.bin",dev->dev->driver->name);
if(ret < 0)
	return -EINVAL;
dev_info(dev->dev,"Load firmware : %s\n",path);
fp = filp_open(path, O_RDONLY, 0);
if (IS_ERR(fp)) {
	dev_info(dev->dev,"Load firmware Faile : %s\n",path);
	return -ENOENT;
}
ret = kernel_read(fp, dev->eeprom.data, len, &pos);
if(ret < len){
	dev_info(dev->dev,"Load firmware ERR, count %dbyte\n",ret);
	ret = -ENOENT;
}else{
	dev_info(dev->dev,"Load firmware OK, count %dbyte\n",ret);
	ret = 0;
}
filp_close(fp, 0);
return ret;
}

static int
mt76_get_of_eeprom(struct mt76_dev *dev, int len)
{
#if defined(CONFIG_OF) && defined(CONFIG_MTD)
	struct device_node *np = dev->dev->of_node;
	struct mtd_info *mtd;
	const __be32 *list;
	const char *part;
	phandle phandle;
	int offset = 0;
	int size;
	size_t retlen;
	int ret;
	
	if (!np)
		return -ENOENT;
	
	list = of_get_property(np, "mediatek,mtd-eeprom", &size);
	if (!list)
		return -ENOENT;

	phandle = be32_to_cpup(list++);
	if (!phandle)
		return -ENOENT;

	np = of_find_node_by_phandle(phandle);
	if (!np)
		return -EINVAL;

	part = of_get_property(np, "label", NULL);
	if (!part)
		part = np->name;

	mtd = get_mtd_device_nm(part);
	if (IS_ERR(mtd)) {
		ret =  PTR_ERR(mtd);
		goto out_put_node;
	}
	if (size <= sizeof(*list)) {
		ret = -EINVAL;
		goto out_put_node;
	}
	
	offset = be32_to_cpup(list);
	ret = mtd_read(mtd, offset, len, &retlen, dev->eeprom.data);
	put_mtd_device(mtd);
	if (ret)
		goto out_put_node;
	if (retlen < len) {
		ret = -EINVAL;
		goto out_put_node;
	}
out_put_node:
	of_node_put(np);
	return ret;
#else
	return -ENOENT;
#endif
}

void
mt76_eeprom_override(struct mt76_dev *dev)
{
#ifdef CONFIG_OF
	struct device_node *np = dev->dev->of_node;
	const u8 *mac;

	if (!np)
		return;

	mac = of_get_mac_address(np);
	if (!IS_ERR_OR_NULL(mac))
		memcpy(dev->macaddr, mac, ETH_ALEN);
#endif

	if (!is_valid_ether_addr(dev->macaddr)) {
		eth_random_addr(dev->macaddr);
		dev_info(dev->dev,
			 "Invalid MAC address, using random address %pM\n",
			 dev->macaddr);
	}
}
EXPORT_SYMBOL_GPL(mt76_eeprom_override);

int
mt76_eeprom_init(struct mt76_dev *dev, int len)
{
	dev->eeprom.size = len;
	dev->eeprom.data = devm_kzalloc(dev->dev, len, GFP_KERNEL);
	if (!dev->eeprom.data)
		return -ENOMEM;
	return (!mt76_get_of_file(dev, len)) || (!mt76_get_of_eeprom(dev, len));//mtd priority mt76
}
EXPORT_SYMBOL_GPL(mt76_eeprom_init);

Make sure that the folder contains the following two files:

/lib/firmware/mediatek/mt7615e_rf.bin

/lib/firmware/mediatek/mt7622_wmac_rf.bin

root@MT7622:~# dmesg | grep mt7615
[    5.520634] mt7615e 0000:01:00.0: assign IRQ: got 140
[    5.627256] mt7615e 0000:01:00.0: enabling device (0000 -> 0002)
[    5.665298] mt7615e 0000:01:00.0: enabling bus mastering
[    5.709000] mt7615e 0000:01:00.0: Load firmware : /lib/firmware/mediatek/mt7615e_rf.bin
[    5.767877] mt7615e 0000:01:00.0: Load firmware OK, count 1024byte
[    5.810291] mt7615e 0000:01:00.0: HW/SW Version: 0x8a108a10, Build Time: 20180518100604a
[    5.865967] mt7615e 0000:01:00.0: N9 Firmware Version: _reserved_, Build Time: 20190103180756
[    5.919523] mt7615e 0000:01:00.0: CR4 Firmware Version: _reserved_, Build Time: 20181207140436
[   13.659189] mt7615e 0000:01:00.0 wlp1s0: renamed from wlan1
root@MT7622:~# dmesg | grep mt7622
[    1.237992] rtc_mt7622 10212800.rtc: registered as rtc0
[    2.173705] rtc_mt7622 10212800.rtc: setting system clock to 2000-01-01T03:24:56 UTC (946697096)
[    5.503534] mt7622_wmac 18000000.wmac: ASIC revision: 76220010
[    5.539692] mt7622_wmac 18000000.wmac: Load firmware : /lib/firmware/mediatek/mt7622_wmac_rf.bin
[    5.606086] mt7622_wmac 18000000.wmac: Load firmware OK, count 1024byte
[    5.650923] mt7622_wmac 18000000.wmac: MAC addr = 00:0c:43:26:60:00
[    5.722530] mt7622_wmac 18000000.wmac: N9 Firmware Version: _reserved_, Build Time: 20190801210351
[    5.858934] mt7622_wmac 18000000.wmac: Firmware init done
[    5.902642] mt7622_wmac 18000000.wmac: Driver own success
root@MT7622:~#

additionally where is the write function? i can also write 1024byte directly to the file, and I can help implement it if necessary.

1 Like

I think this is a better version without devicetree. Thank you very much. Can you send me your name+email so that i can set author in my repo?

Do you mean my comment about O_RDWR (imho this should be O_RDONLY Or do you mean writing eeprom on card with data from file?

Do you know which byte needs to be modified for tx power (21db+)?

Maybe it is possible to read old mac out before overwriting eeprom in memory.

you are right, although the code O_RDWR does not affect, but O_RDONLY is more rigorous. (I have modified the code on the page just now).

emailļ¼š[email protected]

my english is not very good, and sometimes I misunderstand.

tx0 is 0x58 
tx1 is 0x5e
tx2 is 0x64
tx3 is 0x6a

this is the information I can get:

2 Likes

thanks, these offsets are not in your tableā€¦and it looks like we need to set the tx power for each mode ([V]HTxx/MCSx) separatelyā€¦and 5Ghz is missing

there are two tables above, tx0-4 is in the first picture.

It is true that other people gave me incomplete information, and there is no 5G configuration. I donā€™t know where the four antennas are.

aahh.image is stripped off (goes till 0x1e)ā€¦i have to click on it to see all.

this is the information I obtained in the discussion group. I will ask if there is any other information to provide to you. In addition, do you have debian wlan0 test code? AP and client. I use hostapd -B /etc/hostapd/hostapd.conf to report errors. I donā€™t have these configurations yet.

interface=wlan0
driver=nl80211
ssid=mt7622

root@MT7622:~# hostapd -B /etc/hostapd/hostapd.conf 
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Could not configure driver mode
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
nl80211 driver initialization failed.
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED 
wlan0: CTRL-EVENT-TERMINATING 
hostapd_free_hapd_data: Interface wlan0 wasn't started

I have only ap-code ready (2g4 and 5g,for r2,but you only need to replace iface names)

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:wlan#hostapd

Have not tried yet with mt7615/mt7622. Mt7615 is currently in my r2 (added antenna on wf3 today so i can test 2g4 and 5g). with and without the firmware-file i got a driver own failedā€¦

without i see this:

[   49.882535] mt7622-wmac 18000000.wmac: Load firmware : /lib/firmware/mediatek/mt7622-wmac_rf.bin                                                          
[   49.891445] mt7622-wmac 18000000.wmac: Open file failed : /lib/firmware/mediatek/mt7622-wmac_rf.bin                                                       
[   49.901529] mt7622-wmac 18000000.wmac: Invalid MAC address, using random address 02:9d:39:63:ac:55                                                        
[   51.114069] mt7622-wmac 18000000.wmac: driver own failed

with the file i see this:

[   31.582413] mt7622-wmac 18000000.wmac: Load firmware : /lib/firmware/mediatek/mt7622-wmac_rf.bin                                                          
[   31.594925] mt7622-wmac 18000000.wmac: Load firmware ERR, count 1024byte                                                                                  
[   31.601739] mt7622-wmac 18000000.wmac: Load firmware OK, count -2byte                                                                                     
[   31.610768] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'                                                                                 
root@bpi-r64:~# [   32.826357] mt7622-wmac 18000000.wmac: driver own failed

looks like the error message is added by this patchset: https://www.spinics.net/lists/linux-wireless/msg200710.html

i cannot start AP on wlan0

Could not set interface wlan0 flags (UP): Input/output error                                                                                                 
nl80211: Could not set interface 'wlan0' UP

i still have the rfkill-option active (softdep rfkill pre: mt7622)

tried 5.9-main (without the eeprom-patch), same result

seems like it is the rfkill-issue againā€¦ i loaded rfkill-module before mt7615e and then i got the firmware-load and can start hostapd

i tried to change the rule because driver-module is named mt7615e instead of mt7622m same result (after reboot). directly after boot i get the driver own failure, if i unload the module and load again, i get the firmware-infoā€¦maybe mt7622 is blocked some time

mt7622-wmac 18000000.wmac: N9 Firmware Version: _reserved_, Build Time: 20190801210351

rfkill is loaded on boot, maybe the wlan0-interface in /etc/network/interfaces blocksā€¦removed it so network is started completely, but same

root@bpi-r64:~# service networking status                                                                                                                    
ļæ½ā— networking.service - Raise network interfaces                                                                                                             
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor prese                                                                             
   Active: active (exited) since Thu 2019-02-14 10:12:03 UTC; 1 years 7 months a                                                                             
     Docs: man:interfaces(5)                                                                                                                                 
  Process: 164 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0                                                                             
 Main PID: 164 (code=exited, status=0/SUCCESS)                                                                                                               
                                                                                                                                                             
Feb 14 10:12:02 bpi-r64 systemd[1]: Starting Raise network interfaces...                                                                                     
Feb 14 10:12:03 bpi-r64 systemd[1]: Started Raise network interfaces.                                                                                        
root@bpi-r64:~# lsmod                                                                                                                                        
Module                  Size  Used by                                                                                                                        
aes_generic            36864  1                                                                                                                              
cmac                   16384  1                                                                                                                              
btmtkuart              24576  0                                                                                                                              
bluetooth             512000  20 btmtkuart                                                                                                                   
ecdh_generic           16384  2 bluetooth                                                                                                                    
ecc                    24576  1 ecdh_generic                                                                                                                 
rfkill                 32768  3 bluetooth                                                                                                                    
libaes                 16384  2 bluetooth,aes_generic                                                                                                        
ip_tables              28672  0                                                                                                                              
x_tables               36864  1 ip_tables                                                                                                                    
root@bpi-r64:~# modprobe mt7615e                                                                                                                             
[   52.224481] cfg80211: Loading compiled-in X.509 certificates for regulatory database                                                                      
[   52.380732] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'                                                                                    
[   52.388300] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2                                                            
[   52.399402] cfg80211: failed to load regulatory.db                                                                                                        
[   52.564273] mt7622-wmac 18000000.wmac: Load firmware : /lib/firmware/mediatek/mt7622-wmac_rf.bin                                                          
[   52.584584] mt7622-wmac 18000000.wmac: Load firmware ERR, count 1024byte                                                                                  
[   52.592669] mt7622-wmac 18000000.wmac: Load firmware OK, count -2byte                                                                                     
[   52.615394] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'                                                                                 
root@bpi-r64:~# [   53.823422] mt7622-wmac 18000000.wmac: driver own failed                                                                                  
root@bpi-r64:~# modprobe -r mt7615e                                                                                                                          
root@bpi-r64:~# modprobe mt7615e                                                                                                                             
[   83.800559] cfg80211: Loading compiled-in X.509 certificates for regulatory database                                                                      
[   83.820595] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'                                                                                    
[   83.827979] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2                                                            
[   83.850229] cfg80211: failed to load regulatory.db                                                                                                        
[   83.948589] mt7622-wmac 18000000.wmac: Load firmware : /lib/firmware/mediatek/mt7622-wmac_rf.bin                                                          
[   83.958684] mt7622-wmac 18000000.wmac: Load firmware ERR, count 1024byte                                                                                  
[   83.974036] mt7622-wmac 18000000.wmac: Load firmware OK, count -2byte                                                                                     
[   84.001470] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'                                                                                 
[   84.054993] mt7622-wmac 18000000.wmac: N9 Firmware Version: _reserved_, Build Time: 20190801210351                                                        
root@bpi-r64:~#

btw. it looks like the eeprom does not get loadedā€¦(ok-message is wrong because on err there is only ret-var set, but not returned). i added the len in brackets to see difference

[  157.004155] mt7622-wmac 18000000.wmac: Load firmware : /lib/firmware/mediatek/mt7622-wmac_rf.bin                                                          
[  157.019551] mt7622-wmac 18000000.wmac: Load firmware ERR, count 1024 byte (19880)

imho the len is wrong, it is passed to function so i guess itā€™s the size of full eeprom and sobuffer needs to initialized with zeros till len and then overridden with file-data (or filled after last file-byte)

root@bpi-r64:~# ls -lh /lib/firmware/mediatek/mt7622-wmac_rf.bin
-rw-r--r-- 1 root root 1.0K Sep 16 12:23 /lib/firmware/mediatek/mt7622-wmac_rf.bin
root@bpi-r64:~# ls -l /lib/firmware/mediatek/mt7622-wmac_rf.bin
-rw-r--r-- 1 root root 1024 Sep 16 12:23 /lib/firmware/mediatek/mt7622-wmac_rf.bin

but i get the same values second time i insert the moduleā€¦but then initialization succeeds

@nagi have you an idea why driver own failes the first time (also without eeprom-patch - 5.9-main)? without the patch (revert 894b7767ec2fc21574775c354ab5350e51c2171c) i get this:

 mt7622-wmac 18000000.wmac: Timeout for driver own

Could you try to uncheck ā€œBluetooth subsystem supportā€ in make kernel_menuconfig?

Networking support --> < > Bluetooth subsystem support

Indeed ret does not return, I have modified the above code. You try again:

static int
mt76_get_of_file(struct mt76_dev *dev, int len)
{
	char path[64]="";
	struct file *fp;
	loff_t pos=0;
	int ret;
	
	ret = snprintf(path,sizeof(path),"/lib/firmware/mediatek/%s_rf.bin",dev->dev->driver->name);
	if(ret < 0)
		return -EINVAL;
	dev_info(dev->dev,"Load firmware : %s\n",path);
	fp = filp_open(path, O_RDONLY, 0);
	if (IS_ERR(fp)) {
		dev_info(dev->dev,"Load firmware Faile : %s\n",path);
		return -ENOENT;
	}
	ret = kernel_read(fp, dev->eeprom.data, len, &pos);
	if(ret < len){
		dev_info(dev->dev,"Load firmware ERR, count %dbyte\n",ret);
		ret = -ENOENT;
	}else{
		dev_info(dev->dev,"Load firmware OK, count %dbyte\n",ret);
		ret = 0;
	}
	filp_close(fp, 0);
	return ret;
}

As i have compiled bluetooth-support as module i can try to unload it before loading mt7615e module. Should be same,right? bluetooth-module canā€™t be unloadedā€¦still in use (have unloaded all depencies (mtkbtuart)), but still in useā€¦i guess bluetooth-daemon blocks it. need to drop the revert so i compile and install again without bluetooth.

same result:

root@bpi-r64:~# lsmod                                                           
Module                  Size  Used by                                           
ip_tables              28672  0                                                 
x_tables               36864  1 ip_tables                                       
root@bpi-r64:~# modprobe mt7615e                                                
[   22.867561] cfg80211: Loading compiled-in X.509 certificates for regulatory d
atabase                                                                         
[   22.897073] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'       
[   22.914501] platform regulatory.0: Direct firmware load for regulatory.db fai
led with error -2                                                               
[   22.923360] cfg80211: failed to load regulatory.db                           
[   23.042029] mt7622-wmac 18000000.wmac: Load firmware : /lib/firmware/mediatek
/mt7622-wmac_rf.bin                                                             
[   23.054968] mt7622-wmac 18000000.wmac: Load firmware ERR, count 1024byte     
[   23.065892] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'    
root@bpi-r64:~# [   24.269933] mt7622-wmac 18000000.wmac: driver own failed

and now unloading/reloading does not workā€¦have tried many times

@skype, which problem do you mean? i have only the problem with eeprom, where len is larger than the eeprom-file

Indeed ret does not return, I have modified the above, and I provide my test environmentļ¼š

I donā€™t understand your above operations very well, because I always ask you for advice and Google search for wifi configuration. You see if you can get close to my test method so that I can help you solve some problems怂

I have not used rfkill, nor have I installed it yet. This means that after my configuration starts, I can directly search for wireless AP signals. I provided screenshots.

root@MT7622:~# dmesg | grep mt7622
[    1.237983] rtc_mt7622 10212800.rtc: registered as rtc0
[    2.174171] rtc_mt7622 10212800.rtc: setting system clock to 2000-01-01T03:50:41 UTC (946698641)
[    5.545529] mt7622_wmac 18000000.wmac: ASIC revision: 76220010
[    5.589460] mt7622_wmac 18000000.wmac: Load firmware : /lib/firmware/mediatek/mt7622_wmac_rf.bin
[    5.664182] mt7622_wmac 18000000.wmac: Load firmware OK, count 1024byte
[    5.702666] mt7622_wmac 18000000.wmac: MAC addr = 00:0c:43:26:60:00
[    5.767225] mt7622_wmac 18000000.wmac: N9 Firmware Version: _reserved_, Build Time: 20190801210351
[    5.893336] mt7622_wmac 18000000.wmac: Firmware init done
[    5.922671] mt7622_wmac 18000000.wmac: Driver own success
root@MT7622:~# dmesg | grep mt7615e
[    5.554275] mt7615e 0000:01:00.0: assign IRQ: got 140
[    5.676722] mt7615e 0000:01:00.0: enabling device (0000 -> 0002)
[    5.739069] mt7615e 0000:01:00.0: enabling bus mastering
[    5.782814] mt7615e 0000:01:00.0: Load firmware : /lib/firmware/mediatek/mt7615e_rf.bin
[    5.834248] mt7615e 0000:01:00.0: Load firmware OK, count 1024byte
[    5.880527] mt7615e 0000:01:00.0: HW/SW Version: 0x8a108a10, Build Time: 20180518100604a
[    5.953826] mt7615e 0000:01:00.0: N9 Firmware Version: _reserved_, Build Time: 20190103180756
[    6.011722] mt7615e 0000:01:00.0: CR4 Firmware Version: _reserved_, Build Time: 20181207140436
[   13.727317] mt7615e 0000:01:00.0 wlp1s0: renamed from wlan1
root@MT7622:~# 

and

root@MT7622:~# ip a
12: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:43:26:60:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.3/24 brd 192.168.1.255 scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:43ff:fe26:6000/64 scope link 
       valid_lft forever preferred_lft forever
13: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:43:28:05:ab brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.5/24 brd 192.168.1.255 scope global wlp1s0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:43ff:fe28:5ab/64 scope link 
       valid_lft forever preferred_lft forever

and

root@MT7622:~# iw dev
phy#1
        Interface wlp1s0
                ifindex 13
                wdev 0x100000001
                addr 00:0c:43:28:05:ab
                ssid mt7615e
                type AP
                channel 48 (5240 MHz), width: 20 MHz, center1: 5240 MHz
                txpower 6.00 dBm
                multicast TXQ:
                        qsz-byt qsz-pkt flows   drops   marks   overlmt hashcol tx-bytes   tx-packets
                        0       0       0       0       0       0       0       0          0
phy#0
        Interface wlan0
                ifindex 12
                wdev 0x1
                addr 00:0c:43:26:60:00
                ssid mt7622
                type AP
                channel 6 (2437 MHz), width: 20 MHz, center1: 2437 MHz
                txpower 20.00 dBm
                multicast TXQ:
                        qsz-byt qsz-pkt flows   drops   marks   overlmt hashcol tx-bytes   tx-packets
                        0       0       0       0       0       0       0       0          0
root@MT7622:~# 

I will provide my two bin files again, it seems there is no problem at present.

eeprom.c (2.7 KB) mt7615e_rf.bin (1.2 KB) mt7622_wmac_rf.bin (1 KB)

I have found no fatal problems in my current testļ¼

I tested only mt7622 and used eeprom-file from first post of this thread. But also without modifying eeprom.c i have the driver own issue. With bluetooth i can unload mt7615e module and reload it to get it working. Without bluetooth i got always the driver own issue

Could you try my 5.9-mt76eeprom branch to have same config? My buster rootfs is prepared to test bluetooth too,so i have installed those tools.

No problem, I will test it next week. Can you provide your configuration, and I will refer to your config for testing.

you mean my hostapd-config? (works only if not driver own issue appears)

#ctrl_interface=/var/run/hostapd
#ctrl_interface_group=0 # These 2 are just parameters so that the hostap daemon runs.

interface=wlan0
driver=nl80211

ssid=r64_APi

hw_mode=g
channel=2
#macaddr_acl=0
auth_algs=1
#ignore_broadcast_ssid=0
#wpa=2
#wmm_enabled=1
#wpa_passphrase=12345678
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
#rsn_pairwise=CCMP

my kernelconfig:

https://github.com/frank-w/BPI-R2-4.14/blob/5.9-mt76eeprom/arch/arm64/configs/mt7622_bpi-r64_defconfig (currently with disabled CONFIG_BT, which is set to m in defconfig)

maybe any patch in my tree may break wifi? these are for bluetooth on r64

  • 6fc2b86858a8 bluetooth: mt7622: increase sleeptime in scpsys
  • 8b3ed61bb312 bluetooth: firmware: add mt7622 bluetooth firmware
  • d43115dd13d6 arm64: dts: enable bluetooth-node
  • f92108b7acfa tty: serial: donā€™t do termios for BTIF

the rfkill was previously used to fix the semaphore-issue: [BPI-R64] mt7622 mac80211 WiFi driver

i guess pcie and switch-changes does not affect wifi. strange that you donā€™t get the ret<len errorā€¦