OpenWrt and XS Stick P14

This is a quick and dirty howto on how you can make an XS Stick P14 work on OpenWrt Barrier Braker 14.07.

The XS Stick is a USB 3G dongle/modem. It behaves the same brain damaged way like many others: when you first plug it in, the host detects a USB optical drive, which contains the Windows & OS X drivers. You need the usbmode utility to switch it into modem mode. Then the kernel detects the newly appeared USB serial ports, which could be used by pppd to establish an internet connection.

Unfortunately the configuration supplied by Barrier Braker for usbmode is incorrect, you need to apply this patch if you want to make it work:

$ diff -u usb-mode.json.original usb-mode.json
--- usb-mode.json.original	2015-03-02 23:11:26.000000000 +0100
+++ usb-mode.json	2015-03-02 23:11:52.000000000 +0100
@@ -2351,16 +2351,16 @@
 			}
 		},
 		"1c9e:f000": {
-			"*": {
+			":uMa=USB_Modem": {
 				"t_vendor": 7326,
 				"t_product": [ 36864, 38403, 38405, 38407, 39168 ],
-				"msg": [ 39 ],
+				"msg": [ 14 ],
 				"wait": 1
 			},
-			":uMa=USB_Modem": {
+			"*": {
 				"t_vendor": 7326,
 				"t_product": [ 36864, 38403, 38405, 38407, 39168 ],
-				"msg": [ 14 ],
+				"msg": [ 39 ],
 				"wait": 1
 			}
 		},
$
The patch changes the issued command, the correct one is the 14th element of the msg array.

My dongle uses the following ID's:
USB ID before mode switch 1c9e:f000
USB ID after mode switch 1c9e:9605

So in theory, the default configuration would also work. But it does not. How did I find this out? I already had this stick working with 12.09 (Attitude Adjustment), so I knew the correct mode switch command string was 55534243123456788000000080000606f50402527000000000000000000000. If you grep for this string, you can see it's msg[14]. I have no idea why the OpenWrt developers put the wildcard device name to the first place and the more specific ":uMa=USB_Modem" to the second.

Comments and suggestions are welcome, you can find me as adiz0r on Twitter.

- Gabor Adorjani