mediatek: add support for TP-Link TL-XDR3230 v1
Specifications:
- SoC: Mediatek MT7622B
- RAM: 256M
- Flash: EN25QH128 16M
- Ethernet: RTL8367S 4xGE
- WiFi: MT7622 2.4G 4x4 + MT7905 5G 4x4
Flash instruction:
TP-Link locks down their firmware and serial console, so the firmware
in this patch must be flashed with an SPI flash programmer.
1. Desolder the flash and backup the original flash content with a flash
programmer.
2. Save the following script as gen_image.sh:
===========Script begins here==========
FULLFLASH=$1
IMG_DIR=$2
OUTPUT=$3
BL2=${IMG_DIR}/openwrt-mediatek-mt7622-tplink_tl-xdr3230-v1-preloader.bin
FIP=${IMG_DIR}/openwrt-mediatek-mt7622-tplink_tl-xdr3230-v1-bl31-uboot.fip
FW=${IMG_DIR}/openwrt-mediatek-mt7622-tplink_tl-xdr3230-v1-squashfs-sysupgrade.bin
macaddr_add() {
local mac=$1
local val=$2
local oui=${mac%:*:*:*}
local nic=${mac#*:*:*:}
nic=$(printf "%06x" $((0x${nic//:/} + val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
echo $oui:$nic
}
macaddr_2bin() {
local mac=$1
echo -ne \\x${mac//:/\\x}
}
dd if=/dev/zero bs=4k count=236 | tr "\000" "\377" > ${OUTPUT}
dd conv=notrunc if=${BL2} of=${OUTPUT} bs=4k
dd conv=notrunc if=${FIP} of=${OUTPUT} bs=4k seek=32
dd conv=notrunc if=${FULLFLASH} of=${OUTPUT} bs=4k seek=112 skip=110 count=2
MAC=$(hexdump -v -n 6 -s 0x6d81c -e '5/1 "%02x:" 1/1 "%02x"' ${FULLFLASH})
macaddr_2bin ${MAC} | dd conv=notrunc of=${OUTPUT} bs=1 seek=458756 count=6
MAC_5G=$(macaddr_add ${MAC} 2)
macaddr_2bin ${MAC_5G} | dd conv=notrunc of=${OUTPUT} bs=1 seek=462852 count=6
dd conv=notrunc if=${FW} of=${OUTPUT} bs=64k seek=8
===========Script ends here==========
3. generate a image for flash programmer:
./gen_image.sh original_flash_backup.bin openwrt/bin/targets/mediatek/mt7622 output_image.bin
4. flash the generated output_image.bin with a flash programmer and
solder the chip back onto the device.