[LEDE-DEV] [PATCH 2/4] Add support for new device: tew827dru

John Crispin john at phrozen.org
Thu Sep 8 00:13:30 PDT 2016



On 08/09/2016 07:04, J Mo wrote:
> The TRENDnet TEW-827DRU is an ipq806x wireless router.
> 
> ipq8064 SoC with 2x ARMv7-ish Krait 300 CPUs at 1.4Ghz
> 512MB RAM, 256MB SLC NAND flash (64MB default UBI img size)
> 1x qca8337-al3c 1000BASE-T ethernet switch, 1-WAN, 4-LAN
> 2x qca9980 802.11 radios
> 2x USB3 type A
> 
> Product page: https://www.trendnet.com/products/wifi/AC2600-MU-MIMO-AC-routers/TEW-827DRU
> 
> Development thread: https://forum.openwrt.org/viewtopic.php?id=65956
> 
> The tew827dru factory image format supports installation from both the OEM web interface and a u-boot "recovery loader" HTTP page, which is accessible by booting the device with the reset button held down for four seconds. This factory image must be packaged in a FIT file with specific content and a Cameo signature/hwid appended to the file. The FIT image itself contains a u-boot hush shell script which installs a UBI image containing the kernel, sqaushfs-rootfs, and ubifs-overlay. Supporting this factory image required the addition of a new ITS formatter tool (its-maker.sh), a u-boot shell script (tew827dru-flash.scr), and a tiny "Fail Safe" bootconfig binary blob (tew827dru-bootconfig.bin).
> 
> Signed-off-by: jmomo <jmomo at jmomo.net>
> ---
>  include/image-commands.mk                          | 45 ++++++++++++++++++++++
>  package/boot/uboot-envtools/files/ipq              |  3 ++
>  .../linux/ipq806x/base-files/etc/board.d/01_leds   |  6 +++
>  .../ipq806x/base-files/etc/board.d/02_network      |  4 ++
>  target/linux/ipq806x/base-files/etc/diag.sh        |  3 ++
>  .../etc/hotplug.d/firmware/11-ath10k-caldata       |  8 ++++
>  .../etc/hotplug.d/ieee80211/10_fix_wifi_mac        |  3 ++
>  target/linux/ipq806x/base-files/lib/ipq806x.sh     |  3 ++
>  .../base-files/lib/preinit/06_set_iface_mac        | 24 ++++++++++++
>  .../ipq806x/base-files/lib/upgrade/platform.sh     |  6 ++-
>  target/linux/ipq806x/image/Makefile                | 19 ++++++++-
>  .../linux/ipq806x/patches-4.4/800-devicetree.patch |  1 +
>  12 files changed, 122 insertions(+), 3 deletions(-)
>  create mode 100644 target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac
> 
> diff --git a/include/image-commands.mk b/include/image-commands.mk
> index 40a9619..209caf4 100644
> --- a/include/image-commands.mk
> +++ b/include/image-commands.mk
> @@ -167,3 +167,48 @@ define Build/sysupgrade-tar
>  		--rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
>  		$@
>  endef
> +
> +define Build/mkfit-TEW827DRU
> +	$(TOPDIR)/scripts/its-maker.sh \
> +		--device $(DEVICE_NAME) \
> +		-O $@.its \
> +		--img-name 0 script \
> +		--img-descr 0 "u-boot-HTTP firmware update script" \
> +		--img-file 0 $(TOPDIR)/target/linux/ipq806x/image/tew827dru-flash.scr \
> +		--img-type 0 script --img-arch 0 $(ARCH) \
> +		--img-compression 0 none \
> +		--img-hashes 0 crc32 \
> +		--img-name 1 ubi-image \
> +		--img-descr 1 "UBI rootfs image" \
> +		--img-file 1 $@ \
> +		--img-type 1 firmware \
> +		--img-arch 1 $(ARCH) \
> +		--img-compression 1 none \
> +		--img-hashes 1 crc32 \
> +		--img-name 2 bootconfig \
> +		--img-descr 2 "BOOTCONFIG: boot from APPSBL and rootfs" \
> +		--img-file 2 $(TOPDIR)/target/linux/ipq806x/image/tew827dru-bootconfig.bin \
> +		--img-type 2 firmware \
> +		--img-arch 2 $(ARCH) \
> +		--img-compression 2 none \
> +		--img-hashes 2 crc32
> +	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.fit
> +	@rm $@.its
> +	@mv $@.fit $@
> +endef
> +
> +define Build/cameo-sig
> +	{ \
> +		cameo_sig=$(word 1, $(1)) ;\
> +		align=$(if $(2),$(2),64) ;\
> +		oldsize=$$(stat -c %s $@) ;\
> +		sigsize=$$(echo -n $$cameo_sig | wc -c) ;\
> +		padsize=$$(( ( ( ( $$oldsize + $$sigsize ) / $$align ) + 1 ) - ( ( $$oldsize + $$sigsize ) / $$align ) )) ;\
> +		newsize=$$(( $$oldsize + $$padsize )) ;\
> +		echo "Appending Cameo signature: \"$$cameo_sig\", oldsize=$$oldsize align=$$align sigsize=$$sigsize padsize=$$padsize newsize=$$newsize" ;\
> +		dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync ;\
> +		echo -n "$$cameo_sig" >> $@.new ; \
> +	}
> +	@mv $@.new $@
> +endef
> +

there is no reason for this to be in the generic code. please add it to
the target code.

> diff --git a/package/boot/uboot-envtools/files/ipq b/package/boot/uboot-envtools/files/ipq
> index 8cf0ddb..f66aabc 100755
> --- a/package/boot/uboot-envtools/files/ipq
> +++ b/package/boot/uboot-envtools/files/ipq
> @@ -18,6 +18,9 @@ case "$board" in
>  "ea8500")
>  	ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
>  	;;
> +"tew827dru")
> +	ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x40000" "0x20000" "2"
> +	;;
>  esac
>  
>  config_load ubootenv

this should go into its own "uboot-envtools" patch


> diff --git a/target/linux/ipq806x/base-files/etc/board.d/01_leds b/target/linux/ipq806x/base-files/etc/board.d/01_leds
> index 0b75b11..269dfa8 100755
> --- a/target/linux/ipq806x/base-files/etc/board.d/01_leds
> +++ b/target/linux/ipq806x/base-files/etc/board.d/01_leds
> @@ -33,6 +33,12 @@ ea8500)
>  	ucidef_set_led_wlan "wifi" "WIFI" "ea8500:green:wifi" "phy0radio"
>  	ucidef_set_led_default "wps" "WPS" "ea8500:green:wps" "0"
>  	;;
> +tew827dru)
> +	ucidef_set_led_usbdev "usb2" "USB2" "tew827dru:blue:usb" "2-1"
> +	# The ledtrig_usbdev kernel module can only map 1 LED-GPIO to 1 USB port.
> +	# Thus, this only works for one of the two ports, for now.
> +	# ucidef_set_led_usbdev "usb4" "USB4" "tew827dru:blue:usb" "4-1"
> +	;;
>  *)
>  	;;
>  esac
> diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network
> index b720455..e419f9b 100755
> --- a/target/linux/ipq806x/base-files/etc/board.d/02_network
> +++ b/target/linux/ipq806x/base-files/etc/board.d/02_network
> @@ -22,6 +22,10 @@ r7800)
>  	ucidef_add_switch "switch0" \
>  		"1:lan" "2:lan" "3:lan" "4:lan" "6 at eth1" "5:wan" "0 at eth0"
>  	;;
> +tew827dru)
> +	ucidef_add_switch "switch0" \
> +		"1:lan" "2:lan" "3:lan" "4:lan" "6t at eth1" "5:wan" "0t at eth0"
> +	;;
>  db149)
>  	ucidef_set_interface_lan "eth1 eth2 eth3"
>  	ucidef_add_switch "switch0" \
> diff --git a/target/linux/ipq806x/base-files/etc/diag.sh b/target/linux/ipq806x/base-files/etc/diag.sh
> index 0bf5934..11705ee 100755
> --- a/target/linux/ipq806x/base-files/etc/diag.sh
> +++ b/target/linux/ipq806x/base-files/etc/diag.sh
> @@ -11,6 +11,9 @@ get_status_led() {
>  	ea8500)
>  		status_led="ea8500:white:power"
>  		;;
> +	tew827dru)
> +		status_led="tew827dru:blue:power"
> +		;;
>  	esac
>  }
>  
> diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> index c7977e6..a218183 100644
> --- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> @@ -60,6 +60,10 @@ case "$FIRMWARE" in
>           r7800)
>  		ath10kcal_extract "art" 4096 12064
>  		;;
> +	tew827dru)
> +		hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
> +		ath10kcal_extract "ART" 4096 12064
> +		;;
>  	esac
>  	;;
>  "ath10k/cal-pci-0001:01:00.0.bin")
> @@ -76,6 +80,10 @@ case "$FIRMWARE" in
>          r7800)
>  		ath10kcal_extract "art" 20480 12064
>  		;;
> +	tew827dru)
> +		hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
> +		ath10kcal_extract "ART" 20480 12064
> +		;;
>  	esac
>  	;;
>  *)
> diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> index 1ae4352..a3326ab 100644
> --- a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
> @@ -18,6 +18,9 @@ case "$board" in
>  	ea8500)
>  		echo $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
>  		;;
> +	tew827dru)
> +		echo $(macaddr_add $(mtd_get_mac_ascii APPSBLENV wan_mac) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress
> +		;;
>  	*)
>  		;;
>  esac
> diff --git a/target/linux/ipq806x/base-files/lib/ipq806x.sh b/target/linux/ipq806x/base-files/lib/ipq806x.sh
> index 0b11b72..ffd08ea 100644
> --- a/target/linux/ipq806x/base-files/lib/ipq806x.sh
> +++ b/target/linux/ipq806x/base-files/lib/ipq806x.sh
> @@ -38,6 +38,9 @@ ipq806x_board_detect() {
>  	*"R7800")
>  		name="r7800"
>  		;;
> +	"TRENDnet TEW-827DRU")
> +		name="tew827dru"
> +		;;
>  	esac
>  
>  	[ -z "$name" ] && name="unknown"
> diff --git a/target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac b/target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac
> new file mode 100644
> index 0000000..04d92ff
> --- /dev/null
> +++ b/target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac
> @@ -0,0 +1,24 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2014 The Linux Foundation. All rights reserved.
> +#
> +
> +set_ether_mac() {
> +	. /lib/functions/uci-defaults.sh
> +	. /lib/ipq806x.sh
> +	. /lib/functions/system.sh
> +
> +	board=$(ipq806x_board_name)
> +
> +	case "$board" in
> +	tew827dru)
> +		# Set the correct ethernet MAC addresses per OEM intent.
> +		ifconfig eth0 hw ether $(mtd_get_mac_ascii APPSBLENV wan_mac) 2>/dev/null
> +		ifconfig eth1 hw ether $(mtd_get_mac_ascii APPSBLENV lan_mac) 2>/dev/null
> +		;;
> +	esac
> +
> +}
> +
> +boot_hook_add preinit_main set_ether_mac
> +

trailing blank line





> diff --git a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
> index 7726abb..69bda42 100644
> --- a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh
> @@ -11,7 +11,8 @@ platform_check_image() {
>  	ea8500 |\
>  	r7500 |\
>  	r7500v2 |\
> -	r7800)
> +	r7800 |\
> +	tew827dru)
>  		nand_do_platform_check $board $1
>  		return $?;
>  		;;
> @@ -36,7 +37,8 @@ platform_pre_upgrade() {
>  	d7800 |\
>  	r7500 |\
>  	r7500v2 |\
> -	r7800)
> +	r7800 |\
> +	tew827dru)
>  		nand_do_upgrade "$1"
>  		;;
>  	ea8500)
> diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile
> index 8c1064e..43a98ec 100644
> --- a/target/linux/ipq806x/image/Makefile
> +++ b/target/linux/ipq806x/image/Makefile
> @@ -201,6 +201,23 @@ define Device/R7800
>  	DEVICE_PACKAGES := ath10k-firmware-qca9984
>  endef
>  
> -TARGET_DEVICES += AP148 AP148-legacy C2600 D7800 DB149 EA8500 R7500 R7500v2 R7800
> +define Device/TEW827DRU
> +	DEVICE_DTS := qcom-ipq8064-tew827dru
> +	BLOCKSIZE := 128KiB
> +	PAGESIZE := 2048
> +	FILESYSTEMS := squashfs
> +	KERNEL_SUFFIX := -uImage
> +	KERNEL = kernel-bin | append-dtb | uImage none | pad-to 2k
> +	KERNEL_NAME := zImage
> +	KERNEL_IN_UBI := 1
> +	IMAGES := factory.bin sysupgrade.tar
> +	IMAGE/factory.bin := append-ubi | mkfit-TEW827DRU | cameo-sig AP148AR9880-RT-150127-00
> +	IMAGE/sysupgrade.tar := sysupgrade-tar
> +	BOARD_NAME := tew827dru
> +	DEVICE_TITLE := TRENDnet TEW-827DRU
> +	DEVICE_PACKAGES := ath10k-firmware-qca99x0
> +endef
> +
> +TARGET_DEVICES += AP148 AP148-legacy C2600 D7800 DB149 EA8500 R7500 R7500v2 R7800 TEW827DRU
>  
>  $(eval $(call BuildImage))
> diff --git a/target/linux/ipq806x/patches-4.4/800-devicetree.patch b/target/linux/ipq806x/patches-4.4/800-devicetree.patch
> index 85f2534..35308c1 100644
> --- a/target/linux/ipq806x/patches-4.4/800-devicetree.patch
> +++ b/target/linux/ipq806x/patches-4.4/800-devicetree.patch
> @@ -23,6 +23,7 @@ Signed-off-by: Jonas Gorski <jogo at openwrt.org>
>  +	qcom-ipq8064-r7500.dtb \
>  +	qcom-ipq8064-r7500v2.dtb \
>  +	qcom-ipq8065-r7800.dtb \
> ++	qcom-ipq8064-tew827dru.dtb \
>   	qcom-msm8660-surf.dtb \
>   	qcom-msm8960-cdp.dtb \
>   	qcom-msm8974-sony-xperia-honami.dtb
> 

at this point the build system thinks that the image is buildable but
the dts file has so far not been added. patch 3 needs to be reorder to
be prior to this patch.




More information about the Lede-dev mailing list