Tuesday 27 March 2012

Vodafone K5005 (Huawei E389) 4G modem on Ubuntu

This modem works with Ubuntu Precise Pangolin (12.04) but it is not detected automatically by network manager.

UPDATE: In the comments, a reader named "Big Brother" has a nicer solution, instead of using the scripts below, just follow this steps:

1- Add these lines to /lib/udev/rules.d/40-usb_modeswitch.rules:
# Vodafone K5005 (Huawei E398)
ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="14c3", RUN+="usb_modeswitch '%b/%k'"
2- Create file /etc/usb_modeswitch.d/12d1:14c3:
# Vodafone K5005 (Huawei E398)
TargetVendor= 0x12d1
TargetProduct= 0x14c8
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
3- Unplug device, plug it back and it should work automagically ;)

Deprecated method:
In order to get it working with network manager I have to use the following script (it must be ran as root):
#!/bin/bash
rmmod option
modprobe option
echo "12d1 14c8" > /sys/bus/usb-serial/drivers/option1/new_id
usb_modeswitch -v 12d1 -p 14c3 -V 12d1 -P 14c8 -M "55534243123456780000000000000011062000000100000000000000000000" -n 1
Note that the commands above are for the Vodafone branded (K5005) Huawei E389 dongle, for the unbranded device the product ID is different and you should use:
#!/bin/bash
rmmod option
modprobe option
echo "12d1 1506" > /sys/bus/usb-serial/drivers/option1/new_id
usb_modeswitch -v 12d1 -p 1505 -V 12d1 -P 1506 -M "55534243123456780000000000000011062000000100000000000000000000" -n 1
You can check the product id with:
lsusb
In my case I get:
Bus 002 Device 007: ID 12d1:14c3 Huawei Technologies Co., Ltd.

Possibly Related Posts

8 comments:

  1. Thank you for this tutorial mate!
    A question: why do you use 14c8 when in fact the lsusb gives you 14c3??

    would it be possible for you to explain what these parameters mean? sudo usb_modeswitch -v 12d1 -p 1505 -V 12d1 -P 1506 -M

    thank you!

    ReplyDelete
    Replies
    1. I use what worked for me :P

      14c3 is the default ID of the original mode (when the modem is detected as a storage device)
      14c8 is the target mode, I got that ID from trial and error...

      Delete
  2. Just a tip (works for me on a fresh ubuntu 12.04 lts install where i'm running broadband pen connection for the very first time).

    If you can't find /sys/bus/usb-serial/drivers/option1/new_id (/sys/bus/usb-serial does not exist) run:
    sudo modprobe -v option

    After this path will be allways available and you may run Luis Davim's script whenever you want (after you run Luis's script you will be prompted for pen pin, if any)


    Also, after script (must be ran each time you need to connect - I'll investigate a way for auto-run this later) and if is your first time connecting using Vodafone 4g pen, you must:
    1. run "Network Connections" from "Dash home" (or "nm-connection-editor" from command line)
    2. under "Mobile BroadBand" tab add a new device by clicking "Add"
    3. click "Continue" (after check if "Vodafone Group (Huawai) Vodafone Mobile Broadband (Huawai)" is selected under "Create a connection for this mobile broadband device:")
    4. select your country and click "Continue"
    5. select "Vodafone" provider and click "Continue"
    6. now leave defaults(Plan: default, APN: internet.vodafone.pt <- for me) and click "Continue"
    7. click "Apply"
    8. you do not need to change anything on the new window, but you can change "Connection name" and set to "Connect automatically" if you want, and finally click "Save..."

    Now your pen is listed on "Network Connections" app, under "Mobile Broadband" tab.
    To connect just click at connection icon at top right of desktop bar (wifi icon) and you'll see your new connection available. Click on it to connect.

    Cheers!

    ReplyDelete
  3. Thanks to you all, my K5005 is working! Cheers!

    ReplyDelete
  4. For Ubuntu 12.04:

    - Add these lines to /lib/udev/rules.d/40-usb_modeswitch.rules:
    # Vodafone K5005 (Huawei E398)
    ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="14c3", RUN+="usb_modeswitch '%b/%k'"

    - Create file /etc/usb_modeswitch.d/12d1:14c3:

    # Vodafone K5005 (Huawei E398)

    TargetVendor= 0x12d1
    TargetProduct= 0x14c8

    MessageContent="55534243123456780000000000000011062000000100000000000000000000"

    - Unplug device, plug it back and it should work automagically ;)

    ReplyDelete
  5. Thanks to Big Brother, got my E389 modem to work on Debian laptop, connecting to Swedish Tele2. Tele2 support wash their hands of Linux, just refer to some Huawei software which does NOT work. So huge thanks once more.

    ReplyDelete
  6. I have just reinstalled wheezy on my HP Pavilion dm1, again using the Huawei E398 obtained from Tele2, Sweden, and now find the following:
    - lsusb shows the device ID to be 1506
    - /lib/udev/rules.d/40-usb_modeswitch.rules already contained the line proposed by Big Brother
    - I inserted a line with device ID 1506 instead of 14c3
    - I made a file in /etc/usb_modeswitch.d/ 12d1:1506 with the content suggested (switching mode to whatever 14c8 would call for)
    - I found that that file was superfluous, just took it away and the modem still connects
    - for anyone working in Sweden with Tele2, in the Edit Network Connection dialogue I have APN 4g.tele2.se, Connect Automatically and System Connection are checked, PIN setting is Not Required.
    Hope this may be helpful.

    ReplyDelete