Support for Linksys E2500 V4

Ok. Now you can find all leds and buttons.
Pay attension to the correspondence of lan numbers in LUCI interface and in device. LUCI by default show physical port numbers.

Well it has 6 LED's total.
4=LAN
1=WAN
1=WPS

2 buttons total
1=Reset on the bottom
1=WPS between WAN port and power plug

As I understand lan/wan leds working? And what about wps?
I've said above than by default short hit of reset button reboot router.
Pls check both button.

WPS button reboots router, LED's appear to be working as normal except for WPS LED. reset button does nothing.

It's really long story to find gpio for button and leds. Full instruction here
https://openwrt.org/docs/techref/hardware/port.gpio
I'll correct firmware if you do this job.
But it's only cosmetic.

i will look at it now and reply back.

question. now could i flash the last BIN file to another E2500 V4 router i have over the linksys web upgrade?

also i used binwalk and such to decompress the factory firmware. i wonder if there might be hints in there to cheat at getting the GPIO ports right?

No. Linksys firmware is signed. As we see uboot check signature for tftp images too. Only by hand through serial console.

ok, i will solder header into my other router for serial port than.

Decompressed factory firmware may help but I'm not sure that it will be faster then openwrt instruction. You can see GPL sources too.

dont know if this will help but i just found this in the factory firmware in a file called check_fw.sh.

#!/bin/sh

#FW_TYPE="Stage"

#test URL
STAGE_URL="https://update1-stage.linksys.com/api/v2/fw/update"
#normal URL
PROD_URL="https://update1.linksys.com/api/v2/fw/update"
if [ "${FW_TYPE}" = "Stage" ]; then
	FW_URL="${STAGE_URL}"
else
	FW_URL="${PROD_URL}"
fi

RESP="/tmp/.resp"
FW_INFO="/tmp/.fw_info"

wan_mac="$(nvram_get 2860 wan_hwaddr)"
hw_version="$(nvram_get 2860 hw_version)"
model_number="$(nvram_get 2860 model_number)"
fw_ver="$(nvram_get 2860 fw_version)"
wan_ip="$(nvram_get 2860 wan_ipaddr)"
sn="$(nvram_get 2860 get_sn)"
params="mac_address=$wan_mac&hardware_version=$hw_version&model_number=$model_number&installed_version=$fw_ver&ip_address=$wan_ip&serial_number=$sn"

retry=3

rm $RESP -rf 
rm $FW_INFO -rf 

#cp /lib/libcrypto.so.1.0.0.lzma /lib/libcrypto.so.1.0.0.lzma-1
cp /lib/libssl.so.1.0.0.lzma /lib/libssl.so.1.0.0.lzma-1
cp /lib/libcurl.so.lzma /lib/libcurl.so.lzma-1

unlzma /lib/libcurl.so.lzma
#unlzma /lib/libcrypto.so.1.0.0.lzma
unlzma /lib/libssl.so.1.0.0.lzma
#ln -sf /lib/libcrypto.so.1.0.0 /lib/libcrypto.so
ln -sf /lib/libssl.so.1.0.0 /lib/libssl.so

while [ $retry -gt 0 ]; do
if curl -m 30 -o "$RESP" -k "$FW_URL?$params"; then
#        if curl -m 300 -o "$RESP" -k "$FW_URL"; then
                if [ -s $RESP ];then
                        echo "check f/w info OK!" >/dev/console
                        retry=0
                        local fw_info="$(cat $RESP | sed -e 's/{//g' -e 's/}//g' -e 's/"//g')"
                        echo $fw_info >$FW_INFO 
                else
                        echo "curl reponse null to check f/w info from Update Server!" >/dev/console
			retry=`awk -v a=$retry 'BEGIN{print a-1}'`
                fi
        else
                echo "fail to check f/w info from Internet Server!" >/dev/console
		retry=`awk -v a=$retry 'BEGIN{print a-1}'`
        fi
done

#rm /lib/libcrypto.so.1.0.0 -rf
rm /lib/libssl.so.1.0.0 -rf
#rm /lib/libcrypto.so -rf
rm /lib/libssl.so -rf
#mv /lib/libcrypto.so.1.0.0.lzma-1 /lib/libcrypto.so.1.0.0.lzma
mv /lib/libssl.so.1.0.0.lzma-1 /lib/libssl.so.1.0.0.lzma
mv /lib/libcurl.so.lzma-1 /lib/libcurl.so.lzma

and this was in a file called fw_upgrade.sh

#!/bin/sh

FW_URL="$(nvram_get 2860 online_fw_dl_url)"
GPG_FW_PATH="/tmp/code.bin.gpg"
FW_PATH="/tmp/code.bin"
DEFAULT_KEY="/etc_ro/pubkey"
PUB_KEY="/tmp/pub_key"

manufacturer="cybertan"
mac_address=`nvram_get 2860 WAN_MAC_ADDR`
wan_mac=`echo $mac_address | sed 's/:/-/g'`
hardware_version=`nvram_get 2860 hw_version`
model_number=`nvram_get 2860 model_name`
installed_version=`nvram_get 2860 fw_version`
serial_number=`nvram_get 2860 get_sn`

KEY_URL="https://update.linksys.com/api/v2/key?manufacturer=$manufacturer&mac_address=$wan_mac&hardware_version=$hardware_version&model_number=$model_number&installed_version=$installed_version&serial_number=$serial_number"

kill_process()
{
	killall miniupnpd
	killall tftpd
	killall cron
#	killall cesmDNS
#	killall dnsmasq
	killall dhcpd
	rm /lib/libzebra-0.9.28.so
	rm /lib/libdhcp.so
	unlzma /lib/libcurl.so.lzma
#	unlzma /lib/libcrypto.so.1.0.0.lzma
	unlzma /lib/libssl.so.1.0.0.lzma
#	ln -sf /lib/libcrypto.so.1.0.0 /lib/libcrypto.so
	ln -sf /lib/libssl.so.1.0.0 /lib/libssl.so

	echo 3 > /proc/sys/vm/drop_caches
}

check_mem()
{
	mem=`expr $1 \* 1024`
	free_mem=`free | awk '/Mem/ {print $4}'`
	echo "free:$free_mem------need mem:$mem"
	if [ $free_mem -ge $mem ]; then
		return 0
	fi
	return 1
}

handle_cbt_download_fw()
{
	retry=3
	kill_process
	check_mem 10
	ret=$?
	if [ $ret -eq 0 ];then
		while [ $retry -gt 0 ]; do
			if curl -m 120 -o "$GPG_FW_PATH" -k "$FW_URL"; then
				if [ -s $GPG_FW_PATH ];then
					echo "Download f/w OK!" >/dev/console
					return 0	
				else
					echo "download f/w fail from Internet Server!" >/dev/console
					retry=`awk -v a=$retry 'BEGIN{print a-1}'`
					rm $FW_PATH
				fi
			else
				echo "fail to download f/w from Internet Server!" >/dev/console
				retry=`awk -v a=$retry 'BEGIN{print a-1}'`
				rm $GPG_FW_PATH
			fi
		done
	fi
	return 1
}

backup_to_local()
{
	unlzma /bin/openssl.lzma
	cbtinfo w pubkey $PUB_KEY
	return 0
}

load_local_key()
{
	cbtinfo r pubkey
	return 0
}

check_key()
{
	sta=`cat $PUB_KEY | sed -n 1p | cut -d '"' -f 4`
	content=`cat $PUB_KEY | sed '1d' | sed '$d'`
	end=`cat $PUB_KEY | sed -n '$p' | cut -d '"' -f 1`
	echo "$sta" > $PUB_KEY
	echo "$content" >> $PUB_KEY
	echo "$end" >> $PUB_KEY
}

handle_cbt_download_pubkey()
{
	retry=3
	while [ $retry -gt 0 ]; do
#if wget -O "$PUB_KEY" "$KEY_URL"; then
		if curl -m 300 -o "$PUB_KEY" -k "$KEY_URL"; then
			if [ -s $PUB_KEY ];then
				echo "Download key OK!" >/dev/console
				check_key
				backup_to_local
				return 0	
			else
				echo "download f/w fail from Internet Server!" >/dev/console
				retry=`awk -v a=$retry 'BEGIN{print a-1}'`
				rm $PUB_KEY
			fi
		else
			echo "fail to download f/w from Internet Server!" >/dev/console
			retry=`awk -v a=$retry 'BEGIN{print a-1}'`
			rm $PUB_KEY
		fi
	done
	load_local_key
	ret=$?
	if [ $ret -eq 0 ];then
		return 0
	else
		return 1
	fi
}

verify_sign_fw()
{
	unlzma /usr/sbin/gpg.lzma
	free_mem.sh
	check_mem 10
	ret=$?
	if [ $ret -eq 0 ];then
		echo "key file:$PUB_KEY"
		if gpg --import "$PUB_KEY"; then
			if gpg --verify "$GPG_FW_PATH"; then
				if gpg -vv "$GPG_FW_PATH"; then
					return 0
				else
					echo "gpg -vv fail"
					return -1
				fi
			fi
		fi
	fi
	return 1
}

handle_cbt_code_pattern()
{
	[ -z "$1" ] && exit 0
	if [ $(hexdump -n 4 -e '4 "%c"' $1) != "$(nvram_get 2860 code_pt)" ]; then
		echo "code pattern is wrong!" > /dev/console
		return 1
        fi

	return 0	
}

mtd_write_fw()
{
	handle_cbt_code_pattern $FW_PATH
	ret=$?
	if [ $ret -eq 0 ];then
		size=`ls -l $FW_PATH | awk '{print $5}'`
		#ignore 32 bytes code header
		mtd_write -o 32 -l $size write $FW_PATH Kernel
		ret=$?
		if [ $ret -eq 0 ];then
			echo "1" > /tmp/.fw_up_result
			nvram_set 2860 wz_fw_up_result 1
			nvram_commit 2860
			return 0
		fi
	fi
}

handle_cbt_download_fw
ret=$?
if [ $ret -eq 0 ];then
	handle_cbt_download_pubkey
	ret=$?
	if [ $ret -eq 0 ];then
		verify_sign_fw
		ret=$?
		if [ $ret -eq 0 ];then
			mtd_write_fw
			return 0
		elif [ $ret -eq 1 ];then
			echo "user default key"
			PUB_KEY=$DEFAULT_KEY
			verify_sign_fw
			ret=$?
			if [ $ret -eq 0 ];then
				mtd_write_fw
				return 0
			fi
		fi
	fi
fi
echo "0" >/tmp/.fw_up_result
nvram_set 2860 wz_fw_up_result 0
nvram_commit 2860

Here is some GPIO test results. as of right now the WPS button is the reset button so i cannot test it because it forces the router to reboot every time its pressed. if you can move the reset button to the correct GPIO than i can test the WPS button. It appears that the LAN and WAN LED's cant be controlled, they are switches that detect when a cable is plugged in or not but i guess we can try to control them.

[gpiochip0:8:in]=Reset Button
[gpiochip32:37]=WPS LED
[gpiochip32:39:in] = WAN port LED
[gpiochip32:40:in] = LAN port 4 LED
[gpiochip32:41:in] = LAN port 3 LED
[gpiochip32:42:in] = LAN port 2 LED
[gpiochip32:43:in] = LAN port 1 LED

Also i added tech data to the wiki on here for this router.

Refreshed archive:


lan/wan leds is hardwired to switch so we don't touch them.
wps led color? I set green in name = "e2500-v4:green:wps" (cosmetic)
wps button action may be seen in output of command

logread

It really start wps connection.

@vwnut8392 Where can I find the PR that you mentioned in the E2500 v4 dataentry?

A search on github shows no PRs for this device.

im new to this, i dont have github. myself and 123serge123 have been building firmware and i was going to work with him to figure out how to get it submitted.

none of the BIN files in the last file you posted work on the router. it hangs at random: crng init done.

U-Boot 1.1.3 (Jun 26 2019 - 16:03:40)
MT7628 # tftpboot 82000000 test.bin

 NetTxPacket = 0x83FE39C0

 KSEG1ADDR(NetTxPacket) = 0xA3FE39C0

 NetLoop,call eth_halt !

 NetLoop,call eth_init !
Trying Eth0 (10/100-M)

 Waitting for RX_DMA_BUSY status Start... done


 ETH_STATE_ACTIVE!!
TFTP from server 10.10.10.3; our IP address is 10.10.10.123
Filename 'test.bin'.

 TIMEOUT_COUNT=10,Load address: 0x82000000
Loading: checksum bad
checksum bad
checksum bad
checksum bad
checksum bad
checksum bad
checksum bad
checksum bad
checksum bad
Got ARP REPLY, set server/gtwy eth addr (38:60:77:b8:17:36)
Got it
#################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################################Got ARP REQUEST, return our IP
##################
         #################################################################
         #################################################################
         #################################################################
         ###############
done
Bytes transferred = 3735612 (39003c hex)
LoadAddr=82000000 NetBootFileXferSize= 0039003c
MT7628 # spi erase 50000 410000
erase offs 0x50000, len 0x410000
.................................................................
MT7628 # cp.linux 82000000
Unknown command 'cp.linux' - try 'help'
MT7628 # cp.linux 82000000

 Copy linux image[3735612 byte] to SPI Flash[0x00050000]....
.........................................................
MT7628 # reset

[03050D0A][03050D0A][87870000][31315252][00313153]
DU Setting Cal Done


U-Boot 1.1.3 (Jun 26 2019 - 16:03:40)

CBT: 0.1.1
Board: Ralink APSoC DRAM:  64 MB
relocate_code Pointer at: 83fb0000
******************************
Software System Reset Occurred
******************************
flash manufacture id: c2, device id 20 18
find flash: MX25L12805D
============================================
Ralink UBoot Version: 5.0.0.0
--------------------------------------------
ASIC 7628_MP (Port5<->None)
DRAM component: 512 Mbits DDR, width 16
DRAM bus: 16 bit
Total memory: 64 MBytes
Flash component: SPI Flash
Date:Jun 26 2019  Time:16:03:40
============================================
icache: sets:512, ways:4, linesz:32 ,total:65536
dcache: sets:256, ways:4, linesz:32 ,total:32768

 ##### The CPU freq = 580 MHZ ####
 estimate memory size =64 Mbytes
RESET MT7628 PHY!!!!!!
 mdio.w addr[0x00000007]  value[0x00077070]

 mdio.w addr[0x0000000D]  value[0x0000001F]

 mdio.w addr[0x0000000E]  value[0x00000024]

 mdio.w addr[0x0000000D]  value[0x0000401F]

 mdio.w addr[0x0000000E]  value[0x00000000]

This verison of Uboot support Httpd Server 0.9

Please choose the operation:
   1: Load system code to SDRAM via TFTP.
   2: Load system code then write to Flash via TFTP.
   3: Boot system code via Flash (default).
   4: Entr boot command line interface.
   7: Load Boot Loader code then write to Flash via Serial.
   9: Load Boot Loader code then write to Flash via TFTP.
default: 3                                                                                                                                                 0

3: System Boot system code via Flash.
ethernet init

## Booting image at bc050000 ...
   Image Name:   MIPS OpenWrt Linux-4.14.167
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    1564412 Bytes =  1.5 MB
   Load Address: 80000000
   Entry Point:  80000000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
No initrd
## Transferring control to Linux (at address 80000000) ...
## Giving linux memsize in MB, 64

Starting kernel ...

[    0.000000] Linux version 4.14.167 (builder@buildhost) (gcc version 7.5.0 (OpenWrt GCC 7.5.0 r10911-c155900f66)) #0 Wed Jan 29 16:05:35 2020
[    0.000000] Board has DDR2
[    0.000000] Analog PMU set to hw control
[    0.000000] Digital PMU set to hw control
[    0.000000] SoC Type: MediaTek MT7628AN ver:1 eco:2
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019655 (MIPS 24KEc)
[    0.000000] MIPS: machine is ZyXEL Keenetic Viva
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] random: get_random_bytes called from 0x8047f740 with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,57600 rootfstype=squashfs,jffs2
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Writing ErrCtl register=00046ac0
[    0.000000] Readback ErrCtl register=00046ac0
[    0.000000] Memory: 58804K/65536K available (3914K kernel code, 181K rwdata, 500K rodata, 1220K init, 215K bss, 6732K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 256
[    0.000000] CPU Clock: 580MHz
[    0.000000] clocksource: systick: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 583261500 ns
[    0.000000] systick: enable autosleep mode
[    0.000000] systick: running - mult: 214748, shift: 32
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6590553264 ns
[    0.000011] sched_clock: 32 bits at 290MHz, resolution 3ns, wraps every 7405115902ns
[    0.007501] Calibrating delay loop...
[   14.804333] random: fast init done
[   14.962577] random: crng init done

Sorry, wrong link. This is correct link for linksys e2500 v4 19.07.1 with last changes:


BTW, openwrt update can be done from LUCI web interface.

no problem. downloading and testing here shortly.