Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
14.09.2016 14:17, J Mo: On 09/11/2016 01:39 AM, Mathias Kresin wrote: This one is quite neat. It allows me to verify my changes. Would you please try the attached patch. Before: $ ./caldata -i './caldata1.bin' -v Size: 12064 MAC: 12:34:56:78:90:12 Checksum: 0xdf10 (OK) Patched: $ ./caldata -v -i ./patched.bin Size: 12064 MAC: aa:bb:cc:dd:ee:ff Checksum: 0x184c (OK) Just tested. firmware fails to load. There was an endianess issue in the script which is fixed. Can we continue discussing my approach to patch the mac address at https://github.com/lede-project/source/pull/324? It is about the same topic and we already made some progress. The latest version of my patch is linked there as well. It doesn't work yet completely, since there seams to be something in the caldata which triggers the replacement of parts of the mac address with random(?) values. Mathias ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
2016-09-14 14:17 GMT+02:00 J Mo : > On 09/11/2016 01:39 AM, Mathias Kresin wrote: >> 11.09.2016 03:36, J Mo: >>> On 09/10/2016 10:27 AM, Mathias Kresin wrote: 10.09.2016 03:35, J Mo: > > --- a/include/image-commands.mk > +++ b/include/image-commands.mk > @@ -168,3 +168,19 @@ define Build/sysupgrade-tar > --rootfs $(call > param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \ > $@ > 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 >>> >>> I'm not doing anything obscure here. This should be self-evident. Add a >>> byte-aligned signature. pad-to can't do that. >> >> >> Well if it would be obvious what you are trying to do I wouldn't ask. >> >> I still don't get what and to which boundary you are trying to align. >> After fixing the build errors I do get the following: >> >> Appending Cameo signature: "AP148AR9880-RT-150127-00", oldsize=5901955 >> align=64 sigsize=24 padsize=1 newsize=5901956 >> >> PreFooter size: 5901956 >> PostFooter size: 5901979 >> >> Neither the pre footer image nor the post footer image is padded to a >> multiple of 64 byte. >> >> Do you want to add the signature to a 64 byte padded image or should the >> image + signature padded to a multiple of 64byte? Where does the 64 byte >> does come from? It doesn't seam to be related to the 128k blocksize of the >> flash. >> > > Okay, I apologize. I don't know WTF I was thinking when I did that. It was > actually working before and then I changed it for reasons I can't explain > properly without drugs. > > padsize=$$(( ( ( ( ( ( $$oldsize + $$sigsize ) / $$align ) + 1 ) * $$align ) > - $$oldsize ) - $$sigsize )) ;\ > > This works. I've to admit, I'm not sure if you try to troll me. I asked you two times to _explain_ what you are trying to do here. The last time I even provided boiler plate answers. I mean how should one check the formula without knowing what they _should_ do. Mathias ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
On 09/11/2016 01:39 AM, Mathias Kresin wrote: 11.09.2016 03:36, J Mo: On 09/10/2016 10:27 AM, Mathias Kresin wrote: 10.09.2016 03:35, J Mo: --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -168,3 +168,19 @@ define Build/sysupgrade-tar --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \ $@ 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 I'm not doing anything obscure here. This should be self-evident. Add a byte-aligned signature. pad-to can't do that. Well if it would be obvious what you are trying to do I wouldn't ask. I still don't get what and to which boundary you are trying to align. After fixing the build errors I do get the following: Appending Cameo signature: "AP148AR9880-RT-150127-00", oldsize=5901955 align=64 sigsize=24 padsize=1 newsize=5901956 PreFooter size: 5901956 PostFooter size: 5901979 Neither the pre footer image nor the post footer image is padded to a multiple of 64 byte. Do you want to add the signature to a 64 byte padded image or should the image + signature padded to a multiple of 64byte? Where does the 64 byte does come from? It doesn't seam to be related to the 128k blocksize of the flash. Okay, I apologize. I don't know WTF I was thinking when I did that. It was actually working before and then I changed it for reasons I can't explain properly without drugs. padsize=$$(( ( ( ( ( ( $$oldsize + $$sigsize ) / $$align ) + 1 ) * $$align ) - $$oldsize ) - $$sigsize )) ;\ This works. 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 This whole file (already before your changes) looks completely wrong to me. Would you please send me a dump of your ART partition! I'll have a look at the checksum. I've a checksum patcher for ath9k in place (https://git.io/vi0eK) which might work for QCA99x0 caldata as well. This way the ath10kcal_patch_mac function in hotplug.d/firmware/11-ath10k-caldata can be used to fix the wifi mac address. I have uploaded a dump of two ART partitions from two different tew827dru here if you or anyone else wants to look at them: http://jmomo.net/files/lede/tew827dru-ARTs/ There is some discussion about this over on the TP-Link Archer C2600 thread. I suggest you go check it out for additional background: https://forum.openwrt.org/viewtopic.php?id=54973&p=13 https://forum.openwrt.org/viewtopic.php?id=54973&p=14 https://forum.openwrt.org/viewtopic.php?pid=317711#p317711 https://github.com/ianchi/openwrt/commit/83084c84414b44801a1ba8f323b363f0bc748e64 This one is quite neat. It allows me to verify my changes. Would you please try the attached patch. Before: $ ./caldata -i './caldata1.bin' -v Size: 12064 MAC: 12:34:56:78:90:12 Checksum: 0xdf10 (OK) Patched: $ ./caldata -v -i ./patched.bin Size: 12064 MAC: aa:bb:cc:dd:ee:ff Checksum: 0x184c (OK) Just tested. firmware fails to load. Here is some log: [ 10.439390] ath10k_pci :01:00.0: enabling device (0140 -> 0142) [ 10.439947] ath10k_pci :01:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0 [ 10.573751] ath10k_pci :01:00.0: Direct firmware load for ath10k/pre-cal-pci-:01:00.0.bin failed with error -2 [ 10.573784] ath10k_pci :01:00.0: Falling back to user helper [ 10.608498] firmware ath10k!pre-cal-pci-:01:00.0.bin: firmware_loading_store: map pages failed [ 10.608742] ath10k_pci :01:00.0: Direct firmware load for ath10k/cal-pci-:01:00.0.bin failed with error -2 [ 10.616430] ath10k_pci :01:00.0: Falling back to user helper [ 11.245654] ath10k_pci :01:00.0: qca99x0 hw2.0 target 0x0100 chip_id 0x003b01ff sub 168c:0002 [ 11.245691] ath10k_pci :01:00.0: kconfig debug 0 debug
Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
11.09.2016 06:07, J Mo: On 09/10/2016 06:36 PM, J Mo wrote: 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 000..b4ed225 --- /dev/null +++ b/target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac @@ -0,0 +1,23 @@ +#!/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 Okay I guess I see what you are trying to do. But you doing it at the wrong place using the wrong functions. Please have a look at https://git.lede-project.org/?p=source.git;a=blob;f=target/linux/lantiq/base-files/etc/board.d/02_network to see how to set the mac addresses properly. Oh yea, that's much better. Nevermind, your method does not address the problem. This probably has to be done in preinit or at least before any subinterfaces are created. Other devices are already doing this, probably for the same reasons. Which doesn't mean that it's correct what is done with other boards. It's the job of netifd to set mac addresses. Bypassing netifd for the network configuration is a no go for me. Right: root@lede:/# ifconfig -a | egrep -i hwadd br-lanLink encap:Ethernet HWaddr D8:EB:97:30:30:03 eth0 Link encap:Ethernet HWaddr D8:EB:97:30:30:03 eth0.1Link encap:Ethernet HWaddr D8:EB:97:30:30:03 eth1 Link encap:Ethernet HWaddr D8:EB:97:30:30:04 eth1.2Link encap:Ethernet HWaddr D8:EB:97:30:30:04 Wrong: root@lede:/# ifconfig -a | egrep -i hwadd br-lanLink encap:Ethernet HWaddr D8:EB:97:30:30:03 eth0 Link encap:Ethernet HWaddr 00:03:7F:BA:DB:01 eth0.1Link encap:Ethernet HWaddr D8:EB:97:30:30:03 eth1 Link encap:Ethernet HWaddr 00:03:7F:BA:DB:02 eth1.2Link encap:Ethernet HWaddr D8:EB:97:30:30:04 Well, it is perfect fine. Your configured lan (br-lan) and wan (eth1.2) are using the configured mac addresses. The physical interfaces are having a random macs, which is fine since no package is send over these interface. I mean having the correct mac address for the physical interfaces looks nice but isn't really required. Feel free to use tcpdump/wireshark to confirm that outgoing packages have the correct mac address. ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
11.09.2016 03:36, J Mo: On 09/10/2016 10:27 AM, Mathias Kresin wrote: 10.09.2016 03:35, J Mo: --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -168,3 +168,19 @@ define Build/sysupgrade-tar --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \ $@ 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 I'm not doing anything obscure here. This should be self-evident. Add a byte-aligned signature. pad-to can't do that. Well if it would be obvious what you are trying to do I wouldn't ask. I still don't get what and to which boundary you are trying to align. After fixing the build errors I do get the following: Appending Cameo signature: "AP148AR9880-RT-150127-00", oldsize=5901955 align=64 sigsize=24 padsize=1 newsize=5901956 PreFooter size: 5901956 PostFooter size: 5901979 Neither the pre footer image nor the post footer image is padded to a multiple of 64 byte. Do you want to add the signature to a 64 byte padded image or should the image + signature padded to a multiple of 64byte? Where does the 64 byte does come from? It doesn't seam to be related to the 128k blocksize of the flash. 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 This whole file (already before your changes) looks completely wrong to me. Would you please send me a dump of your ART partition! I'll have a look at the checksum. I've a checksum patcher for ath9k in place (https://git.io/vi0eK) which might work for QCA99x0 caldata as well. This way the ath10kcal_patch_mac function in hotplug.d/firmware/11-ath10k-caldata can be used to fix the wifi mac address. I have uploaded a dump of two ART partitions from two different tew827dru here if you or anyone else wants to look at them: http://jmomo.net/files/lede/tew827dru-ARTs/ There is some discussion about this over on the TP-Link Archer C2600 thread. I suggest you go check it out for additional background: https://forum.openwrt.org/viewtopic.php?id=54973&p=13 https://forum.openwrt.org/viewtopic.php?id=54973&p=14 https://forum.openwrt.org/viewtopic.php?pid=317711#p317711 https://github.com/ianchi/openwrt/commit/83084c84414b44801a1ba8f323b363f0bc748e64 This one is quite neat. It allows me to verify my changes. Would you please try the attached patch. Before: $ ./caldata -i './caldata1.bin' -v Size: 12064 MAC: 12:34:56:78:90:12 Checksum: 0xdf10 (OK) Patched: $ ./caldata -v -i ./patched.bin Size: 12064 MAC: aa:bb:cc:dd:ee:ff Checksum: 0x184c (OK) 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 a218183..71fa1e6 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 @@ -1,5 +1,25 @@ #!/bin/sh +[ -e /lib/firmware/$FIRMWARE ] && exit 0 + +. /lib/ipq806x.sh +. /lib/functions.sh +. /lib/functions/system.sh + +# xor multiple hex values of the same length +xor() { + local ret="0x$1" + + shift 1 + while [[ "$1" ]]; do + local val="0x$1" + ret=$((${ret:-0} ^ ${val:-0})) + shift 1 + done + + printf "%02x" "$ret" +} + ath10kcal_die() { echo "ath10cal: " "$*" exit 1 @@ -30,39 +50,46 @@ ath10kcal_extract() { ath10kcal_patch_mac() { local mac=$1 + local mac_offset=6 + local chksum_offset=2 + local xor_mac + local xor_fw_mac + local xor_fw_chksum [ -z "$mac" ] && return - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6 -} + xor_mac="${mac:0:2}${mac:3:2} ${mac:6:2}${mac:9:2} ${mac:12:2}${mac:15:2}" + xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/2 "%04x "' /lib/firmware/$FIRMWARE) -[ -e /lib/firmwar
Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
10.09.2016 03:35, J Mo: diff --git a/target/linux/ipq806x/patches-4.4/800-devicetree.patch b/target/linux/ipq806x/patches-4.4/800-devicetree.patch index 85f2534..ae174fd 100644 --- a/target/linux/ipq806x/patches-4.4/800-devicetree.patch +++ b/target/linux/ipq806x/patches-4.4/800-devicetree.patch @@ -12,7 +12,7 @@ Signed-off-by: Jonas Gorski --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -506,7 +506,13 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -506,7 +506,14 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ qcom-ipq8064-ap148.dtb \ @@ -23,6 +23,7 @@ Signed-off-by: Jonas Gorski + 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 After your change: Applying patch platform/800-devicetree.patch patching file arch/arm/boot/dts/Makefile patch: malformed patch at line 29: qcom-msm8974-sony-xperia-honami.dtb If you edit the patch by hand, you should adjust the patch header as well: -@@ -506,7 +506,13 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -506,7 +506,14 @@ dtb-$(CONFIG_ARCH_QCOM) += \ But I still get a build error using the patches from patchwork: bash: /data/build/lede/scripts/its-maker.sh: Permission denied Makefile:223: recipe for target '/data/build/lede/build_dir/target-arm_cortex-a15+neon-vfpv4_musl-1.1.15_eabi/linux-ipq806x/tmp/lede-ipq806x-TEW827DRU-squashfs-factory.bin' failed You have a few trailing whitespace errors in your patches. Please use ./scripts/checkpatch.pl on your patches and fix at least the trailing whitespace errors! ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
On 09/10/2016 06:36 PM, J Mo wrote: 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 000..b4ed225 --- /dev/null +++ b/target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac @@ -0,0 +1,23 @@ +#!/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 Okay I guess I see what you are trying to do. But you doing it at the wrong place using the wrong functions. Please have a look at https://git.lede-project.org/?p=source.git;a=blob;f=target/linux/lantiq/base-files/etc/board.d/02_network to see how to set the mac addresses properly. Oh yea, that's much better. Nevermind, your method does not address the problem. This probably has to be done in preinit or at least before any subinterfaces are created. Other devices are already doing this, probably for the same reasons. Right: root@lede:/# ifconfig -a | egrep -i hwadd br-lanLink encap:Ethernet HWaddr D8:EB:97:30:30:03 eth0 Link encap:Ethernet HWaddr D8:EB:97:30:30:03 eth0.1Link encap:Ethernet HWaddr D8:EB:97:30:30:03 eth1 Link encap:Ethernet HWaddr D8:EB:97:30:30:04 eth1.2Link encap:Ethernet HWaddr D8:EB:97:30:30:04 Wrong: root@lede:/# ifconfig -a | egrep -i hwadd br-lanLink encap:Ethernet HWaddr D8:EB:97:30:30:03 eth0 Link encap:Ethernet HWaddr 00:03:7F:BA:DB:01 eth0.1Link encap:Ethernet HWaddr D8:EB:97:30:30:03 eth1 Link encap:Ethernet HWaddr 00:03:7F:BA:DB:02 eth1.2Link encap:Ethernet HWaddr D8:EB:97:30:30:04 ___ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev
Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
On 09/10/2016 10:27 AM, Mathias Kresin wrote: 10.09.2016 03:35, J Mo: --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -168,3 +168,19 @@ define Build/sysupgrade-tar --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \ $@ 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" ;\ remove the debug output Yes. +dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync ;\ +echo -n "$$cameo_sig" >> $@.new ; \ +} +@mv $@.new $@ +endef Please move the build recipe to the ipq806x Makefile. The tew827dru is the only board which uses the recipe. It can be moved to image-commands.mk as soon as another board requires the recipe. I might don't get what you are trying to do here but this looks way to complicated to me. It looks rather a job for pad-offset. Would you please explain how the footer should look like. Cameo signatures are already used by a large number of devices. This should do the same thing, but in the new makefile style. The old style was nearly incomprehensible. I'm not doing anything obscure here. This should be self-evident. Add a byte-aligned signature. pad-to can't do that. + 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" drop the comments and add the info to the commit message. Yes. +;; *) ;; 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@eth1" "5:wan" "0@eth0" ;; +tew827dru) +ucidef_add_switch "switch0" \ +"1:lan" "2:lan" "3:lan" "4:lan" "6t@eth1" "5:wan" "0t@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 +;; Copy/Paste leftover? As far as I can see, there isn't even an devinfo partition from which the mac address could be extracted. Thanks for finding that. I am guessing it slipped in during a git rebase. 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-file
Re: [LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
10.09.2016 03:35, J Mo: --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -168,3 +168,19 @@ define Build/sysupgrade-tar --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \ $@ 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" ;\ remove the debug output + dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync ;\ + echo -n "$$cameo_sig" >> $@.new ; \ + } + @mv $@.new $@ +endef Please move the build recipe to the ipq806x Makefile. The tew827dru is the only board which uses the recipe. It can be moved to image-commands.mk as soon as another board requires the recipe. I might don't get what you are trying to do here but this looks way to complicated to me. It looks rather a job for pad-offset. Would you please explain how the footer should look like. + 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" drop the comments and add the info to the commit message. + ;; *) ;; 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@eth1" "5:wan" "0@eth0" ;; +tew827dru) + ucidef_add_switch "switch0" \ + "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth1" "5:wan" "0t@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 + ;; Copy/Paste leftover? As far as I can see, there isn't even an devinfo partition from which the mac address could be extracted. 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)) ) > /sy
[LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru
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: Jesse Molina --- include/image-commands.mk | 16 + .../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| 23 ++ .../ipq806x/base-files/lib/upgrade/platform.sh | 6 +- .../arch/arm/boot/dts/qcom-ipq8064-tew827dru.dts | 354 + target/linux/ipq806x/image/Makefile| 48 ++- .../linux/ipq806x/image/tew827dru-bootconfig.bin | Bin 0 -> 84 bytes target/linux/ipq806x/image/tew827dru-flash.scr | 57 .../linux/ipq806x/patches-4.4/800-devicetree.patch | 3 +- 14 files changed, 530 insertions(+), 4 deletions(-) create mode 100644 target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac create mode 100644 target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8064-tew827dru.dts create mode 100644 target/linux/ipq806x/image/tew827dru-bootconfig.bin create mode 100644 target/linux/ipq806x/image/tew827dru-flash.scr diff --git a/include/image-commands.mk b/include/image-commands.mk index 9db150c..2f3e082 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -168,3 +168,19 @@ define Build/sysupgrade-tar --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \ $@ 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 + 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@eth1" "5:wan" "0@eth0" ;; +tew827dru) + ucidef_add_switch "switch0" \ + "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth1" "5:wan" "0t@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/ba