Installing OpenWrt on RB2011UiAS-2HnD-IN fails

Hello Koen

The staging tree version work fine for me. I hope to see the patch in the official branch.

Thanks,

Erwann

fyi, I've pushed the r2 version patch to master.

Regards,

Koen

2 Likes

Hi Koen!

The switch1 leds(6-10) not working on my r2 when the trigger is "Switchport activity (switch1)".

Regards,
Norbert

EDIT: Master image has installed succesfully on my r2

1 Like

Hello RebroN, we have the same problem. Could you give us a link to download the correct sysupgrade file?

thank you very much in advance

If you refer to the led problem, than that problem has not been fixed yet.

Regards,

Norbert

tb2019 via OpenWrt Forum mail@forum.openwrt.org ezt írta (időpont: 2019. ápr. 25., Csü 13:48):

Hi Norbert, my problem is when i load the sysupgrade.bin file the router reboot continously.
I think you solved this problem building a new one. I'd be very grateful if you could tell me how to solve this problem.

Regards,
Tb.

Hi!

I had a different problem.
Build an image from Koen's staging tree!

Regards,
Norbert

Hi Koen,

Thank you for this.

Your fix also works for the Mikrotik RouterBOARD 2011iLS (5 x fast ethernet, 5 x GBit ethernet, 1x SFP, no Wireless, no USB, No serial terminal from rooterboot) ,
Board identifier seems to be 2011r5

Kernel command line: parts=1 boot_part_size=4194304 gpio=249387 HZ=300000000 mem=64M kmac=B8:69:F4:ba:db:ad board=2011r5 board=2011r5 ver=3.41 hw_opt=00110001 boot=1 mlc=11 console=ttyS0,115200 rootfstype=squashfs noinitrd

byt cpuinfo reports as expected

 cat /proc/cpuinfo
system type             : Atheros AR9344 rev 3
machine                 : Mikrotik RouterBOARD 2011iLS
processor               : 0
cpu model               : MIPS 74Kc V4.12
BogoMIPS                : 299.82
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa                     : mips1 mips2 mips32r1 mips32r2
ASEs implemented        : mips16 dsp dsp2
shadow register sets    : 1
kscratch registers      : 0
package                 : 0
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available

1 Like

@DDK

Thanks for testing :slight_smile:

I'll let it sit in staging for another week until I'm confident enough that it doesn't break anything else.

If it's stable after more testing, I'll check if it can be added to the 19.07 branch so it will be present in the next official release.

Regards,

Koen

Hello,

Any news or guidance on this one? The only one I could get working as the 19 version of : ECC errors in UBI RB2011UiAS-2HnD-IN (and solution)

However, I'm having lots of troubles with kernel modules as the packages on the openwrt repository requires different kernel version than the one running on this image.

Thanks,
Marcelo

Does anyone have working SFP on these ?
I found this post ( Mikrotik Rb2011ILS-IN SFP port not working ) that mentions that SFP power is connected to a switch LED pin, But I have not managed to get them working using the regular build ( master ) or that proposed fix.

@DDK

If I have some time tomorrow i'll give it a try. :slight_smile:

I'm also poking around on mine ( trying to find the buzzer gpio ), but SFP is more important ( Lightning doesn't go thru glass )

I got SFP working with the proposed fix - The device needs a power cycle for the switch to apply new settings to the LED control register - a simple system reboot didn't do it - ( page 58 : http://microchip.ho.ua/data/AR8327.pdf ) - seems port3 LED2 is connected to a transistor that controls power to the SFP cage.

swconfig still reports that the link is down, but there is traffic on the port ( using it as a VLAN trunk between 2 sites )

Edit: Iperf results between devices on either side of the SFP connection ( VLAN tagging and untagging is also involved ) :

Connecting to host 10.0.0.117, port 5201
[  4] local 10.0.0.180 port 11188 connected to 10.0.0.117 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   104 MBytes   876 Mbits/sec
[  4]   1.00-2.00   sec   111 MBytes   929 Mbits/sec
[  4]   2.00-3.00   sec   110 MBytes   924 Mbits/sec
[  4]   3.00-4.00   sec   112 MBytes   940 Mbits/sec
[  4]   4.00-5.00   sec   110 MBytes   925 Mbits/sec
[  4]   5.00-6.00   sec   110 MBytes   918 Mbits/sec
[  4]   6.00-7.00   sec   108 MBytes   904 Mbits/sec
[  4]   7.00-8.00   sec   107 MBytes   897 Mbits/sec
[  4]   8.00-9.00   sec   105 MBytes   880 Mbits/sec
[  4]   9.00-10.00  sec   112 MBytes   935 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec  1.06 GBytes   913 Mbits/sec                  sender
[  4]   0.00-10.00  sec  1.06 GBytes   913 Mbits/sec                  receiver

Hello. It has already been a long time, but I still got the SFP to work in RB2011. swconfig showed the link on SFP port.
This is my version of mach-rb2011.c(for LEDE):

/*
 *  MikroTik RouterBOARD 2011 support
 *
 *  Copyright (C) 2012 Stijn Tintel <stijn@linux-ipv6.be>
 *  Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License version 2 as published
 *  by the Free Software Foundation.
 */

#define pr_fmt(fmt) "rb2011: " fmt

#include <linux/phy.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/ath9k_platform.h>
#include <linux/ar8216_platform.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
#include <linux/routerboot.h>
#include <linux/gpio.h>

#include <asm/prom.h>
#include <asm/mach-ath79/ath79.h>
#include <asm/mach-ath79/ar71xx_regs.h>

#include "common.h"
#include "dev-eth.h"
#include "dev-m25p80.h"
#include "dev-gpio-buttons.h"
#include "dev-nfc.h"
#include "dev-usb.h"
#include "dev-wmac.h"
#include "machtypes.h"
#include "routerboot.h"

#define RB2011_GPIO_PORT10_POE 2
#define RB2011_GPIO_NAND_NCE	14
#define RB2011_GPIO_BTN_RESET	15
#define RB2011_GPIO_USB_POE	20
#define RB2011_GPIO_SFP_LOS	21
#define RB2011_GPIO_SPEAKER	22

#define RBHAPX_KEYS_POLL_INTERVAL 20 /* msecs */
#define RBHAPX_KEYS_DEBOUNCE_INTERVAL (3 * RBHAPX_KEYS_POLL_INTERVAL)

#define RB_ROUTERBOOT_OFFSET	0x0000
#define RB_ROUTERBOOT_MIN_SIZE	0xb000
#define RB_HARD_CFG_SIZE	0x1000
#define RB_BIOS_OFFSET		0xd000
#define RB_BIOS_SIZE		0x1000
#define RB_SOFT_CFG_OFFSET	0xf000
#define RB_SOFT_CFG_SIZE	0x1000

#define RB_ART_SIZE		0x10000

#define RB2011_FLAG_OLD_SFP		BIT(0)
#define RB2011_FLAG_NEW_SFP		BIT(1)
#define RB2011_FLAG_USB				BIT(2)
#define RB2011_FLAG_WLAN			BIT(3)

static struct mtd_partition rb2011_spi_partitions[] = {
	{
		.name		= "routerboot",
		.offset		= RB_ROUTERBOOT_OFFSET,
		.mask_flags	= MTD_WRITEABLE,
	}, {
		.name		= "hard_config",
		.size		= RB_HARD_CFG_SIZE,
		.mask_flags	= MTD_WRITEABLE,
	}, {
		.name		= "bios",
		.offset		= RB_BIOS_OFFSET,
		.size		= RB_BIOS_SIZE,
		.mask_flags	= MTD_WRITEABLE,
	}, {
		.name		= "soft_config",
		.size		= RB_SOFT_CFG_SIZE,
	}
};

static void __init rb2011_init_partitions(const struct rb_info *info)
{
	rb2011_spi_partitions[0].size = info->hard_cfg_offs;
	rb2011_spi_partitions[1].offset = info->hard_cfg_offs;
	rb2011_spi_partitions[3].offset = info->soft_cfg_offs;
}

static struct mtd_partition rb2011_nand_partitions[] = {
	{
		.name	= "booter",
		.offset	= 0,
		.size	= (256 * 1024),
		.mask_flags = MTD_WRITEABLE,
	},
	{
		.name	= "kernel",
		.offset	= (256 * 1024),
		.size	= (4 * 1024 * 1024) - (256 * 1024),
	},
	{
		.name	= "ubi",
		.offset	= MTDPART_OFS_NXTBLK,
		.size	= MTDPART_SIZ_FULL,
	},
};

static struct flash_platform_data rb2011_spi_flash_data = {
	.parts		= rb2011_spi_partitions,
	.nr_parts	= ARRAY_SIZE(rb2011_spi_partitions),
};

static struct ar8327_pad_cfg rb2011_ar8327_pad0_cfg = {
	.mode = AR8327_PAD_MAC_RGMII,
	.txclk_delay_en = true,
	.rxclk_delay_en = true,
	.txclk_delay_sel = AR8327_CLK_DELAY_SEL3,
	.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
};

static struct ar8327_pad_cfg rb2011_ar8327_pad6_cfg;
static struct ar8327_sgmii_cfg rb2011_ar8327_sgmii_cfg;

static struct ar8327_led_cfg rb2011_ar8327_led_cfg = {
	.led_ctrl0 = 0xc731c731,
	.led_ctrl1 = 0x00000000,
	.led_ctrl2 = 0x00008000, //shut down led on LCD screen(sw LED PORT 2)
	.led_ctrl3 = 0x0030c300,
	.open_drain = false,
};

static const struct ar8327_led_info rb2011_ar8327_leds[] __initconst = {
	AR8327_LED_INFO(PHY0_0, HW, "rb:green:eth1"),
	AR8327_LED_INFO(PHY1_0, HW, "rb:green:eth2"),
	AR8327_LED_INFO(PHY2_0, HW, "rb:green:eth3"),
	AR8327_LED_INFO(PHY3_0, HW, "rb:green:eth4"),
	AR8327_LED_INFO(PHY4_0, HW, "rb:green:eth5"),
	AR8327_LED_INFO(PHY0_1, SW, "rb:green:eth6"),
	AR8327_LED_INFO(PHY1_1, SW, "rb:green:eth7"),
	AR8327_LED_INFO(PHY2_1, SW, "rb:green:eth8"),
	AR8327_LED_INFO(PHY3_1, SW, "rb:green:eth9"),
	AR8327_LED_INFO(PHY4_1, SW, "rb:green:eth10"),
	AR8327_LED_INFO(PHY4_2, SW, "rb:green:usr"),
	{
		.name = "rb:lcd:led",
		.led_num = AR8327_LED_PHY0_2,
		.mode = AR8327_LED_MODE_SW,
		.active_low = 0,
		.default_trigger = "default-on",
	}
};

static struct ar8327_platform_data rb2011_ar8327_data = {
	.pad0_cfg = &rb2011_ar8327_pad0_cfg,
	.port0_cfg = {
		.force_link = 1,
		.speed = AR8327_PORT_SPEED_1000,
		.duplex = 1,
		.txpause = 1,
		.rxpause = 1,
	},
	.led_cfg = &rb2011_ar8327_led_cfg,
	.num_leds = ARRAY_SIZE(rb2011_ar8327_leds),
	.leds = rb2011_ar8327_leds,
};

static struct mdio_board_info rb2011_mdio0_info[] = {
	{
		.bus_id = "ag71xx-mdio.0",
		.phy_addr = 0,
		.platform_data = &rb2011_ar8327_data,
	},
};

static struct gpio_keys_button rb2011_gpio_keys[] __initdata = {
	{
		.desc = "Reset button",
		.type = EV_KEY,
		.code = KEY_RESTART,
		.debounce_interval = RBHAPX_KEYS_DEBOUNCE_INTERVAL,
		.gpio = RB2011_GPIO_BTN_RESET,
		.active_low = 1,
	},
};

static void __init rb2011_wlan_init(void)
{
	char *art_buf;
	u8 wlan_mac[ETH_ALEN];

	art_buf = rb_get_wlan_data();
	if (art_buf == NULL)
		return;

	ath79_init_mac(wlan_mac, ath79_mac_base, 11);
	ath79_register_wmac(art_buf + 0x1000, wlan_mac);

	kfree(art_buf);
}

static void rb2011_nand_select_chip(int chip_no)
{
	switch (chip_no) {
	case 0:
		gpio_set_value(RB2011_GPIO_NAND_NCE, 0);
		break;
	default:
		gpio_set_value(RB2011_GPIO_NAND_NCE, 1);
		break;
	}
	ndelay(500);
}

static struct nand_ecclayout rb2011_nand_ecclayout = {
	.eccbytes	= 6,
	.eccpos		= { 8, 9, 10, 13, 14, 15 },
	.oobavail	= 9,
	.oobfree	= { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
};

static int rb2011_nand_scan_fixup(struct mtd_info *mtd)
{
	struct nand_chip *chip = mtd->priv;

	if (mtd->writesize == 512) {
		/*
		 * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot
		 * will not be able to find the kernel that we load.
		 */
		chip->ecc.layout = &rb2011_nand_ecclayout;
	}

	return 0;
}

static void __init rb2011_nand_init(void)
{
	gpio_request_one(RB2011_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE");

	ath79_nfc_set_scan_fixup(rb2011_nand_scan_fixup);
	ath79_nfc_set_parts(rb2011_nand_partitions,
			    ARRAY_SIZE(rb2011_nand_partitions));
	ath79_nfc_set_select_chip(rb2011_nand_select_chip);
	ath79_nfc_set_swap_dma(true);
	ath79_register_nfc();
}

static int rb2011_old_get_port_link(unsigned port)
{
	if (port != 6)
		return -EINVAL;

	/* The Loss of signal line is active low */
	return !gpio_get_value(RB2011_GPIO_SFP_LOS);
}


static void __init rb2011_old_sfp_init(void)
{
	gpio_request_one(RB2011_GPIO_SFP_LOS, GPIOF_IN, "SFP LOS");

	rb2011_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;

	rb2011_ar8327_data.pad6_cfg = &rb2011_ar8327_pad6_cfg;

	rb2011_ar8327_sgmii_cfg.sgmii_ctrl = 0xc70167d0;
	rb2011_ar8327_sgmii_cfg.serdes_aen = true;

	rb2011_ar8327_data.sgmii_cfg = &rb2011_ar8327_sgmii_cfg;

	rb2011_ar8327_data.port6_cfg.force_link = 1;
	rb2011_ar8327_data.port6_cfg.speed = AR8327_PORT_SPEED_1000;
	rb2011_ar8327_data.port6_cfg.duplex = 1;

	rb2011_ar8327_data.get_port_link = rb2011_old_get_port_link;
}


static void __init rb2011_new_sfp_init(void)
{
	rb2011_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
	rb2011_ar8327_pad6_cfg.rxclk_delay_en = true;
	rb2011_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;

	rb2011_ar8327_data.pad6_cfg = &rb2011_ar8327_pad6_cfg;

	rb2011_ar8327_sgmii_cfg.sgmii_ctrl = 0xc701e7d0;
	rb2011_ar8327_sgmii_cfg.serdes_aen = true; //autonegotination

	rb2011_ar8327_data.sgmii_cfg = &rb2011_ar8327_sgmii_cfg;

	rb2011_ar8327_data.port6_cfg.force_link = 0;
	rb2011_ar8327_data.port6_cfg.speed = AR8327_PORT_SPEED_1000;
	rb2011_ar8327_data.port6_cfg.duplex = 1;
	rb2011_ar8327_data.port6_cfg.txpause = 1;
	rb2011_ar8327_data.port6_cfg.rxpause = 1;
	rb2011_ar8327_data.port6_custom_set_power_state = 20115;
}

static int __init rb2011_setup(u32 flags)
{
	const struct rb_info *info;
	char buf[64];

	info = rb_init_info((void *) KSEG1ADDR(0x1f000000), 0x10000);
	if (!info)
		return -ENODEV;

	scnprintf(buf, sizeof(buf), "Mikrotik RouterBOARD %s",
		  (info->board_name) ? info->board_name : "");
	mips_set_machine_name(buf);

	rb2011_init_partitions(info);

	ath79_register_m25p80(&rb2011_spi_flash_data);
	rb2011_nand_init();

	ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
					 AR934X_ETH_CFG_RXD_DELAY |
				   AR934X_ETH_CFG_SW_ONLY_MODE);

	ath79_register_mdio(1, 0x0);
	ath79_register_mdio(0, 0x0);

	mdiobus_register_board_info(rb2011_mdio0_info,
				    ARRAY_SIZE(rb2011_mdio0_info));

	/* GMAC0 is connected to an ar8327 switch */
	ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
	ath79_eth0_data.phy_mask = BIT(0);
	ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
	ath79_eth0_pll_data.pll_1000 = 0x6f000000; //here tx/rx delay is more.
	//ath79_eth0_pll_data.pll_1000 = 0x2000000; //also work!

	ath79_register_eth(0);

	/* GMAC1 is connected to the internal switch */
	ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 5);
	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
	ath79_eth1_data.speed = SPEED_1000;
	ath79_eth1_data.duplex = DUPLEX_FULL;

	ath79_register_eth(1);

	if (flags & RB2011_FLAG_OLD_SFP)
		rb2011_old_sfp_init();

	if (flags & RB2011_FLAG_NEW_SFP)
		rb2011_new_sfp_init();

	if (flags & RB2011_FLAG_WLAN)
		rb2011_wlan_init();

	if (flags & RB2011_FLAG_USB){
		ath79_register_usb();
		gpio_request_one(RB2011_GPIO_USB_POE, GPIOF_ACTIVE_LOW |
			GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "USB power off");
	}
	gpio_request_one(RB2011_GPIO_PORT10_POE, GPIOF_OUT_INIT_LOW |
		GPIOF_EXPORT_DIR_FIXED, "Port10 PoE");

	ath79_register_gpio_keys_polled(-1, RBHAPX_KEYS_POLL_INTERVAL,
		ARRAY_SIZE(rb2011_gpio_keys), rb2011_gpio_keys);

	return 0;
}

static void __init rb2011l_setup(void)
{
	rb2011_setup(0);
}

MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011L, "2011L", rb2011l_setup);

static void __init rb2011us_setup(void)
{
	rb2011_setup(RB2011_FLAG_OLD_SFP | RB2011_FLAG_USB);
}

MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011US, "2011US", rb2011us_setup);

static void __init rb2011r5_setup(void)
{
	//RB2011_FLAG_WLAN
	rb2011_setup(RB2011_FLAG_NEW_SFP | RB2011_FLAG_USB);
}

MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011R5, "2011r5", rb2011r5_setup);

static void __init rb2011g_setup(void)
{
	rb2011_setup(RB2011_FLAG_OLD_SFP |
		     RB2011_FLAG_USB |
		     RB2011_FLAG_WLAN);
}

MIPS_MACHINE_NONAME(ATH79_MACH_RB_2011G, "2011G", rb2011g_setup);

All my changes you can see here: https://github.com/adron-s/ag71xx_my
Hope this helps You.

P.S.: As far as I remember the most important thing is collected in the rb2011_new_sfp_init() function.

1 Like

A post was split to a new topic: Get 24V passive PoE working from Port 10 with RB2011

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.