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

ath79: add support for MikroTik RouterBOARD 493AH (rb4xx series) #3138

Closed
wants to merge 1 commit into from

Conversation

flyn-org
Copy link
Contributor

This is a work in progress to extend the work of @ch6574 in PR #3026 to the RB493AH.

Right now I am unable to netboot the image this produces, so I do not get a sysupgrade capable of installing this.

The RB493AH is very similar to the RB493G. The former:

  • Does not have a USB interface
  • Does not have a micro SD interface
  • Has only 128 MB of RAM
  • Has 100/10 Mb/s Ethernet interfaces
  • Has a single switch interface that covers eight ports

There was some initial discussion about this work at the tail end of PR #3026.

};
};

&eth1 {
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 can delete this, and the alias above, as this only has 1 Ethernet switch.

Copy link
Contributor

@ch6574 ch6574 Jun 29, 2020

Choose a reason for hiding this comment

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

Also, I think you can add this after removing &eth1 as gpio7 is available.

keys: keys {                                
    compatible = "gpio-keys";               
                                            
    reset_key: reset {                      
        label = "reset";                    
        linux,code = <KEY_RESTART>;         
        gpios = <&gpio 7 GPIO_ACTIVE_LOW>;  
        debounce-interval = <60>;           
    };                                      
};                                          

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 was able to netboot an ath79 kernel, and this is big progress. The router boots, but neither Ethernet interfaces seem to work. I tried both with my original configuration and after removing the definition of eth1 as @ch6574 suggested. The switch also seems undetected; running swconfig list does not list anything.

I saw this in dmesg when booting my ath79 kernel:

[    6.367446] ag71xx 19000000.eth: invalid MAC address, using random address
[    6.713850] ag71xx 19000000.eth: connected to PHY at mdio.0:00 [uid=02430d80, driver=Gener]
[    6.723463] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: rgmii
[    6.729954] ag71xx 1a000000.eth: invalid MAC address, using random address
[    7.063880] ag71xx 1a000000.eth: Could not connect to PHY device. Deferring probe.
[    7.124519] ag71xx 1a000000.eth: invalid MAC address, using random address
[    7.448389] ag71xx 1a000000.eth: Could not connect to PHY device. Deferring probe.
[    7.456397] ag71xx 1a000000.eth: invalid MAC address, using random address
[    7.780378] ag71xx 1a000000.eth: Could not connect to PHY device. Deferring probe.
[    8.328963] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   15.564619] ag71xx 1a000000.eth: invalid MAC address, using random address
[   15.888489] ag71xx 1a000000.eth: Could not connect to PHY device. Deferring probe.
[   30.680785] br-lan: port 1(eth0) entered blocking state
[   30.686079] br-lan: port 1(eth0) entered disabled state
[   30.691659] device eth0 entered promiscuous mode
[  268.458696] device eth0 left promiscuous mode
[  268.463230] br-lan: port 1(eth0) entered disabled state
[  268.498295] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

To clarify, I think the RB493AH has two Ethernet interfaces but one switch interface. To compare, booting an old ar71xx kernel says:

[    6.930000] eth0: Atheros AG71xx at 0xb9000000, irq 4                        
[    7.240000] eth1: Atheros AG71xx at 0xba000000, irq 5

Copy link
Contributor

Choose a reason for hiding this comment

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

The above dmesg shows eth0 working (it's 19000000.eth), and eth1 not (hence my comment to delete it).

Do you not see eth0 as an interface?

N.B. You might find the VLAN settings need adjusting.

Copy link
Contributor

Choose a reason for hiding this comment

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

As for your eth1, you'll need to set it up as per

ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
.

Notice it's not the same mdio gpio setup the 493g has.

Copy link
Contributor

@ch6574 ch6574 Jul 4, 2020

Choose a reason for hiding this comment

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

I forgot to mention, you might need this for your eth0

&eth0 {
	phy-mode = "mii";
};

and perhaps something as simple as this will work for eth1 (I have no way to test it out, so this is guesswork)

&mdio1 {
	status = "okay";

	phy1: ethernet-phy@1{
		reg = <1>; // possibly 0?
	};
};

&eth1 {
	status = "okay";
	
	phy-mode = "rmii";
	phy-handle = <&phy1>;
};

@@ -31,6 +31,7 @@ platform_do_upgrade() {
local board=$(board_name)

case "$board" in
mikrotik,routerboard-493|\
Copy link
Member

Choose a reason for hiding this comment

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

no "ah" suffix

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if a wildcard is appropriate here, as in mikrotik,routerboard-4* as all these 4xx series boards need the same

Copy link
Contributor Author

@flyn-org flyn-org Jun 29, 2020

Choose a reason for hiding this comment

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

no "ah" suffix

Strangely, I found that sysupgrade rejected a version I built using routerboard-493ah. It seemed to expect routerboard-493, so I changed things to reflect that. I will take another look at this to be sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's because at line 7 of your DTS you have the wrong string.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if a wildcard is appropriate here, as in mikrotik,routerboard-4* as all these 4xx series boards need the same

Please, no wildcards in base-files. It's really terrible if you want to find the settings of a particular device afterwards (you cannot grep reliably anymore).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@f00b4r0, where would I find the right string? (Note that I ended up using "mikrotik,routerboard-493" because sysupgrade rejected "mikrotik,routerboard-493ah."

Copy link
Member

Choose a reason for hiding this comment

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

Well, your old version has the old incorrect compatible "mikrotik,routerboard-493" in the DTS, and that's used for "idenfication" in the upgrade process. So, you would have to update all occurences of that string in your current PR. Then, you would need to force upgrade from your old "incorrect" version, as the new corrected one does not now the old "incorrect" string anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

@flyn-org as I pointed out above DTS compatible must agree with this script case. Fix both at the same time to use « ah » and it’ll work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. My confusion came from the fact that a booted the board using an old firmware before I tried to run sysupgrade for the first time. That firmware must have used a string different than the one I used first, routerboard-493ah.

@adschm adschm added the target/ath79 pull request/issue for ath79 target label Jun 25, 2020
This patch adds support for the MikroTik RouterBOARD RB493AH, ported
from the ar71xx target and following the work on the RB493G.

See https://routerboard.com/RB493AH for details

Specification:
- SoC Qualcomm Atheros AR7161
- RAM: 128 MiB
- Storage: 128MiB NAND
- Ethernet: 9x 100/10 Mbps
- PCIe: 3x Mini slot

Working:
- Board/system detection
- Ethernet
- SPI
- NAND
- LEDs
- Sysupgrade

Enabled (but untested due to lack of hardware):
- PCIe - ath79_pci_irq struct has the slot/pin/IRQ mappings if needed

Installation methods:
- tftp boot initramfs image, scp then flash via "sysupgrade -n"
- nand boot existing OpenWrt, scp then flash via "sysupgrade -n"

Notes:
- initramfs image will not work if uncompressed image size over ~8.5Mb
- The "rb4xx" drivers have been enabled
@flyn-org
Copy link
Contributor Author

flyn-org commented Jul 1, 2020

I just force-pushed some updates:

  • use "ah" in the identifier string.
  • remove the eth1 definition
  • add the keys definition

I still need to figure out how to get eth1 and the switch interface to work. I plan to study the link from @ch6574 tomorrow.

@ynezz ynezz added the work in progress pull request the author is still working on label Jul 8, 2020
keys: keys {
compatible = "gpio-keys";

status = "disabled";
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't make any sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's actually a bad cut and paste I put in an earlier comment suggesting this.

Yes, this line should be deleted, and the physical reset button should then be seen to work.


status = "disabled";

reset_key: reset {
Copy link
Member

Choose a reason for hiding this comment

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

reset_key not needed

compatible = "mikrotik,routerboard-493ah", "qca,ar7161";
model = "MikroTik RouterBOARD 493AH";

keys: keys {
Copy link
Member

Choose a reason for hiding this comment

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

"keys:" not needed

@@ -1,5 +1,16 @@
include ./common-mikrotik.mk

define Device/mikrotik_routerboard-493ah
$(Device/mikrotik)
Copy link
Member

Choose a reason for hiding this comment

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

You can use (recently added) Device/mikrotik_nand for this include instead, and then drop IMAGE/sysupgrade.bin and DEVICE_PACKAGES below.

@adschm
Copy link
Member

adschm commented Aug 12, 2020

Missing Signed-off-by in the commit message BTW.

@adschm
Copy link
Member

adschm commented May 28, 2021

This is obviously abandoned.

@adschm adschm closed this May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/ath79 pull request/issue for ath79 target work in progress pull request the author is still working on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants