Installing OpenWrt on Mikrotik wAP R (RBwAPR-2nD)

Pretty sure the card's dead. I tried a different model and it immediately showed up as a usb device. I did try taping the USB 3 pins just in case, but it didn't work. I ordered a new LTE card. Thanks for all the suggestions. Some I'll have to try when the new card shows up.

Can someone confirm that all of the LEDs are configured properly so a PR to complete wAP R support can be opened?

All gpio leds are configured correctly.

Maybe worth mentioning that 4G rssi indication leds (1, 2 and 3) are allocated for WiFi indication but this is probably the right thing as it is not really possible to generalise rssi config for all possible modems..

Yes, I allocated LTE leds for WiFi since I am not aware of a way to configure them for RSSI in a way that is generic

Hi Guys. I try install on this Mikrotik but no way. I can't see the USB Modem. I have installed the robymarko image. How can i activate the modem?
This is my dmesg

root@OpenWrt:~# dmesg
[    0.000000] Linux version 4.9.108 (robimarko@localhost.localdomain) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r7241-628f070dc8) ) #0 Sat Jun 23 10:13:38 2018
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019374 (MIPS 24Kc)
[    0.000000] SoC: Qualcomm Atheros QCA9533 ver 2 rev 0
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] User-defined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] On node 0 totalpages: 16384
[    0.000000] free_area_init_node: node 0, pgdat 804a3c34, node_mem_map 81000020
[    0.000000]   Normal zone: 128 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 16384 pages, LIFO batch:3
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: no-uart no-buzzer no-nand parts=1 boot_part_size=16777216 gpio=0 HZ=325000000 mem=64M kmac=64:D1:54:7D:D8:AA board=wap-lte board=wap-lte ver=3.41 hw_opt=00684001 boot=1 mlc=11 console=ttyS0,115200 rootfstype=squashfs noinitrd
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 57212K/65536K available (3415K kernel code, 148K rwdata, 808K rodata, 2724K init, 211K bss, 8324K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:51
[    0.000000] Clocks: CPU:650.000MHz, DDR:600.000MHz, AHB:300.000MHz, Ref:25.000MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5880801374 ns
[    0.000009] sched_clock: 32 bits at 325MHz, resolution 3ns, wraps every 6607641598ns
[    0.008865] Calibrating delay loop... 432.53 BogoMIPS (lpj=2162688)
[    0.071955] pid_max: default: 32768 minimum: 301
[    0.077302] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.084810] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.095478] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.106666] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.114164] NET: Registered protocol family 16
[    0.122869] MIPS: machine is MikroTik RouterBOARD wAP R-2nD
[    0.129445] ar724x-pci ar724x-pci.0: PCIe link is down
[    0.135282] registering PCI controller with io_map_base unset
[    0.396162] PCI host bridge to bus 0000:00
[    0.400830] pci_bus 0000:00: root bus resource [mem 0x10000000-0x11ffffff]
[    0.408681] pci_bus 0000:00: root bus resource [io  0x0000]
[    0.415003] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
[    0.422706] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    0.431707] pci_bus 0000:00: busn_res: [bus 00-ff] end is updated to 00
[    0.432475] clocksource: Switched to clocksource MIPS
[    0.439307] NET: Registered protocol family 2
[    0.445066] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.453037] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.460258] TCP: Hash tables configured (established 1024 bind 1024)
[    0.467576] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.474242] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.481598] NET: Registered protocol family 1
[    0.486612] PCI: CLS 0 bytes, default 32
[    2.582485] random: fast init done
[    3.322592] Crashlog allocated RAM at address 0x3f00000
[    3.329660] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    3.343647] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    3.350268] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    3.446343] io scheduler noop registered
[    3.450799] io scheduler deadline registered (default)
[    3.456961] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[    3.464627] console [ttyS0] disabled
[    3.488819] serial8250.0: ttyS0 at MMIO 0x18020000 (irq = 11, base_baud = 1562500) is a 16550A
[    3.498615] console [ttyS0] enabled
[    3.506172] bootconsole [early0] disabled
[    3.517833] m25p80 spi0.0: found w25q128jv, expected m25p80
[    3.532837] m25p80 spi0.0: w25q128jv (16384 Kbytes)
[    3.576289] Creating 6 MTD partitions on "spi0.0":
[    3.581262] 0x000000000000-0x00000000e000 : "routerboot"
[    3.588236] 0x00000000e000-0x00000000f000 : "hard_config"
[    3.595418] 0x00000000f000-0x000000010000 : "bios"
[    3.601863] 0x000000010000-0x00000001f000 : "routerboot2"
[    3.609006] 0x00000001f000-0x000000020000 : "soft_config"
[    3.616176] 0x000000020000-0x000001000000 : "firmware"
[    3.623976] libphy: Fixed MDIO Bus: probed
[    3.741308] libphy: ag71xx_mdio: probed
[    4.374790] ag71xx-mdio.1: Found an AR934X built-in switch
[    4.428319] eth0: Atheros AG71xx at 0xba000000, irq 5, mode:GMII
[    4.436344] NET: Registered protocol family 10
[    4.444368] NET: Registered protocol family 17
[    4.449019] 8021q: 802.1Q VLAN Support v1.8
[    4.471873] Freeing unused kernel memory: 2724K
[    4.476590] This architecture does not have kernel memory protection.
[    4.496480] init: Console is alive
[    4.500226] init: - watchdog -
[    4.523221] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    4.532678] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    4.550861] init: - preinit -
[    4.761144] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[    6.903908] eth0: link up (1000Mbps/Full duplex)
[    6.908711] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    7.902719] eth0: link down
[    7.916793] procd: - early -
[    7.919878] procd: - watchdog -
[    8.468800] procd: - watchdog -
[    8.472306] procd: - ubus -
[    8.482647] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.525412] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.532395] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.539877] procd: - init -
[    8.710149] kmodloader: loading kernel modules from /etc/modules.d/*
[    8.720880] ip6_tables: (C) 2000-2006 Netfilter Core Team
[    8.737865] Loading modules backported from Linux version wt-2017-11-01-0-gfe248fc2c180
[    8.746199] Backport generated by backports.git v4.14-rc2-1-31-g86cf0e5d
[    8.756106] ip_tables: (C) 2000-2006 Netfilter Core Team
[    8.769614] nf_conntrack version 0.5.0 (1024 buckets, 4096 max)
[    8.825146] xt_time: kernel timezone is -0000
[    8.881664] PPP generic driver version 2.4.2
[    8.888541] NET: Registered protocol family 24
[    8.935539] ath: EEPROM regdomain: 0x0
[    8.935549] ath: EEPROM indicates default country code should be used
[    8.935552] ath: doing EEPROM country->regdmn map search
[    8.935567] ath: country maps to regdmn code: 0x3a
[    8.935572] ath: Country alpha2 being used: US
[    8.935576] ath: Regpair used: 0x3a
[    8.946359] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
[    8.950514] ieee80211 phy0: Atheros AR9531 Rev:2 mem=0xb8100000, irq=47
[    8.992926] kmodloader: done loading kernel modules from /etc/modules.d/*
[   10.117696] urandom_read: 5 callbacks suppressed
[   10.117704] random: jshn: uninitialized urandom read (4 bytes read)
[   10.184539] random: jshn: uninitialized urandom read (4 bytes read)
[   19.013511] br-lan: port 1(eth0) entered blocking state
[   19.018921] br-lan: port 1(eth0) entered disabled state
[   19.024742] device eth0 entered promiscuous mode
[   19.111898] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[   20.633910] eth0: link up (1000Mbps/Full duplex)
[   20.638732] br-lan: port 1(eth0) entered blocking state
[   20.644156] br-lan: port 1(eth0) entered forwarding state
[   20.681573] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[  126.562520] random: crng init done

@borsss There's a chance his changes are in master now. See 091e915.

Not sure if I missed it, but I don't see anything related to USB in that dmsesg log.

Right.....no USB in dmesg..... which image you use for your W AP r?

Hello

I bought a RB mAPl-2ND (RouterBoard mAP Lite) today and tried to flash the latest OpenWRT 18.06.01 firmware on it without success.
Using a TFTP/DHCP server and the reset button method, the device successfully booted the initramfs-kernel.bin image and I could ssh to it, but i could not get to flash the squashfs-sysupgrade.bin image using sysupgrade.
Also, /proc/mtd did not list any partition.

Using the same images that @robimarko built for @borsss that supports the new W25Q128JVSIM flash, the 6 mtd partitions now appears in dmesg and /proc/mtd.

[    3.488583] m25p80 spi0.0: found w25q128jv, expected m25p80
[    3.504000] m25p80 spi0.0: w25q128jv (16384 Kbytes)
[    3.549434] Creating 6 MTD partitions on "spi0.0":
[    3.554409] 0x000000000000-0x00000000e000 : "routerboot"
[    3.561422] 0x00000000e000-0x00000000f000 : "hard_config"
[    3.568693] 0x00000000f000-0x000000010000 : "bios"
[    3.575263] 0x000000010000-0x00000001f000 : "routerboot2"
[    3.582422] 0x00000001f000-0x000000020000 : "soft_config"
[    3.589669] 0x000000020000-0x000001000000 : "firmware"

The images can still be found here:

  • openwrt-ar71xx-mikrotik-rb-nor-flash-16M-initramfs-kernel.bin
  • openwrt-ar71xx-mikrotik-rb-nor-flash-16M-squashfs-sysupgrade.bin

The SN printed on the box of my mAPl-2ND ends with ".../821/r2/", i guess the "/r2" means a new flash chip.
The FCC ID is still the same: TV7MAPL2ND.

Thanks @robimarko !

Hello all,

I have been waiting for some more comprehensive support for this device, but as it was not coming, I have tried to set up this using the information here.

First, using the sources from @robimarko, I did manage to install OpenWRT on the device and I do have Ethernet and WLAN working just fine.

Using the GPIO15, I can see the R11LTE modem and I did install all the relevant modules. My lsusb -t looks as it should, like this:

/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    |__ Port 1: Dev 3, If 0, Class=Wireless, Driver=rndis_host, 480M
    |__ Port 1: Dev 3, If 1, Class=CDC Data, Driver=rndis_host, 480M
    |__ Port 1: Dev 3, If 2, Class=Communications, Driver=cdc_acm, 480M
    |__ Port 1: Dev 3, If 3, Class=CDC Data, Driver=cdc_acm, 480M
    |__ Port 1: Dev 3, If 4, Class=Communications, Driver=cdc_acm, 480M
    |__ Port 1: Dev 3, If 5, Class=CDC Data, Driver=cdc_acm, 480M
    |__ Port 1: Dev 3, If 6, Class=Mass Storage, Driver=, 480M

However, I do not see to be able to get the LTE working and I am not sure what the problem is. I do see the eth1 device and the /dev/ttyACM1 devices. I have tried to follow the suggestions in the post of @cezary (adding the section to /etc/config/network, editing /etc/gcom/ncm.js and /lib/netifd/proto/ncm.sh.

I am not sure if I am missing some additional package or if something is misconfigured - most importantly I do not see any activity in the syslog. The ifstatus wan shows this:

{
	"up": false,
	"pending": false,
	"available": false,
	"autostart": true,
	"dynamic": false,
	"proto": "none",
	"data": {
		
	},
	"errors": [
		{
			"subsystem": "proto",
			"code": "INVALID_PROTO"
		}
	]
}

and after I manually try ifup wan, I do get this instead:

{
	"up": false,
	"pending": false,
	"available": false,
	"autostart": true,
	"dynamic": false,
	"proto": "none",
	"data": {
		
	},
	"errors": [
		{
			"subsystem": "interface",
			"code": "NO_DEVICE"
		}
	]
}

there is nothing in syslog at all about anything.

Any suggestions from anyone?

Thanks a lot.

Here is a short update to my previous post.

First, I was able to find and fix a missing bactick at the end of the line 76 in the script in /lib/netifd/proto/ncm.sh. Once that is fixed, the connection does progress much further.

However, it still does not seem to work as expected.

Here is the syslog:

Sat Dec 15 15:38:36 2018 daemon.notice netifd: lte (1129): Configuring modem
Sat Dec 15 15:38:37 2018 daemon.notice netifd: lte (1129): sending -> AT*CGDFLT=0,"IP","internet",,,,,,,,,,,,,,,,,,1
Sat Dec 15 15:39:09 2018 daemon.notice netifd: lte (1129): Starting network lte
Sat Dec 15 15:39:09 2018 daemon.notice netifd: lte (1129): Connecting modem
Sat Dec 15 15:39:10 2018 daemon.notice netifd: lte (1129): sending -> AT+CFUN=1
Sat Dec 15 15:39:10 2018 daemon.notice netifd: lte (1129): Setting up eth1
Sat Dec 15 15:39:10 2018 daemon.notice netifd: Interface 'lte' is now up
Sat Dec 15 15:39:10 2018 daemon.notice netifd: Network device 'eth1' link is up
Sat Dec 15 15:39:10 2018 daemon.notice netifd: Network alias 'eth1' link is up
Sat Dec 15 15:39:10 2018 daemon.notice netifd: Interface 'lte_4' is enabled
Sat Dec 15 15:39:10 2018 daemon.notice netifd: Interface 'lte_4' has link connectivity
Sat Dec 15 15:39:10 2018 daemon.notice netifd: Interface 'lte_4' is setting up now
Sat Dec 15 15:39:10 2018 daemon.notice netifd: lte_4 (1623): udhcpc: started, v1.29.3
Sat Dec 15 15:39:10 2018 daemon.notice netifd: lte_4 (1623): udhcpc: sending discover
Sat Dec 15 15:39:13 2018 daemon.notice netifd: lte_4 (1623): udhcpc: sending discover
Sat Dec 15 15:39:16 2018 daemon.notice netifd: lte_4 (1623): udhcpc: sending discover

and here is the ifstatus:

{
	"up": true,
	"pending": false,
	"available": true,
	"autostart": true,
	"dynamic": false,
	"uptime": 270,
	"l3_device": "eth1",
	"proto": "ncm",
	"updated": [
		"data"
	],
	"metric": 0,
	"dns_metric": 0,
	"delegation": true,
	"ipv4-address": [
		
	],
	"ipv6-address": [
		
	],
	"ipv6-prefix": [
		
	],
	"ipv6-prefix-assignment": [
		
	],
	"route": [
		
	],
	"dns-server": [
		
	],
	"dns-search": [
		
	],
	"inactive": {
		"ipv4-address": [
			
		],
		"ipv6-address": [
			
		],
		"route": [
			
		],
		"dns-server": [
			
		],
		"dns-search": [
			
		]
	},
	"data": {
		"manufacturer": "mikrotik"
	}
}

it keeps sending DHCP requests but it is never getting any answer back.

listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
15:40:22.884035 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from ac:ff:ff:00:00:00 (oui Unknown), length 300
15:40:25.887467 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from ac:ff:ff:00:00:00 (oui Unknown), length 300
15:40:28.890966 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from ac:ff:ff:00:00:00 (oui Unknown), length 300
15:40:31.894038 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from ac:ff:ff:00:00:00 (oui Unknown), length 300
15:40:34.897468 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from ac:ff:ff:00:00:00 (oui Unknown), length 300

With the original Mikrotik firmware and the same USIM this was working without issues.

Any suggestions would be highly appreciated.

1 Like

The device support seems to be good; your issue is with the LTE card, and because it supports most Mini PCIE LTE cards, there isn't a general solution to getting one running. It will depend on which LTE card you have.

I ended up taking a lot of notes for what I had to do specifically for a Sierra Wireless MC7354 on Sprint.

In my case, I also had an issue with not getting an IP via DHCP. My problem was that I needed to set the proto to qmi, but this depends on your LTE card.

config interface 'wwan0'
        option ifname 'wwan0'
        option proto 'qmi'
        option device '/dev/cdc-wdm0'
        option apn 'r.ispsn'
        option delay 10
        option modes 'all'
        option metric 10

@dehrmann thank you very much for the links and your comments.

I have eventually managed to get it working, albeit with some modification of the ncm support in OpenWRT. As mentioned in my post, the card is the one sold with the device as a bundle called wAP-R-LTE (the card is also available separately as R11e-LTE).

What was missing was 2 more commands to activate the link. I have sniffed those commands using the original Mikrotik firmware and while I was Googling their meaning, I have also found them independently documented here:
http://eko.one.pl/?p=modem-r11elte

The missing commands are

AT+CGDCONT?
AT+CGCONTRDP=<profile>

With those 2 commands added, it starts to work. The issue is that the ncm support in netifd protocol does only allow a single command in the "connect" item in the modem jSON file. Also, there needs to be a delay between the command or an error is reported. So with modifying ncm.sh and adding those 2 commands, it all works fine.

Hi to all

Quick start guide to use wap-lte modem:

  1. boot the board using openwrt-ar71xx-mikrotik-rb-nor-flash-16M-initramfs-kernel.bin (got it from the latest build)
  2. ssh root[at]192.168.1.1, download openwrt-ar71xx-mikrotik-rb-nor-flash-16M-squashfs-sysupgrade.bin and install openwrt on flash using:
 mtd erase /dev/mtd5
 sysupgrade -F openwrt-ar71xx-mikrotik-rb-nor-flash-16M-squashfs-sysupgrade.bin
 (the device reboots ...)
  1. again ssh root[at]192.168.1.1, then install needed packages:
 opkg update
 opkg install kmod-usb-acm kmod-usb-core kmod-usb-core kmod-usb-ehci kmod-usb-ohci kmod-usb-ohci-pci \
 kmod-usb2 kmod-usb2-pci kmod-usb3 kmod-usb-net-rndis kmod-usb-net-cdc-ncm libsqlite3 \
 comgt comgt-ncm tio ppp-mod-pptp kmod-nf-nathelper-extra hostapd-utils

then install additional files:

/etc/gcom/r11.gcom

# stabilisce una connessione con modem mikrotik
opengt
 print "DIALOGUE BEGINS\n"
 set com 115200n81
 set senddelay 0.1
 waitquiet 3 0.5
 set clocal on
 flash 0.1

 send "AT&F^m"
 send "ATE1^m"
 send "AT+CFUN=0^m"
 send "AT+CFUN=4^m"
# 4g+3g
 send "AT*BAND=11,79,147,480,589829,0,2,0^m"
 send "AT+CMEE=2^m"
 send "AT+CGREG=1^m"
 send "AT+CNMI=0,0,0,0,0^m"
 send 'AT*CGDFLT=0,"IP","'
 send $env("pdptype")
 send '","'
 send $env("apn")
 send '",,,,,,,,,,1,0,,,,,,,1^m'
 send "AT+CFUN=1^m"

 waitfor 60 "+CGEV: EPS PDN ACT" 
 if % = -1 goto timeout
 print "RECEIVED +CGEV: EPS PDN ACT\n"
 get 1 "^m" $p
 print "profile="$p"\n"
 send 'AT+CGDCONT?^m'
 send "AT+CGCONTRDP="
 send $p
 send "^m"
 print "Polite exit\n"
 exit 0

:timeout             
 print "Timeout, exit.\n"
 exit 1

/lib/netifd/proto/r11.sh

#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
	. /lib/functions.sh
	. ../netifd-proto.sh
	init_proto "$@"
}

proto_r11_init_config() {
	no_device=1
	available=1
	proto_config_add_string "device:device"
	proto_config_add_string apn
	proto_config_add_string auth
	proto_config_add_string username
	proto_config_add_string password
	proto_config_add_string pincode
	proto_config_add_string delay
	proto_config_add_string mode
	proto_config_add_string pdptype
	proto_config_add_int profile
	proto_config_add_defaults
}

proto_r11_setup() {
	local interface="$1"
	local manufacturer initialize setmode connect finalize ifname devname devpath
	local device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS
	json_get_vars device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS

	[ "$metric" = "" ] && metric="0"

	[ -n "$profile" ] || profile=1

	pdptype=`echo "$pdptype" | awk '{print toupper($0)}'`
	[ "$pdptype" = "IP" -o "$pdptype" = "IPV6" -o "$pdptype" = "IPV4V6" ] || pdptype="IP"

	[ -n "$ctl_device" ] && device=$ctl_device

	[ -n "$device" ] || {
		echo "No control device specified"
		proto_notify_error "$interface" NO_DEVICE
		proto_set_available "$interface" 0
		return 1
	}

	device="$(readlink -f $device)"
	[ -e "$device" ] || {
		echo "Control device not valid"
		proto_set_available "$interface" 0
		return 1
	}

	devname="$(basename "$device")"
	case "$devname" in
	'tty'*)
		devpath="$(readlink -f /sys/class/tty/$devname/device)"
		ifname="$( ls "$devpath"/../*/net )"
		;;
	*)
		devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)"
		ifname="$( ls "$devpath"/net )"
		;;
	esac
	[ -n "$ifname" ] || {
		echo "The interface could not be found."
		proto_notify_error "$interface" NO_IFACE
		proto_set_available "$interface" 0
		return 1
	}

	[ -n "$delay" ] && sleep "$delay"	

	echo "MODEM ATTIVO:" $device

	gcom -d "$device" -s /etc/gcom/r11.gcom
	[ $? -ne 0 ] && {                                                                                
		echo "Error connecting"                                                                                         
		proto_notify_error "$interface" CONNECT_FAILED                               
		return 1                                                                                 
	} 

	echo "Setting up $ifname"
	proto_init_update "$ifname" 1
	proto_add_data
	json_add_string "manufacturer" "$manufacturer"
	proto_close_data
	proto_send_update "$interface"	
	
	[ "$pdptype" = "IP" -o "$pdptype" = "IPV4V6" ] && {
		json_init
		json_add_string name "${interface}_4"
		json_add_string ifname "@$interface"
		json_add_string proto "dhcp"
		proto_add_dynamic_defaults
		ubus call network add_dynamic "$(json_dump)"
	}

	[ "$pdptype" = "IPV6" -o "$pdptype" = "IPV4V6" ] && {
		json_init
		json_add_string name "${interface}_6"
		json_add_string ifname "@$interface"
		json_add_string proto "dhcpv6"
		json_add_string extendprefix 1
		proto_add_dynamic_defaults
		ubus call network add_dynamic "$(json_dump)"
	}
}

proto_r11_teardown() {
	local interface="$1"
	local manufacturer disconnect

	local device profile
	json_get_vars device profile

	[ -n "$ctl_device" ] && device=$ctl_device

	[ -n "$profile" ] || profile=1

	echo "Stopping network $interface ($device)"

	disconnect="AT+CFUN=0"
	eval COMMAND="$disconnect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
		echo "Failed to disconnect"
		proto_notify_error "$interface" DISCONNECT_FAILED
		return 1
	}

	echo "proto_init_update"
	proto_init_update "*" 0
	echo "proto_send_update"
	proto_send_update "$interface"
	echo "esco da proto_r11_teardown"
}
[ -n "$INCLUDE_ONLY" ] || {
	add_protocol r11
}

add to /etc/config/network the following entry:

     config interface 'wan'
        option proto 'r11'
        option device '/dev/ttyACM1'
        option apn 'your-apn-here'

That'a all folks !

These instructions create a new protocol, called r11.

Now you have only to ifup/ifdown wan.

Notice:
Pay attention to the band selection, here is for 4g+3g networks.

If you want change band please refer to http://eko.one.pl/?p=modem-r11elte.

Axinno

2 Likes

There is already a topic about RB912R-2nD: Mikrotik RB912R-2nD

1 Like

Hi to all
Does anyone have 25q128jv dump? I have this router with dead flash and I want repair it, flash openwrt.

I found
http://www.filedropper.com/mikrotikbin

Hello guys, I've installed the snapshot like showned in the guide, and it seems to work ok. But I have a problem with luci. I get an error involving RPC. Which version of luci/rpc do I need for this snapshot? Thx

I have sniffed those commands using the original Mikrotik firmware

What tools have you used for that?

I'm trying to bring up (supposedly) the same hardware, but the modem neither replies to DHCP requests over RNDIS, nor speaks to pppd after CONNECT, even though it works in RouterOS.

Is the miniPCIe card working properly on 02.21.0? I can't start the EC25-E modem in the new image, OpenWrt worked without any problems on the old one. Evidently problem with USB, lsusb throws an error.

opkg install luci-proto-qmi kmod-usb-serial-option screen

I just tested this and is working great.

I was missing LUCI support so I've modified 3g scripts to fit "reasonably" r11 protocol.

Please mind it's the first time I do something like this so expect unneeded/unsupported options ahead and even bugs.

/www/luci-static/resources/protocol/r11.js

'use strict';
'require rpc';
'require uci';
'require form';
'require network';


var callFileList=rpc.declare({object:'file',method:'list',params:['path'],expect:{entries:[]},filter:function(list,params)
{
  var rv=[];
  
  for(var i=0;i<list.length;i++)
    if(list[i].name.match(/^tty[A-Z]/)||list[i].name.match(/^cdc-wdm/)||list[i].name.match(/^[0-9]+$/))
      rv.push(params.path+list[i].name);
  return rv.sort();
}});


network.registerPatternVirtual(/^r11-.+$/);


function write_keepalive(section_id,value)
{
  var f_opt=this.map.lookupOption('_keepalive_failure',section_id),i_opt=this.map.lookupOption('_keepalive_interval',section_id),f=(f_opt!=null)?+f_opt[0].formvalue(section_id):null,i=(i_opt!=null)?+i_opt[0].formvalue(section_id):null;
  if(f==null||f==''||isNaN(f)) 0;
  if(i==null||i==''||isNaN(i)||i<1) i=1;
  if(f>0) uci.set('network',section_id,'keepalive','%d %d'.format(f,i));
  else uci.unset('network',section_id,'keepalive');
}


return network.registerProtocol('r11',
{

  getI18n:function()
    {return _('Mikrotik R11');},

  getIfname:function()
    {return this._ubus('l3_device')||'r11-%s'.format(this.sid);},

  getOpkgPackage:function()
    {return'comgt';},

  isFloating:function()
    {return true;},

  isVirtual:function()
    {return true;},

  getDevices:function()
    {return null;},

  containsDevice:function(ifname)
    {return(network.getIfnameOf(ifname)==this.getIfname());},

  renderFormOptions:function(s)
  {
    var o;
    o=s.taboption('general',form.Value,'_modem_device',_('Modem device'));
    o.ucioption='device';
    o.rmempty=false;
    o.load=function(section_id)
    {
      return callFileList('/dev/').then(
      L.bind(function(devices)
      {
        for(var i=0;i<devices.length;i++)
        this.value(devices[i]);return callFileList('/dev/tts/');
      },this)).then(
      L.bind(function(devices)
      {
        for(var i=0;i<devices.length;i++)
        this.value(devices[i]);
        return form.Value.prototype.load.apply(this,[section_id]);
      },this));
    };
    o=s.taboption('general',form.Value,'pdptype',_('PDP Type'));
    o.value('',_('-- Please choose --'));
    o.value('IP','IP');
    o.value('IPV6',_('IPV6'));
    o.value('IPV4V6',_('IPV4V6'));
    o=s.taboption('general',form.Value,'apn',_('APN'));
    o.validate=function(section_id,value)
    {
      if(value==null||value=='') return true;
      if(!/^[a-zA-Z0-9\-.]*[a-zA-Z0-9]$/.test(value)) return _('Invalid APN provided');
      return true;
    };
    o=s.taboption('general',form.Value,'pincode',_('PIN'));
    o.datatype='and(uinteger,minlength(4),maxlength(8))';
    s.taboption('general',form.Value,'username',_('PAP/CHAP username'));
    o=s.taboption('general',form.Value,'password',_('PAP/CHAP password'));
    o.password=true;
    //o=s.taboption('general',form.Value,'dialnumber',_('Dial number'));o.placeholder='*99***1#';
    if(L.hasSystemFeature('ipv6'))
    {
      o=s.taboption('advanced',form.ListValue,'ppp_ipv6',_('Obtain IPv6 address'));
      o.ucioption='ipv6';
      o.value('auto',_('Automatic'));
      o.value('0',_('Disabled'));
      o.value('1',_('Manual'));
      o.default='auto';
    }
    o=s.taboption('advanced',form.Value,'delay',_('Modem init timeout'),_('Maximum amount of seconds to wait for the modem to become ready'));
    o.placeholder='10';
    o.datatype='min(1)';
    o=s.taboption('advanced',form.Value,'_keepalive_failure',_('LCP echo failure threshold'),_('Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures'));
    o.placeholder='0';
    o.datatype='uinteger';
    o.write=write_keepalive;
    o.remove=write_keepalive;
    o.cfgvalue=function(section_id)
    {
        var v=uci.get('network',section_id,'keepalive');
        if(typeof(v)=='string'&&v!='')
        {
          var m=v.match(/^(\d+)[ ,]\d+$/);
          return m?m[1]:v;
        }
    };
    o=s.taboption('advanced',form.Value,'_keepalive_interval',_('LCP echo interval'),_('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
    o.placeholder='5';
    o.datatype='min(1)';
    o.write=write_keepalive;
    o.remove=write_keepalive;
    o.cfgvalue=function(section_id)
    {
      var v=uci.get('network',section_id,'keepalive');
      if(typeof(v)=='string'&&v!='')
      {
        var m=v.match(/^\d+[ ,](\d+)$/);
        return m?m[1]:v;
      }  
    };
    o=s.taboption('advanced',form.Value,'demand',_('Inactivity timeout'),_('Close inactive connection after the given amount of seconds, use 0 to persist connection'));
    o.placeholder='0';
    o.datatype='uinteger';
  }
});

Also I had to add:

/usr/lib/lua/luci/model/network/proto_r11.lua

local netmod = luci.model.network
local interface = luci.model.network.interface

local proto = netmod:register_protocol("r11")

function proto.get_i18n(self)
        return luci.i18n.translate("Mikrotik R11")
end

function proto.ifname(self)
        return "r11-" .. self.sid
end

function proto.get_interface(self)
        return interface(self:ifname(), self)
end

function proto.is_installed(self)
        return nixio.fs.access("/lib/netifd/proto/r11.sh")
end

function proto.opkg_package(self)
        return "comgt"
end

function proto.is_floating(self)
        return true
end

function proto.is_virtual(self)
        return true
end

function proto.get_interfaces(self)
        return nil
end

function proto.contains_interface(self, ifc)
        if self:is_floating() then
                return (netmod:ifnameof(ifc) == self:ifname())
        else
                return netmod.protocol.contains_interface(self, ifc)
        end
end

netmod:register_pattern_virtual("^r11%-%w")

Hope this is helpful to someone.