Support for MikroTik LtAP mini with R11e-LTE

@klukonin has already done most of the hard part of adding support for this router in his pull request and later improved in a branch. Similar patch has been also shared by @drwatson32.

All of the essentials like ethernet, wireless, sysupgrade, leds and reset work.

However, I'm struggling to get the mniPCIe modem working. The software part appears to have been solved with kmod-acm kmod-usb-net-rndis. Similar solution here.

The biggest pain is that the modem almost never shows up after triggering the relevant GPIO13, instead, I'm just getting a Marvell Nezha device with Vendor=1286 ProdID=8130:

lsusb

Bus 001 Device 006: ID 1286:8130 Marvell Semiconductor, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
cat /sys/kernel/debug/usb/devices

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  5 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs=  1
P:  Vendor=1286 ProdID=8130 Rev= 0.00
S:  Manufacturer=MARVELL
S:  Product=NEZHA
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 10mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
dmesg

[ 1114.475335] usb 1-1: new high-speed USB device number 5 using ehci-platform
[ 1114.677742] usb 1-1: config 1 interface 0 altsetting 0 bulk endpoint 0x81 has invalid maxpacket 64
[ 1114.687037] usb 1-1: config 1 interface 0 altsetting 0 bulk endpoint 0x2 has invalid maxpacket 64
[ 1148.524813] usb 1-1: USB disconnect, device number 5

Somehow, right on the very first couple of tries it did show up, but I couldn't replicate it since then:

cat /sys/kernel/debug/usb/devices

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  4 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2cd2 ProdID=0001 Rev= 1.00
S:  Manufacturer=MikroTik
S:  Product=R11e-LTE
S:  SerialNumber=000000000000
C #Ifs= 7 Cfg#= 1 Atr=c0 MxPwr=500mA
dmesg

[ 3375.219882] usb 1-1: new high-speed USB device number 4 using ehci-platform
[ 3380.541662] rndis_host 1-1:1.0 eth1: register 'rndis_host' at usb-ehci-platform-1, RNDIS device, ac:ff:ff:00:00:100  

I think we could be missing a GPIO to disable the USB power. Interestingly though, there seems to be nothing like that in the ROS 6.44 patch:

+static struct platform_device ltap_hb_led_device = {
+	.name	= "leds-rb",
+	.id	= -1,
+	.dev	= {
+		.platform_data = &(unsigned[]) {
+			PLD(user_led, 14, GPIO),
+			PLD(wlan_led, 11, GPIO),
+			PLD(sfp_led, 4, GPIO),
+			PLDI(button, 16, GPIOLIB),
+			PLDI(mode_button, 3, GPIOLIB),
+			PLDI(pcie_power_off, 13, GPIOLIB),
+			PLD(sim_select, 15, GPIOLIB),
+                        PLED(gps_mux, 0, GPIOLIB, PLED_CFG_KEEP),
+                        PLD(gps_ant_select, 1, GPIOLIB),
+                        PLD(gps_reset, 2, GPIOLIB),
+			0
+		},
+	},
+};

What firmware version is running on the modem? at+cgmr?
I have a bunch of these (and R11e-4G's also) and I'm currently playing with them in order to also support these.

They have a different AT command set to start with .. (joy..)
as seen in in ROS when enabling LTE prints.

@xback this is the version of the modem I have:

/interface lte at-chat lte1 
input: AT+CGMR 
  output: +CGMR: "MikroTik_CP_2.160.000_v008"
OK

More info (without SIM):

/interface lte info lte1 once        
  functionality: tx and rx rf circuit disabled
   manufacturer: "MikroTik"
          model: "R11e-LTE"
       revision: "MikroTik_CP_2.160.000_v008"

Latest version would be:

/interface lte firmware-upgrade lte1 
  installed: MikroTik_CP_2.160.000_v008
     latest: MikroTik_CP_2.160.000_v013

More info (with SIM and correct APN):

/interface lte info lte1 once 
           pin-status: ok
  registration-status: roaming
        functionality: full
         manufacturer: "MikroTik"
                model: "R11e-LTE"
             revision: "MikroTik_CP_2.160.000_v013"

USB ports:

/system resource usb print 
 # DEVICE VENDOR                                 NAME                                SPEED                               
 0 1-0    Linux 3.3.5 ehci_hcd                   RB400 EHCI                          480                                 
 1 1-1    MikroTik                               R11e-LTE                            480

So, I've just upgraded the modem firmware to latest version and booted the openwrt initramfs, and the modem showed up:

cat /sys/kernel/debug/usb/devices

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 4.14
S:  Manufacturer=Linux 4.14.146 ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=ehci-platform
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2cd2 ProdID=0001 Rev= 1.00
S:  Manufacturer=MikroTik
S:  Product=R11e-LTE
S:  SerialNumber=000000000000
C:* #Ifs= 7 Cfg#= 1 Atr=c0 MxPwr=500mA
A:  FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=03
A:  FirstIf#= 2 IfCount= 2 Cls=02(comm.) Sub=02 Prot=01
A:  FirstIf#= 4 IfCount= 2 Cls=02(comm.) Sub=02 Prot=01
I:* If#= 0 Alt= 0 #EPs= 1 Cls=e0(wlcon) Sub=01 Prot=03 Driver=rndis_host
E:  Ad=8c(I) Atr=03(Int.) MxPS=  16 Ivl=4096ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host
E:  Ad=8e(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=0d(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=01 Driver=cdc_acm
E:  Ad=84(I) Atr=03(Int.) MxPS=  16 Ivl=4096ms
I:* If#= 3 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm
E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 4 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=01 Driver=cdc_acm
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=4096ms
I:* If#= 5 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm
E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 6 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=8b(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=0a(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
dmesg

[   14.768275] cdc_acm 1-1:1.2: ttyACM0: USB ACM device
[   14.786782] cdc_acm 1-1:1.4: ttyACM1: USB ACM device
...
[   17.037983] rndis_host 1-1:1.0 eth1: register 'rndis_host' at usb-ehci-platform-1, RNDIS device, ac:ff:ff:00:00:100 
ls -lh /dev

crw-rw----    1 root     dialout   166,   0 Oct  5 12:51 ttyACM0
crw-rw----    1 root     dialout   166,   1 Oct  5 12:51 ttyACM1
lsusb

Bus 001 Device 002: ID 2cd2:0001
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Rebooted to initramfs again... and the modem is still there.

Flashed sysupgrade... and it's still there.

Rebooted again... still there. Honestly, not sure what to think. All that I did was:

  1. Install latest stable ROS (6.45.6)
  2. Connect with the modem to the network, had to enable roaming
  3. Upgrade the modem over its own connection
  4. Flash the same OpenWRT which I've already tested before

Here's a full successful connection log from ROS:

00:13:17 lte,async,event +CGEV: ME DETACH 
00:13:17 lte,async,raw +CREG: 0 
00:13:17 lte,async lte1: rcvd OK 
00:13:17 lte,async lte1: sent AT+CREG=2 
00:13:17 lte,async lte1: rcvd OK 
00:13:17 lte,async lte1: sent AT+CGREG=2 
00:13:17 lte,async lte1: rcvd OK 
00:13:17 lte,async lte1: sent AT+CEREG=2 
00:13:17 lte,async lte1: rcvd OK 
00:13:17 lte,async lte1: sent AT+CGEREP=2,0 
00:13:17 lte,async lte1: rcvd OK 
00:13:17 lte,async lte1: sent AT+CMGF=0 
00:13:17 lte,async lte1: rcvd OK 
00:13:17 lte,async lte1: sent AT+CNMI=1,1,0,1,0 
00:13:17 lte,async lte1: rcvd OK 
00:13:17 lte,async lte1: sent AT+EEMOPT=1 
00:13:17 lte,async lte1: rcvd OK 
00:13:17 lte,async lte1: sent AT*MRD_SN? 
00:13:17 lte,async lte1: rcvd  
00:13:17 lte,debug lte serial:  
00:13:17 lte,async lte1: sent AT+CFUN=4 
00:13:18 lte,async,event *MRD_SN:redacted 
00:13:18 lte,async lte1: rcvd OK 
00:13:18 lte,async lte1: sent AT*CGDFLT=0,"IP","em",,,,,,,,,,1,0,,,,,,,1 
00:13:18 lte,async lte1: rcvd OK 
00:13:18 lte,async lte1: sent AT*CGDFAUTH=0,0 
00:13:18 lte,async lte1: rcvd OK 
00:13:18 lte,async lte1: sent AT+CPIN? 
00:13:18 lte,async lte1: rcvd  
00:13:18 lte,async,event +CPIN: READY 
00:13:22 lte,async lte1: sent AT+CPMS="SM","SM","SM" 
00:13:22 lte,async lte1: rcvd +CPMS: 0,20,0,20,0,0 
00:13:22 lte,async lte1: sent AT+CFUN? 
00:13:22 lte,async lte1: rcvd +CFUN: 4 
00:13:22 lte,async lte1: sent AT+ICCID? 
00:13:22 lte,async lte1: rcvd +ICCID: redacted
00:13:22 lte,async lte1: sent AT+CNUM 
00:13:22 lte,async lte1: rcvd +CME ERROR: 100 
00:13:22 lte,async lte1: sent AT+CIMI 
00:13:23 lte,async lte1: rcvd redacted 
00:13:23 lte,async lte1: sent AT+CPIN? 
00:13:23 lte,async lte1: rcvd +CPIN: READY 
00:13:23 lte,async lte1: sent AT*BAND=15,78,147,160,524487,0,2,0 
00:13:23 lte,async lte1: rcvd OK 
00:13:24 lte,async lte1: sent AT+COPS=0 
00:13:24 lte,async lte1: rcvd OK 
00:13:24 lte,async lte1: sent AT+CFUN=1 
00:13:24 lte,async,raw +CREG: 2 
00:13:24 lte,async,raw +CEREG: 2 
00:13:24 lte,async lte1: rcvd OK 
00:13:24 lte,async lte1: sent AT+COPS=3,0 
00:13:24 lte,async lte1: rcvd OK 
00:13:24 lte,debug lte1: config ok  
00:13:24 lte,async,raw lte1: sent AT+CFUN? 
00:13:24 lte,async,raw lte1: rcvd +CFUN: 1 
00:13:24 lte,async,raw lte1: sent AT+CSQ 
00:13:24 lte,async,raw lte1: rcvd +CSQ: 99,99 
00:13:27 lte,async,raw lte1: sent AT+CSQ 
00:13:27 lte,async,raw lte1: rcvd +CSQ: 99,99 
00:13:30 lte,async,raw lte1: sent AT+CSQ 
00:13:30 lte,async,raw lte1: rcvd +CSQ: 99,99 
00:13:33 lte,async,raw lte1: sent AT+CSQ 
00:13:33 lte,async,raw lte1: rcvd +CSQ: 99,99 
00:13:36 lte,async,raw lte1: sent AT+CSQ 
00:13:36 lte,async,raw lte1: rcvd +CSQ: 99,99 
00:13:39 lte,async,raw lte1: sent AT+CSQ 
00:13:39 lte,async,raw lte1: rcvd +CSQ: 99,99 
00:13:42 lte,async,raw lte1: sent AT+CSQ 
00:13:42 lte,async,raw lte1: rcvd +CSQ: 99,99 
00:13:43 lte,async,raw +CREG: 5, redacted, redacted, 7 
00:13:43 lte,debug lte1: network access technology: Evolved 3G (LTE) 
00:13:43 lte,info lte1: registered roaming

Some useful commands to note:

Set technology (all bands enabled)

AT*BAND=??,78,147,160,524487,0,2,0

1 = 0001 - 3G
5 = 0101 - 4G
11 = 1011 - 3G+4G
15 = 1111 - GSM+3G+4G

Set roaming

AT*BAND=15,78,147,160,524487,??,2,0

1 - enable roaming
0 - disable roaming

Set default APN to "myapn"

AT*CGDFLT=0,"IP","myapn",,,,,,,,,,1,0,,,,,,,1

I have some working code, but can't publish it because of NDA agreement.

So... may be I can inject r11e support inside current netifd 3g protocol.

What do you think?

Would be great!

Hey there guys,
I've just bought Mikrotik LtAP LTE6 kit and I'd aim to install OpenWRT on this device - to be able to use multipath TCP.

Have you tried that? I'm totally green in OpenWRT world.
Is it even possible to do that?

Hi, were you successful? I'm interested in this HW and was about to buy it but I would rather have a peace of mind to know it actually is somehow manageable to get OpenWRT up and running. :innocent: