Skip to content
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

lantiq: Update TP-Link TD-W89x0 flash layout #9775

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

Conversation

Rupurudu
Copy link
Contributor

Flash space is scarce on 8MB devices, this commit adds 124KB of usable space by reusing OEM user configuration and unused space. I also split the partitions to seperate MAC Address & WPS key, Memory configuration, and Wi-Fi calibration data.

@mans0n mans0n added the target/lantiq pull request/issue for lantiq target label Apr 26, 2022
Copy link
Member

@dangowrt dangowrt left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@hauke
Copy link
Member

hauke commented Apr 30, 2022

Please fix the commit message.

  • Please write your name in the same way in the Author attribute line and the Signed-off by line.
  • Please line break your commit message.

@Rupurudu
Copy link
Contributor Author

Rupurudu commented May 1, 2022

Please fix the commit message.

* Please write your name in the same way in the Author attribute  line and the Signed-off by line.

* Please line break your commit message.

Hello @hauke ,

  • Changed the Signed-off line to use the same casing as my Author name. (previously I used uppercase.)
  • Line breaked to 75 lines (Previously 80 lines.)

@hauke
Copy link
Member

hauke commented May 16, 2022

It does not detect my wifi devce any more:

Mon May 16 17:20:56 2022 kern.info kernel: [   23.108400] NET: Registered protocol family 24
Mon May 16 17:20:56 2022 kern.warn kernel: [   23.518484] ifx_pcie_bios_map_irq port 0 dev 0000:01:00.0 slot 0 pin 1
Mon May 16 17:20:56 2022 kern.warn kernel: [   23.523683] ifx_pcie_bios_map_irq dev 0000:01:00.0 irq 144 assigned
Mon May 16 17:20:56 2022 kern.info kernel: [   23.530072] ath9k 0000:01:00.0: enabling device (0000 -> 0002)
Mon May 16 17:20:56 2022 kern.warn kernel: [   23.536452] ath9k 0000:01:00.0: Direct firmware load for ath9k-eeprom-pci-0000:01:00.0.bin failed with error -2
Mon May 16 17:20:56 2022 kern.warn kernel: [   23.545964] ath9k 0000:01:00.0: Falling back to sysfs fallback for: ath9k-eeprom-pci-0000:01:00.0.bin
Mon May 16 17:20:56 2022 kern.err kernel: [   25.390484] ath: phy0: Unable to load EEPROM file ath9k-eeprom-pci-0000:01:00.0.bin
Mon May 16 17:20:56 2022 kern.err kernel: [   25.396913] ath9k 0000:01:00.0: Failed to initialize device
Mon May 16 17:20:56 2022 kern.warn kernel: [   25.402480] ath9k: probe of 0000:01:00.0 failed with error -22
Mon May 16 17:20:56 2022 user.info kernel: [   25.410066] kmodloader: done loading kernel modules from /etc/modules.d/*

@xdarklight
Copy link
Contributor

It does not detect my wifi devce any more:

I think target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom needs to be updated as well.
Or preferably this PR would switch from that userspace script to using nvmem for the EEPROM like (for example) target/linux/ath79/dts/qcn5502_tplink_archer-a9-v6.dts does

@Rupurudu Rupurudu force-pushed the w89x0_flash branch 6 times, most recently from 22fffab to 7fce8df Compare May 18, 2022 20:07
@Rupurudu
Copy link
Contributor Author

It does not detect my wifi devce any more:

Thanks for testing.

I think target/linux/lantiq/xrx200/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom needs to be updated as well. Or preferably this PR would switch from that userspace script to using nvmem for the EEPROM like (for example) target/linux/ath79/dts/qcn5502_tplink_archer-a9-v6.dts does

I checked this file and while I do think switching to nvmem is better, but I see not all of the targets can switch to nvmem because they manipulate the firmware in different ways (reverse, patch, external scripts). I just fixed the offset on the script, wifi should work now.

@xdarklight
Copy link
Contributor

I checked this file and while I do think switching to nvmem is better, but I see not all of the targets can switch to nvmem because they manipulate the firmware in different ways (reverse, patch, external scripts).

Just to be clear (because I think my last comment wasn't that clear): my thought was to only switch the two TP-Link boards (which are managed in one .dtsi anyways) to nvmem, not all boards.

@Rupurudu
Copy link
Contributor Author

Rupurudu commented May 19, 2022

Okay, I can switch to nvmem for TP-Link TD-W8970 and TP-Link TD-W8980.

@Rupurudu Rupurudu requested a review from hauke May 24, 2022 12:28
@xdarklight
Copy link
Contributor

Looks good to me, so:

Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

@hauke
Copy link
Member

hauke commented Apr 2, 2023

The wifi driver is still not able to find the eeprom:

[   20.596332] ifx_pcie_bios_map_irq port 0 dev 0000:01:00.0 slot 0 pin 1 
[   20.601589] ifx_pcie_bios_map_irq dev 0000:01:00.0 irq 144 assigned
[   20.607810] ath9k 0000:01:00.0: enabling device (0000 -> 0002)
[   20.614270] ath9k 0000:01:00.0: Direct firmware load for ath9k-eeprom-pci-0000:01:00.0.bin failed with error -2
[   20.623823] ath9k 0000:01:00.0: Falling back to sysfs fallback for: ath9k-eeprom-pci-0000:01:00.0.bin
[   21.239397] ath: phy0: Unable to load EEPROM file ath9k-eeprom-pci-0000:01:00.0.bin
[   21.245709] ath9k 0000:01:00.0: Failed to initialize device
[   21.251478] ath9k: probe of 0000:01:00.0 failed with error -22
[   21.258671] kmodloader: done loading kernel modules from /etc/modules.d/*
[   43.810582] gswip 1e108000.switch lan1: configuring for phy/rgmii link mode

@github-actions github-actions bot added the kernel pull request/issue with Linux kernel related changes label Nov 4, 2024
@Rupurudu
Copy link
Contributor Author

Rupurudu commented Nov 4, 2024

The wifi driver is still not able to find the eeprom:

[   20.596332] ifx_pcie_bios_map_irq port 0 dev 0000:01:00.0 slot 0 pin 1 
[   20.601589] ifx_pcie_bios_map_irq dev 0000:01:00.0 irq 144 assigned
[   20.607810] ath9k 0000:01:00.0: enabling device (0000 -> 0002)
[   20.614270] ath9k 0000:01:00.0: Direct firmware load for ath9k-eeprom-pci-0000:01:00.0.bin failed with error -2
[   20.623823] ath9k 0000:01:00.0: Falling back to sysfs fallback for: ath9k-eeprom-pci-0000:01:00.0.bin
[   21.239397] ath: phy0: Unable to load EEPROM file ath9k-eeprom-pci-0000:01:00.0.bin
[   21.245709] ath9k 0000:01:00.0: Failed to initialize device
[   21.251478] ath9k: probe of 0000:01:00.0 failed with error -22
[   21.258671] kmodloader: done loading kernel modules from /etc/modules.d/*
[   43.810582] gswip 1e108000.switch lan1: configuring for phy/rgmii link mode

Hello,
I'm sorry that it took me so long to fix this.
I removed qca,no-eeprom; which is why I believe wifi driver is unable to find the eeprom.

@Rupurudu
Copy link
Contributor Author

Rupurudu commented Nov 4, 2024

Force pushed to squash the commits.

@Rupurudu
Copy link
Contributor Author

Rupurudu commented Dec 19, 2024

@hauke can we please merge this before 24.10 release? Currently 24.10-rc2 with default package configuration is too big for this device by 56089 bytes, with this change it barely fits.

I know I can always compile from the sources, but given this is one of the rare dsl devices, I would love to have official builds for everyone to use.

edit: I just saw #17303 I'm moving the changes to the xrx200_legacy, hopefully this can get merged after it.

@Rupurudu Rupurudu force-pushed the w89x0_flash branch 2 times, most recently from 3dc8157 to 3d52754 Compare December 19, 2024 14:12
@Rupurudu
Copy link
Contributor Author

This is now based on the @neheb's work on converting the W89x0 to nvmem layout and fixing the calibration size on W8980.
Thanks @neheb!

Check #17278 for more details.

@@ -57,7 +57,7 @@ lantiq_setup_macs()
;;
tplink,tdw8970|\
tplink,tdw8980)
wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0xf100)" 1)
wan_mac=$(macaddr_add "$(mtd_get_mac_binary boardconfig 0x100)" 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be handled in dts, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right. This is for an interface not specified in dts. nvm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, it's for the dsl interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this further, there’s the vdsl node. If the driver uses of_get_mac_address, it can be converted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know. I checked the other lantiq based devices, but I couldn't find any device that sets the mac address of the dsl port through dts.

Copy link
Contributor

Choose a reason for hiding this comment

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

i checked the driver. Not happening.

@hauke
Copy link
Member

hauke commented Dec 20, 2024

Does sysupgrde work without problems from an older version to this version with changed partition layout?
If some manual changes are needed please update the COMPAT version.

@hauke
Copy link
Member

hauke commented Dec 20, 2024

What was inside this partition you are reusing? Does this make going back to the vendor firmware more complicated than before?

@Rupurudu
Copy link
Contributor Author

Rupurudu commented Dec 20, 2024

What was inside this partition you are reusing? Does this make going back to the vendor firmware more complicated than before?

The old config partition has the OEM firmware's user configuration. It's basically a xml file with a checksum in the header. The OEM firmware allows you to download this config with it's web UI, if the user has that they can basically restore that.

Modifying the config is explained in the wiki: https://openwrt.org/toh/tp-link/td-w8970_v1#installation_without_opening_the_case_web_interface_hack

If the user doesn't have a config file, holding down the reset button while the device is booting should reset this the config to the factory defaults if it's not already reset because of the incorrect checksum. In case it doesn't I put my config file which others can use: TD-W8970_config_partition.zip

The space between 0x7d0000 - 0x7df000 is completely blank. These sectors could be erased before going back to OEM firmware, though it's not necessary.

Does sysupgrde work without problems from an older version to this version with changed partition layout? If some manual changes are needed please update the COMPAT version.

Going from an older version to this version works, even with the config.

But, going from this version to another version does not. I tested this today with my only vdsl router and found out the hard way. While the flash EN56Q64-104HIP supports both 4KB and 64KB erasesizes, the MTD driver is configured to use 64KB uniform erase. After the boot you get this warning in the system log:

mtd: partition "firmware" doesn't start on an erase/write block boundary -- force read-only

The device fully works in this state except you can't sysupgrade, since the firmware partition is now locked. I had to open the device and recover from serial console with tftpboot.

To fix this either CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE or CONFIG_MTD_SPI_NOR_USE_4K_SECTORS should be used. I'm using CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE and I had no problems right now.

@Rupurudu
Copy link
Contributor Author

Added CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE=y to the kernel config.

Flash space is scarce on 8MB devices, this commit adds 124KB of usable
space by reusing OEM user configuration and unused space.

This commit also switches from userspace script to using nvmem for ath9k
calibration data.

Signed-off-by: Mustafa Can Elmacı <mustafacan@elmaci.net>
@Rupurudu
Copy link
Contributor Author

#16555 got merged, so this is only the flash layout changes now.

@Rupurudu
Copy link
Contributor Author

Rupurudu commented Jan 7, 2025

@hauke @dangowrt is there a possibility that we can merge and backport this to 24.10 before it ships?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel pull request/issue with Linux kernel related changes target/lantiq pull request/issue for lantiq target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants