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

ipq40xx: Add support for TP-Link Deco M5 EU v3.0 #4309

Closed
wants to merge 2 commits into from
Closed

ipq40xx: Add support for TP-Link Deco M5 EU v3.0 #4309

wants to merge 2 commits into from

Conversation

GoliathLabs
Copy link
Contributor

@GoliathLabs GoliathLabs commented Jun 24, 2021

TP-Link Deco M5 EU (v3.0) is a wireless router

Specification
SoC: Qualcomm IPQ4019
RAM: 256 MiB
Flash: 32 MiB
WiFi: Qualcomm IPQ4019 (2,4 GHz + 5 GHz) 802.11bgnac
Ethernet : 1x (10/100/1000 Mbps) IPQ4019
Switch: Qualcomm Atheros QCA8072
LEDs: 1x
USB: 1x 2.0
FCCID: TE7M5V3

Installation

It is possible to install OpenWrt on this model. The same method works for restoring the default firmware.

→ generic.flashing.tftp

Connect one of the LAN ports (might need to be specifically port 1) to a machine running a TFTP server. Configure the server machine with IP 192.168.0.66/24 [1]. The router will run as a TFTP client at 192.168.0.88.

Obtain a stock firmware or a 'factory' OpenWrt image. Save the firmware to the TFTP server as M5v3_tp_recovery.bin. Replace the v3 with the version number of your hardware if you don't have a v3.

To start the TFTP recovery process on the router, press and hold the WPS/Reset button and turn on the router. Hold down the WPS/Reset button until the TFTP transfer starts.

If everything went correctly, you should see a read request in your TFTP server. The flash process will take about 3 to 5 minutes.

Further sysupgrades can be performed via the web interface.

Signed-off-by: Felix Golatofski git@xdfr.de

@GoliathLabs
Copy link
Contributor Author

GoliathLabs commented Jun 24, 2021

This is my first PR regarding OpenWrt, so don't expect everything to be perfect. Nonetheless, I hope to bring official support for this device upstream.

The repository I took changes from also modified the safeloader quite a bit. I don't know to what extent this is necessary in this case (https://github.com/lntgn/openwrt/blob/master/tools/firmware-utils/src/tplink-safeloader.c). The maintainer of the repository has contacted me to see if I am willing to add support for this device to the upstream, he does not want credit for it.

In the meantime, you are doing a great job with maintaining this heavy codebase and supporting some older router models for years to come! Thank you very much 😄.

EDIT: The safeloader from @lntgn's repository is just a modified one from the 19.07 branch of OpenWrt

Signed-off-by: Felix Golatofski <git@xdfr.de>

Added: board to ipq-wifi

Signed-off-by: Felix Golatofski <git@xdfr.de>

Added: device to base-files as well as .dts file

Signed-off-by: Felix Golatofski <git@xdfr.de>

Added: generic target for device

Signed-off-by: Felix Golatofski <git@xdfr.de>

Added: Deco M5 EU v3 to tplink safeloader

Signed-off-by: Felix Golatofski <git@xdfr.de>
@dniminenn
Copy link

The repository I took changes from also modified the safeloader quite a bit. I don't know to what extent this is necessary in this case (https://github.com/lntgn/openwrt/blob/master/tools/firmware-utils/src/tplink-safeloader.c).

Instead of fixing the conflicts that came up when merging from frankveltmans/openwrt I just copied the file verbatim. It worked well enough for my own use, but it certainly wasn't appropriate to submit a pull request with that bastardized tplink-safeloader.c

Thank you for taking the time to do it correctly.

@GoliathLabs
Copy link
Contributor Author

No problem, didn't take that long. Just do a quick grep for "Deco M5" and you have the appropriate sections to move to the master's safeloader.

@GoliathLabs
Copy link
Contributor Author

This could also work for the non-EU variant, as the only differences seem to be in the power supply.

@dniminenn
Copy link

dniminenn commented Jun 24, 2021

This could also work for the non-EU variant, as the only differences seem to be in the power supply.

Confirmed working on Deco M5 V3/CA. Purchased in Canada with a 120V power supply and a barrel connector on the device. I believe the EU variant has a USB-C connector for power rather than barrel plug. The USB-C connector is reportedly only for power, no host or client functionality.

Edit -- tplink-safeloader.c does not build.

@GoliathLabs
Copy link
Contributor Author

If a reviewer says things are good as they are now, I could change things to an international format I guess? (Deco M5 v3)

Advice from an advanced contributor would be appreciated here 😄

@dniminenn
Copy link

I just tried building this, your tplink-safeloader.c spits out a bunch of errors. It needs to be reworked it into a format compatible with the current state of openwrt. That's where I got stuck.

@GoliathLabs
Copy link
Contributor Author

Can you provide me the log?

@GoliathLabs
Copy link
Contributor Author

GoliathLabs commented Jun 24, 2021

I'll take a look at it later

EDIT: Okay. Looks like the changes to the safeloader are quite small. These should be quite easily adapted to the master branch, I think

@dniminenn
Copy link

Can you provide me the log?

https://pastebin.com/UY55YEUU

Thank you.

@adschm adschm added the target/ipq40xx pull request/issue for ipq40xx target label Jun 27, 2021
@adschm
Copy link
Member

adschm commented Jun 27, 2021

This has formal issues.

Please clean up your commit message and add Specifications, Flashing instructions, and MAC addr table.

https://openwrt.org/submitting-patches
https://openwrt.org/docs/guide-developer/device-support-policies

@@ -50,7 +50,8 @@ ALLWIFIBOARDS:= \
netgear_wac510 \
plasmacloud_pa1200 \
plasmacloud_pa2200 \
qxwlan_e2600ac
qxwlan_e2600ac \
tp-link_deco_m5_eu_v3.0
Copy link
Member

Choose a reason for hiding this comment

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

Typically, TP-Link uses the same hardware for all y in vx.y.

So, would v3 be enough here instead of v3.0?

Do you know whether non-eu versions are different? eu should only be added if it's different from the other v3, and when this is the case it should be last, i.e. Vendor Model Vx (EU) and vendor_model-vx-eu ...

Choose a reason for hiding this comment

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

I did not submit the PR but I will reply since it may help with this effort.

Yes, v3 would do the trick. V3.2 and V3 have identical hardware. I believe V1 also, since TP-Link reuses the same firmware for V1, V3 and V3.2 variants. Those have NOR flash, while the V2 model has NAND flash. (Not sure if there are other differences)

International variants only differ in the provided power supply. The CA and US devices have a 120V adapter along with a barrel connector, the EU variant I believe has a USB-C port for power (and only power, not hooked up to USB logic).

Copy link
Member

Choose a reason for hiding this comment

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

v1 and v3 should be separate then, and this should probably be named v3 without region ...

@@ -117,6 +117,9 @@ ipq40xx_setup_interfaces()
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
;;
tp-link,deco-m5-eu-v3.0)
Copy link
Member

Choose a reason for hiding this comment

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

Vendor prefix for TP-Link is tplink in the compatible. You can make your and our job much easier by having a look at what other people have done in similar cases before you ...

Copy link
Member

Choose a reason for hiding this comment

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

And for the particular setup here, this can be merged with the proper case above.

@@ -159,6 +159,10 @@ case "$FIRMWARE" in
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
;;
tp-link,deco-m5-eu-v3.0)
caldata_extract "0:ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/dev/mtd10" 0x8) +2)
Copy link
Member

Choose a reason for hiding this comment

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

Please use the proper partition name. use "2" instead of "+2".

@@ -273,6 +277,10 @@ case "$FIRMWARE" in
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
;;
tp-link,deco-m5-eu-v3.0)
caldata_extract "0:ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/dev/mtd10" 0x8) +3)
Copy link
Member

Choose a reason for hiding this comment

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

See above.

@@ -29,6 +29,11 @@ preinit_set_mac_address() {
base_mac=$(cat /sys/class/net/eth0/address)
ip link set dev eth0 address $(macaddr_add "$base_mac" 2)
ip link set dev eth1 address $(macaddr_add "$base_mac" 3)
;;
tp-link,deco-m5-eu-v3.0)
Copy link
Member

Choose a reason for hiding this comment

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

Alphabetic sorting.

tp-link,deco-m5-eu-v3.0)
base_mac=$(get_mac_binary "/dev/mtd10" 0x8)
ip link set dev eth0 address "${base_mac}"
ip link set dev eth1 address $(macaddr_add "$base_mac" +1)
Copy link
Member

Choose a reason for hiding this comment

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

See above. But this looks like it can be set in DTS instead and removed here anyway.

* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Copy link
Member

Choose a reason for hiding this comment

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

use SPDX instead.

+ qcom-ipq4019-deco-m5-eu-v3.0.dtb \
+ qcom-ipq4019-a62.dtb \
+ qcom-ipq4019-cm520-79f.dtb \
+ qcom-ipq4019-ea8300.dtb \
Copy link
Member

Choose a reason for hiding this comment

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

This looks unrelated.

Choose a reason for hiding this comment

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

AFAIK they are unrelated. Since it's a patch file, github is showing green lines where there shouldn't be... the only line that was actually added is line 48. 49, 50 and 51 just moved down one line.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so, these lines are duplicated.

@@ -2473,6 +2473,82 @@ static struct device_info boards[] = {
.first_sysupgrade_partition = "os-image",
.last_sysupgrade_partition = "file-system"
},
{
.id = "DECO-M5-EU-V3.0",
Copy link
Member

Choose a reason for hiding this comment

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

Sorting ...

"{product_name:M5,product_ver:3.2.0,special_id:49440000}\n"
"{product_name:M5,product_ver:3.2.0,special_id:53570000}\n"
"{product_name:M5,product_ver:3.2.0,special_id:42340000}\n"
"{product_name:M5,product_ver:3.2.0,special_id:54570000}\n",
Copy link
Member

Choose a reason for hiding this comment

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

Ah, so now you are contradicting yourself, since this is neither limited to 3.0 nor to EU.
And please do not add 1.0 strings to a v3. This should be sorted, and please check whether the partition table in all of the devices finally chosen is the same.

Copy link

@dniminenn dniminenn Jun 28, 2021

Choose a reason for hiding this comment

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

Some more info about this device... V1, V3 and V3.2 seem compatible with each other. I cannot say for 100% certainty, but the stock firmware is identical for all three. It only differs on V2... with that said, I have a V3 / CA working flawlessly. These "special_id's" match what is found in stock firmware.

edit -- they are all the same, the only differences are supplied power adaptors. V1 and V2 come with a GD25Q256 NOR flash and V3/3.2 come with W25Q256 NOR flash. They both support the same quirky 3/4 byte addressing mode and are pin compatible, so should be a non-issue! :)

Copy link
Member

Choose a reason for hiding this comment

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

v1 and v3 should be treated separately if v2 is different.

{"device-config", 0x210000, 0x10000},
{"group-info", 0x220000, 0x10000},
{"partition-table@0", 0x230000, 0x02000},
{"os-image@0", 0x240000, 0x300000},
Copy link
Member

Choose a reason for hiding this comment

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

Is this @0 syntax correct here?

@@ -2921,6 +2997,30 @@ static void build_image(const char *output,
os_image_partition->size = kernel.st_size;
}

if (strcasecmp(info->id, "DECO-M5-EU-V3.0") == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

What's that supposed to do. This should be discussed in your commit message. If you have to introduce that much logic, I'd even consider to make the tplink-safeloader changes a separate commit before adding the actual device.

@GoliathLabs
Copy link
Contributor Author

@lntgn I have invited you to the repository. I'm in the middle of my exams at university right now, so I don't have that much time to sort things out. Maybe you want to try it out

@dniminenn
Copy link

dniminenn commented Jul 2, 2021 via email

@wulfy23
Copy link
Contributor

wulfy23 commented Jul 4, 2021

when the commit message is sorted... please clarify usb port type and feature-set...

@gustavargas
Copy link

Reporting from:

SoC: Qualcomm IPQ4019
RAM: 256 MiB
Flash: 32 MiB
WiFi: Qualcomm IPQ4019 (2,4 GHz + 5 GHz) 802.11bgnac
Ethernet : 1x (10/100/1000 Mbps) IPQ4019
Switch: Qualcomm Atheros QCA8072
LEDs: 1x
USB: 0x 2.0
FCCID: TE7M5V3
Version compiled: OpenWrt SNAPSHOT r17048-f32b247c50 / LuCI Master git-21.196.22411-7d9ab8d
Variant: US/3.0 with power cable, no usb port.

Working without any problem. Flashed with TFTP method.

@Gamerayers
Copy link

Any chance it works on the Deco M9 also? I know the major difference between M5 and M9 is that the M9 has additional hardware for Home Automation Hub?

@robhanlon22
Copy link

@gustavargas did you have to make any modifications to get it working on your US/3.0?

@gustavargas
Copy link

@gustavargas did you have to make any modifications to get it working on your US/3.0?

No, I just compile the source from the pull request (https://github.com/MorphNetwork/openwrt) and flashed with the TFTP method. 3 days working just fine in 3 M5 US 3.0 Version.

@LennardF1989
Copy link

Does the whole mesh feature still work with this? Or will it become a "normal" Router/AP depending on configuration?

@gustavargas
Copy link

Does the whole mesh feature still work with this? Or will it become a "normal" Router/AP depending on configuration?

The OpenWRT recognizes the mesh feature, but I didn't use it. I connected with lan cables the APs and works nicely with fast roaming.

@beandj
Copy link

beandj commented Aug 22, 2021

@gustavargas, How did you build? I get error on tplink-safeloader.c during build. Can you share the compiled .bin? Or explain which selections in make menuconfig ?

@GoliathLabs
Copy link
Contributor Author

@gustavargas or others interested in getting upstream support for this device, feel free to send me pull requests and I will merge them here. I don't have much time right now, so I can't do much work on this at the moment. Help is always appreciated :).

@adschm
Copy link
Member

adschm commented Nov 1, 2021

Looks like nothing has changed here?

@adschm adschm added the stale pull request without feedback by the author for a long time label Nov 1, 2021
@dniminenn
Copy link

dniminenn commented Nov 1, 2021 via email

@colinfindlay-nz
Copy link

@lntgn @GoliathLabs
I might have a few days free - was it only cosmetic and documentation changes required to get this merged?

@GoliathLabs
Copy link
Contributor Author

GoliathLabs commented Dec 17, 2021 via email

TomerCo added a commit to TomerCo/openwrt that referenced this pull request Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs changes stale pull request without feedback by the author for a long time target/ipq40xx pull request/issue for ipq40xx target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants