Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ramips: add support for DLINK DWR-921-C1 #793

Closed
wants to merge 1 commit into from

Conversation

fid0did0
Copy link
Contributor

@fid0did0 fid0did0 commented Mar 10, 2018

The DWR-921-C1 Wireless Routers with LTE embedded modem is based on the MT7620N SoC.

Specification:

  • MediaTek MT7620N (580 Mhz)
  • 64 MB of RAM
  • 16 MB of FLASH
  • 802.11bgn radio
  • 5x 10/100 Mbps Ethernet (1 WAN and 4 LAN)
  • 2x external, detachable (LTE) antennas
  • UART header on PCB (57600 8n1)
  • 6x LED (GPIO-controlled)
  • 1xbi-color Signal Strength LED (GPIO-controlled)
  • 2x button
  • JBOOT bootloader

Known issues:

  • LTE Modem not yet working (subject for a new PR)
  • No status led has been assigned

Installation:
Apply factory image via d-link http web-gui.

How to revert to OEM firmware:
1.) Push the reset button and turn on the power. Wait until LED start blinking (~10sec.)
2.) Upload original factory image via JBOOT http (IP: 192.168.123.254)
3.) If http doesn't work, it can be done with curl command:
curl -F FN=@XXXXX.bin http://192.168.123.254/upg
where XXXXX.bin is name of firmware file.

Signed-off-by: Giuseppe Lippolis giu.lippolis@gmail.com

@fid0did0
Copy link
Contributor Author

This PR requires the following commit to build properly:

0b767b8
280e7cb
4070f7d

@fid0did0
Copy link
Contributor Author

The dwr-921 doesn't have a led suitable for the status led function.
The power led seems not be driven by gpio but hardwired do vcc.

Is there an alternative solution to share some led function?

@fid0did0
Copy link
Contributor Author

Currently I plan to use the mt7620 capability to drive the wlan led.

in /sys/class/leds/ I can see the following folder:
rt2800soc-phy0::assoc rt2800soc-phy0::quality rt2800soc-phy0::radio

but if I try to drive them (writing in brightness) nothing happens.

If I configure the wlan led as gpio driven in the device-tree, it works as expected.

@dedeckeh dedeckeh added the target/ramips pull request/issue for ramips target label Mar 12, 2018
@fid0did0
Copy link
Contributor Author

What about if I configure a potential shared led (like the sms as an example) acting as status led?

@fid0did0 fid0did0 force-pushed the dwr-921-c1_board_porting branch 3 times, most recently from d0cdcd8 to c310138 Compare March 18, 2018 15:01
Copy link
Contributor

@CHKDSK88 CHKDSK88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I marked some points. You could consider to make changes.

@@ -41,6 +41,12 @@ board=$(board_name)
case "$FIRMWARE" in
"soc_wmac.eeprom")
case $board in
dwr-921-c1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be like bellow?
dlink,dwr-116-a1|\
dlink,dwr-921-c1)

Copy link
Contributor Author

@fid0did0 fid0did0 Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set the board name "dwr-921-c1" in the target/linux/ramips/base-files/lib/ramips.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set the "dwr-921-c1" name in target/linux/ramips/base-files/lib/ramips.sh

@@ -169,6 +169,9 @@ ramips_board_detect() {
*"DWR-512 B")
name="dwr-512-b"
;;
*"DWR-921 C1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do You test generic board detection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to be coherent with the format used in the file.

Copy link
Member

@mkresin mkresin Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fid0did0 You should really consider @CHKDSK88 input (which is much appreciated by the way - as it safes my time), as I've done a full review of his PR recently.

Drop this line to use the generic board detection. Which means, use dlink,dwr-921-c1 as userspace boardname. Instead of sticking to an outdated way of doing something, you should check the commit history to see how it was done for all recent ramips additions.

@@ -158,6 +158,7 @@ dir-615-h1)
set_wifi_led "rt2800pci-phy0::radio"
;;
dir-620-d1|\
dwr-921-c1|\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dlink,dwr-921-c1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to be coherent with the format used in the file.

};

&ethernet {
mtd-mac-address = <&config 0xe2ac>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, You should use jboot-tools to set IP. It's possible, that some another C1 have different offset. Like in DWR-116.

};
};

&wmac {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use 10-rt2x00-eeprom. This should be droped.

@fid0did0 fid0did0 force-pushed the dwr-921-c1_board_porting branch 3 times, most recently from d294293 to 432afb0 Compare March 19, 2018 17:45
@fid0did0
Copy link
Contributor Author

fixed the comments and the conflict.

@mkresin
Do you have some advice about the leds (wifi, status)?

Bye.

@mkresin
Copy link
Member

mkresin commented Mar 20, 2018

Do you have some advice about the leds (wifi, status)?

The wifi LED setup look good to me. Do I miss something?

We might can misuse the "Signal Strength" LED as status LED and set it to off after boot in 01_leds:

dlink,dwr-921-c1)
 	set_wifi_led "$boardname:green:wifi"
	ucidef_set_led_default "sigstrength" "Signal Strength" "$boardname:green:sigstrength" "0"
 	;;

It might make sense to to use ucidef_set_led_switch to make the lan led working.

@fid0did0
Copy link
Contributor Author

thanks for the advice mkresin.
I will fix the led accordingly.

About the wifi led I would like to let it drive by the HW.
I try to remove the wifi led definition and configure in the dts the wled as below:

     wled_pins: wled {
                wled {
                        ralink,group = "wled";
                        ralink,function = "wled";
                };
        };

but when I set the value in
/sys/class/leds/rt2800soc-phy0::assoc, rt2800soc-phy0::quality, rt2800soc-phy0::radio
nothing happens.

I'm making something wrong?

@@ -271,7 +271,8 @@ platform_check_image() {
}
return 0
;;
dlink,dwr-116-a1)
dlink,dwr-116-a1|\
dwr-921-c1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dlink,dwr-921-c1?

@mkresin
Copy link
Member

mkresin commented Mar 21, 2018

About the wifi led I would like to let it drive by the HW.

To my knowledge it doesn't work, hence the LED is set for all boards to GPIO. I never had a look at the code why it doesn't work or how it is supposed to work.

@CHKDSK88
Copy link
Contributor

@fid0did0

You forgot about MAC setup in 02network.

#include <dt-bindings/input/input.h>

/ {
compatible = "d-link,dwr-921-c1", "ralink,mt7620n-soc";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"d-link,dwr-921-c1" -> "dlink,dwr-921-c1"

Did You test it @fid0did0 ?

gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
};
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gpio_export {
compatible = "gpio-export";
#size-cells = <0>;

usb_power {
gpio-export,name = "usb";
gpio-export,output = <1>;
gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>;
};
};

I have C3 version and pcb is the same. Please try add this and check if modem is detected.

Copy link
Contributor Author

@fid0did0 fid0did0 Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LTE support is argument for a new PR.
Please see PR #812.

DTS := DWR-921-C1
IMAGE_SIZE := $(ralink_default_fw_size_16M)
DEVICE_TITLE := D-Link DWR-921 C1
DLINK_ROM_ID := DLK6E2414001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed:
DEVICE_PACKAGES := jboot-tools

@fid0did0
Copy link
Contributor Author

fid0did0 commented Mar 22, 2018

All the open point are now fixed.
I tested the image, now the mac are configured as below:
lan mac= wifi mac
wan mac=lan mac +1

@@ -162,6 +162,11 @@ dlink,dwr-116-a1|\
mzk-ex300np)
set_wifi_led "$boardname:green:wifi"
;;
dlink,dwr-921-c1)
set_wifi_led "$boardname:green:wifi"
ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" "br-lan"
Copy link
Member

@mkresin mkresin Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You really make it harder than it has to be...

Please don't do it this way. You most likely will not find any example in the tree using a not physical interface with the netdev trigger.

Please use ucidef_set_led_switch as suggested. The hex value used for the trigger is a binary mask selecting the switch ports which should trigger the LED. It has to be read from right (port 0) to left (port 4). For your board the following should do the trick:

ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x0f"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

dlink,dwr-921-c1)
set_wifi_led "$boardname:green:wifi"
ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" "br-lan"
ucidef_set_led_default "sigstrength" "Signal Strength" "$boardname:red:sigstrength" "0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I've ignored it, but as you have to touch the file anyway: Can we use the green sigstrength led for diag? red leds are usually used for warning/error. For sure a matter of taste and nothing really critical.

Copy link
Contributor Author

@fid0did0 fid0did0 Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer the red to keep the attention high during the sysupgrade operation.
But I changed in green.

Bye.

The DWR-921-C1 Wireless Routers with LTE embedded modem is based on the MT7620N SoC.

Specification:

* MediaTek MT7620N (580 Mhz)
* 64 MB of RAM
* 16 MB of FLASH
* 802.11bgn radio
* 5x 10/100 Mbps Ethernet (1 WAN and 4 LAN)
* 2x external, detachable (LTE) antennas
* UART header on PCB (57600 8n1)
* 6x LED (GPIO-controlled)
* 1xbi-color Signal Strength LED (GPIO-controlled)
* 2x button
* JBOOT bootloader

Known issues:
* LTE Modem not yet working (subject for a new PR)
* The status led has been assigned to the dwr-921-c1:green:sigstrength (lte signal
strength led). At the end of the boot it is switched off and is available for lte
operation. Work correctly also during sysupgrade operation.

Installation:
Apply factory image via d-link http web-gui.

How to revert to OEM firmware:
1.) Push the reset button and turn on the power. Wait until LED start blinking (~10sec.)
2.) Upload original factory image via JBOOT http (IP: 192.168.123.254)
3.) If http doesn't work, it can be done with curl command:
    curl -F FN=@XXXXX.bin http://192.168.123.254/upg
    where XXXXX.bin is name of firmware file.

Signed-off-by: Giuseppe Lippolis <giu.lippolis@gmail.com>
@mkresin
Copy link
Member

mkresin commented Mar 23, 2018

merged into my staging tree.

@mkresin mkresin closed this Mar 23, 2018
@fid0did0 fid0did0 deleted the dwr-921-c1_board_porting branch April 20, 2018 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/ramips pull request/issue for ramips target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants