Ar71xx-mikrotik: Mikrotik wAP ac support

I just bought an "Mikrotik wAP ac"[0] to figure out how well the hardware is. The data sheet and the price look promising. I would love to have OpenWrt/LEDE support for this access point but have not yet ported any device to OpenWrt/LEDE. So I might need some help. Also I heard that sysupgrade is broken for ar71xx-mikrotik.

My final plan is to use this device in my local Freifunk community for places where we need a outdoor access point.

I'll provide pictures and more documentation when I have the device in my hands (planned for in 16h).

[0] https://mikrotik.com/product/RBwAPG-5HacT2HnD

Instead of a bunch of hours it took me a week…

front:

back:

Sadly the serial console cable (a friend soldered for me) does not seem to work. At least I do not get any output.

wikidevi: https://wikidevi.com/wiki/MikroTik_RouterBOARD_wAP_ac_(RBwAPG-5HacT2HnD)

Hi,

I'm starting to work on this board, I'll write the update on this post.

    + /*
    +  * RBwAPG-5HacT2HnD board:
    +  *  -Power     : PoE AT - DC.in (12 - 57)V
    +  *  -SoC        : QCA9556
    +  *  -Net:         : AR8033
    +  *  -Phy0       : Built-in SoC
    +  *  -Phy1       : QCA9880
    +  *  -RAM       : 64 MiB
    +  *  -FLASH   : 16 MiB
    +  *  -IC           : ZT2046Q provide a temperature and voltage sensor.
    +  *                                                                                                                                        
    +  *  -HWID     :  wapg-sc
    +  */

From mikrotik's gpl:

  1. ./arch/mips/rb/prom.c
▸       } else if (strncmp(board_type, "wapg-sc", sizeof(board_type)) == 0) {                                                               
▸       ▸       mips_machgroup = MACH_GROUP_MT_RB700;
▸       ▸       mips_machtype = MACH_MT_wAPG;
  1. ./arch/mips/rb/platform.c
▸       ▸       case MACH_MT_wAPG:                                                                                                          
▸       ▸       ▸       return platform_add_devices(
▸       ▸       ▸           wapg_devices,  ARRAY_SIZE(wapg_devices));
static struct platform_device *wapg_devices[] = {                                                                                           
▸       &scorpionL_spi_device,
▸       &ar9340_gpio_device,
▸       &g52c_mdio_device,
▸       &g52c_eth_device,
▸       &wapg_led_device,
▸       &ar9330_wlan_device,
};
  1. spi
static struct spi_board_info slow_large_spi_nor = {                                                                                         
▸       .modalias = "m25p80",
▸       .max_speed_hz = 30 * 1000 * 1000,
▸       .bus_num = 0,
▸       .chip_select = 4,
▸       .mode = SPI_MODE_0,
        .platform_data = &nor_data,
};

static struct spi_board_info rb2011_spi_ts = {                                                                                              
▸       .modalias = "rb2011-spi-ts",
▸       .max_speed_hz = 2500 * 1000,
▸       .bus_num = 0,
▸       .chip_select = 2,
▸       .mode = SPI_MODE_3,
▸       .platform_data = (void *) 16,
};

static struct spi_board_info *scorpionL_spi_info[] = {
▸       &slow_large_spi_nor,
▸       &rb2011_spi_ts,
▸       NULL
};

static struct platform_device scorpionL_spi_device = {                                                                                      
▸       .name▸  = "rb900-spi",
▸       .id▸    = -1,
▸       .dev▸   = {
▸       ▸       .platform_data = scorpionL_spi_info,
▸       },
};
  1. gpio
static struct platform_device ar9340_gpio_device = {                                                                                        
▸       .name▸  = "rb400-gpio",
▸       .id▸    = -1,
▸       .dev▸   = {
▸       ▸       .platform_data = (void *)RB400_GPIO_INVERT_OE,
▸       },
};
  1. Ethernet
static struct mdio_gpio_platform_data g52c_mdio_platform_data = {
▸       .mdc = 12,
▸       .mdio = 11,
▸       .phy_mask = 0,
};

struct platform_device g52c_mdio_device = {                                                                                                 
▸       .name   = "mdio-gpio",
▸       .id     = 1,
▸       .dev    = {
▸       ▸       .platform_data = &g52c_mdio_platform_data,
▸       },
};

static int g52c_eth_port_map[] = { 1, 1, 0 | BIT(30), -1 };
static struct platform_device g52c_eth_device = {
▸       .name▸  = "ag7240",
▸       .id▸    = -1,
▸       .dev▸   = {
▸       ▸       .platform_data = g52c_eth_port_map,
▸       },
};
  1. Leds
static struct platform_device wapg_led_device = {
▸       .name▸  = "rb400-led",
▸       .id▸    = -1,
▸       .dev▸   = {
▸       ▸       .platform_data = &(unsigned[]) {
▸       ▸       ▸       PLDI(led1, 1, WIFI),
▸       ▸       ▸       PLDI(led2, 8, WIFI),
▸       ▸       ▸       PLDI(led3, 9, WIFI),
▸       ▸       ▸       PLED(power_led, 16, GPIO, PLED_CFG_ON | PLED_CFG_INV),
▸       ▸       ▸       PLDI(button, 1, GPIO),
▸       ▸       ▸       0
▸       ▸       },
▸       },
};
1 Like

Hi

First Draft 29.09.2017

Bootlog:

[    0.000000] Linux version 4.4.88 (giuseppe@vaio) (gcc version 6.3.0 (GCC) ) #7 Fri Sep 29 14:18:25 CEST 2017
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019750 (MIPS 74Kc)
[    0.000000] SoC: Qualcomm Atheros QCA9556 ver 1 rev 0
.
.
.
[    0.121528] MIPS: machine is MikroTik RouterBOARD wAP G-5HacT2HnD
.
.
.
[    2.983775] bootconsole [early0] disabled
[    2.994630] m25p80 spi0.0: found w25q128, expected m25p80
[    3.000165] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    3.009775] Creating 6 MTD partitions on "spi0.0":
[    3.014647] 0x000000000000-0x00000000e000 : "routerboot"
[    3.021312] 0x00000000e000-0x00000000f000 : "hard_config"
[    3.028178] 0x00000000f000-0x000000010000 : "bios"
[    3.034360] 0x000000010000-0x00000001f000 : "routerboot2"
[    3.041220] 0x00000001f000-0x000000020000 : "soft_config"
[    3.048067] 0x000000020000-0x000001000000 : "firmware"
[    3.218829] libphy: GPIO Bitbanged MDIO: probed
[    3.886678] ag71xx ag71xx.0: connected to PHY at gpio-1:00 [uid=004dd074, driver=Atheros 8031/8033 ethernet]
[    3.897274] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode:SGMII
[    3.904313] NET: Registered protocol family 17
.
.
.
- initramfs -

My question is: The SoC QCA9556 and transceiver AR8033 are both supporting SGMII and RGMII. How I can choose the right one.

That you gotta find in either stock boot log or GPL source.
I will take a look, it is most likely hidden in one of the functions.
GPL really does not provide any info on what eth_port_map[] functions actually set.

1 Like

Hi all

here last rbspi diff, bootlog.

Problems:

  1. I don't know the right mode (RGMII vs SGMII) to set between SoC and ar8083. I'm trying RGMII and SGMII but I've the same result. The kernel notifies me the changes of speed and link-up/down, but I've no connectivity.
  2. About devices of the spi's bus:
    How can I edit the code and make it ready to handle the setup of 2th device ?
    The 2th device on spi bus is TS device instead of SSR. I don't know the logic of chip select yet.

I'm seeing others mach files that uses qca955x + ar803x.

From ar8083 datasheet, at page 22:
For RGMII, by default AR8033 adds 2 ns delay for RX_CLK reference to RXD to meet the MAC
input setup and hold time. The MAC to PHY direction requires to add 2 ns typical delay of GTX_
CLK reference to TXD for PHY to capture the data.

Maybe i need of something like:

    static void __init om5p_acv2_setup_qca955x_eth_cfg(u32 mask,
    ▸       ▸       ▸       ▸       ▸       ▸          unsigned int rxd,
    ▸       ▸       ▸       ▸       ▸       ▸          unsigned int rxdv,
    ▸       ▸       ▸       ▸       ▸       ▸          unsigned int txd,
    ▸       ▸       ▸       ▸       ▸       ▸          unsigned int txe)
    {
    ▸       void __iomem *base;
    ▸       u32 t;

    ▸       base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);

    ▸       t = mask;
    ▸       t |= rxd << QCA955X_ETH_CFG_RXD_DELAY_SHIFT;
    ▸       t |= rxdv << QCA955X_ETH_CFG_RDV_DELAY_SHIFT;
    ▸       t |= txd << QCA955X_ETH_CFG_TXD_DELAY_SHIFT;
    ▸       t |= txe << QCA955X_ETH_CFG_TXE_DELAY_SHIFT;

    ▸       __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);

    ▸       iounmap(base);
    }

And for pll setup?

testing new setup

+ static void __init rbwap_setup_qca955x_eth_cfg(u32 mask,
+ ▸       ▸       ▸       ▸       ▸       ▸       unsigned int rxd,
+ ▸       ▸       ▸       ▸       ▸       ▸       unsigned int rxdv,
+ ▸       ▸       ▸       ▸       ▸       ▸       unsigned int txd,
+ ▸       ▸       ▸       ▸       ▸       ▸       unsigned int txe)
+ {
+ ▸       void __iomem *base;
+ ▸       u32 t;
+ 
+ ▸       base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
+ 
+ ▸       t = mask;
+ ▸       t |= rxd << QCA955X_ETH_CFG_RXD_DELAY_SHIFT;
+ ▸       t |= rxdv << QCA955X_ETH_CFG_RDV_DELAY_SHIFT;
+ ▸       t |= txd << QCA955X_ETH_CFG_TXD_DELAY_SHIFT;
+ ▸       t |= txe << QCA955X_ETH_CFG_TXE_DELAY_SHIFT;
+ 
+ ▸       __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
+ 
+ ▸       iounmap(base);
+ }

and I used rbwap_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN, 3 (or 2), 3 (or 2), 0, 0); instead of ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);

I don't have connectivity yet with:

  1. Unsets plls
/*
     ath79_eth0_pll_data.pll_1000 = 0xae000000;
     ath79_eth0_pll_data.pll_100 = 0xa0000101;
     ath79_eth0_pll_data.pll_10 = 0xa0001313;    
*/
  1. if it uses the mr17500's (and mr900) ppls
     ath79_eth0_pll_data.pll_1000 = 0xae000000;
     ath79_eth0_pll_data.pll_100 = 0xa0000101;
     ath79_eth0_pll_data.pll_10 = 0xa0001313;    
  1. if it uses the om5pacv2 (both cases) ppls
         ath79_eth0_pll_data.pll_1000 = 0x82000101;
         ath79_eth0_pll_data.pll_100 = 0x80000101;
         ath79_eth0_pll_data.pll_10 = 0x80001313;
         ath79_eth0_pll_data.pll_1000 = 0x82000101;
         ath79_eth0_pll_data.pll_100 = 0x80000101;
         ath79_eth0_pll_data.pll_10 = 0x80001313;

I do not have any idea for the next step.

Do you maybe have source on github?

My first message quotes gpl's code about this board. I think that ethernet probe stage it's ok while the problem is guess a correct pll...

Regarding second SPI device.
I think that you can do something like this

And regarding AR8033
UBNT UAP AC Lite uses the same thing

I asked about you current working code for wap

1 Like

Update: Diff, bootlog

Now the AR80833 transceiver is working, I would measure the performance loss with lede, any idea?

I've added iperf at default lede packages, and I did a simple test:

[WAPG-SC]<-------(ethernet)------->[PC]

$ iperf -c 10.10.10.111 -r -t 15
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 10.10.10.111, TCP port 5001
TCP window size:  374 KByte (default)
------------------------------------------------------------
[  4] local 10.10.10.112 port 34772 connected with 10.10.10.111 port 5001
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-15.0 sec   650 MBytes   363 Mbits/sec
[  4] local 10.10.10.112 port 5001 connected with 10.10.10.111 port 59640
[  4]  0.0-15.0 sec   456 MBytes   255 Mbits/sec

Server's session ran on mikrotik, while the client's session ran on my machine. I don't know is this result is influenced by the SoC's capabilities or if the current setup needs some fixes.

Next steps:

  1. Improve the SPI devices registrer. My board uses a TS chip that provide voltage and pbc's temperature monitoring.
  2. Leds

thanks to robimarko for the tips.

Awesome progress.
You didn't have to modify patch that supports AR8033 switch?
I ported LEDE on LigoDLB 5 a few days ago and it uses the same AR8033 switch and without the modified patch, I was getting kernel panics.

That ZT2046Q they use in pretty much everything that does not have full POE on all ports to monitor voltage and temperature.
That thing is primarily touchscreen driver.
If you get it working that would be great, many devices would benefit from it.

Have you had any progress on voltage and temperature monitor?
I got GPL sources that include code for that IC,that may help you get it running.
https://github.com/robimarko/routeros-GPL/raw/master/6.41rc38/voltage.tgz

Hi @Ciusss89,

Did you have any success in getting the 5 GHz radio working? I have been working recently on supporting this device (I grabbed a few lines from your diff :wink:) but this is missing.

Hello @rogerpueyo

I did accidentally a short circuit on the board and I broke it :sweat_smile:

Do you have source uploaded to Github or somewhere else?

@robimarko: sure, please check https://github.com/rogerpueyo/lede-source/commits/rb-wapg-5hact2hnd

@Ciusss89: ooops... :anguished:

When I lost my router-board I'm was working on spi and my goal was register the ts controller. I'll share my code in next day.

:wink: