Tuesday, July 24, 2012

Cisco Linksys AE3000 WiFi USB Dongle and Linux Driver Installation

So, back again with yet another geek niggle! This time its to do with drivers. 

[ Bored of the  crap that i  have written, jump to the bottom directly, to install the driver :). ]

I was wanting to experiment something with setting up a web server and was very excited to get to work right away! There goes, formatted my personal computer, and installed Ubuntu 12.04 Precise Pangolin. I have a 8GB RAM, good enough eh!, won't compromise with the 32 bit edition, so went for the 64 bit edition. Downloaded the live cd, installed, and was all thrilled to my desktop. Of course i installed it using wired ethernet that ran across my house much to the cribbing's from my wife. I installed ubuntu-desktop as well, for some reason known only to me, and unplugged my wired cable, plugged in my shinny new Cisco AE3000 just to find out that neither ndiswrapper nor compiling driver from the chip-set vendor would work. Mere frustration, without Internet. 

Finally decided to dig into the bare metal, and figured a working solution. Why ndiswrapper when you can get it working natively? So ventured into it, and after 30 minutes of trials and errands, got the "Blue LED" blinking!! and thought might as well share it here, so that someone could benefit from it.

First, why it won't work either way.

1. NDISWRAPPER 1.57(the default that ships with Ubuntu 12.04) needs the 64 bit windows driver, and cisco does not ship the driver with the CD that is included with the WiFi dongle or is it available in the CCO website. I tested using the ndiswrapper on a 32bit ubuntu and even then it complained and was not working. So if you use the "x86" driver under the Windows XP folder in the package cd (Don't use Windows Vista or Windows 7 drivers with ndiswrapper, they are not supported for any cards AFAIK) you could get an error saying "64 bit kernel detected by ndiswrapper". So bottom line it won't work.

2. Option 2, rt2800usb the default module for majority of Ralink chipsets, that comes included with the kernel does not support RT3573 (the chipset used in Cisco AE3000) chipsets. Why? rt3573 is a 3x3 chipset, a relatively new one to linux kernel, and development work is on-going.

3. So! why not go to the chipset vendor and ask for the driver? Thank god it is OPENSOURCE !! Problem, compilation works, module gets installed, but the "Blue LED" won't blink !!!  why ! because it still doesn't recognize the usb device as a WiFi dongle. The AE3000 is not part of the usb device table.

So solution!., start coding!

1. Download and extract the source (provided here). Extract it anywhere doesn't matter.

2. Navigate to the source folder.

3. Make sureyou have "g++", "build-essential" and "linux-headers" installed.

[The above steps are pretty basic, so i'm not posting the commands]

4. Navigate to the following folder and open the file below in your favorite editor.

cd <driver-source-folder>
vim common/rtusb_dev_id.c

5. Look for the following lines, and add the line highlighted in bold. 
[Note: the line highlighted in bold, is the only change you need to make. Its vendor id for Cisco AE3000.]

#ifdef RT3573
    {USB_DEVICE(0x148F,0x3573)}, /* Ralink 3573 */
    {USB_DEVICE(0x7392,0x7733)}, /* Edimax */
    {USB_DEVICE(0x0B05,0x17AD)}, /*ASUS */
    {USB_DEVICE(0x13B1,0x003B)}, /* Cisco LinkSys AE3000 */
#endif /* RT3573 */

6. Close the file, and compile and install the driver.

sudo make -j10 <------- "sudo" is needed
sudo make install

sudo depmod -a
sudo modprobe -v rt3573sta

Bingo !! LED will blink and your device is ready to use.

Easy Enough !! Please add a '+1' :p :) !!

Sunday, December 18, 2011

Loading ICE CREAM SANDWICH on a Verizon CDMA Samsung Galaxy Tab

[Disclaimer: Contents in this post, could lead to bricking your tablet. Do not blame me for a burnt tablet. You will try it under your own responsibility. My only contribution is putting all the steps that i went through and have shared my personal experiences and emotions in this blog. As such the low level kernel stuffs were done by many many geniuses, and their links are spread all over the internet in XDA, Rootzwiki, MyDroidWorld and many many other forums]

OK with the disclaimer on , just protected myself against any potential law suits :).
Fine now, getting my hands dirty on my first ever experimental rooting stuffs. Honestly, i have never tried rooting until this post.
I purchased my first tablet computer, the Verizon CDMA 7" Galaxy Tab in February. I have heard stories of people experimenting with custom ROM and Cyanogen Mod, honestly i had appreciated all their work only by reading the posts. All of a sudden, at the stroke of a lightening, i realized, "why not experiment for myself, what worse could happen, i would end up with a 200$ brick!, (Well!, that is not entirely true!!, you will see why in my experiences below - in short, i bricked my galaxy tab 17 times!! before i got it all right, so don't panic, unless you are extremely careless, you can still recover it! [ read the disclaimer].
Through all my search and findings, which was fruitful in a way!, i envisioned writing my experiences in this blog as a one shot hub which amalgamates all the steps that are required right from stock factory sealed to ice-cream sandwich(Android 4.0.1) rooted tablet. I will try to include all the software's that i had used and post as many links that are required to get the tasks done.

[Working in this ICS ROM]
1. wifi little flaky while re-scanning networks, but its ok for alpha. Connection works perfectly.
2. bluetooth
3. GPS
4. Sdcard

[Please let me know if any links does not work, i shall repost them. If any step fails, please let me know, i will update it correctly]
[If you bricked your device because of the steps, most like you can unbrick it using heimdall - steps mentioned below to stock rom, but use under your own risk.]

Ok enough said, now to work!

1. Get a Samsung Galaxy tab from some retail store or online. If you are like me, owning a CDMA Verizon Galaxy Tab, read on!.

2. The steps are __only__ for Verizon CDMA Galaxy Tab, i have not tried this on  any other device.

3. If you have the stock Froyo, Lets first upgrade that. We need to have a rooted ROM to install ClockWorkMod(CWM). CWM is an application by itself, which facilitates easy installation of custom ROMs, on android devices.

4. Installing Heimdall 1.1.1: Grab Heimdall. Heimdall is a tool used to flash kernel and ROM (aka firmware). At the time of writing, Heimdall is at 1.3.1, but I'm old school, and i always preferred 1.1.1 and it has worked well for me. I will therefore stick with it and the software can be obtained from the Heimdall download link.

5. Extract the compressed file to a folder, and keep it aside, we will come back to this later.

6. Installing Windows USB device drivers for your Galaxy Tab: Download the Samsung Galaxy Tab Windows 7(or your appropriate OS) USB driver from the link. The link will lead to installation of Samsung Kies software. Connect your tab to the PC, and install the driver using Samsung Kies software.

7. Now launch the "Zadig" software from the extracted Heimdall folder, which is under the "Drivers" folder of the extracted Heimdall tool.
8. Under "Options" select "List all Devices, and if you had installed the USB device driver correctly in the earlier steps, you will find "Samsung Android Composite ADB Interface" under the "USB Devices" drop-down list.

9. Now choose "Install Driver", and accept the warning message. This is a one time process and from now on, you wouldn't have to repeat the steps 6 through 9.

10. Flashing a rooted Verizon Stock Gingerbread kernel: I got my rooted stock ROM from the link, and details on how to flash is below or you could refer to the post at XDA.

11. Place the Galaxy Tab in Download mode. Power off the device. Power on again by holding the "Power + Volume Down" buttons together for about 3-4 seconds. You will see a "Downloading Message".

12. Open the "heimdall-frontend.exe" from the extracted heimdall folder.
13. Place all the files from the extracted stock ROM in the correct locations. [It is very important that you do this step correctly, if you need your galaxy tab]
FactoryFS = factoryfs.rfs
Kernel (zImage) = zImage
Param.lfs = param.lfs
Cache = cache.rfs
Database Data = dbdata.rfs
Recovery = recovery.bin

14. Once the files are placed appropriately, click "Start". Please wait patiently for sometime and your galaxy tab will reboot by itself once the process is completed successfully. You may have to push "Start" couple of times before it works correctly.
15. Once the Tab reboots, power down the tab immediately [do not let it power up fully, after flashing].

16. Power up again in recovery mode by holding the "Power + Volume Up" buttons together for about 3-4 seconds and once you see the "Samsung" Logo still continuing to hold the "Volume Up" button leave the "Power" button. You will see a "Recovery mode". This is "Android System Recovery" software, not ClockWorkMod recovery[we will install this later].
17. Once in recovery, use the "Volume" buttons to navigate up or down and the "Home" button for "Enter" key. Wipe "data/cache" and "cache" partitions, and reboot.
18. You now have a fully working "Rooted Verizon Stock Gingerbread 2.3.5" with RFS partition system format[what this is, i will come to it later]. You can stop at this point if you feel so.
19. Converting File System to EXT4: Now, we need to convert our file system to EXT4 partition type. Why? because it will be faster!, user experience and app loading will be better off in EXT4 format and for the ICS port that I'm using, it is required that you have already a Gingerbread boot loader on a EXT4 partition. I was originally stuck here for long hours, until some experimentation.
20.  I navigated to the forum in RootzWiki by [Cdma] [Vzwtab] Cm7 Beta-Kang [Unofficial] 11/01. I grabbed the recovery tool which is ClockWorkMod [ Copyright notice - This link is from my ftp site, but all copyrights and ownership belongs to the original author of ClockWordMod tool. Since the original  download link no longer exists, i have placed a copy of the file in my FTP for convenience and download. ]
21. Before proceeding any further, it is very important that you have all the future files mentioned below in your Galaxy Tab's SDCARD. Do so if you don't want to repeat all the steps mentioned above again. 
22. I grabbed the CM-7.1 ROM from the above forum as well. Then i navigated to this forum for fetching the AOSP ICS / CM9 for the CDMA Build 3 ROM and the corresponding google apps. [ Upgrading to any AOSP ICS Build is up to the discretionary of the end user. I would recommend reading the cautionary notes from the original post, I'm not responsible for burned boards. Also the later builds e.g Build 5 onward, the file-system is again changed. I would recommend, first upgrading to Build 3 and then Build 7. ]

Connect your Tab to the PC and mount the SD Card and copy the downloaded files to your sdcard. [Do not extract the zip file. Copy the zip file.]

23. Flash CWM Now open heimdall-frontend again. Place your Galaxy tab in download mode as explained in step 11. In Heimdall, place all the files in the correct locations. [It is very important that you do this step correctly, if you need your galaxy tab]
Kernel (zImage) = zImage [ from unzipped CWM tar file]
Recovery = recovery.bin
[ from unzipped CWM tar file]

24. Galaxy Tab will reboot and put it in recovery mode as explained in step 16. Now unlike the earlier "Android Recovery Manager" you will see a "ClockWorkMod" recovery manager. This will have more options than the earlier one. If you don't see this, then something is wrong, and let me know, i will see if some steps have been missed. But on reboot, you should still have a rooted gingerbread.

25. Update to CM7.1:  In the recovery mode(Volume Up/Down - navigation and "Power" button is Enter key, navigate to "mounts and storage" and Format only the following "/system, /data, /cache". Hit "Go Back" and "Wipe data/factory reset and cache partition"

26. Select "Install zip from sdcard" and select your zip file, and select your custom ROM. "Select the CM-7.1 ROM". It is very important you first select this because, this ROM installation will convert your partition type from RFS to EXT4 automatically.

27. Reboot and enjoy fully working CM7.1 gingerbread ROM. You can stop here if you wish or proceed further for ICS, but this is a very stable ROM from my personal usage perspective.

28. Reboot into recovery similar to step 25 onwards to step 27, but instead of the CM7.1 ROM select your ICS ROM in the "install zip from sdcard". Reboot and enjoy ICS.

29. Installing Google Apps: This Rom or the step 25 ROM does not come with google apps pre-installed, meaning you have to install it separately.

30. Reboot into recovery mode, and under "mounts and storage" select "Mount /system". It is very Important that you DO NOT FORMAT or wipe any folder or partition. Select the "gapps-final.zip" from the sdcard and install it by selecting "install zip from sdcard".

31. Reboot and enjoy ICS
What it will look like after all steps:

Saturday, August 20, 2011

Using SharedPreferences and Data Storage – Android Development

Well, there is a lot of help online for creating a folder in the Android file system. A little bit of googling and you should be good with it. The reason i have posted this blog entry is for those who want stuffs in one page. Here it is, with explanation.

Objective: To create a folder in the public SD Card directory of android.

Public directory in android terms refers to directory which is not deleted when application is uninstalled. 

There is a great detail of information in the links at the references section.

The code below can be altered to make it create a non-public directory, to create folder only at the time of installation of application and so on. The only way to create a directory only at the time of installation is to create a SharedPreferences boolean key for and set it true / false when the folder is created.

The reason, i have created the folder in the application context is because, the folder will be created at the application installation and will be available across all activities. Depending on your application design, you could choose to create the folder either in ApplicationContext or ActivityContext.

For implementing in ActivityContext, simply change the Application to Activity

Here is code

import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import java.io.IOException;

import com.mvl.android.er.utils.ActivityUtils;

public class ErApplication extends Application { // Activity or Application
    private static ErApplication singleton;
    private static final String ER_ROOT_FOLDER = "er";
    private static final String ER_ROOT_FOLDER_PREFERENCES = "RootFolder";
    public static ErApplication getInstance()  {
        return singleton;
    /** Called when the application is first created. */
    public final void onCreate() {
        singleton = this;
        /** Root folder creation on first time installation of application */
        try {
        } catch (IOException e) {
            /** Unable to create file, because external storage is not mounted */
            Log.w("ExternalStorage", "Error creating directory", e);
    /** SharedPreferences configuration for setting folder creation flag */
    private void SetFolderCreationPreferences() throws IOException {
        /** Get the default SharedPreferences object */
        SharedPreferences mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
        /** Checks if key "RootFolder" exists in preferences else returns
         * the default value of true
        boolean mCreateRootFolder = mSharedPrefs.getBoolean(ER_ROOT_FOLDER_PREFERENCES, false);
        if(mCreateRootFolder) {
              /** Do some crap */
        } else {
            /** Set "NoRootFolder" key to true and commit the preference value*/
            SharedPreferences.Editor mSharedprefsEditor = mSharedPrefs.edit();
            mSharedprefsEditor.putBoolean(ER_ROOT_FOLDER_PREFERENCES, true);

    /** SharedPreferences configuration for setting folder creation flag */
    public static void CreatePublicFolder(String publicFolderName) throws IOException {
        /** You may want to have a check for MEDIA_MOUNTED here for safety
          * I did not add that, but its just 1 line “if” code
        File publicDirectory = new File(Environment.getExternalStorageDirectory() + "/" + publicFolderName);


[1] Environment - http://developer.android.com/reference/android/os/Environment.html

[2] SharedPreferences - http://developer.android.com/reference/android/content/SharedPreferences.html

[3] Data Storage - http://developer.android.com/guide/topics/data/data-storage.html