Re: [LEDE-DEV] [PATCH] ar71xx: Fix sysupgrade for the Airtight Networks C-55

2016-09-11 Thread Mathias Kresin

11.09.2016 17:43, Chris Blake:

Additionally, it appears that other devices like the ZyXEL NBG6616 may
be affected by this.


I'm working on the same at the moment. And till now the ZyXEL NBG6616 
and the Ubiquiti UAP Pro are affected by the same error as well. I'm 
compiling a few more targets to check for more affected devices.


@nbd

I would like to get rid of the optional padding parameter for 
append-kernel/append-rootfs and force the use of pad-to. It is way more 
obvious what is done and it throws an error in case the param is 
missing. At the moment I'm using pad-to to find more of these kind of 
errors.


Any opinion on that?

Mathias

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


Re: [LEDE-DEV] [PATCH] ar71xx: Fix sysupgrade for the Airtight Networks C-55

2016-09-11 Thread Chris Blake
On Sun, Sep 11, 2016 at 10:40 AM, Chris Blake  wrote:
> It appears that (KERNEL_SIZE) was not passing to append-kernel,
> causing sysupgrade images to brick units due to the invalid rootfs
> offset. This is fixed by removing the 2 extra $$'s in front of the
> variables. Additionally, check-size was added to ensure that we don't
> have a kernel larger than our partition.
>
> Before: kernel@0x0,rootfs@0x13EDF8
> After: kernel@0x0,rootfs@0x20
>
> Signed-off-by: Chris Blake 
> ---
>  target/linux/ar71xx/image/generic.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/linux/ar71xx/image/generic.mk 
> b/target/linux/ar71xx/image/generic.mk
> index bd92a84..5144334 100644
> --- a/target/linux/ar71xx/image/generic.mk
> +++ b/target/linux/ar71xx/image/generic.mk
> @@ -443,7 +443,7 @@ define Device/c-55
>KERNEL_SIZE = 2048k
>IMAGE_SIZE = 15872k
>MTDPARTS = 
> spi0.0:256k(u-boot)ro,128k(u-boot-env)ro,2048k(kernel),13824k(rootfs),13824k(opt)ro,2624k(failsafe)ro,64k(art)ro,15872k@0x6(firmware)
> -  IMAGE/sysupgrade.bin = append-kernel (KERNEL_SIZE) | append-rootfs | 
> pad-rootfs | check-size (IMAGE_SIZE)
> +  IMAGE/sysupgrade.bin = append-kernel $$(KERNEL_SIZE) | check-size 
> $$(KERNEL_SIZE) | append-rootfs | pad-rootfs | check-size $$(IMAGE_SIZE)
>  endef
>
>  TARGET_DEVICES += c-55
> --
> 2.7.4
>

Additionally, it appears that other devices like the ZyXEL NBG6616 may
be affected by this.

- Chris Blake

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


Re: [LEDE-DEV] [PATCH] ar71xx: add check-size when append-kernel is used

2016-09-11 Thread Chris Blake
@Mathias,

Just to make sure, is check-size (IMAGE_SIZE) also affected by
this bug as well? If so, let me know and I can rebase this patch again
later tonight to fix that as well.

- Chris Blake

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


[LEDE-DEV] [PATCH 5/5] ar71xx: add support for D-Link DAP-2695 rev. A1

2016-09-11 Thread Stijn Tintel
Signed-off-by: Stijn Tintel 
---
 package/boot/uboot-envtools/files/ar71xx   |   1 +
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   5 +
 .../linux/ar71xx/base-files/etc/board.d/02_network |   5 +
 .../etc/hotplug.d/firmware/11-ath10k-caldata   |   4 +
 .../base-files/etc/uci-defaults/09_fix-checksum|   9 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh   |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh  |  13 ++
 target/linux/ar71xx/config-4.4 |   1 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |   9 +
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../files/arch/mips/ath79/mach-dap-2695-a1.c   | 191 +
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/generic.mk   |  38 
 13 files changed, 281 insertions(+)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dap-2695-a1.c

diff --git a/package/boot/uboot-envtools/files/ar71xx 
b/package/boot/uboot-envtools/files/ar71xx
index a075020..45f1f45 100644
--- a/package/boot/uboot-envtools/files/ar71xx
+++ b/package/boot/uboot-envtools/files/ar71xx
@@ -54,6 +54,7 @@ om2p-lc)
 dr531)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0xf800" "0x1"
;;
+dap-2695-a1 | \
 wzr-hp-ag300h)
ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x1" "0x1"
;;
diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds 
b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index cf05859..96352a2 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -197,6 +197,11 @@ rb-2011uias-2hnd)
ucidef_set_led_switch "eth10" "ETH10" "rb:green:eth10" "switch1" "0x02"
;;
 
+dap-2695-a1)
+   ucidef_set_led_default "power" "POWER" "d-link:green:power" "1"
+   ucidef_set_led_default "diag" "DIAG" "d-link:red:power" "0"
+   ucidef_set_led_wlan "wlan2g" "WLAN 2.4 GHz" "d-link:green:wlan2g" 
"phy1tpt"
+   ;;
 dhp-1565-a1)
ucidef_set_led_switch "wan" "WAN" "d-link:green:planet" "switch0" "0x20"
;;
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network 
b/target/linux/ar71xx/base-files/etc/board.d/02_network
index b637113..65292b0 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -538,6 +538,11 @@ wndr3700)
ucidef_add_switch_port_attr "switch0" 5 led 2
;;
 
+dap-2695-a1)
+   ucidef_set_interfaces_lan_wan "eth0" "eth1"
+   ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
+   ;;
+
 *)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
diff --git 
a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata 
b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 0e93feb..31f54e3 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -47,6 +47,10 @@ board=$(ar71xx_board_name)
 case "$FIRMWARE" in
 "ath10k/cal-pci-:00:00.0.bin")
case $board in
+   dap-2695-a1)
+   ath10kcal_extract "radiocfg" 20480 2116
+   ath10kcal_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
+   ;;
dlan-pro-1200-ac)
ath10kcal_extract "art" 20480 2116
;;
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-checksum 
b/target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-checksum
index 1bfd525..057afe0 100644
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-checksum
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-checksum
@@ -11,9 +11,18 @@ fixtrx() {
mtd -o 32 fixtrx firmware
 }
 
+fixwrgg() {
+   local kernel_size=$(sed -n 's/mtd[0-9]*: 
\([0-9a-f]*\).*"kernel".*/\1/p' /proc/mtd)
+
+   [ "$kernel_size" ] && mtd -c 0x$kernel_size fixwrgg firmware
+}
+
 case "$board" in
 mynet-rext |\
 wrt160nl)
fixtrx
;;
+dap-2695-a1)
+   fixwrgg
+   ;;
 esac
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh 
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index e57701a..82c1872 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -469,6 +469,9 @@ ar71xx_board_detect() {
*CR5000)
name="cr5000"
;;
+   *"DAP-2695 rev. A1")
+   name="dap-2695-a1"
+   ;;
*"DB120 reference board")
name="db120"
;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh 
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 716fa52..e94dd13 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -105,6 +105,10 @@ 

[LEDE-DEV] [PATCH 1/5] firmware-utils: mkwrggimg: new tool for D-Link DAP-2695

2016-09-11 Thread Stijn Tintel
Based on mkwrgimg.c.

Signed-off-by: Stijn Tintel 
---
 tools/firmware-utils/Makefile|   1 +
 tools/firmware-utils/src/mkwrggimg.c | 282 +++
 2 files changed, 283 insertions(+)
 create mode 100644 tools/firmware-utils/src/mkwrggimg.c

diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index f4a5222..9d100e5 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -57,6 +57,7 @@ define Host/Compile
$(call cc,buffalo-tag buffalo-lib, -Wall)
$(call cc,buffalo-tftp buffalo-lib, -Wall)
$(call cc,mkwrgimg md5, -Wall)
+   $(call cc,mkwrggimg md5, -Wall)
$(call cc,mkedimaximg)
$(call cc,mkbrncmdline)
$(call cc,mkbrnimg)
diff --git a/tools/firmware-utils/src/mkwrggimg.c 
b/tools/firmware-utils/src/mkwrggimg.c
new file mode 100644
index 000..a224b25
--- /dev/null
+++ b/tools/firmware-utils/src/mkwrggimg.c
@@ -0,0 +1,282 @@
+/*
+ *  Copyright (C) 2011 Gabor Juhos 
+ *  Copyright (C) 2016 Stijn Tintel 
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "md5.h"
+
+#define ERR(fmt, ...) do { \
+   fflush(0); \
+   fprintf(stderr, "[%s] *** error: " fmt "\n", \
+   progname, ## __VA_ARGS__ ); \
+} while (0)
+
+#define ERRS(fmt, ...) do { \
+   int save = errno; \
+   fflush(0); \
+   fprintf(stderr, "[%s] *** error: " fmt ", %s\n", \
+   progname, ## __VA_ARGS__, strerror(save)); \
+} while (0)
+
+#define WRGG03_MAGIC   0x20080321
+
+struct wrgg03_header {
+   charsignature[32];
+   uint32_tmagic1;
+   uint32_tmagic2;
+   charversion[16];
+   charmodel[16];
+   uint32_tflag[2];
+   uint32_treserve[2];
+   charbuildno[16];
+   uint32_tsize;
+   uint32_toffset;
+   chardevname[32];
+   chardigest[16];
+} __attribute__ ((packed));
+
+static char *progname;
+static char *ifname;
+static char *ofname;
+static char *signature;
+static char *version;
+static char *model;
+static uint32_t flag = 0;
+static uint32_t reserve = 0;
+static char *buildno;
+static uint32_t offset;
+static char *devname;
+static int big_endian;
+
+void usage(int status)
+{
+   FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
+
+   fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
+   fprintf(stream,
+"\n"
+"Options:\n"
+"  -b  create image in big endian format\n"
+"  -B build number\n"
+"  -iread input from the file \n"
+"  -dset device name to \n"
+"  -m   model name\n"
+"  -owrite output to the file \n"
+"  -O  set offset to \n"
+"  -s set image signature to \n"
+"  -h  show this screen\n"
+   );
+
+   exit(status);
+}
+
+static void put_u32(void *data, uint32_t val, int swap)
+{
+   unsigned char *p = data;
+
+   if (swap) {
+   p[0] = (val >> 24) & 0xff;
+   p[1] = (val >> 16) & 0xff;
+   p[2] = (val >> 8) & 0xff;
+   p[3] = val & 0xff;
+   } else {
+   p[3] = (val >> 24) & 0xff;
+   p[2] = (val >> 16) & 0xff;
+   p[1] = (val >> 8) & 0xff;
+   p[0] = val & 0xff;
+   }
+}
+
+static void get_digest(struct wrgg03_header *header, char *data, int size)
+{
+   MD5_CTX ctx;
+
+   MD5_Init();
+
+   MD5_Update(, (char *)>offset, sizeof(header->offset));
+   MD5_Update(, (char *)>devname, sizeof(header->devname));
+   MD5_Update(, data, size);
+
+   MD5_Final(header->digest, );
+}
+
+int main(int argc, char *argv[])
+{
+   struct wrgg03_header *header;
+   char *buf;
+   struct stat st;
+   int buflen;
+   int err;
+   int res = EXIT_FAILURE;
+
+   FILE *outfile, *infile;
+
+   progname = basename(argv[0]);
+
+   while ( 1 ) {
+   int c;
+
+   c = getopt(argc, argv, "bd:i:m:o:s:v:B:O:h");
+   if (c == -1)
+   break;
+
+   switch (c) {
+   case 'b':
+   big_endian = 1;
+   break;
+   case 'B':
+   buildno = optarg;
+   break;
+   case 'd':
+   devname = optarg;
+   break;
+   case 'i':
+   ifname = optarg;
+   break;
+   case 'm':
+   model = optarg;
+   break;
+ 

[LEDE-DEV] [PATCH 0/5] add support for D-Link DAP-2695 rev. A1

2016-09-11 Thread Stijn Tintel
This patch series adds support for D-Link DAP-2695 rev. A1.

Both the factory and the sysupgrade can be used to flash the device from
the bootloader. When flashing via the web interface of the stock
firmware, only the factory image can be used.

With the stock firmware, this device is only usable as a dumb AP. With
LEDE, it is configured as a router by default. The LAN1(PoE) port is
configured as the LAN port, the LAN2 port is configured as the WAN port.

The only thing that doesn't work, is the 5GHz LED, as it does not seem
to be connected to any of the SoC's GPIOs.

The WRGG naming comes from the D-Link GPL code. The mkwrggimg utility
also works for the D-Link DAP-2553. For more info, see
https://forum.openwrt.org/viewtopic.php?id=52048

Stijn Tintel (5):
  firmware-utils: mkwrggimg: new tool for D-Link DAP-2695
  kernel: mtdsplit: add support for WRGG images
  mtd: add fixwrgg command
  ar71xx/base-files: rename 09_fix-trx-header 09_fix-checksum
  ar71xx: add support for D-Link DAP-2695 rev. A1

 package/boot/uboot-envtools/files/ar71xx   |   1 +
 package/system/mtd/src/Makefile|   3 +-
 package/system/mtd/src/mtd.c   |  28 +-
 package/system/mtd/src/mtd.h   |   1 +
 package/system/mtd/src/wrgg.c  | 189 ++
 package/system/mtd/src/wrgg.h  |  20 ++
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   5 +
 .../linux/ar71xx/base-files/etc/board.d/02_network |   5 +
 .../etc/hotplug.d/firmware/11-ath10k-caldata   |   4 +
 .../base-files/etc/uci-defaults/09_fix-checksum|  28 ++
 .../base-files/etc/uci-defaults/09_fix-trx-header  |  19 --
 target/linux/ar71xx/base-files/lib/ar71xx.sh   |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh  |  13 +
 target/linux/ar71xx/config-4.4 |   2 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |   9 +
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../files/arch/mips/ath79/mach-dap-2695-a1.c   | 191 ++
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/generic.mk   |  38 +++
 target/linux/generic/config-3.18   |   1 +
 target/linux/generic/config-4.1|   1 +
 target/linux/generic/config-4.4|   1 +
 .../generic/files/drivers/mtd/mtdsplit/Kconfig |   5 +
 .../generic/files/drivers/mtd/mtdsplit/Makefile|   1 +
 .../files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c | 109 
 tools/firmware-utils/Makefile  |   1 +
 tools/firmware-utils/src/mkwrggimg.c   | 282 +
 27 files changed, 940 insertions(+), 22 deletions(-)
 create mode 100644 package/system/mtd/src/wrgg.c
 create mode 100644 package/system/mtd/src/wrgg.h
 create mode 100644 
target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-checksum
 delete mode 100644 
target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-trx-header
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dap-2695-a1.c
 create mode 100644 
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c
 create mode 100644 tools/firmware-utils/src/mkwrggimg.c

-- 
2.7.3


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


[LEDE-DEV] [PATCH 3/5] mtd: add fixwrgg command

2016-09-11 Thread Stijn Tintel
Based on fixseama.

Signed-off-by: Stijn Tintel 
---
 package/system/mtd/src/Makefile |   3 +-
 package/system/mtd/src/mtd.c|  28 +-
 package/system/mtd/src/mtd.h|   1 +
 package/system/mtd/src/wrgg.c   | 189 
 package/system/mtd/src/wrgg.h   |  20 +
 5 files changed, 238 insertions(+), 3 deletions(-)
 create mode 100644 package/system/mtd/src/wrgg.c
 create mode 100644 package/system/mtd/src/wrgg.h

diff --git a/package/system/mtd/src/Makefile b/package/system/mtd/src/Makefile
index 70c61e5..4e39a89 100644
--- a/package/system/mtd/src/Makefile
+++ b/package/system/mtd/src/Makefile
@@ -4,7 +4,8 @@ LDFLAGS += -lubox
 
 obj = mtd.o jffs2.o crc32.o md5.o
 obj.seama = seama.o md5.o
-obj.ar71xx = trx.o $(obj.seama)
+obj.wrgg = wrgg.o md5.o
+obj.ar71xx = trx.o $(obj.seama) $(obj.wrgg)
 obj.brcm = trx.o
 obj.brcm47xx = $(obj.brcm)
 obj.bcm53xx = $(obj.brcm) $(obj.seama)
diff --git a/package/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c
index 8fbddf5..20048b0 100644
--- a/package/system/mtd/src/mtd.c
+++ b/package/system/mtd/src/mtd.c
@@ -53,6 +53,7 @@
 
 #define TRX_MAGIC  0x48445230  /* "HDR0" */
 #define SEAMA_MAGIC0x5ea3a417
+#define WRGG03_MAGIC   0x20080321
 
 #if !defined(__BYTE_ORDER)
 #error "Unknown byte order"
@@ -61,9 +62,11 @@
 #if __BYTE_ORDER == __BIG_ENDIAN
 #define cpu_to_be32(x) (x)
 #define be32_to_cpu(x) (x)
+#define le32_to_cpu(x) bswap_32(x)
 #elif __BYTE_ORDER == __LITTLE_ENDIAN
 #define cpu_to_be32(x) bswap_32(x)
 #define be32_to_cpu(x) bswap_32(x)
+#define le32_to_cpu(x)  (x)
 #else
 #error "Unsupported endianness"
 #endif
@@ -72,6 +75,7 @@ enum mtd_image_format {
MTD_IMAGE_FORMAT_UNKNOWN,
MTD_IMAGE_FORMAT_TRX,
MTD_IMAGE_FORMAT_SEAMA,
+   MTD_IMAGE_FORMAT_WRGG03,
 };
 
 static char *buf = NULL;
@@ -200,6 +204,8 @@ image_check(int imagefd, const char *mtd)
imageformat = MTD_IMAGE_FORMAT_TRX;
else if (be32_to_cpu(magic) == SEAMA_MAGIC)
imageformat = MTD_IMAGE_FORMAT_SEAMA;
+   else if (le32_to_cpu(magic) == WRGG03_MAGIC)
+   imageformat = MTD_IMAGE_FORMAT_WRGG03;
 
switch (imageformat) {
case MTD_IMAGE_FORMAT_TRX:
@@ -208,6 +214,8 @@ image_check(int imagefd, const char *mtd)
break;
case MTD_IMAGE_FORMAT_SEAMA:
break;
+   case MTD_IMAGE_FORMAT_WRGG03:
+   break;
default:
 #ifdef target_brcm
if (!strcmp(mtd, "firmware"))
@@ -676,6 +684,10 @@ resume:
if (mtd_fixseama)
mtd_fixseama(mtd, 0, 0);
break;
+   case MTD_IMAGE_FORMAT_WRGG03:
+   if (mtd_fixwrgg)
+   mtd_fixwrgg(mtd, 0, 0);
+   break;
default:
break;
}
@@ -721,6 +733,10 @@ static void usage(void)
fprintf(stderr,
"fixseamafix the checksum in a seama header on 
first boot\n");
}
+   if (mtd_fixwrgg) {
+   fprintf(stderr,
+   "fixwrgg fix the checksum in a wrgg header on 
first boot\n");
+   }
fprintf(stderr,
"Following options are available:\n"
"-q  quiet mode (once: no [w] on writing,\n"
@@ -738,9 +754,9 @@ static void usage(void)
fprintf(stderr,
"-o offset   offset of the image header in the 
partition(for fixtrx)\n");
}
-   if (mtd_fixtrx || mtd_fixseama) {
+   if (mtd_fixtrx || mtd_fixseama || mtd_fixwrgg) {
fprintf(stderr,
-   "-c datasize amount of data to be used for checksum 
calculation (for fixtrx / fixseama)\n");
+   "-c datasize amount of data to be used for checksum 
calculation (for fixtrx / fixseama / fixwrgg)\n");
}
fprintf(stderr,
 #ifdef FIS_SUPPORT
@@ -781,6 +797,7 @@ int main (int argc, char **argv)
CMD_JFFS2WRITE,
CMD_FIXTRX,
CMD_FIXSEAMA,
+   CMD_FIXWRGG,
CMD_VERIFY,
CMD_DUMP,
CMD_RESETBC,
@@ -895,6 +912,9 @@ int main (int argc, char **argv)
} else if (((strcmp(argv[0], "fixseama") == 0) && (argc == 2)) && 
mtd_fixseama) {
cmd = CMD_FIXSEAMA;
device = argv[1];
+   } else if (((strcmp(argv[0], "fixwrgg") == 0) && (argc == 2)) && 
mtd_fixwrgg) {
+   cmd = CMD_FIXWRGG;
+   device = argv[1];
} else if ((strcmp(argv[0], "verify") == 0) && (argc == 3)) {
cmd = CMD_VERIFY;
imagefile = argv[1];
@@ -991,6 +1011,10 @@ int main (int argc, char **argv)
if (mtd_fixseama)

Re: [LEDE-DEV] [PATCH 5/5] ar71xx: add support for D-Link DAP-2695 rev. A1

2016-09-11 Thread Yousong Zhou
On 12 September 2016 at 00:12, Stijn Tintel  wrote:
> Signed-off-by: Stijn Tintel 
> ---
>  package/boot/uboot-envtools/files/ar71xx   |   1 +
>  target/linux/ar71xx/base-files/etc/board.d/01_leds |   5 +
>  .../linux/ar71xx/base-files/etc/board.d/02_network |   5 +
>  .../etc/hotplug.d/firmware/11-ath10k-caldata   |   4 +
>  .../base-files/etc/uci-defaults/09_fix-checksum|   9 +
>  target/linux/ar71xx/base-files/lib/ar71xx.sh   |   3 +
>  .../ar71xx/base-files/lib/upgrade/platform.sh  |  13 ++
>  target/linux/ar71xx/config-4.4 |   1 +
>  .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |   9 +
>  target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
>  .../files/arch/mips/ath79/mach-dap-2695-a1.c   | 191 
> +
>  .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
>  target/linux/ar71xx/image/generic.mk   |  38 
>  13 files changed, 281 insertions(+)
>  create mode 100644 
> target/linux/ar71xx/files/arch/mips/ath79/mach-dap-2695-a1.c

We have just got rid of the 09_fix-seama-header by excluding jffs2
marker from the calculation of checksum.  The result image flashes
just fine because it looks like the device will flash the whole
uploaded file instead of just the size in the image header.  If that
is also the case with fixwrgg then we can save a few flash block
erases.

yousong

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


[LEDE-DEV] [PATCH 4/6] ipq806x: Add check-size when append-kernel is used

2016-09-11 Thread Chris Blake
When append-kernel is used and a KERNEL_SIZE is defined, we need to make
sure that our kernel fits within it's partition size.

Signed-off-by: Chris Blake 
---
 target/linux/ipq806x/image/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/ipq806x/image/Makefile 
b/target/linux/ipq806x/image/Makefile
index daf910e..0fa881f 100644
--- a/target/linux/ipq806x/image/Makefile
+++ b/target/linux/ipq806x/image/Makefile
@@ -156,7 +156,7 @@ define Device/EA8500
PROFILES += $$(DEVICE_NAME)
BOARD_NAME := ea8500
IMAGES := factory.bin sysupgrade.tar
-   IMAGE/factory.bin := append-kernel | pad-to {KERNEL_SIZE} | 
append-ubi
+   IMAGE/factory.bin := append-kernel | check-size $$(KERNEL_SIZE) | 
pad-to {KERNEL_SIZE} | append-ubi
IMAGE/sysupgrade.tar := sysupgrade-tar
DEVICE_TITLE := Linksys EA8500
DEVICE_PACKAGES := ath10k-firmware-qca99x0
-- 
2.7.4


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


[LEDE-DEV] [PATCH 3/6] ar71xx: Add check-size when append-kernel is used

2016-09-11 Thread Chris Blake
When append-kernel is used and a KERNEL_SIZE is defined, we need to make
sure that our kernel fits within it's partition size.

Signed-off-by: Chris Blake 
---
 target/linux/ar71xx/image/generic.mk | 4 ++--
 target/linux/ar71xx/image/ubnt.mk| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/linux/ar71xx/image/generic.mk 
b/target/linux/ar71xx/image/generic.mk
index 10717cb..3aeff12 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -410,7 +410,7 @@ define Device/NBG6616
   CMDLINE += mem=128M
   IMAGES := sysupgrade.bin
   KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma | jffs2 
boot/vmlinux.lzma.uImage
-  IMAGE/sysupgrade.bin = append-kernel $$(KERNEL_SIZE) | append-rootfs | 
pad-rootfs | check-size (IMAGE_SIZE)
+  IMAGE/sysupgrade.bin = append-kernel $$(KERNEL_SIZE) | check-size 
$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | check-size (IMAGE_SIZE)
   # We cannot currently build a factory image. It is the sysupgrade image
   # prefixed with a header (which is actually written into the MTD device).
   # The header is 2kiB and is filled with 0xff. The format seems to be:
@@ -443,7 +443,7 @@ define Device/c-55
   KERNEL_SIZE = 2048k
   IMAGE_SIZE = 15872k
   MTDPARTS = 
spi0.0:256k(u-boot)ro,128k(u-boot-env)ro,2048k(kernel),13824k(rootfs),13824k(opt)ro,2624k(failsafe)ro,64k(art)ro,15872k@0x6(firmware)
-  IMAGE/sysupgrade.bin = append-kernel $$(KERNEL_SIZE) | append-rootfs | 
pad-rootfs | check-size (IMAGE_SIZE)
+  IMAGE/sysupgrade.bin = append-kernel $$(KERNEL_SIZE) | check-size 
$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | check-size (IMAGE_SIZE)
 endef
 
 TARGET_DEVICES += c-55
diff --git a/target/linux/ar71xx/image/ubnt.mk 
b/target/linux/ar71xx/image/ubnt.mk
index 99496f7..2d0d464 100644
--- a/target/linux/ar71xx/image/ubnt.mk
+++ b/target/linux/ar71xx/image/ubnt.mk
@@ -261,7 +261,7 @@ define Device/ubnt-uap-pro
   DEVICE_PROFILE := UBNT UAPPRO
   KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma | jffs2 kernel0
   IMAGES := sysupgrade.bin factory.bin
-  IMAGE/sysupgrade.bin = append-kernel $$(KERNEL_SIZE) | append-rootfs | 
pad-rootfs | check-size (IMAGE_SIZE)
+  IMAGE/sysupgrade.bin = append-kernel $$(KERNEL_SIZE) | check-size 
$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | check-size (IMAGE_SIZE)
   IMAGE/factory.bin = $$(IMAGE/sysupgrade.bin) | mkubntimage2
 endef
 
-- 
2.7.4


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


[LEDE-DEV] [PATCH 5/6] kirkwood: Add check-size when append-kernel is used

2016-09-11 Thread Chris Blake
When append-kernel is used and a KERNEL_SIZE is defined, we need to make
sure that our kernel fits within it's partition size.

Signed-off-by: Chris Blake 
---
 target/linux/kirkwood/image/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/linux/kirkwood/image/Makefile 
b/target/linux/kirkwood/image/Makefile
index 33eaa4f..92d32cb 100644
--- a/target/linux/kirkwood/image/Makefile
+++ b/target/linux/kirkwood/image/Makefile
@@ -59,7 +59,7 @@ define Device/linksys-audi
   FILESYSTEMS := squashfs
   PROFILES := Generic AUDI
   IMAGES += factory.bin
-  IMAGE/factory.bin := append-kernel (KERNEL_SIZE) | append-ubi
+  IMAGE/factory.bin := append-kernel (KERNEL_SIZE) | check-size 
$$(KERNEL_SIZE) | append-ubi
 endef
 
 define Device/linksys-viper
@@ -68,7 +68,7 @@ define Device/linksys-viper
   FILESYSTEMS := squashfs
   PROFILES := Generic VIPER
   IMAGES += factory.bin
-  IMAGE/factory.bin := append-kernel (KERNEL_SIZE) | append-ubi
+  IMAGE/factory.bin := append-kernel (KERNEL_SIZE) | check-size 
$$(KERNEL_SIZE) | append-ubi
 endef
 
 define Image/BuildKernel/Template
-- 
2.7.4


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


[LEDE-DEV] [PATCH 1/6] apm821xx: Add default kernel size

2016-09-11 Thread Chris Blake
Adding a default KERNEL_SIZE will ensure that we have an option for
check-size when used on any future targets.

Signed-off-by: Chris Blake 
---
 target/linux/apm821xx/image/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/linux/apm821xx/image/Makefile 
b/target/linux/apm821xx/image/Makefile
index 607df06..7ab46f7 100644
--- a/target/linux/apm821xx/image/Makefile
+++ b/target/linux/apm821xx/image/Makefile
@@ -13,6 +13,7 @@ define Device/Default
   KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
   DEVICE_PROFILE :=
   DEVICE_DTS :=
+  KERNEL_SIZE := 2048k
   KERNEL_ENTRY := 0x
   KERNEL_LOADADDR := 0x
   DEVICE_DTS_DIR := ../dts
-- 
2.7.4


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


[LEDE-DEV] [PATCH 6/6] mvebu: Add check-size when append-kernel is used

2016-09-11 Thread Chris Blake
When append-kernel is used and a KERNEL_SIZE is defined, we need to make
sure that our kernel fits within it's partition size.

Signed-off-by: Chris Blake 
---
 target/linux/mvebu/image/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/mvebu/image/Makefile 
b/target/linux/mvebu/image/Makefile
index 7900fb9..b251834 100644
--- a/target/linux/mvebu/image/Makefile
+++ b/target/linux/mvebu/image/Makefile
@@ -72,7 +72,7 @@ endef
 define Device/UBI-factory
   $(Device/UBI)
   IMAGES += factory.img
-  IMAGE/factory.img := append-kernel (KERNEL_SIZE) | append-ubi | pad-to 
(PAGESIZE)
+  IMAGE/factory.img := append-kernel (KERNEL_SIZE) | check-size 
$$(KERNEL_SIZE) | append-ubi | pad-to (PAGESIZE)
 endef
 
 define Device/NAND-128K
-- 
2.7.4


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


[LEDE-DEV] [PATCH 2/6] apm821xx: Add check-size when append-kernel is used

2016-09-11 Thread Chris Blake
When append-kernel is used and a KERNEL_SIZE is defined, we need to make
sure that our kernel fits within it's partition size.

Signed-off-by: Chris Blake 
---
 target/linux/apm821xx/image/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/linux/apm821xx/image/Makefile 
b/target/linux/apm821xx/image/Makefile
index 7ab46f7..cc145e3 100644
--- a/target/linux/apm821xx/image/Makefile
+++ b/target/linux/apm821xx/image/Makefile
@@ -158,8 +158,8 @@ define Device/WNDR4700
   KERNEL_SIZE := 1920k
   KERNEL := dtb | kernel-bin | lzma | uImage lzma | pad-offset $$(BLOCKSIZE) 
64 | append-fakerootfs
   KERNEL_INITRAMFS := kernel-bin | gzip | dtb | wndr4700-specialImage gzip
-  IMAGE/factory.img := create-uImage-dtb | append-kernel | pad-to 2M | 
append-ubi | \
-  netgear-dni | check-size (IMAGE_SIZE)
+  IMAGE/factory.img := create-uImage-dtb | append-kernel | check-size 
$$(KERNEL_SIZE) | pad-to 2M | \
+  append-ubi | netgear-dni | check-size (IMAGE_SIZE)
   IMAGE/sysupgrade.tar := sysupgrade-tar
   NETGEAR_BOARD_ID := WNDR4700
   NETGEAR_HW_ID := 29763875+128+256
-- 
2.7.4


___
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-11 Thread Mathias Kresin

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

2016-09-11 Thread Mathias Kresin

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