Skip to content

Commit

Permalink
Include support for Linksys WHW03 (Velop)
Browse files Browse the repository at this point in the history
ethernet: works
mesh: works
upgrade: works
bt: wip
zigbee: wip
  • Loading branch information
flipy authored and Anthony Sepa committed Nov 4, 2023
1 parent ec54022 commit 7af69a7
Show file tree
Hide file tree
Showing 13 changed files with 543 additions and 2 deletions.
18 changes: 18 additions & 0 deletions package/base-files/files/lib/functions/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ find_mtd_chardev() {
echo "${INDEX:+$PREFIX$INDEX}"
}

mmc_get_mac_ascii() {
local partname="$1"
local key="$2"
local part
local mac_dirty

part=$(find_mmc_part "$partname")
if [ -z "$part" ]; then
echo "mmc_get_mac_ascii: partition $partname not found!" >&2
return
fi

mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')

# "canonicalize" mac
[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"
}

mtd_get_mac_ascii() {
local mtdname="$1"
local key="$2"
Expand Down
3 changes: 3 additions & 0 deletions package/boot/uboot-envtools/files/ipq40xx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ linksys,mr8300)
linksys,whw01)
ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x40000" "0x10000"
;;
linksys,whw03)
ubootenv_add_uci_config "/dev/mmcblk0p11" "0x0" "0x100000"
;;
linksys,whw03v2)
ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x80000" "0x20000"
;;
Expand Down
4 changes: 3 additions & 1 deletion package/firmware/ipq-wifi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ALLWIFIBOARDS:= \
dynalink_dl-wrx36 \
edgecore_eap102 \
edimax_cax1800 \
linksys_whw03 \
netgear_wax218 \
prpl_haze \
qnap_301w \
Expand Down Expand Up @@ -106,7 +107,7 @@ Do not install it for any other device!
endef

define Package/ipq-wifi-$(1)/install-overlay
$$$$(foreach IPQ_WIFI_BOARD_FILE,$$$$(wildcard $(PKG_BUILD_DIR)/board-$(1).*),\
$$$$(foreach IPQ_WIFI_BOARD_FILE,$$$$(wildcard $(PKG_BUILD_DIR)/board-$(1).*) $$$$(wildcard board-$(1).*),\
$$$$(call ipq-wifi-install-one,$$$$(IPQ_WIFI_BOARD_FILE),$$(1)))
endef

Expand All @@ -122,6 +123,7 @@ $(eval $(call generate-ipq-wifi-package,compex_wpq873,Compex WPQ-873))
$(eval $(call generate-ipq-wifi-package,dynalink_dl-wrx36,Dynalink DL-WRX36))
$(eval $(call generate-ipq-wifi-package,edgecore_eap102,Edgecore EAP102))
$(eval $(call generate-ipq-wifi-package,edimax_cax1800,Edimax CAX1800))
$(eval $(call generate-ipq-wifi-package,linksys_whw03,Linksys WHW03))
$(eval $(call generate-ipq-wifi-package,netgear_wax218,Netgear WAX218))
$(eval $(call generate-ipq-wifi-package,qnap_301w,QNAP 301w))
$(eval $(call generate-ipq-wifi-package,prpl_haze,prpl Haze))
Expand Down
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion target/linux/ipq40xx/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ipq40xx_setup_interfaces()
glinet,gl-ap1300|\
glinet,gl-b2200|\
google,wifi|\
linksys,whw03|\
linksys,whw03v2|\
luma,wrtq-329acn|\
mikrotik,cap-ac|\
Expand Down Expand Up @@ -139,7 +140,6 @@ ipq40xx_setup_dsl()
ucidef_add_vdsl_modem "$annex" "$tone" "$xfer_mode"
ucidef_set_interface_wan "dsl0" "pppoe"
}

ipq40xx_setup_macs()
{
local board="$1"
Expand Down Expand Up @@ -201,6 +201,10 @@ ipq40xx_setup_macs()
wan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
lan_mac=$(macaddr_add "$wan_mac" 1)
;;
linksys,whw03)
wan_mac=$(emmc_get_mac_ascii devinfo hw_mac_addr)
lan_mac=$(macaddr_add "$wan_mac" 1)
;;
mikrotik,cap-ac |\
mikrotik,hap-ac2|\
mikrotik,hap-ac3|\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ case "$FIRMWARE" in
# OEM assigns 4 sequential MACs
ath10k_patch_mac $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 4))
;;
linksys,whw03)
caldata_extract_mmc "0:ART" 0x9000 0x2f20
ath10k_patch_mac $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 4))
;;
netgear,rbr50|\
netgear,rbs50|\
netgear,srr60|\
Expand Down Expand Up @@ -104,6 +108,10 @@ case "$FIRMWARE" in
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
;;
linksys,whw03)
caldata_extract_mmc "0:ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2))
;;
meraki,mr33 |\
meraki,mr74)
caldata_extract_ubi "ART" 0x1000 0x2f20
Expand Down Expand Up @@ -200,6 +208,10 @@ case "$FIRMWARE" in
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 3)
;;
linksys,whw03)
caldata_extract_mmc "0:ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 3))
;;
meraki,mr33 |\
meraki,mr74)
caldata_extract_ubi "ART" 0x5000 0x2f20
Expand Down
37 changes: 37 additions & 0 deletions target/linux/ipq40xx/base-files/etc/init.d/bootcount
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

START=99

mmc_resetbc() {
local part_label="$1"
local part_device magic_number last_count

. /lib/functions.sh

part_device=$(find_mmc_part "$part_label")
[ -z "$part_device" ] && {
echo "Unable to find partition for name ${part_label}"
return
}

magic_number=$(hexdump -e '"0x%02x\n"' -n 4 "$part_device")
[ "0x20110811" != "$magic_number" ] && {
echo "Magic number doesn't match expect number"
return
}

last_count=$(hexdump -e '"0x%02x\n"' -n 4 -s 4 "$part_device")
[ "0x00" = "$last_count" ] && {
return
}

printf "\x00" | dd of="$part_device" bs=4 seek=1 count=1 conv=notrunc 2>/dev/null

last_count=$(hexdump -e '"0x%02x\n"' -n 4 -s 4 "$part_device")
[ "0x00" != "$last_count" ] && {
echo "Unable to reset boot counter."
return
}

return
}

boot() {
case $(board_name) in
alfa-network,ap120c-ac)
Expand All @@ -15,6 +49,9 @@ boot() {
linksys,whw03v2)
mtd resetbc s_env || true
;;
linksys,whw03)
mmc_resetbc s_env || true
;;
netgear,wac510)
fw_setenv boot_cnt=0
;;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ preinit_set_mac_address() {
ip link set dev lan1 address $(macaddr_add "$base_mac" 1)
ip link set dev eth0 address $(macaddr_setbit "$base_mac" 7)
;;
linksys,whw03)
base_mac=$(mmc_get_mac_ascii devinfo hw_mac_addr)
ip link set dev lan address "${base_mac}"
ip link set dev wan address $(macaddr_add "${base_mac}" 1)
;;
mikrotik,wap-ac|\
mikrotik,wap-ac-lte|\
mikrotik,wap-r-ac)
Expand Down
35 changes: 35 additions & 0 deletions target/linux/ipq40xx/base-files/lib/upgrade/linksys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,38 @@ platform_do_upgrade_linksys() {
get_image "$1" | mtd -e "$part_label" write - "$part_label"
}
}

linksys_get_rootfs() {
local rootfsdev

if read cmdline < /proc/cmdline; then
case "$cmdline" in
*root=*)
rootfsdev="${cmdline##*root=}"
rootfsdev="${rootfsdev%% *}"
;;
esac

echo "${rootfsdev}"
fi
}

linksys_set_boot_part() {
if [ "/dev/mmcblk0p15" != "$(linksys_get_rootfs)" ]; then
CI_KERNPART="kernel"
CI_ROOTPART="rootfs"
fw_setenv -s - <<-EOF
boot_part 1
auto_recovery yes
EOF
else
CI_KERNPART="alt_kernel"
CI_ROOTPART="alt_rootfs"
fw_setenv -s - <<-EOF
boot_part 2
auto_recovery yes
EOF
fi

touch /var/lock/fw_printenv.lock
}
5 changes: 5 additions & 0 deletions target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ platform_do_upgrade() {
linksys,whw03v2)
platform_do_upgrade_linksys "$1"
;;
linksys,whw03)
linksys_set_boot_part
emmc_do_upgrade "$1"
;;
meraki,mr33 |\
meraki,mr74)
CI_KERNPART="part.safe"
Expand Down Expand Up @@ -230,6 +234,7 @@ platform_do_upgrade() {

platform_copy_config() {
case "$(board_name)" in
linksys,whw03 |\
glinet,gl-b2200 |\
google,wifi)
emmc_copy_config
Expand Down
Loading

0 comments on commit 7af69a7

Please sign in to comment.