Re: [LEDE-DEV] Adding support for dlink dwr-512

2016-10-16 Thread Giuseppe Lippolis
Mathias,
Thanks for the tips.
I'm going to work on it.

Bye.

> -Ursprüngliche Nachricht-
> Von: Mathias Kresin [mailto:d...@kresin.me]
> Gesendet: Sonntag, 16. Oktober 2016 09:54
> An: Giuseppe Lippolis <giu.lippo...@gmail.com>; lede-
> d...@lists.infradead.org
> Betreff: Re: [LEDE-DEV] Adding support for dlink dwr-512
> 
> Hi Giuseppe,
> 
> find a few remarks inline.
> 
> 16.10.2016 00:03, Giuseppe Lippolis:
> > Hi all,
> > I'm proceeding to finalize the support:
> > Now the wifi is enabled, the LEDs and the buttons are supported.
> >
> > To complete the device support I need to:
> > 1. enable the 3G modem
> > 2. crack the header file to generate the factory image
> 
> Run the strings command on the binboy binary. The binary includes some
> text which looks to me like the description of different headers.
> 
> It might be possible that there is already a tool for writing the binboy
header
> in tools/firmware-utils.
> 
> >
> > Will take some time.
> >
> > In the meantime, here the patch:
> >
> > diff --git a/target/linux/ramips/base-files/etc/board.d/02_network
> > b/target/linux/ramips/base-files/etc/board.d/02_network
> > index c8b57ca..719078c 100755
> > --- a/target/linux/ramips/base-files/etc/board.d/02_network
> > +++ b/target/linux/ramips/base-files/etc/board.d/02_network
> > @@ -71,6 +71,7 @@ ramips_setup_interfaces()
> > dir-320-b1|\
> > dir-610-a1|\
> > dir-615-h1|\
> > +   dwr-512-b|\
> > firewrt|\
> > hlk-rm04|\
> > mac1200rv2|\
> > diff --git a/target/linux/ramips/base-files/lib/ramips.sh
> > b/target/linux/ramips/base-files/lib/ramips.sh
> > index bb379f7..a0f041e 100755
> > --- a/target/linux/ramips/base-files/lib/ramips.sh
> > +++ b/target/linux/ramips/base-files/lib/ramips.sh
> > @@ -154,6 +154,9 @@ ramips_board_detect() {
> > *"DIR-860L B1")
> > name="dir-860l-b1"
> > ;;
> > +   *"DWR-512 B")
> > +   name="dwr-512-b"
> > +   ;;
> > *"Dovado Tiny AC")
> > name="tiny-ac"
> > ;;
> > diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh
> > b/target/linux/ramips/base-files/lib/upgrade/platform.sh
> > index 0ef2308..36ea469 100755
> > --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
> > +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
> > @@ -50,6 +50,7 @@ platform_check_image() {
> > dir-620-a1|\
> > dir-620-d1|\
> > dir-810l|\
> > +   dwr-512-b|\
> > duzun-dm06|\
> > e1700|\
> > esr-9753|\
> > diff --git a/target/linux/ramips/dts/DWR-512-B.dts
> > b/target/linux/ramips/dts/DWR-512-B.dts
> > index e69de29..2a69ce7 100644
> > --- a/target/linux/ramips/dts/DWR-512-B.dts
> > +++ b/target/linux/ramips/dts/DWR-512-B.dts
> > @@ -0,0 +1,109 @@
> > +/dts-v1/;
> > +
> > +/include/ "rt5350.dtsi"
> > +
> > +/ {
> > +   compatible = "ralink,rt5350-soc";
> > +   model = "D-Link DWR-512 B";
> > +
> > +   gpio-keys-polled {
> > +   compatible = "gpio-keys-polled";
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +   poll-interval = <20>;
> > +
> > +   wps {
> > +   label = "wps";
> > +   gpios = < 0 1>;
> > +   linux,code = <0x211>;
> > +   };
> > +   };
> > +
> > +   gpio-leds {
> > +   compatible = "gpio-leds";
> > +
> > +   sms {
> > +   label = "dwr-512-b:green:sms";
> > +   gpios = < 8 1>;
> > +   };
> > +   status {
> > +   label = "dwr-512-b:green:status";
> > +   gpios = < 9 1>;
> > +   };
> > +   2g {
> > +   label = "dwr-512-b:green:2g";
> > +   gpios = < 17 1>;
> > +   };
> > +   3g {
> > +   label = "dwr-512-b:green:3g";
> > +   gpios = < 19 1>;
> > +   };
> > +   sstrengthr {
> > +   label = "dwr-512-b:red:sigstrength";
> > +   gpios = < 20 1>;
> > +   };
> > +

Re: [LEDE-DEV] Adding support for dlink dwr-512

2016-10-05 Thread John Crispin
Hi,

congrats, please make sure to add a proper SoB line when you submit
this. also the changes to the kernel config look out of place, please
remove them when submitting the patch

John

On 04/10/2016 22:27, Giuseppe Lippolis wrote:
> Dear All,
> Today I reach an important milestone in " Adding support for dlink dwr-512":
> 
> BusyBox v1.25.0 () built-in shell (ash)
> 
>  _
> //\  ____ ___  ___
>/  LE/  \| |  | __|   \| __|
>   /DE  /\   | |__| _|| |) | _|
>  //  LE  \  ||___|___/|___|
> lede-project.org
>  \\   DE /
>   \LE  \/
> ---
>\  DE\  /Reboot (HEAD, r1727)
> \\/
> ---
> 
> root@lede:/#  
> 
> Here is the complete bootlog:
> 
> Starting kernel @8000...
> [0.00] Linux version 4.4.23 (lippo@nice) (gcc version 5.4.0 (LEDE
> GCC 5.4.0 r1727) ) #0 Fri Sep 30 18:08:21 2016
> [0.00] SoC Type: Ralink RT5350 id:1 rev:3
> [0.00] bootconsole [early0] enabled
> [0.00] CPU0 revision is: 0001964c (MIPS 24KEc)
> [0.00] MIPS: machine is D-Link DWR-512
> [0.00] Determined physical RAM map:
> [0.00]  memory: 0200 @  (usable)
> [0.00] Initrd not found or empty - disabling initrd
> [0.00] Zone ranges:
> [0.00]   Normal   [mem 0x-0x01ff]
> [0.00] Movable zone start for each node
> [0.00] Early memory node ranges
> [0.00]   node   0: [mem 0x-0x01ff]
> [0.00] Initmem setup node 0 [mem
> 0x-0x01ff]
> [0.00] Primary instruction cache 32kB, VIPT, 4-way, linesize 32
> bytes.
> [0.00] Primary data cache 16kB, 4-way, VIPT, no aliases, linesize 32
> bytes
> [0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total
> pages: 8128
> [0.00] Kernel command line: console=ttyS0,57600
> rootfstype=squashfs,jffs2
> [0.00] PID hash table entries: 128 (order: -3, 512 bytes)
> [0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
> [0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
> [0.00] Writing ErrCtl register=8d10
> [0.00] Readback ErrCtl register=8d10
> [0.00] Memory: 28496K/32768K available (2773K kernel code, 127K
> rwdata, 648K rodata, 156K init, 191K bss, 4272K reserved, 0K cma-reserved)
> [0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
> [0.00] NR_IRQS:256
> [0.00] CPU Clock: 360MHz
> [0.00] clocksource: systick: mask: 0x max_cycles: 0x,
> max_idle_ns: 583261500 ns
> [0.00] systick: running - mult: 214748, shift: 32
> [0.00] clocksource: MIPS: mask: 0x max_cycles: 0x,
> max_idle_ns: 10618113593 ns
> [0.16] sched_clock: 32 bits at 180MHz, resolution 5ns, wraps every
> 11930464253ns
> [0.015668] Calibrating delay loop... 239.61 BogoMIPS (lpj=1198080)
> [0.090893] pid_max: default: 32768 minimum: 301
> [0.100347] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
> [0.113437] Mountpoint-cache hash table entries: 1024 (order: 0, 4096
> bytes)
> [0.136931] clocksource: jiffies: mask: 0x max_cycles:
> 0x, max_idle_ns: 1911260446275 ns
> [0.156782] pinctrl core: initialized pinctrl subsystem
> [0.168534] NET: Registered protocol family 16
> [0.217394] rt2880_gpio 1600.gpio: registering 22 gpios
> [0.228519] rt2880_gpio 1600.gpio: registering 22 irq handlers
> [0.243616] clocksource: Switched to clocksource MIPS
> [0.256384] NET: Registered protocol family 2
> [0.266738] TCP established hash table entries: 1024 (order: 0, 4096
> bytes)
> [0.280625] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
> [0.293209] TCP: Hash tables configured (established 1024 bind 1024)
> [0.306075] UDP hash table entries: 256 (order: 0, 4096 bytes)
> [0.317698] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
> [0.330709] NET: Registered protocol family 1
> [0.349053] rt-timer 1100.timer: maximum frequency is 3662Hz
> [0.362894] futex hash table entries: 256 (order: -1, 3072 bytes)
> [0.375205] Crashlog allocated RAM at address 0x1f0
> [0.419466] squashfs: version 4.0 (2009/01/31) Phillip Lougher
> [0.43] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME)
> (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
> [0.457061] io scheduler noop registered
> [0.464867] io scheduler deadline registered (default)
> [0.475467] ralink-usb-phy usbphy: invalid resource
> [0.486505] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
> [0.501454] console [ttyS0] disabled
> [0.508624] 1c00.uartlite: ttyS0 at MMIO 0x1c00 (irq = 20,
> 

Re: [LEDE-DEV] Adding support for dlink dwr-512

2016-10-03 Thread Giuseppe Lippolis
Hi Mathias,

> > use the "KERNEL := kernel-bin | patch-dtb | lzma" config  instead?
> 
> Well, that is exactly the KERNEL line I've send in my last mail. Not 
> sure
if I get
> what you are asking here. But such a kernel works for most of the 
> rt305x devices.

In your previous email your advice was: 
   KERNEL := kernel-bin | append-dtb | lzma

The difference is patch-dtb against append-dtb.

> > 1) From my understanding the append-dtb seems to append the dtb 
> > after the kernel. But in this way in my opinion the kernel cannot 
> > point to the dbt (remember that currently It seems that the oem 
> > bootloader cannot pass kernel parameter).
> > In the
> > build_dir/target-mipsel_24kc_musl-1.1.15/linux-ramips_rt305x/linux-4
> > .4 .23/ar ch/mips/ralink/of.c the __dt_setup_arch(&__image_dtb); 
> > point to the __image_dtb area embedded in the kernel. This area 
> > should be populated after the compilation process by the patch-dtb 
> > tool. Shall I use the "KERNEL := kernel-bin | patch-dtb | lzma" 
> > config  instead?

Can you please confirm my understanding



> > what shall I do to propagate the change effect in the 
> > target/linux/ramips/image/rt305x.mk
> b/target/linux/ramips/image/rt305x.mk?
> 
> The contents of the lede-ramips-rt305x-dwr-512-b* files should be 
> different. Please ignore the remaining files in the directory. These 
> are generic files which are generated due to the fact that some rt305x 
> boards are still using the old build code. These files are _not_ 
> specific for your board.
> 
> As written in my last mail. You will find the kernel generated for 
> your board in
build_dir/target-mipsel_24kc_musl-1.1.15/linux-ramips_rt305x/.
> 
> But at this point I would try to tftpboot the initramfs-kernel.bin 
> from uboot to check if everything works. Most bootloader do not 
> enforce a vendor specific header for images loaded via tftp.
> 
> > Currently the only way I found to apply a change in the target/linux/...
is:
> > Make distclean
> > Make menuconfig
> > Make

With the current change in the target/linux/ramips/image/rt305x.mk :
+  KERNEL := kernel-bin | patch-dtb | lzma  IMAGES := factory.bin  
+ IMAGE/factory.bin := \
+   append-kernel

I'm able (after make distclean, make menuconfig, make) to find in
bin/targets/ramips/rt305x/ the image
lede-ramips-rt305x-dwr-512-b-squashfs-factory.bin

This seems to be exactly what I'm looking for (vmlinux lzma compressed with
device tree embedded).

> make target/linux/{clean,install} should work.
This cmd works as expected.

Thanks,
I'm going to test the new fw.



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


Re: [LEDE-DEV] Adding support for dlink dwr-512

2016-10-02 Thread Giuseppe Lippolis
Dear Mathias,
thanks for your info.

Just a couple of question before to proceed.

1) From my understanding the append-dtb seems to append the dtb after the
kernel. But in this way in my opinion the kernel cannot point to the dbt
(remember that currently It seems that the oem bootloader cannot pass kernel
parameter). 
In the
build_dir/target-mipsel_24kc_musl-1.1.15/linux-ramips_rt305x/linux-4.4.23/ar
ch/mips/ralink/of.c the __dt_setup_arch(&__image_dtb); point to the
__image_dtb area embedded in the kernel. This area should be populated after
the compilation process by the patch-dtb tool. Shall I use the "KERNEL :=
kernel-bin | patch-dtb | lzma" config  instead?

2) Currently I make this patch

diff --git a/target/linux/ramips/image/rt305x.mk
b/target/linux/ramips/image/rt305x.mk
index be21ac4..f768785 100644
--- a/target/linux/ramips/image/rt305x.mk
+++ b/target/linux/ramips/image/rt305x.mk
@@ -168,6 +168,17 @@ endef
 TARGET_DEVICES += dir-620-d1


+define Device/dwr-512-b
+  DTS := DWR-512-B
+  KERNEL := kernel-bin | patch-dtb | lzma
+  IMAGES := factory.bin
+  IMAGE/factory.bin := \
+   append-kernel
+  DEVICE_TITLE := D-Link DWR-512 B
+endef
+TARGET_DEVICES += dwr-512-b

But If run the make script I get the same files I had before in the
bin/targets/ramips/rt305x/
lede-ramips-rt305x-dwr-512-b-initramfs-kernel.bin  
lede-ramips-rt305x-dwr-512-b-squashfs-factory.bin
lede-ramips-rt305x-dwr-512-b-squashfs-sysupgrade.bin  
lede-ramips-rt305x-root.squashfs   
lede-ramips-rt305x-uImage-initramfs.bin
lede-ramips-rt305x-uImage.bin 
lede-ramips-rt305x-vmlinux-initramfs.bin   
lede-ramips-rt305x-vmlinux-initramfs.elf
lede-ramips-rt305x-vmlinux.bin
lede-ramips-rt305x-vmlinux.elf


what shall I do to propagate the change effect in the
target/linux/ramips/image/rt305x.mk b/target/linux/ramips/image/rt305x.mk?
Currently the only way I found to apply a change in the target/linux/... is:
Make distclean
Make menuconfig
Make

But this is annoying (every time recompile all). Do you have some advice
about?

Thanks.



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


Re: [LEDE-DEV] Adding support for dlink dwr-512

2016-10-02 Thread Mathias Kresin

02.10.2016 21:10, Giuseppe Lippolis:

Hi all,
I'm trying to port lede to the dwr-512.
I'm using the latest trunk downloaded with
git clone https://git.lede-project.org/source.git

The dwr-512 oem bootloader accept a firmware image that shall be processed
with a dlink tool called binboy and need the binary_kernel_image (lzma
compressed) + the sqashfs_root.
In addition, using the oem bootloader, I'm unable to pass kernel param and
device tree.

More detail here: https://wiki.openwrt.org/inbox/d-link/d-link_dwr-512_b in
the section FW installation.

I start some discussion in the bug report but I realize it is better to use
the mailing list.
According with the latest advice of Mathias Kresin I should use the default
strategy to generate an Image, therefore I add the following path:

diff --git a/target/linux/ramips/image/rt305x.mk
b/target/linux/ramips/image/rt305x.mk
index be21ac4..e830675 100644
--- a/target/linux/ramips/image/rt305x.mk
+++ b/target/linux/ramips/image/rt305x.mk
@@ -168,6 +168,13 @@ endef
 TARGET_DEVICES += dir-620-d1


+define Device/dwr-512-b
+  DTS := DWR-512-B
+  DEVICE_TITLE := D-Link DWR-512 B
+endef
+TARGET_DEVICES += dwr-512-b
+
+
 define Device/esr-9753
   DTS := ESR-9753
   BLOCKSIZE := 64k


You need to add support for the binboy format to tools/firmware-utils/. 
Might be possible that there is already a util to create the required 
header format.


Next step is to add a build recipe for the binboy header. Have a look at 
[0] for an example.


Your build code _might_ look like the following in the end:

define Device/dwr-512-b
  DTS := DWR-512-B
  KERNEL := kernel-bin | append-dtb | lzma
  IMAGES := factory.bin
  IMAGE/factory.bin := \
append-kernel | binboy-header | append-rootfs | binboy-header
  DEVICE_TITLE := D-Link DWR-512 B
endef
TARGET_DEVICES += dwr-512-b

The basic build recipes like append-dtb are defined in 
include/image-commands.mk. Have a look at target/linux/*/image/Makefile 
to see how it is done for other boards.


The build code is made to build complete images and hide the build 
artefacts from the user. You can find the kernel created by the KERNEL 
line in build_dir/target-mipsel_24kc_musl-1.1.15/linux-ramips_rt305x/.


To see what really happens during the image build, run 'make 
target/linux/install V=s' after the build is finished.


Mathias

[0] 
https://git.lede-project.org/?p=source.git;a=blob;f=target/linux/ramips/image/Makefile;h=d165ec55126e0824cc4b7b11e09a6dc3e425a496;hb=HEAD#l86


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