Skip to content

ipq40xx: add support for Linksys EA6350v3 #1716

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/image-commands.mk
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ define Build/combined-image
@mv $@.new $@
endef

define Build/linksys-image
$(TOPDIR)/scripts/linksys-image.sh \
"$(call param_get_default,type,$(1),$(DEVICE_NAME))" \
$@ $@.new
mv $@.new $@
endef

define Build/openmesh-image
$(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \
"$(call param_get_default,ce_type,$(1),$(DEVICE_NAME))" \
Expand Down
4 changes: 4 additions & 0 deletions package/boot/uboot-envtools/files/ipq40xx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ ubootenv_mtdinfo () {
}

case "$board" in
linksys,ea6350v3)
# this device has 2 partitions. We are using "u_env"
ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
;;
glinet,gl-b1300 |\
openmesh,a42 |\
openmesh,a62)
Expand Down
3 changes: 2 additions & 1 deletion package/firmware/ipq-wifi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ endef
# Please send a mail with your device-specific board files upstream.
# You can find instructions and examples on the linux-wireless wiki:
# <https://wireless.wiki.kernel.org/en/users/drivers/ath10k/boardfiles>
ALLWIFIBOARDS:=engenius_eap1300
ALLWIFIBOARDS:=engenius_eap1300 linksys_ea6350v3
ALLWIFIPACKAGES:=$(foreach BOARD,$(ALLWIFIBOARDS),ipq-wifi-$(BOARD))

define Package/ipq-wifi-default
Expand Down Expand Up @@ -53,5 +53,6 @@ endef

#$(eval $(call generate-ipq-wifi-package,<devicename>,<filename>,<displayname>))
$(eval $(call generate-ipq-wifi-package,engenius_eap1300,board-engenius_eap1300.bin,EnGenius EAP1300))
$(eval $(call generate-ipq-wifi-package,linksys_ea6350v3,board-linksys_ea6350v3.bin,Linksys EA6350v3))

$(foreach PACKAGE,$(ALLWIFIPACKAGES),$(eval $(call BuildPackage,$(PACKAGE))))
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Index: backports-4.19.7-1/drivers/net/wireless/ath/regd.c
===================================================================
--- backports-4.19.7-1.orig/drivers/net/wireless/ath/regd.c
+++ backports-4.19.7-1/drivers/net/wireless/ath/regd.c
@@ -703,6 +703,12 @@ ath_regd_init_wiphy(struct ath_regulator
*/
static void ath_regd_sanitize(struct ath_regulatory *reg)
{
+ /*
+ * This will sanitize the following values:
+ * - 0x834b -> in the Linksys EA6350v3
+ * - 0x8000 -> some manufacturers use this invalid code
+ */
- if (reg->current_rd != COUNTRY_ERD_FLAG)
+ if (reg->current_rd != COUNTRY_ERD_FLAG &&
+ reg->current_rd != 0x834b)
return;
printk(KERN_DEBUG "ath: EEPROM regdomain sanitized\n");
1 change: 1 addition & 0 deletions package/system/mtd/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ obj.ramips = $(obj.seama) $(obj.wrg)
obj.mvebu = linksys_bootcount.o
obj.kirkwood = linksys_bootcount.o
obj.ipq806x = linksys_bootcount.o
obj.ipq40xx = linksys_bootcount.o

ifdef FIS_SUPPORT
obj += fis.o
Expand Down
67 changes: 67 additions & 0 deletions scripts/linksys-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh
#
# Copyright (C) 2018 Oceanic Systems (UK) Ltd
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# Maintained by: Ryan Pannell <ryan [at] o s u k l .com> <github.com/Escalion>
#
# Write Linksys signature for factory image
# This is appended to the factory image and is tested by the Linksys Upgrader - as observed in civic.
# The footer is 256 bytes. The format is:
# .LINKSYS. This is detected by the Linksys upgrader before continuing with upgrade. (9 bytes)
# <VERSION> The version number of upgrade. Not checked so use arbitary value (8 bytes)
# <TYPE> Model of target device, padded (0x20) to (15 bytes)
# <CRC> CRC checksum of the image to flash (8 byte)
# <padding> Padding (0x20) (7 bytes)
# <signature> Signature of signer. Not checked so use Arbitary value (16 bytes)
# <padding> Padding (0x00) (192 bytes)
# 0x0A (1 byte)

## version history
# * version 1: initial commit

set -e

ME="${0##*/}"

usage() {
echo "Usage: $ME <type> <in filename>"
[ "$IMG_OUT" ] && rm -f "$IMG_OUT"
exit 1
}

[ "$#" -lt 3 ] && usage

TYPE=$1

tmpdir="$( mktemp -d 2> /dev/null )"
if [ -z "$tmpdir" ]; then
# try OSX signature
tmpdir="$( mktemp -t 'ubitmp' -d )"
fi

if [ -z "$tmpdir" ]; then
exit 1
fi

trap "rm -rf $tmpdir" EXIT

IMG_TMP_OUT="${tmpdir}/out"

IMG_IN=$2
IMG_OUT="${IMG_IN}.new"

[ ! -f "$IMG_IN" ] && echo "$ME: Not a valid image: $IMG_IN" && usage

dd if="${IMG_IN}" of="${IMG_TMP_OUT}"
CRC=$(printf "%08X" $(dd if="${IMG_IN}" bs=$(stat -c%s "${IMG_IN}") count=1|cksum| cut -d ' ' -f1))

printf ".LINKSYS.01000409%-15s%-8s%-7s%-16s" "${TYPE}" "${CRC}" "" "K0000000F0246434" >> "${IMG_TMP_OUT}"

dd if=/dev/zero bs=1 count=192 conv=notrunc >> "${IMG_TMP_OUT}"

printf '\12' >> "${IMG_TMP_OUT}"

cp "${IMG_TMP_OUT}" "${IMG_OUT}"
9 changes: 9 additions & 0 deletions target/linux/ipq40xx/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ glinet,gl-b1300)
ucidef_add_switch "switch0" \
"0u@eth0" "3:lan" "4:lan"
;;
linksys,ea6350v3)
wan_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
lan_mac_addr=$(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
ucidef_set_interface_macaddr "wan" "$wan_mac_addr"
ucidef_set_interface_macaddr "lan" "$lan_mac_addr"
;;
openmesh,a42 |\
openmesh,a62)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ case "$FIRMWARE" in
case "$board" in
8dev,jalapeno |\
glinet,gl-b1300 |\
linksys,ea6350v3 |\
qcom,ap-dk01.1-c1)
ath10kcal_extract "ART" 4096 12064
;;
Expand Down Expand Up @@ -152,6 +153,7 @@ case "$FIRMWARE" in
case "$board" in
8dev,jalapeno |\
glinet,gl-b1300 |\
linksys,ea6350v3 |\
qcom,ap-dk01.1-c1)
ath10kcal_extract "ART" 20480 12064
;;
Expand Down
21 changes: 21 additions & 0 deletions target/linux/ipq40xx/base-files/etc/init.d/linksys_recovery
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org

START=97
boot() {
. /lib/functions.sh

case $(board_name) in
linksys,ea6350v3)
# make sure auto_recovery in uboot is always on
IS_AUTO_RECOVERY="`fw_printenv -n auto_recovery`"
if [ "$IS_AUTO_RECOVERY" != "yes" ] ; then
fw_setenv auto_recovery yes
echo "Linksys EA6350v3: fw_setenv: auto_recovery has been set to yes"
fi
# reset the boot counter
mtd resetbc s_env
echo "Linksys EA6350v3: mtd: boot counter has been reset"
;;
esac
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set_preinit_boot_count() {
. /lib/functions.sh

case $(board_name) in
linksys,ea6350v3)
fw_setenv boot_count 0
echo "Linksys EA6350v3: fw_setenv: boot counter has updated to 0"
;;
*)
;;
esac
}

boot_hook_add preinit_main set_preinit_boot_count
101 changes: 101 additions & 0 deletions target/linux/ipq40xx/base-files/lib/upgrade/linksys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#
# Copyright (C) 2014-2015 OpenWrt.org
#

linksys_get_target_firmware() {
cur_boot_part=`/usr/sbin/fw_printenv -n boot_part`
target_firmware=""
if [ "$cur_boot_part" = "1" ]
then
# current primary boot - update alt boot
target_firmware="alt_kernel"
fw_setenv boot_part 2
#In EA6350v3 this causes the device to reboot in the old partition
#fw_setenv bootcmd "run altnandboot"
elif [ "$cur_boot_part" = "2" ]
then
# current alt boot - update primary boot
target_firmware="kernel"
fw_setenv boot_part 1
#In EA6350v3 this causes the device to reboot in the old partition
#fw_setenv bootcmd "run nandboot"
fi

# re-enable recovery so we get back if the new firmware is broken
fw_setenv auto_recovery yes

echo "$target_firmware"
}

linksys_get_root_magic() {
(get_image "$@" | dd skip=786432 bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev/null
}

platform_do_upgrade_linksys() {
local magic_long="$(get_magic_long "$1")"

mkdir -p /var/lock
local part_label="$(linksys_get_target_firmware)"
touch /var/lock/fw_printenv.lock

if [ ! -n "$part_label" ]
then
echo "cannot find target partition"
exit 1
fi

local target_mtd=$(find_mtd_part $part_label)

[ "$magic_long" = "73797375" ] && {
CI_KERNPART="$part_label"
if [ "$part_label" = "kernel" ]
then
CI_UBIPART="rootfs"
else
CI_UBIPART="alt_rootfs"
fi


# remove "squashfs" vol (in case we are flashing over a stock image, which is also UBI)

local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
if [ ! "$mtdnum" ]; then
echo "cannot find ubi mtd partition $CI_UBIPART"
return 1
fi

local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
if [ ! "$ubidev" ]; then
ubiattach -m "$mtdnum"
sync
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
fi

if [ "$ubidev" ]; then

local squash_ubivol="$( nand_find_volume $ubidev squashfs )"

# kill volume
[ "$squash_ubivol" ] && ubirmvol /dev/$ubidev -N squashfs || true
fi


# complete std upgrade
nand_upgrade_tar "$1"
}
[ "$magic_long" = "27051956" ] && {
# check firmwares' rootfs types
local oldroot="$(linksys_get_root_magic $target_mtd)"
local newroot="$(linksys_get_root_magic "$1")"

if [ "$newroot" = "55424923" -a "$oldroot" = "55424923" ]
# we're upgrading from a firmware with UBI to one with UBI
then
# erase everything to be safe
mtd erase $part_label
get_image "$1" | mtd -n write - $part_label
else
get_image "$1" | mtd write - $part_label
fi
}
}
3 changes: 3 additions & 0 deletions target/linux/ipq40xx/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ platform_do_upgrade() {
CI_KERNPART="linux"
nand_do_upgrade "$1"
;;
linksys,ea6350v3)
platform_do_upgrade_linksys "$ARGV"
;;
openmesh,a42 |\
openmesh,a62)
PART_NAME="inactive"
Expand Down
Loading