自编译Tl-wdr5600-v1的OpenWrt固件

自编译Tl-wdr5600-v1的OpenWrt固件:wdr5600-v1在OpenWrt官网上并没有可用的固件供下载,所以通常我们都是利用wdr6500-v2模板,通过修改相应文件来编译产生适用于wdr5600-v1的固件。当然你也可以做得更彻底,跟wdr7400-v2一样通过添加新设备的方式直接生成像官方固件一样正式的固件。受篇幅所限,本文只介绍wdr5600-v1与wdr6500-v2在编译之前需要知道的不同之处,其它过程像wdr5600-v1刷breed、自编译过程、添加新设备等过程都统统略去。

一、保证无线5G正常工作

由于wdr6500-v2的5G无线采用的是qca9882芯片,而wdr5600-v1采用的则是qca9887芯片,所以必须采用不同的驱动程序,否则无线5G不能用。

修改 ~/target/linux/ar71xx/image/generic-tp-link.mk 中wdr6500-v2的5G无线驱动程序:

define Device/tl-wdr6500-v2
  $(Device/tplink-8mlzma)
  DEVICE_TITLE := TP-LINK TL-WDR6500 v2
  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport kmod-ath10k-ct ath10k-firmware-qca988x-ct
  KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
  KERNEL_INITRAMFS := kernel-bin | patch-cmdline | lzma | uImage lzma | tplink-v1-header
  BOARDNAME := TL-WDR6500-v2
  DEVICE_PROFILE := TLWDR6500V2
  TPLINK_HWID := 0x65000002
  TPLINK_HEADER_VERSION := 2
endef
TARGET_DEVICES += tl-wdr6500-v2

将 kmod-ath10k-ct 修改为 kmod-ath10k;将 ath10k-firmware-qca988x-ct 修改为 ath10k-firmware-qca9887

define Device/tl-wdr6500-v2
  $(Device/tplink-8mlzma)
  DEVICE_TITLE := TP-LINK TL-WDR6500 v2
  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport kmod-ath10k ath10k-firmware-qca9887
  KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
  KERNEL_INITRAMFS := kernel-bin | patch-cmdline | lzma | uImage lzma | tplink-v1-header
  BOARDNAME := TL-WDR6500-v2
  DEVICE_PROFILE := TLWDR6500V2
  TPLINK_HWID := 0x65000002
  TPLINK_HEADER_VERSION := 2
endef
TARGET_DEVICES += tl-wdr6500-v2
二、保证网络及系统指示灯工作正常

1、修改 ~/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr6500-v2.c 文件中指示灯的配置

#define TL_WDR6500_V2_GPIO_LED_SYS	21
#define TL_WDR6500_V2_GPIO_LED_WAN	18
#define TL_WDR6500_V2_GPIO_LED_LAN1	17
#define TL_WDR6500_V2_GPIO_LED_LAN2	16
#define TL_WDR6500_V2_GPIO_LED_LAN3	15
#define TL_WDR6500_V2_GPIO_LED_LAN4	14
{
        .name		= "tp-link:white:system",
        .gpio		= TL_WDR6500_V2_GPIO_LED_SYS,
        .active_low	= 0,
    },

先将WAN口指示灯GPIO从 18 改为 19

#define TL_WDR6500_V2_GPIO_LED_SYS	21
#define TL_WDR6500_V2_GPIO_LED_WAN	19
#define TL_WDR6500_V2_GPIO_LED_LAN1	17
#define TL_WDR6500_V2_GPIO_LED_LAN2	16
#define TL_WDR6500_V2_GPIO_LED_LAN3	15
#define TL_WDR6500_V2_GPIO_LED_LAN4	14

再将系统指示灯从高电平点亮修改为低电平点亮

{
        .name		= "tp-link:white:system",
        .gpio		= TL_WDR6500_V2_GPIO_LED_SYS,
        .active_low	= 1,
    },

2、修改~/target/linux/ar71xx/base-files/etc/board.d/01_leds 文件中WAN口交换机switch的名称

tl-wdr6500-v2|\
tl-wr741nd)
    ucidef_set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
    ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x02"
    ucidef_set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x04"
    ucidef_set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x08"
    ucidef_set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x10"

修改为

tl-wdr6500-v2|\
tl-wr741nd)
    ucidef_set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth0"
    ucidef_set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x02"
    ucidef_set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x04"
    ucidef_set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x08"
    ucidef_set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x10"
三、解决wan口卡死问题

网络上有人在说wdr5600-v1路由器按wdr6500-v2自编译固件运行后,会出现wan口卡死现象,自己测试时并未发现有此问题,所以下面的解决方法仅做为备选方案讨论。

修改 ~/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c 文件如下内容:

case ATH79_SOC_QCA956X:
        if (id == 0) {
            pdata->reset_bit = QCA955X_RESET_GE0_MAC |
                       QCA955X_RESET_GE0_MDIO;

            if (pdata->phy_if_mode == PHY_INTERFACE_MODE_SGMII)
                pdata->set_speed = qca956x_set_speed_sgmii;
            else
                pdata->set_speed = ar934x_set_speed_ge0;

            pdata->disable_inline_checksum_engine = 1;

修改为

case ATH79_SOC_QCA956X:
        if (id == 0) {
            pdata->reset_bit = QCA955X_RESET_GE0_MAC |
                       QCA955X_RESET_GE0_MDIO;

            if (pdata->phy_if_mode == PHY_INTERFACE_MODE_SGMII)
                pdata->set_speed = qca956x_set_speed_sgmii;
            else
                pdata->set_speed = ath79_set_speed_dummy;

            pdata->disable_inline_checksum_engine = 1;
四、自编译Tl-wdr5600-v1的OpenWrt固件

wdr5600-v1以添加新设备方式产生的OpenWrt19.07.7版本固件,我已经编译完成:openwrt-ar71xx-generic-tl-wdr5600-v1-squashfs-factory.bin,目前刷入路由器后运行一切正常:

自编译Tl-wdr5600-v1的OpenWrt固件-1

 

自编译Tl-wdr5600-v1的OpenWrt固件-2

有需要的朋友,可以给我发邮件:hzshw@hz.cn