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 0000:01:00.0: enabling device (0140 -> 0142)
[ 10.439947] ath10k_pci 0000:01:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0 [ 10.573751] ath10k_pci 0000:01:00.0: Direct firmware load for ath10k/pre-cal-pci-0000:01:00.0.bin failed with error -2
[   10.573784] ath10k_pci 0000:01:00.0: Falling back to user helper
[ 10.608498] firmware ath10k!pre-cal-pci-0000:01:00.0.bin: firmware_loading_store: map pages failed [ 10.608742] ath10k_pci 0000:01:00.0: Direct firmware load for ath10k/cal-pci-0000:01:00.0.bin failed with error -2
[   10.616430] ath10k_pci 0000:01:00.0: Falling back to user helper
[ 11.245654] ath10k_pci 0000:01:00.0: qca99x0 hw2.0 target 0x01000000 chip_id 0x003b01ff sub 168c:0002 [ 11.245691] ath10k_pci 0000:01:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 1 [ 11.255382] ath10k_pci 0000:01:00.0: firmware ver 10.4.1.00030-1 api 5 features no-p2p crc32 d2901e01 [ 11.262415] ath10k_pci 0000:01:00.0: failed to fetch board data for bus=pci,vendor=168c,device=0040,subsystem-vendor=168c,subsystem-device=0002 from ath10k/QCA99X0/hw2.0/board-2.bin [ 11.271406] ath10k_pci 0000:01:00.0: board_file api 1 bmi_id N/A crc32 7e56fd07 [ 12.389071] ath10k_pci 0000:01:00.0: firmware crashed! (uuid 68d0f098-4df1-4a02-a242-6c31e76ba5e0) [ 12.389112] ath10k_pci 0000:01:00.0: qca99x0 hw2.0 target 0x01000000 chip_id 0x003b01ff sub 168c:0002 [ 12.396928] ath10k_pci 0000:01:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 1 [ 12.407781] ath10k_pci 0000:01:00.0: firmware ver 10.4.1.00030-1 api 5 features no-p2p crc32 d2901e01 [ 12.414418] ath10k_pci 0000:01:00.0: board_file api 1 bmi_id N/A crc32 7e56fd07 [ 12.423576] ath10k_pci 0000:01:00.0: htt-ver 0.0 wmi-op 6 htt-op 4 cal file max-sta 32 raw 0 hwcrypto 1
[   12.432720] ath10k_pci 0000:01:00.0: firmware register dump:
[ 12.440065] ath10k_pci 0000:01:00.0: [00]: 0x01000000 0x000015B3 0x009CEE0B 0x00955B31 [ 12.445969] ath10k_pci 0000:01:00.0: [04]: 0x009CEE0B 0x00060530 0x00000011 0x00411D7C [ 12.453695] ath10k_pci 0000:01:00.0: [08]: 0x00413A80 0x00400000 0x00406790 0x00417224 [ 12.461594] ath10k_pci 0000:01:00.0: [12]: 0x00000009 0x00000000 0x000D2C34 0x000D2C3F [ 12.469492] ath10k_pci 0000:01:00.0: [16]: 0x00953438 0x000D2C37 0x00000000 0x00000000 [ 12.477393] ath10k_pci 0000:01:00.0: [20]: 0x409CEE0B 0x004066BC 0x00000001 0x00403428 [ 12.485291] ath10k_pci 0000:01:00.0: [24]: 0x809811A4 0x0040671C 0x00000036 0xC09CEE0B [ 12.493191] ath10k_pci 0000:01:00.0: [28]: 0x800D8767 0x0040678C 0x00000004 0x004119F0 [ 12.501091] ath10k_pci 0000:01:00.0: [32]: 0x800C383A 0x004067BC 0x00411880 0x00400000 [ 12.508989] ath10k_pci 0000:01:00.0: [36]: 0x809800A3 0x004067EC 0x00411890 0x009C3254 [ 12.516889] ath10k_pci 0000:01:00.0: [40]: 0x8098003A 0x0040683C 0x00400000 0x00400600 [ 12.524789] ath10k_pci 0000:01:00.0: [44]: 0x809407AD 0x0040686C 0xD8400100 0x0040687C [ 12.532688] ath10k_pci 0000:01:00.0: [48]: 0x8094087E 0x0040688C 0x00000000 0x00000008 [ 12.540588] ath10k_pci 0000:01:00.0: [52]: 0x80940DFB 0x004068AC 0x00400000 0x00400600 [ 12.548550] ath10k_pci 0000:01:00.0: [56]: 0x80940E5D 0x004068CC 0x00000000 0x00400600 [ 13.390376] ath10k_pci 0000:01:00.0: failed to receive control response completion, polling..
[   14.390276] ath10k_pci 0000:01:00.0: ctl_resp never came in (-110)
[   14.390303] ath10k_pci 0000:01:00.0: failed to connect to HTC: -110
[   14.455864] ath10k_pci 0000:01:00.0: could not init core (-110)
[   14.456011] ath10k_pci 0000:01:00.0: could not probe fw (-110)



_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to