Provisional success with usb_modeswitch on Adam / Android

Heyas!

[Update: The modems are working now!  See my newer blog post, and this thread on TabletROMs.]

I have good news with a caveat, if you are a pessimist, but if you are an optimist, I have bad news with saving grace.

Remember my effort to get USB datamodems (3G and EVDO) working on the Adam with usb_modeswitch?

I had to stop short of running usb_modeswitch on the Adam due to the missing support in the kernel for some drivers (usb-serial and option, i.e. gsmmodem).  Of course, getting the said support added had been held up because Notion Ink had not released the kernel source, nor pointed to where we could get it.

Later, someone leaked the kernel source related to the Adam, and Notion Ink followed it up with their official release.  Thank goodness.

I had been asking everyone I met (well, the hackers / developers at least) on the forums if someone could compile a kernel for me with the requisite support.  I am very happy to say that the person better known to Android tablet owners as MrGuy sent me a modified kernel and a driver for Option modems [CAUTION: these files are for testing purposes only. Use them at your own risk!].

I have now installed the kernel on the Adam, and inserted the driver module by following these steps:

  1. Download the latest recovery files from Notion Ink.  Use this FAQ to learn more.
  2. Extract the files to a folder on your hard drive
  3. Download / copy the kernel image (Boot2.img) and the module (option.ko) linked above to this folder, where you will also find the nvflash utility
  4. Connect the Adam via USB to your computer and switch it on in the recovery mode (press Vol ‘-‘ and Power On)
  5. Depending on whether you have run the recovery mode earlier, you may or may not need to add drivers if prompted by Windows.  Follow these steps if prompted.  Follow the steps for Linux if you are on a Linux PC.
  6. Once it boots to the APX recovery mode (blank screen), run the command shell on Windows and enter the following command: nvflash --bl bootloader.bin --getpartitiontable parttable.txt
  7. This will create a file named parttable.txt, which lists all the partitions on the Adam’s internal memory
  8. Identify the partition number denoted by the label LNX.  It will be 8 or 9, depending on the version of nvflash / recovery file used
  9. Run the command: nvflash -r --download X Boot2.img (where X is the number of the LNX partition you have noted down) [in case you happened to disconnect or reboot the Adam after Step 6, run nvflash --bl bootloader.bin --download X Boot2.img instead]
  10. This should flash the new kernel to the appropriate location. If successful, shut the Adam down, reboot into normal mode
  11. Next, you need to copy the option.ko file to /system/lib on the Adam.  There are some alternative methods for doing this:
  12. Alternative 1: if you have a rooted Adam (obviously), open a terminal emulator, become root, and issue mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system to make /system writable. Then proceed to copy the file to /system/lib or any other folder you think is better suited for it, then run /system/xbin/insmod /PATH/TO/option.ko (replace /path/to/ with the actual path to where it has been copied).  Run /system/xbin/lsmod to check if the option module has been loaded.  Proceed to Step 17.
  13. Alternative 2: If you are masochistic, download the Android SDK and Android USB Driver for Windows, install the SDK and then modify the driver according to instructions here, connect Adam powered up normally, update driver to modified driver, and then proceed to Step 15 if successful, else Step 14
  14. If you are at Step 13 and after connecting the Adam to Windows, you don’t see the driver installation prompt, you may need to uninstall the driver actually in use (if you see the Adam connected with a Mass Storage Driver), by using this utility.  You may need to run the utility with Administrator rights.  Look for the Mass Storage driver for NI Adam USB device.  Once you uninstall it, plug the Adam in again.  Windows will reinstall the drivers, and probably install one for Android Debug Bridge from Windows Update.  If this happens, you can go to device manager, switch to ‘View Devices By Connection’ view, locate the Adam with the said ADB driver, and update the driver to the one modified as per Step 13.  Now, check if your device registers with Windows and ADB by issuing the command adb devices (the command prompt needs to be in the directory ‘platform-tools’ within the tree where you installed Android SDK).  If you see something listed, you’re through.  At this point, you will realise that a third alternative, that of using Linux would have been much better as it does not require a USB driver for ADB.
  15. Next, make /system on the Adam writable by issuing adb remount. Then push the kernel object to the Adam by running adb push /PATH/TO/option.ko /system/lib (again, replace /PATH/TO/ with actual path, and you can use another folder instead of /system/lib if you think that is a better idea).
  16. Reboot the Adam normally, (disconnect it from your PC as it might obstruct access to the internal sdcard, but do so safely), go to Terminal Emulator, become root, and run /system/xbin/insmod /PATH/TO/option.ko (replace /path/to/ with the actual path to where it has been copied).  Run /system/xbin/lsmod to check if the option module has been loaded.  If you get any permission denied errors for insmod, make the /system folder writable by issuing mount -0 rw,remount -t yaffs2 /dev/block/mtdblock3 /system
  17. Now read my earlier post again, and proceed according to the steps mentioned therein, starting at number 4.
  18. After you complete the 21st step as per the old post, you need to make the Option driver aware of the switched ID of your modem on the fly.  Issue the command echo "12d1 140b" > /sys/bus/usb-serial/drivers/option1/new_id as root (replace “12d1 140b” with the ID specific to your modem. I use a Huawei EC1262.  Instructions in the old post).  You see that path?  The original NI kernel did not have the usb-serial support necessary, and hence that path was missing.
  19. Now follow instructions of step 22 and 23 in the old post.  If everything goes well, you should see an output from usb_modeswitch that says it found and switched your modem.  Now run dmesg, and check if its output looks like this one. If it matches, you’re successful.  Congrats!  Now your 3G USB modem can run on the Adam!

Now the bad part, as I have discovered.  I have been able to get usb_modeswitch to run on my Adam, and get it to correctly identify and switch the modem.  However, when it comes to using the modem, I am stuck, because the kernel still lacks PPP support.

I need PPP to use dialer scripts to dial the modem and get it connected.  As of now, /system/etc/ppp is empty except for a VPN driver, and it seems Notion Ink did not include the requisite kernel modules or system libraries.  It should be trivial to add this support though, and MrGuy is our guy.

I have asked MrGuy for help, and hopefully he will send me a new kernel with all requisite support compiled in it.  Once I am successful, I will post again with sample dialer scripts etc.  You can view the hints in the original thread on draisberghof.de.

Once I am through with all of this, I will write a clean and lean how-to, so that my readers don’t get put off by all these recursive steps and my weird sense of humour.

Lastly, I hope someone at Notion Ink takes note of all of this, and gives us an update that includes a kernel with (a) usb-serial support; (b) ppp support; (c) option modem driver; and a modem manager that can be used from the GUI, for configuring and dialing a USB modem.  Is it too much to ask?

Advertisements

About ND

carbon-based life form, prefers science, rationality and freedom
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Provisional success with usb_modeswitch on Adam / Android

  1. aneeska says:

    Hi Nishit,

    I am glad I found your blog. I am having a similar problem. I am trying to bring up Reliance Netconnect on Froyov2.2.

    After following your instructions, when I a run ‘usb_modeswitch’, this is what I see. (result obtained through strace.)

    open(“/dev/bus/usb”, O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOENT (No such file or directory)
    open(“/proc/bus/usb”, O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3
    fstat64(3, {st_mode=S_IFDIR|0555, st_size=0, …}) = 0
    fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
    getdents(3, /* 2 entries */, 1024) = 32
    getdents(3, /* 0 entries */, 1024) = 0
    close(3) = 0
    write(2, “usb_set_debug: Setting debugging”…, 50usb_set_debug: Setting debugging level to 15 (on)
    ) = 50
    write(2, “USB error: couldn\’t opendir(): N”…, 57USB error: couldn’t opendir(): No such file or directory
    ) = 57
    write(1, “\n”, 1
    ) = 1
    write(1, “Looking for target devices …\n”, 31Looking for target devices …
    ) = 31
    write(1, ” No devices in target mode or cl”…, 42 No devices in target mode or class found
    ) = 42
    write(1, “Looking for default devices …\n”, 32Looking for default devices …
    ) = 32
    write(1, ” No devices in default mode foun”…, 56 No devices in default mode found. Nothing to do. Bye.

    Any idea why this is so?

    usb_modeswitch version – 1.1.2alpha

    • Nishit says:

      Hi Aneeska,

      Which device are you on? You first need to determine if the directory tree /proc/bus/usb and /dev/bus/usb exist on your file system. Does it support USB devices like pen drives? Secondly, you need to mount USBFS thus:
      mount -t usbfs usbfs /proc/bus/usb
      which would get rid of the ‘Could not Opendir()’ error, but as you see, you need the path /proc/bus/usb to exist.

      Lastly, you should upgrade usb_modeswitch to the latest 1.1.7 static compiled version.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s