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

Mathias Kresin dev at kresin.me
Sun Oct 16 00:54:11 PDT 2016


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 = <&gpio0 0 1>;
> +			linux,code = <0x211>;
> +		};
> +	};
> +
> +	gpio-leds {
> +		compatible = "gpio-leds";
> +
> +		sms {
> +			label = "dwr-512-b:green:sms";
> +			gpios = <&gpio0 8 1>;
> +		};
> +		status {
> +			label = "dwr-512-b:green:status";
> +			gpios = <&gpio0 9 1>;
> +		};
> +		2g {
> +			label = "dwr-512-b:green:2g";
> +			gpios = <&gpio0 17 1>;
> +		};
> +		3g {
> +			label = "dwr-512-b:green:3g";
> +			gpios = <&gpio0 19 1>;
> +		};
> +		sstrengthr {
> +			label = "dwr-512-b:red:sigstrength";
> +			gpios = <&gpio0 20 1>;
> +		};
> +		sstrengthg {
> +			label = "dwr-512-b:green:sigstrength";
> +			gpios = <&gpio0 21 1>;
> +		};
> +	};
> +};
> +
> +&spi0 {
> +	status = "okay";
> +
> +	mx25l6405d at 0 {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		compatible = "macronix,mx25l6405d", "jedec,spi-nor";
> +		reg = <0>;
> +		spi-max-frequency = <30000000>;
> +		fast-read;
> +
> +		partition at 0 {
> +			label = "bootloader";
> +			reg = <0x0 0x10000>;
> +			read-only;
> +		};
> +
> +		partition at 10000 {
> +			label = "Kernel";
> +			reg = <0x10000 0x140000>;
> +			read-only;
> +		};
> +
> +		partition at 150000 {
> +			label = "rootfs";
> +			reg = <0x150000 0x200000>;
> +			read-only;
> +		};
> +
> +		partition at 350000 {
> +			label = "rootfs_data";
> +			reg = <0x350000 0x3c0000>;
> +		};

Use only one big "firmware" partition instead of a fixed size Kernel, 
rootfs, rootfs_data partition. Write a mtd_splitter which gets the 
rootfs offset from the binboy header to setup the rootfs and rootfs_data 
on boot. Have a look at target/linux/generic/files/drivers/mtd/mtdsplit/ 
how it is done for other image/header types.

Your changes to the kernel config shouldn't be required any longer after 
this change, since the available flash space is used more efficient.

> +
> +		partition at 710010 {
> +			label = "ui";
> +			reg = <0x710000 0xe0000>;
> +		};
> +
> +		config: partition at 7f0000 {
> +			label = "config";
> +			reg = <0x7f0000 0x10000>;
> +		};
> +	};
> +};
> +
> +&pinctrl {
> +	state_default: pinctrl0 {
> +		gpio {
> +			ralink,group = "i2c", "jtag", "uartf";
> +			ralink,function = "gpio";
> +		};
> +	};
> +};
> +
> +&wmac {
> +	ralink,mtd-eeprom = <&config 0xe07a>;
> +};
> diff --git a/target/linux/ramips/image/rt305x.mk
> b/target/linux/ramips/image/rt305x.mk
> index be21ac4..fbbabdb 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
> +
> +
>  define Device/esr-9753
>    DTS := ESR-9753
>    BLOCKSIZE := 64k
> diff --git a/target/linux/ramips/rt305x/config-4.4
> b/target/linux/ramips/rt305x/config-4.4
> index b8f6cda..dcf318f 100644
> --- a/target/linux/ramips/rt305x/config-4.4
> +++ b/target/linux/ramips/rt305x/config-4.4
> @@ -132,9 +132,8 @@ CONFIG_MTD_M25P80=y
>  CONFIG_MTD_PHYSMAP=y
>  CONFIG_MTD_SPI_NOR=y
>  CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
> -CONFIG_MTD_SPLIT_FIRMWARE=y
> -CONFIG_MTD_SPLIT_SEAMA_FW=y
> -CONFIG_MTD_SPLIT_UIMAGE_FW=y
> +# CONFIG_MTD_SPLIT is not set
> +# CONFIG_MTD_SPLIT_SQUASHFS_ROOT is not set
>  CONFIG_NEED_DMA_MAP_STATE=y
>  CONFIG_NEED_PER_CPU_KM=y
>  CONFIG_NET_MEDIATEK_ESW_RT3050=y
> @@ -158,6 +157,7 @@ CONFIG_PHY_RALINK_USB=y
>  CONFIG_PINCTRL=y
>  CONFIG_PINCTRL_RT2880=y
>  # CONFIG_PINCTRL_SINGLE is not set
> +CONFIG_PRINTK_TIME=y
>  CONFIG_RALINK=y
>  # CONFIG_RALINK_ILL_ACC is not set
>  CONFIG_RALINK_WDT=y
>
> Bye.
>




More information about the Lede-dev mailing list