Skip to content

Add tx_power check during eeprom loading #954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yukariin
Copy link

@Yukariin Yukariin commented Feb 5, 2025

Hello.
As pointed out in openwrt/openwrt/issues/17489 - some BPI-R4-BE14 cards come with a stock firmware with no tx_power values for 2.4G and 5G bands. Which basically prevents using the 2/5G band as it defaults to 6dBm.
This PR adds a basic check in mt7996_eeprom_load that reads the power value from the first channel group for each band. If any of them is zero, it falls back to loading the default firmware from the disk.
It was confirmed working on both affected and unaffected devices in the main issue.

danpawlik added a commit to danpawlik/bpi-r4-mtk that referenced this pull request Feb 5, 2025
Let's add tx_power patch [1] to the builds.

[1] openwrt/mt76#954
@rmandrad
Copy link

rmandrad commented Feb 5, 2025

@nbd168 ?

@razvanphp
Copy link
Contributor

Would this trick also work on MT7921?

@Headcrabed
Copy link

Such kind of patch should be sent to linux kernel mail list rather than here.

@Headcrabed
Copy link

Besides, when sending patches, please rebase your patch on this repo: https://github.com/nbd168/wireless

@Headcrabed
Copy link

Also I'm not sure if your patch is doing things right... I asked someone who is more knowledged about this, he said that the actual supported TX power caculation is not only depending on MT_EE_TX0_POWER_*G but also some other parameters...

@Headcrabed
Copy link

Headcrabed commented Feb 8, 2025

As far as I know, Sinovoip has delibrately limited TX power for 2.4/5ghz to 20dBm to follow Chinese legal constrictions in BE14 eeprom. And the constrictions are working correctly in BPI's mtwifi-based closed-source firmware.

@morrownr
Copy link

morrownr commented Feb 9, 2025

@razvanphp

see patchwork for wifi: mt76: fix returned txpower for mt7921 and mt7925

It is a series of patches that came in today.

@razvanphp
Copy link
Contributor

haha, I know, I’m the Author of that patch series 🙂

@Headcrabed
Copy link

haha, I know, I’m the Author of that patch series 🙂

@razvanphp Bro your patch really needs line wrapping XD

@razvanphp
Copy link
Contributor

@Headcrabed I've sent v2 which fixes the line wrapping and also added cleanup for MT7996 as you suggested. Thanks!

@morrownr
Copy link

@razvanphp

You will hate me for this but I just noticed:

You forgot to add the following below your Signed-off :

Cc: [email protected]

That keys those that do the backports to apply it to all currently maintained kernels and we could certainly use this being applied to 6.12 for mt7925 and 6.12 and 6.6 for mt7921.

@Headcrabed
Copy link

@razvanphp

You will hate me for this but I just noticed:

You forgot to add the following below your Signed-off :

Cc: [email protected]

That keys those that do the backports to apply it to all currently maintained kernels and we could certainly use this being applied to 6.12 for mt7925 and 6.12 and 6.6 for mt7921.

I think the CC could be added in reply?

@morrownr
Copy link

@Headcrabed

I've never had a problem doing it the way I am. I think there is some code that does something to make sure it gets to where it is going.

@SockToy
Copy link

SockToy commented Feb 15, 2025

Also I'm not sure if your patch is doing things right... I asked someone who is more knowledged about this, he said that the actual supported TX power caculation is not only depending on MT_EE_TX0_POWER_*G but also some other parameters...

That may be true, but as someone with one of the affected BE14's I'll tell you that without this patch it is unusable, and with this patch loading the default fw it works fine. I think the point is not that this is replacing the TX power calculation, but rather that it detecting a known-broken firmware state and reloading with a known-good file.

Which is nice when otherwise you have several hundred dollars of junk ;p

@Jiyuu
Copy link

Jiyuu commented Feb 15, 2025

As far as I know, Sinovoip has delibrately limited TX power for 2.4/5ghz to 20dBm to follow Chinese legal constrictions in BE14 eeprom. And the constrictions are working correctly in BPI's mtwifi-based closed-source firmware.

This patch isn't about going above 20dBm, its about being able to go above 6dBm.
Without this patch plenty of people(me included) couldn't use 2.4/5Ghz at any power above 6dBm regardless of any other tinkering.

After the investigation we realized that the location in the eeprom that the driver is looking at is empty for many of us, while the eeprom image has the proper values there, so we concluded the eeprom is somehow wrong.
it is possible that the version should know to look elsewhere in some cases, but in any case non of us can use a firmware that doesnt have this patch, without it the banana pi is basically useless.

@Headcrabed
Copy link

As far as I know, Sinovoip has delibrately limited TX power for 2.4/5ghz to 20dBm to follow Chinese legal constrictions in BE14 eeprom. And the constrictions are working correctly in BPI's mtwifi-based closed-source firmware.

This patch isn't about going above 20dBm, its about being able to go above 6dBm. Without this patch plenty of people(me included) couldn't use 2.4/5Ghz at any power above 6dBm regardless of any other tinkering.

After the investigation we realized that the location in the eeprom that the driver is looking at is empty for many of us, while the eeprom image has the proper values there, so we concluded the eeprom is somehow wrong. it is possible that the version should know to look elsewhere in some cases, but in any case non of us can use a firmware that doesnt have this patch, without it the banana pi is basically useless.

@Jiyuu But this patch seems currently would completely neglect all calibration data inside the eeprom now. It would be better if only power data is neglected but other things from the eeprom are preserved.

@Jiyuu
Copy link

Jiyuu commented Feb 15, 2025

As far as I know, Sinovoip has delibrately limited TX power for 2.4/5ghz to 20dBm to follow Chinese legal constrictions in BE14 eeprom. And the constrictions are working correctly in BPI's mtwifi-based closed-source firmware.

This patch isn't about going above 20dBm, its about being able to go above 6dBm. Without this patch plenty of people(me included) couldn't use 2.4/5Ghz at any power above 6dBm regardless of any other tinkering.
After the investigation we realized that the location in the eeprom that the driver is looking at is empty for many of us, while the eeprom image has the proper values there, so we concluded the eeprom is somehow wrong. it is possible that the version should know to look elsewhere in some cases, but in any case non of us can use a firmware that doesnt have this patch, without it the banana pi is basically useless.

@Jiyuu But this patch seems currently would completely neglect all calibration data inside the eeprom now. It would be better if only power data is neglected but other things from the eeprom are preserved.

Isnt this patch basically just changing the startup sequence?
I will admit my understanding of this code is far from perfect, but it seemed to me there is an initialization process where the driver checks for the state of the eeprom, if it find a "valid" eeprom it uses it, if it detects something is off it instead loads the eeprom from the drive.
so my understanding was that this would simply catch another way that the eeprom might not be valid and therefore should be loaded from file instead of relying on the existing one..

If this understanding is wrong then I would probably agree that this patch is less appropriate for upsteaming, but then where/who should we reach out to figure this issue out, because i think this solution was basically crowdsourced by a bunch of affected people that were trying to get their hardware to work..

@Headcrabed
Copy link

I agree with this: openwrt/openwrt#17489 (comment)

danpawlik added a commit to danpawlik/bpi-r4-mtk that referenced this pull request Feb 18, 2025
Let's add tx_power patch [1] to the builds.

[1] openwrt/mt76#954
@haohetao
Copy link

nice

@Headcrabed
Copy link

@Headcrabed I've sent v2 which fixes the line wrapping and also added cleanup for MT7996 as you suggested. Thanks!

@razvanphp Did you send your patch email to all output addresses from ./scripts/get_maintainers.pl? Seems you are not doing it correctly?

@haohetao
Copy link

haohetao commented Mar 7, 2025

Why hasn't this PR been merged yet?

@morrownr
Copy link

morrownr commented Mar 7, 2025

@haohetao

It is waiting to be reviewed to go in kernel 6.15:

https://patchwork.kernel.org/project/linux-wireless/list/?series=932665

@Headcrabed
Copy link

@haohetao

It is waiting to be reviewed to go in kernel 6.15:

https://patchwork.kernel.org/project/linux-wireless/list/?series=932665

@morrownr The patch you mentioned above is not related to this MR. Also it seems not working correctly. #783 (comment)

@razvanphp
Copy link
Contributor

@razvanphp Did you send your patch email to all output addresses from ./scripts/get_maintainers.pl? Seems you are not doing it correctly?

No, I just sent it to the list in this list: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS#n14821

I think I can forward it to everybody, including the backport one.

@Headcrabed
Copy link

@razvanphp Did you send your patch email to all output addresses from ./scripts/get_maintainers.pl? Seems you are not doing it correctly?

No, I just sent it to the list in this list: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS#n14821

I think I can forward it to everybody, including the backport one.

@razvanphp better send it to everyone with a resend tag, like this: https://lore.kernel.org/all/TYCPR01MB84373677E45A7BFA5A28232C98792@TYCPR01MB8437.jpnprd01.prod.outlook.com/

@gregoirefavre
Copy link

There was some commits a few hours ago, is this patch still needed ?

im-0 added a commit to im-0/openwrt-mt76 that referenced this pull request Mar 17, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: de3e772 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
im-0 added a commit to im-0/openwrt-mt76 that referenced this pull request Mar 17, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
im-0 added a commit to im-0/openwrt that referenced this pull request Mar 17, 2025
im-0 added a commit to im-0/openwrt that referenced this pull request Mar 17, 2025
@im-0
Copy link

im-0 commented Mar 17, 2025

There was some commits a few hours ago, is this patch still needed ?

This (or alternative) patch is still needed for BPI-R4 / BPI-R4-NIC-BE14.

im-0 added a commit to im-0/openwrt-mt76 that referenced this pull request Mar 18, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
im-0 added a commit to im-0/openwrt that referenced this pull request Mar 18, 2025
@pmarques
Copy link

anybody can guide me on how to apply the patch ?

You need to compile it manually and the easiest way is to add the patch to package/kernel/mt76/patches/, for instance pmarques/openwrt@47008ea

danpawlik pushed a commit to danpawlik/mt76 that referenced this pull request Mar 27, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
(cherry picked from commit aaf90b2)
ptpt52 pushed a commit to ptpt52/mt76 that referenced this pull request Apr 11, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
@MatthewCroughan
Copy link

This is the only patch that fixes the issue on three of my bpi-r4's, whereas #968 does not fix the issue completely. See openwrt/openwrt#17489 (comment) for more details.

smx-smx pushed a commit to smx-smx/mt76 that referenced this pull request Apr 13, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
(cherry picked from commit aaf90b2)
danpawlik pushed a commit to danpawlik/mt76 that referenced this pull request Apr 18, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
(cherry picked from commit aaf90b2)
danpawlik pushed a commit to danpawlik/mt76 that referenced this pull request Apr 18, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
(cherry picked from commit aaf90b2)
frank-w pushed a commit to frank-w/BPI-Router-Linux that referenced this pull request Apr 22, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt/mt76#954
(cherry picked from commit aaf90b24fde77a38ee9f0a60d7097ded6a94ad1f)
@tagatac
Copy link

tagatac commented Apr 25, 2025

What are the next steps to merge or deny this patch? It would have saved me half a day learning how to build OpenWrt yesterday if this were merged 😅

Copy link

@tagatac tagatac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the 6dBm txpower limitation on my BPI-R4 when applied as tagatac/openwrt@19c6417 on top of the v24.10.1 tag, built on Debian with the default config for BPI-R4, and flashed to an SD card, or applied as a sysupgrade to an existing 24.10.1 installation on eMMC

@Critter74
Copy link

maybe the maintainers are still in hibernation ;)
I vote for merge with master

frank-w pushed a commit to frank-w/BPI-Router-Linux that referenced this pull request Apr 29, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt/mt76#954
(cherry picked from commit aaf90b24fde77a38ee9f0a60d7097ded6a94ad1f)
frank-w pushed a commit to frank-w/BPI-Router-Linux that referenced this pull request Apr 29, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt/mt76#954
(cherry picked from commit aaf90b24fde77a38ee9f0a60d7097ded6a94ad1f)
frank-w pushed a commit to frank-w/BPI-Router-Linux that referenced this pull request May 4, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt/mt76#954
(cherry picked from commit aaf90b24fde77a38ee9f0a60d7097ded6a94ad1f)
frank-w pushed a commit to frank-w/BPI-Router-Linux that referenced this pull request May 4, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt/mt76#954
(cherry picked from commit aaf90b24fde77a38ee9f0a60d7097ded6a94ad1f)
ptpt52 pushed a commit to ptpt52/mt76 that referenced this pull request May 8, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
danpawlik pushed a commit to danpawlik/mt76 that referenced this pull request May 9, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt#954
(cherry picked from commit aaf90b2)
frank-w pushed a commit to frank-w/BPI-Router-Linux that referenced this pull request May 10, 2025
Some Banana Pi BPI-R4-NIC-BE14 WiFi modules are sold with zeros instead
of usable tx_power values in EEPROM for 2.4 GHz and 5 GHz bands.

This patch replaces tx_power zeros with default values from firmware
files while keeping the rest of the EEPROM data intact (including valid
6 GHz tx_power table).

Signed-off-by: Ivan Mironov <[email protected]>
Cc: [email protected]
Fixes: 98686cd ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Closes: openwrt/openwrt#17489
Link: openwrt/mt76#954
(cherry picked from commit aaf90b24fde77a38ee9f0a60d7097ded6a94ad1f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.