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 D-Link DIR-506L support #3191

Closed
wants to merge 1 commit into from

Conversation

rozhuk-im
Copy link
Contributor

Specifications:

  • Ralink RT5350 id:1 rev:3 (360 MHz)
  • 32 MB RAM
  • 8 MB Flash
  • 802.11bgn 1T1R
  • 1x internal, non-detachable antenna
  • 1x 10/100 Mbps Ethernet
  • 1x USB 2.0 (Type-A)
  • 5 leds
  • 2 buttons
  • 3 gpio power events
  • UART header on PCB (57600 8n1)
  • JBOOT bootloader
  • 1700 - 2200 mAh battery (Fujifilm NP-120 / Pentax D-Li7, D-L17, DB-43)

Features:

  • upgrade from stock fw via web gui
  • all leds avaible
  • all buttons work
  • battery/charger gpio events added
  • red led on battery low
  • USB power on by default
  • keep jboot recovery

Installation:
Apply factory image via http web-gui or JBOOT recovery page

How to revert to OEM firmware:

  • push the reset button and turn on the power. Wait until LED start blinking (~10sec.)
  • upload original factory image via JBOOT http (IP: 192.168.123.254)
    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: Rozhuk Ivan rozhuk.im@gmail.com

@xabolcs
Copy link
Contributor

xabolcs commented Jul 9, 2020

Does it work with testing kernel 5.4 too?

@rozhuk-im
Copy link
Contributor Author

@ynezz @CHKDSK88 @rmilecki this it try 2 for #1590

@rozhuk-im
Copy link
Contributor Author

Does it work with testing kernel 5.4 too?

I do checks only with default 4.14*.

Also I found that

CONFIG_KERNEL_SQUASHFS_FRAGMENT_CACHE_SIZE=8
CONFIG_TARGET_SQUASHFS_BLOCK_SIZE=64

(defaults: 2, 1024)
make web UI much more responsive.
This must be set for all 32m Ram + 8m Flash routers.


keys {
compatible = "gpio-keys-polled";
poll-interval = <20>;
Copy link
Member

Choose a reason for hiding this comment

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

Can you try with gpio-keys for compatible and dropping poll-interval?

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 check other rt5350 based devices dts files, they all use compatible = "gpio-keys-polled";.

Copy link
Member

Choose a reason for hiding this comment

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

Newly added keenetic lite b uses it. https://github.com/openwrt/openwrt/blob/master/target/linux/ramips/dts/rt5350_zyxel_keenetic-lite-b.dts#L35
And I'm pretty sure it'll also work on your device.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will make build with this and spi change and test on real h/w.
But I remember that polling required for this chip, do not remember where I read this.

Copy link
Member

Choose a reason for hiding this comment

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

You are using battery status gpios as keys here, and I'm not sure it will fit in this case... Typically keys are for state transition (except for EV_SW).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://openwrt.org/docs/guide-user/hardware/hardware.button - Sliding switches
https://github.com/jefferyto/openwrt-slide-switch
this can be handled by scripts.
TP-Link TL-MR3020 and some others use GPIO input as switch.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, TL-MR3020 has a real hardware slide switch...

Copy link
Member

Choose a reason for hiding this comment

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

To me, using gpio-export here also seems more desirable if it can be done properly.

Copy link
Contributor Author

@rozhuk-im rozhuk-im Jul 12, 2020

Choose a reason for hiding this comment

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

Is any disadvantage for this, except that this is not physical button/switch?
Is there any devices that uses GPIO input from non button/switch in base to use it as example?
For me is clear how to use this buttons, and examples exist in wiki, and usage of generic GPIO input is not.

Copy link
Member

Choose a reason for hiding this comment

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

The disadvantage is that it's a hack. These are no buttons, so they shouldn't be implemented as such.
I won't merge it this way.

ralink,mtd-eeprom = <&config 0xe090>;
ralink,led-polarity = <1>;
mtd-mac-address = <&config 0xe084>;
mtd-mac-address-increment = <(1)>;
Copy link
Member

Choose a reason for hiding this comment

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

Will you get a correct MAC address if you just drop mtd-mac-address here? (so, it's taken from the eeprom automatically)

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 can check, but IMHO this required.
Other devices read MAC from config or do almost same via ramips_setup_macs() in 02_network with variations.
Vendor set same MAC for lan and wifi netif, in ramips_setup_macs() no case for it.

ucidef_set_led_gpio "lo_bat" "Low battery" "${boardname}:red:status" "10" "0"
ucidef_set_led_default "status" "Status" "${boardname}:green:status" "1"
ucidef_set_led_netdev "lan" "LAN" "${boardname}:green:usb" "eth0" "tx rx"
ucidef_set_led_netdev "wifi" "WiFi" "rt2800soc-phy0::radio" "wlan0" "tx rx"
Copy link
Member

Choose a reason for hiding this comment

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

No "link"?

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'm trying to avoid make cristmass tree form device, it already have one green led that always on after boot.
Also this saves few mWatts battery power.

@adschm adschm added the target/ramips pull request/issue for ramips target label Jul 9, 2020
@adschm
Copy link
Member

adschm commented Jul 9, 2020

Though I left some comments here, be aware that I probably won't merge this; since this is a 32 MB RAM device, you might have a hard time finding somebody to merge it.

@rozhuk-im rozhuk-im force-pushed the dir-506l branch 3 times, most recently from 21a1c73 to 0ee0600 Compare July 9, 2020 11:56
@@ -66,6 +66,12 @@ asiarf,awapn2403)
dlink,dcs-930l-b1)
ucidef_set_led_netdev "wifi" "WiFi" "$boardname:blue:wps"
;;
dlink,dir-506l)
ucidef_set_led_gpio "lo_bat" "Low battery" "${boardname}:red:status" "10" "0"
Copy link
Member

Choose a reason for hiding this comment

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

What's that supposed to do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Device have battery, this rule connect internal gpio "button" (event?) to red status led to show that battery have low power.
Also charging and on_battery available, but I do not know how to make green led blink on charging.

Copy link
Member

Choose a reason for hiding this comment

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

boardname can be dropped here (see comment for LEDs in DTS).

@adschm
Copy link
Member

adschm commented Jul 9, 2020

Please don't just close all the comments, no matter whether they are resolved or not. Those are meant to be discussed, if you just close anything it will look like you want to hide the problems of your proposal.

DEVICE_VENDOR := D-Link
DEVICE_MODEL := DIR-506L
DEVICE_PACKAGES := jboot-tools kmod-usb2 kmod-spi-dev \
kmod-usb-serial-option kmod-usb-net-cdc-ether comgt-ncm \
Copy link
Member

Choose a reason for hiding this comment

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

I'm not familiar with it, do you really require comgt-ncm here?
If yes, you may drop kmod-usb-serial-option here as well.

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 we usually don't include any 3G/4G modem related packages unless the modem is actually built-in.
Just checked DIR-510L and DWR-116, and there are no WWAN-related packages included for those devices either, although they are advertised to support 4G (just because the OEM firmware has the drivers included).

Anyways, great to see a new PR for this device (I actually thought the first one was closed due to 32 MiB RAM back then).

Copy link
Member

Choose a reason for hiding this comment

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

There is exactly one device in entire ramips that adds comgt-ncm by default. If the modem is not built-in as stated, we should remove it here as well.

@rozhuk-im rozhuk-im force-pushed the dir-506l branch 3 times, most recently from 809838c to af6857d Compare July 9, 2020 13:48
@rozhuk-im
Copy link
Contributor Author

I got message: "Switch switch0 has an unknown topology - the VLAN settings might not be accurate." and LUCI show switch with 5+cpu ports.
How I can fix it or this is LUCI issue?

@rozhuk-im rozhuk-im force-pushed the dir-506l branch 3 times, most recently from e2ee5de to 3dc00c6 Compare July 11, 2020 03:46
@adschm
Copy link
Member

adschm commented Jul 11, 2020

Please don't just close all the comments, no matter whether they are resolved or not. Those are meant to be discussed, if you just close anything it will look like you want to hide the problems of your proposal.

So, you closed everything as resolved again? Please don't hide critical opinions by just resolving them. If you receive feedback and don't apply it, the comment should stay unresolved until the very end, so everybody can see it and think about it.

This is your final warning.

Edit: I just saw that you actually removed comgt-ncm already, so my comment above only applies to the keys vs. gpio-export discussion, and I might have worded it a bit weaker then, as it's only a single case. Anyway, I had to spend time to go through all closed comment to find this out...

@rozhuk-im
Copy link
Contributor Author

Please don't just close all the comments, no matter whether they are resolved or not. Those are meant to be discussed, if you just close anything it will look like you want to hide the problems of your proposal.

So, you closed everything as resolved again? Please don't hide critical opinions by just resolving them. If you receive feedback and don't apply it, the comment should stay unresolved until the very end, so everybody can see it and think about it.

Sorry, misunderstanding from my side.
Who and then should mark discussion thread as resolved?

@adschm
Copy link
Member

adschm commented Jul 11, 2020

Who and then should mark discussion thread as resolved?

From my personal understanding, either when you have been asked for a change and you did that change, or when both person giving feedback and you agreed that the subject is settled.

@rozhuk-im
Copy link
Contributor Author

From my personal understanding, either when you have been asked for a change and you did that change, or when both person giving feedback and you agreed that the subject is settled.

I was thinking that after answer I should mark as resolved, and if there are more questions then some one add comment and mark it as unresolved. And I was miss you prev message to not mark as resolved.

@adschm
Copy link
Member

adschm commented Jul 12, 2020

I was thinking that after answer I should mark as resolved, and if there are more questions then some one add comment and mark it as unresolved. And I was miss you prev message to not mark as resolved.

Just imagine somebody else coming to this PR who hasn't followed it beforehand. If everything is "resolved", it will look like everything is fine, though there actually are point which are unclear or where reviewer disagreed with you so far. He might just overlook particular problems when going through the code.

In contrast, if the relevant section are still open, scanning through them will give the reviewer a first impression about where he/she has to look specifically or may provide help; apart from reviewing, people might give you specific advice on open problems without having to look through everything.

@s-2
Copy link
Contributor

s-2 commented Jul 13, 2020

While I don't mean to add further complexity to this PR, I was wondering what is the preferred way of setting GPIOs for USB ports.

When adding support for DIR-510L, it was mentioned that gpio-export should be avoided for not being upstream-compatible (c.f. #1366 (comment)), while using gpio-hog would not allow for changing the values (e.g. to reset devices) in the running system.

Thus, for DIR-510L the USB GPIOs were added via board.d/03_gpio_switches. However, as someone pointed out in the forums later, this is now effectively preventing anyone from using extroot with that device... Since that device is perfect for adding more storage, I would like to fix extroot for DIR-510L, but am yet unsure on how to deal with USB ports properly.

In ath79, there are some devices with external hub ports declared (e.g. ar9344_teltonika_rut9xx.dtsi). Could someone elaborate on whether this structure could also be used in combination with reset-gpios, regulator-fixed etc.? It really seems that USB power is currently the most frequent use case for gpio-export.

@rozhuk-im
Copy link
Contributor Author

I have DIR-510L and use it with patched dts file, that have gpio_export section with reset and both usb ports power control.
rozhuk-im@7e8e764

How to find in LUCI web UI things from board.d/03_gpio_switches?

@adschm
Copy link
Member

adschm commented Aug 2, 2020

Does it work with testing kernel 5.4 too?

This subtarget needs to move to 5.4 soon, or it will be removed anyway.

So, this should be checked with 5.4. Testing support is already enabled, just enable testing kernel in "Global build settings".

@@ -0,0 +1,159 @@
// SPDX-License-Identifier: BSD-2-Clause
/dts-v1/;
Copy link
Member

Choose a reason for hiding this comment

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

dts-v1 can be dropped, it's in dtsi now.

compatible = "gpio-leds";

usb {
label = "dir-506l:green:usb";
Copy link
Member

Choose a reason for hiding this comment

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

Model (dir-506l:) can be dropped from LED label now, so you can just keep "green:usb" etc.

Specifications:
 - Ralink RT5350 id:1 rev:3 (360 MHz)
 - 32 MB RAM
 - 8 MB Flash
 - 802.11bgn 1T1R
 - 1x internal, non-detachable antenna
 - 1x 10/100 Mbps Ethernet
 - 1x USB 2.0 (Type-A)
 - 5 leds
 - 2 buttons
 - 3 gpio power events
 - UART header on PCB (57600 8n1)
 - JBOOT bootloader
 - 1700 - 2200 mAh battery (Fujifilm NP-120 / Pentax D-Li7, D-L17, DB-43)

Features:
 - upgrade from stock fw via web gui
 - all leds avaible
 - all buttons work
 - battery/charger gpio events added
 - red led on battery low
 - USB power on by default
 - keep jboot recovery

Installation:
Apply factory image via http web-gui or JBOOT recovery page

How to revert to OEM firmware:
 - push the reset button and turn on the power. Wait until LED start blinking (~10sec.)
 - upload original factory image via JBOOT http (IP: 192.168.123.254)
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: Rozhuk Ivan <rozhuk.im@gmail.com>
@adschm
Copy link
Member

adschm commented Feb 5, 2021

@rozhuk-im Ping. Please address the various open issues. Time is not on your side if you want to add a 32 MiB RAM device...

@adschm adschm added the stale pull request without feedback by the author for a long time label Feb 5, 2021
@adschm
Copy link
Member

adschm commented Feb 16, 2021

Since 21.02 has been branched and there is no response here, I'm closing this now...

@adschm adschm closed this Feb 16, 2021
@rozhuk-im
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs changes stale pull request without feedback by the author for a long time target/ramips pull request/issue for ramips target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants