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-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
https://github.com/ianchi/openwrt/blob/master/target/linux/ipq806x/base-files/lib/preinit/04_caldata
    https://forum.openwrt.org/viewtopic.php?id=54973&p=18
    https://forum.openwrt.org/viewtopic.php?id=54973&p=20

There is a patch for ath10k apparently specifically for this issue, so that the MAC can be set in sysfs, which is what I am doing right now.




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..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.




diff --git a/target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8064-tew827dru.dts b/target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8064-tew827dru.dts
new file mode 100644
index 0000000..8f1585f
--- /dev/null
+++ b/target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8064-tew827dru.dts
@@ -0,0 +1,354 @@
+#include "qcom-ipq8064-v1.0.dtsi"
+#include <dt-bindings/input/input.h>
+
+/ {
+    model = "TRENDnet TEW-827DRU";
+    compatible = "trendnet,tew827dru", "qcom,ipq8064";
+
+    memory@0 {
+        reg = <0x42000000 0x1e000000>;
+        device_type = "memory";
+    };
+
+    reserved-memory {
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges;
+        rsvd@41200000 {
+            reg = <0x41200000 0x300000>;
+            no-map;
+        };
+    };
+
+    aliases {
+        serial0 = &uart4;
+        mdio-gpio0 = &mdio0;
+    };
+
+    chosen {
+ bootargs = "console=ttyMSM0,115200n8 ubi.mtd=11 ubi.block=0,1 root=/dev/ubiblock0_1 rootfstype=squashfs";
+        linux,stdout-path = "serial0:115200n8";
+
+    };
+
+    soc {
+        pinmux@800000 {
+            i2c4_pins: i2c4_pinmux {
+                pins = "gpio12", "gpio13";
+                function = "gsbi4";
+                bias-disable;
+            };
+
+            spi_pins: spi_pins {
+                mux {
+                    pins = "gpio18", "gpio19", "gpio21";
+                    function = "gsbi5";
+                    drive-strength = <10>;
+                    bias-none;
+                };
+            };
+            nand_pins: nand_pins {
+                mux {
+                    pins = "gpio34", "gpio35", "gpio36",
+                           "gpio37", "gpio38", "gpio39",
+                           "gpio40", "gpio41", "gpio42",
+                           "gpio43", "gpio44", "gpio45",
+                           "gpio46", "gpio47";
+                    function = "nand";
+                    drive-strength = <10>;
+                    bias-disable;
+                };
+                pullups {
+                    pins = "gpio39";
+                    bias-pull-up;
+                };
+                hold {
+                    pins = "gpio40", "gpio41", "gpio42",
+                           "gpio43", "gpio44", "gpio45",
+                           "gpio46", "gpio47";
+                    bias-bus-hold;
+                };
+            };
+
+            mdio0_pins: mdio0_pins {
+                mux {
+                    pins = "gpio0", "gpio1";
+                    function = "gpio";
+                    drive-strength = <8>;
+                    bias-disable;
+                };
+            };
+
+            rgmii2_pins: rgmii2_pins {
+                mux {
+ pins = "gpio27", "gpio28", "gpio29", "gpio30", "gpio31", "gpio32", + "gpio51", "gpio52", "gpio59", "gpio60", "gpio61", "gpio62" ;
+                    function = "rgmii2";
+                    drive-strength = <8>;
+                    bias-disable;
+                };
+            };
+        };
+
+        gsbi@16300000 {
+            qcom,mode = <GSBI_PROT_I2C_UART>;
+            status = "ok";
+
+            uart4: serial@16340000 {
+                status = "ok";
+            };
+            /*
+             * The i2c device on gsbi4 should not be enabled.
+             * On ipq806x designs gsbi4 i2c is meant for exclusive
+             * RPM usage. Turning this on in kernel manifests as
+             * i2c failure for the RPM.
+             */
+        };
+
+        phy@100f8800 {        /* USB3 port 1 HS phy */
+            status = "ok";
+        };
+
+        phy@100f8830 {        /* USB3 port 1 SS phy */
+            status = "ok";
+        };
+
+        phy@110f8800 {        /* USB3 port 0 HS phy */
+            status = "ok";
+        };
+
+        phy@110f8830 {        /* USB3 port 0 SS phy */
+            status = "ok";
+        };
+
+        usb30@0 {
+            status = "ok";
+        };
+
+        usb30@1 {
+            status = "ok";
+        };
+
+        pcie0: pci@1b500000 {
+            status = "ok";
+            phy-tx0-term-offset = <7>;
+        };
+
+        pcie1: pci@1b700000 {
+            status = "ok";
+            phy-tx0-term-offset = <7>;
+        };
+
+        pcie2: pci@1b900000 {
+            status = "ok";
+            phy-tx0-term-offset = <7>;
+        };
+
+        nand@1ac00000 {
+            status = "ok";
+
+            pinctrl-0 = <&nand_pins>;
+            pinctrl-names = "default";
+
+            nand-ecc-strength = <4>;
+            nand-bus-width = <8>;
+
+            #address-cells = <1>;
+            #size-cells = <1>;
+
+            SBL1@0 {
+                label = "SBL1";
+                reg = <0x0000000 0x0040000>;
+                read-only;
+            };
+
+            MIBIB@40000 {
+                label = "MIBIB";
+                reg = <0x0040000 0x0140000>;
+                read-only;
+            };
+
+            SBL2@180000 {
+                label = "SBL2";
+                reg = <0x0180000 0x0140000>;
+                read-only;
+            };
+
+            SBL3@2c0000 {
+                label = "SBL3";
+                reg = <0x02c0000 0x0280000>;
+                read-only;
+            };
+
+            DDRCONFIG@540000 {
+                label = "DDRCONFIG";
+                reg = <0x0540000 0x0120000>;
+                read-only;
+            };
+
+            SSD@660000 {
+                label = "SSD";
+                reg = <0x0660000 0x0120000>;
+                read-only;
+            };
+
+            TZ@780000 {
+                label = "TZ";
+                reg = <0x0780000 0x0280000>;
+                read-only;
+            };
+
+            RPM@a00000 {
+                label = "RPM";
+                reg = <0x0a00000 0x0280000>;
+                read-only;
+            };
+
+            APPSBL@53a0000 {
+                label = "APPSBL";
+                reg = <0x53a0000 0x500000>;
+                read-only;
+            };
+
+            APPSBLENV@1180000{
+                label = "APPSBLENV";
+                reg = <0x1180000 0x80000>;
+                read-only;
+            };
+
+            ART@1180000 {
+                label = "ART";
+                reg = <0x1200000 0x140000>;
+                read-only;
+            };
+
+            rootfs@58a0000 {
+                label = "rootfs";
+                reg = <0x58a0000 0x4000000>;
+            };
+
+            BOOTCONFIG@5340000{
+                label = "BOOTCONFIG";
+                reg = <0x5340000 0x60000>;
+                read-only;
+            };
+
+            APPSBL_1@c80000{
+                label = "APPSBL_1";
+                reg = <0xc80000 0x500000>;
+                read-only;
+            };
+
+            rootfs_1@1340000 {
+                label = "rootfs_1";
+                reg = <0x1340000 0x4000000>;
+            };
+
+        };
+
+        mdio0: mdio {
+            compatible = "virtual,mdio-gpio";
+            #address-cells = <1>;
+            #size-cells = <0>;
+            gpios = <&qcom_pinmux 1 0 &qcom_pinmux 0 0>;
+            pinctrl-0 = <&mdio0_pins>;
+            pinctrl-names = "default";
+
+            phy0: ethernet-phy@0 {
+                device_type = "ethernet-phy";
+                reg = <0>;
+                qca,ar8327-initvals = <
+                    0x00004 0x7600000   /* PAD0_MODE */
+                    0x00008 0x1000000   /* PAD5_MODE */
+                    0x0000c 0x80        /* PAD6_MODE */
+                    0x000e4 0x6a545     /* MAC_POWER_SEL */
+                    0x000e0 0xc74164de  /* SGMII_CTRL */
+                    0x0007c 0x4e        /* PORT0_STATUS */
+                    0x00094 0x4e        /* PORT6_STATUS */
+                    >;
+            };
+
+            phy4: ethernet-phy@4 {
+                device_type = "ethernet-phy";
+                reg = <4>;
+            };
+        };
+
+        // WAN eth0

use /* */ for all comments in dts files


You might want to go fix all the others where this already exists, and whence it came.



+        gmac1: ethernet@37200000 {
+            status = "ok";
+            phy-mode = "rgmii";
+            qcom,id = <1>;
+            qcom,phy_mdio_addr = <4>;
+            qcom,poll_required = <1>;
+            qcom,rgmii_delay = <0>;
+            qcom,emulation = <0>;
+            pinctrl-0 = <&rgmii2_pins>;
+            pinctrl-names = "default";
+            fixed-link {
+                speed = <1000>;
+                full-duplex;
+            };
+        };
+
+        // LAN eth1
+        gmac2: ethernet@37400000 {
+            status = "ok";
+            phy-mode = "sgmii";
+            qcom,id = <2>;
+            qcom,phy_mdio_addr = <0>;    /* none */
+            qcom,poll_required = <0>;    /* no polling */
+            qcom,rgmii_delay = <0>;
+            qcom,emulation = <0>;
+            fixed-link {
+                speed = <1000>;
+                full-duplex;
+            };
+        };
+
+    };
+
+    gpio-keys {
+        compatible = "gpio-keys";
+
+        rfkill {
+            label = "rfkill";
+            gpios = <&qcom_pinmux 9 1>;
+            linux,code = <KEY_RFKILL>;
+        };
+
+        reset {
+            label = "reset";
+            gpios = <&qcom_pinmux 54 1>;
+            linux,code = <KEY_RESTART >;
+        };
+
+        wps {
+            label = "wps";
+            gpios = <&qcom_pinmux 67 1>;
+            linux,code = <KEY_WPS_BUTTON>;
+        };
+    };
+
+    gpio-leds {
+        compatible = "gpio-leds";
+
+        usb {
+            label = "tew827dru:blue:usb";
+            gpios = <&qcom_pinmux 7 1>;
+            default-state = "off";
+        };
+
+        power {
+            label = "tew827dru:blue:power";
+            gpios = <&qcom_pinmux 53 1>;
+            default-state = "off";
+            linux,default-trigger = "heartbeat";
+        };
+    };
+};
+
+&adm_dma {
+    status = "ok";
+};
+
diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile
index ff5be05..6ca776a 100644
--- a/target/linux/ipq806x/image/Makefile
+++ b/target/linux/ipq806x/image/Makefile

-TARGET_DEVICES += AP148 AP148-legacy C2600 D7800 DB149 EA8500 R7500 R7500v2 R7800
+define Device/TEW827DRU
+    DEVICE_DTS := qcom-ipq8064-tew827dru
+    BLOCKSIZE := 128KiB

use k as unit suffix similar to the other boards in the file


Yes.

+    PAGESIZE := 2048
+    FILESYSTEMS := squashfs
+    KERNEL_SUFFIX := -uImage
+    KERNEL = kernel-bin | append-dtb | uImage none | pad-to 2k

Why does the in ubi kernel needs to be padded?


I did that for a reason but I can't recall what it was right now. I need to do another test build anyway so I'll try it without and see what happens.

I'm certain the OEM was doing this, but I can't remember why. Probably has something to do with NAND, but it's in UBI so.... not sure.




+    KERNEL_NAME := zImage

Use a call to Device/LegacyImage instead. It populates KERNEL* already with the same values. Use Kernel += | pad-to 2k to append your extra step.


Yes.



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

Reply via email to