Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
ipq806x: add support for ruijie_rg-mtfi-m520 (#3025)
Browse files Browse the repository at this point in the history
Signed-off-by: AmadeusGhost <[email protected]>
  • Loading branch information
aiamadeus authored Feb 11, 2020
1 parent cd3bbb5 commit 464fb0c
Show file tree
Hide file tree
Showing 15 changed files with 1,530 additions and 2 deletions.
4 changes: 4 additions & 0 deletions target/linux/ipq806x/base-files/etc/board.d/01_leds
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ netgear,r7800)
ucidef_set_led_switch "wan" "WAN" "${boardname}:white:wan" "switch0" "0x20"
ucidef_set_led_ide "esata" "eSATA" "${boardname}:white:esata"
;;
ruijie,rg-mtfi-m520)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2g" "phy1tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:green:wlan5g" "phy0tpt"
;;
tplink,c2600)
ucidef_set_led_usbport "usb1" "USB 1" "${boardname}:white:usb_2" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "usb2" "USB 2" "${boardname}:white:usb_4" "usb3-port1" "usb4-port1"
Expand Down
7 changes: 7 additions & 0 deletions target/linux/ipq806x/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ qcom,ipq8064-db149)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:lan" "6u@eth1" "5:wan" "0u@eth0"
;;
ruijie,rg-mtfi-m520)
hw_mac_addr=$(mtd_get_mac_ascii PRODUCTINFO ethaddr)
ucidef_add_switch "switch0" \
"1:lan" "6@eth1" "5:wan" "0@eth0"
ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
ucidef_set_interface_macaddr "lan" "$(macaddr_add $hw_mac_addr 1)"
;;
zyxel,nbg6817)
hw_mac_addr=$(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
ucidef_add_switch "switch0" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ ath10kcal_patch_mac_crc() {
board=$(board_name)

case "$FIRMWARE" in
"ath10k/cal-pci-0000:01:00.0.bin")
case "$board" in
ruijie,rg-mtfi-m520)
ath10kcal_extract "ART" 4096 2116
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii PRODUCTINFO ethaddr) +2)
;;
esac
;;
"ath10k/cal-pci-0001:01:00.0.bin")
case "$board" in
ruijie,rg-mtfi-m520)
ath10kcal_extract "ART" 20480 2116
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii PRODUCTINFO ethaddr) +3)
;;
esac
;;
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case $board in
buffalo,wxr-2533dhp)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

. /lib/functions.sh

preinit_set_mac_address() {
case $(board_name) in
ruijie,rg-mtfi-m520)
base_mac=$(mtd_get_mac_ascii PRODUCTINFO ethaddr)
ip link set dev eth0 address $(macaddr_add "$base_mac" +1)
ip link set dev eth1 address $(macaddr_add "$base_mac" +2)
;;
esac
}

boot_hook_add preinit_main preinit_set_mac_address
4 changes: 4 additions & 0 deletions target/linux/ipq806x/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ platform_do_upgrade() {
netgear,r7800 |\
qcom,ipq8064-ap148 |\
qcom,ipq8064-ap161 |\
ruijie,rg-mtfi-m520 |\
zyxel,nbg6817)
nand_do_upgrade "$ARGV"
;;
Expand All @@ -47,6 +48,9 @@ platform_do_upgrade() {

platform_nand_pre_upgrade() {
case "$(board_name)" in
ruijie,rg-mtfi-m520)
ruijie_do_upgrade "$1"
;;
zyxel,nbg6817)
zyxel_do_upgrade "$1"
;;
Expand Down
53 changes: 53 additions & 0 deletions target/linux/ipq806x/base-files/lib/upgrade/ruijie.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# Copyright (C) 2016 lede-project.org
# Copyright (C) 2020 AnYun
#

ruijie_do_flash() {
local tar_file=$1
local kernel=$2
local rootfs=$3

# keep sure its unbound
losetup --detach-all || {
echo Failed to detach all loop devices. Skip this try.
reboot -f
}

# use the first found directory in the tar archive
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
board_dir=${board_dir%/}

echo "flashing kernel to $kernel"
tar xf $tar_file ${board_dir}/kernel -O > $kernel

echo "flashing rootfs to $rootfs"
tar xf $tar_file ${board_dir}/root -O > $rootfs

# Cleanup
losetup -d /dev/loop0 >/dev/null 2>&1
sync
umount -a
reboot -f
}

ruijie_do_upgrade() {
local tar_file="$1"
local board=$(board_name)
local kernel=
local rootfs=

case "$board" in
ruijie,rg-mtfi-m520)
kernel="/dev/mmcblk0p2"
rootfs="/dev/mmcblk0p3"
;;
*)
return 1
;;
esac

ruijie_do_flash $tar_file $kernel $rootfs

return 0
}
1 change: 1 addition & 0 deletions target/linux/ipq806x/config-4.14
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONFIG_AHCI_IPQ=y
CONFIG_ALIGNMENT_TRAP=y
# CONFIG_AMBA_PL08X is not set
# CONFIG_APQ_GCC_8084 is not set
Expand Down
1 change: 1 addition & 0 deletions target/linux/ipq806x/config-4.19
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONFIG_AHCI_IPQ=y
CONFIG_ALIGNMENT_TRAP=y
# CONFIG_APQ_GCC_8084 is not set
# CONFIG_APQ_MMCC_8084 is not set
Expand Down
Loading

0 comments on commit 464fb0c

Please sign in to comment.