ramips: get MAC addr from the encrypted partition (WG4хх223)
This commit resolves #10062. Adds decryption of the Arcadyan WG4xx223 configuration partition (board_data)to get base MAC address from it. As a result, after this change the hack with saving MAC addressees to u-boot-env before installation of OpenWrt is no longer necessary. This is necessary for the following devices: - Beeline Smartbox Flash (Arcadyan WG443223) - MTS WG430223 (Arcadyan WG430223) Example: +----------------+-------------------+------------------------+ | | MTS WG430223 | Beeline Smartbox Flash | +----------------+-------------------+------------------------+ | base mac (mtd) | A4:xx:xx:51:xx:F4 | 30:xx:xx:51:xx:06 | | label | A4:xx:xx:51:xx:F4 | 30:xx:xx:51:xx:09 | | LAN | A4:xx:xx:51:xx:F6 | 30:xx:xx:51:xx:09 | | WAN | A4:xx:xx:51:xx:F4 | 30:xx:xx:51:xx:06 | | WLAN_2g | A4:xx:xx:51:xx:F5 | 30:xx:xx:51:xx:07 | | WLAN_5g | A6:xx:xx:21:xx:F5 | 32:xx:xx:41:xx:07 | +----------------+-------------------+------------------------+ Collected statistic shows that the 2-4th bits of the 7th byte of the WLAN_5g MAC are the constant (see #10062 for more details): - Beeline Smartbox Flash - 100 - MTS WG430223 - 010 Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
This commit is contained in:
		 Mikhail Zhilkin
					Mikhail Zhilkin
				
			
				
					committed by
					
						 Christian Marangi
						Christian Marangi
					
				
			
			
				
	
			
			
			 Christian Marangi
						Christian Marangi
					
				
			
						parent
						
							12c971bc26
						
					
				
				
					commit
					a6b0d08060
				
			| @@ -311,7 +311,7 @@ define Device/beeline_smartbox-flash | |||||||
|   IMAGE/factory.trx := append-kernel | append-ubi | check-size |   IMAGE/factory.trx := append-kernel | append-ubi | check-size | ||||||
|   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata |   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata | ||||||
|   DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e kmod-mt7615-firmware \ |   DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e kmod-mt7615-firmware \ | ||||||
| 	uboot-envtools | 	uboot-envtools uencrypt | ||||||
| endef | endef | ||||||
| TARGET_DEVICES += beeline_smartbox-flash | TARGET_DEVICES += beeline_smartbox-flash | ||||||
|  |  | ||||||
| @@ -1327,7 +1327,7 @@ define Device/mts_wg430223 | |||||||
|   IMAGES += factory.trx |   IMAGES += factory.trx | ||||||
|   IMAGE/factory.trx := append-kernel | append-ubi | check-size |   IMAGE/factory.trx := append-kernel | append-ubi | check-size | ||||||
|   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata |   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata | ||||||
|   DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware uboot-envtools |   DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware uboot-envtools uencrypt | ||||||
| endef | endef | ||||||
| TARGET_DEVICES += mts_wg430223 | TARGET_DEVICES += mts_wg430223 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -138,11 +138,10 @@ ramips_setup_macs() | |||||||
| 		wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr) | 		wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr) | ||||||
| 		label_mac=$(mtd_get_mac_binary factory 0x4) | 		label_mac=$(mtd_get_mac_binary factory 0x4) | ||||||
| 		;; | 		;; | ||||||
| 	beeline,smartbox-flash|\ | 	beeline,smartbox-flash) | ||||||
| 	mts,wg430223) | 		wan_mac=$(mtd_get_mac_encrypted_arcadyan "board_data") | ||||||
| 		lan_mac=$(mtd_get_mac_ascii u-boot-env eth2macaddr) | 		label_mac=$(macaddr_add "$wan_mac" 3) | ||||||
| 		wan_mac=$(mtd_get_mac_ascii u-boot-env eth3macaddr) | 		lan_mac=$label_mac | ||||||
| 		label_mac=$lan_mac |  | ||||||
| 		;; | 		;; | ||||||
| 	buffalo,wsr-1166dhp) | 	buffalo,wsr-1166dhp) | ||||||
| 		local index="$(find_mtd_index "board_data")" | 		local index="$(find_mtd_index "board_data")" | ||||||
| @@ -212,6 +211,11 @@ ramips_setup_macs() | |||||||
| 		wan_mac=$label_mac | 		wan_mac=$label_mac | ||||||
| 		lan_mac=$(macaddr_add $label_mac 1) | 		lan_mac=$(macaddr_add $label_mac 1) | ||||||
| 		;; | 		;; | ||||||
|  | 	mts,wg430223) | ||||||
|  | 		wan_mac=$(mtd_get_mac_encrypted_arcadyan "board_data") | ||||||
|  | 		label_mac=$wan_mac | ||||||
|  | 		lan_mac=$(macaddr_add "$wan_mac" 2) | ||||||
|  | 		;; | ||||||
| 	netgear,wax202) | 	netgear,wax202) | ||||||
| 		lan_mac=$(mtd_get_mac_ascii Config mac) | 		lan_mac=$(mtd_get_mac_ascii Config mac) | ||||||
| 		wan_mac=$(macaddr_add "$lan_mac" 1) | 		wan_mac=$(macaddr_add "$lan_mac" 1) | ||||||
|   | |||||||
| @@ -10,12 +10,13 @@ PHYNBR=${DEVPATH##*/phy} | |||||||
| board=$(board_name) | board=$(board_name) | ||||||
|  |  | ||||||
| case "$board" in | case "$board" in | ||||||
| 	beeline,smartbox-flash|\ | 	beeline,smartbox-flash) | ||||||
| 	mts,wg430223) | 		hw_mac_addr=$(macaddr_add $(mtd_get_mac_encrypted_arcadyan "board_data") 1) | ||||||
| 		hw_mac_addr_ra0="$(mtd_get_mac_ascii u-boot-env ra0macaddr)" | 		[ "$PHYNBR" = "0" ] && echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress | ||||||
| 		hw_mac_addr_rax0="$(mtd_get_mac_ascii u-boot-env rax0macaddr)" | 		hw_mac_addr=$(macaddr_setbit   $hw_mac_addr 26) | ||||||
| 		[ "$PHYNBR" = "0" ] && echo -n $hw_mac_addr_ra0 > /sys${DEVPATH}/macaddress | 		hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 27) | ||||||
| 		[ "$PHYNBR" = "1" ] && echo -n $hw_mac_addr_rax0 > /sys${DEVPATH}/macaddress | 		hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 28) | ||||||
|  | 		[ "$PHYNBR" = "1" ] && macaddr_setbit_la $hw_mac_addr > /sys${DEVPATH}/macaddress | ||||||
| 		;; | 		;; | ||||||
| 	cudy,x6) | 	cudy,x6) | ||||||
| 		hw_mac_addr="$(mtd_get_mac_binary factory 0x4)" | 		hw_mac_addr="$(mtd_get_mac_binary factory 0x4)" | ||||||
| @@ -88,6 +89,14 @@ case "$board" in | |||||||
| 		[ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress | 		[ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress | ||||||
| 		[ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress | 		[ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress | ||||||
| 		;; | 		;; | ||||||
|  | 	mts,wg430223) | ||||||
|  | 		hw_mac_addr=$(macaddr_add $(mtd_get_mac_encrypted_arcadyan "board_data") 1) | ||||||
|  | 		[ "$PHYNBR" = "0" ] && echo -n "$hw_mac_addr" > /sys${DEVPATH}/macaddress | ||||||
|  | 		hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 26) | ||||||
|  | 		hw_mac_addr=$(macaddr_setbit   $hw_mac_addr 27) | ||||||
|  | 		hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 28) | ||||||
|  | 		[ "$PHYNBR" = "1" ] && macaddr_setbit_la $hw_mac_addr > /sys${DEVPATH}/macaddress | ||||||
|  | 		;; | ||||||
| 	oraybox,x3a) | 	oraybox,x3a) | ||||||
| 		if [ "$PHYNBR" = "1" ]; then | 		if [ "$PHYNBR" = "1" ]; then | ||||||
| 			hw_mac_addr="$(mtd_get_mac_binary factory 0x4)" | 			hw_mac_addr="$(mtd_get_mac_binary factory 0x4)" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user