Monday, November 3, 2014

How to unbrick TP-Link mr3020 on OSX Yosemite

For reasons that were less than desirable, i accidentally bricked my router; tired, hungry, rushed, not really thinking.  Anyway, I installed my other router's firmware (WNDR3700) into the MR3020.  Yea, as you might have predicted that didn't go over well.  I learned.

Materials used:

  • 1 bricked mr3020
  • 1 ethernet cable
  • 1 mini usb cable
  • 1 CP2102 USB to UART breakout board  -  http://www.amazon.com/gp/product/B009T2ZR6W/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
  • 3 female to female jumper wires (mine were supplied with the CP2102)
  • 1 soldering iron
  • 1 header with 3 prongs or 3 sockets (male or female) -  http://www.amazon.com/gp/product/B005HN237S/ref=oh_aui_search_detailpage?ie=UTF8&psc=1
  • 1 OSX computer (I used 10.10 Yosemite)
    • Download
      • Correct openwrt mr3020 firmware
    • Download and install 
      • CoolTerm - http://freeware.the-meiers.org
      • TftpServer - http://ww2.unime.it/flr/tftpserver/
      • SLAB_USBtoUART - http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx

Overview and a brief rundown of what is about to take place:

At this moment the router is rebooting constantly (about once every 2 seconds) because it's trying to load an incompatible firmware and it's not smart enough to do anything else but quit and reboot.  What we have to do is gain access to the routers UART pins and send instructions through it using the breakout board and a serial connection.  We have to tell it to re-flash itself with a new image from a hosted TFTP server over a standard rj45 ethernet connection.

Steps:
  1. Open up the MR3020 by taking a really hard piece of plastic or thin screw driver and pry up the edge by the mini usb and ethernet jack.  Work your way around until the whole top pops off.  It's almost impossible to not nick up or break the casing while prying and bending.
  2. Once you managed to get the top off, gently lift the board from the edge that is on the opposite side as the ethernet jack until it comes out.
  3. Holding the board vertical with the ethernet jack pointed upwards, you will notice that there are 4 pins on the bottom with a very small "p1" to the right of them.  The 3 rightmost pins are the ones we are going to use.  From left to right they are, Ground, RX, TX.
  4. Solder the 3 pins from the header in those holes, the leftmost hole should be empty.
  5. Connect your CP2102 breakout board to these pins but you must switch the TX and the RX pins so they are complementing each other, TX should never go with TX.  The ground goes with the ground.
  6. Connect the USB end of the CP2102 breakout board to your computer.
  7. On the OSX mac, download and install CoolTerm, TftpServer, and the SLAB CP2102 usb driver for the breakout board.  Installation is straightforward for all programs.
  8. Open up CoolTerm and click options.  The "Serial Port" option should be lit with a bunch of options on the right including baudrate.  Set the port to SLAB_USBtoUART, baudrate to 115200, data bits 8, parity none, and stop bits 1.  Then click on the "Terminal" option and select "Line Mode" for "Terminal Mode".
  9. Click connect.  Nothing should be showing because we don't have the router powered up.
  10. Open up the Settings app in OSX and create an ethernet connection with a manual address of 192.168.1.100 with a subnet mask of 255.255.255.0
  11. Open the TftpServer and select "Reveal" at the top.  An empty finder window should open up.  Drag your newly downloaded openwrt firmware to the finder window.  Now your Tftp server has a file to upload.
  12. Towards the upper right quadrant of the screen you should see a dropdown drop with at least one network interface.  Make sure that the 192.168.1.100 address is selected.
  13. Start the Tftp Server by pressing the "Start TFTP" button at the top right hand corner of the screen.
  14. Connect the ethernet cable from the router to your mac
  15. Plug in the router and you should see output in the CoolTerm window.  If you do not see any output or the "RX" virtual Green light is not blinking, then diagnose your connection.  It is possible that you may have the TX and RX wires switched up.
  16. Once you start seeing output, you will notice that it goes down for reboot quite frequently.
  17. Type the letters "tpl" into the CoolTerm command line and press enter.  This will cause the firmware to recognize connection and wait for further instruction.  You will know when this works when it populates the word "hornet >"
  18. Type in the following (wait for each command to fully finish, some take longer than others):
    1. setenv ipaddr 192.168.1.111
    2. setenv serverip 192.168.1.100
    3. tftpboot 0x80000000 openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin
    4. erase 0x9f020000 +0x3c0000
    5. cp.b 0x80000000 0x9f020000 0x3c0000
    6. bootm 9f020000
  19. Your router is now rebooting and unbricked! yay!
I hope this helps you and if you have any questions I'll be more than happy to answer them.  Happy hacking!

Props to the developers of CoolTerm and TftpServer.

Great documentation:
http://blog.waysquare.com/how-to-debrick-tl-mr3020/

Friday, September 26, 2014

Upgrade Beaglebone Black (BBB) kernel

An excellent post was written up by Marcos Miranda from element 14 instructing users on how to upgrade the kernel on the BBB.
http://www.element14.com/community/blogs/mirandasoft/2014/04/02/beaglebone-black-upgrading-the-linux-kernel

In a nutshell, it's 3 basic scripts.  Before starting, make a directory to put all your scripts.  You may name the following files and scripts however you want to.  I use generic file names for readability.


1. Create your scripts:
I am naming mine test.sh, upgrade.sh, and clean.sh.

Use vim and save the separate scripts into a directory of your choosing.
mkdir ~/upgradekernel
cd ~/upgradekernel

vim test.sh
_____________________________________________________________________________
#!/bin/bash
wget -nd -p -E https://rcn-ee.net/deb/sid-armhf/LATEST-omap-psp -O ./LatestBBBKernels.txt
cat ./LatestBBBKernels.txt
_____________________________________________________________________________

vim upgrade.sh
_____________________________________________________________________________
#!/bin/bash
# TO BE EXECUTED UNDER ROOT ACCOUNT
# STANDARD DISCLAIMER APPLIES.
set -e
wget -nd -p -E https://rcn-ee.net/deb/sid-armhf/LATEST-omap-psp -O ./LatestBBBKernels.txt
echo -e "#!/bin/bash" > download.sh
echo -ne "wget -c " >> download.sh
sed -n -e 's/ABI:1 STABLE //p' LatestBBBKernels.txt >> download.sh
echo "sh ./install-me.sh" >> download.sh
chmod +x download.sh
sh ./download.sh
rm LatestBBBKernels.txt
_____________________________________________________________________________

vim clean.sh
_____________________________________________________________________________
#!/bin/bash
set -e
# rm -r /root/install-me.sh
# rm -r /root/download.sh
# rm -rf /boot/*-bone41
# rm -rf /boot/uboot/*bak
# rm -f /boot/uboot/tools/restore_bak.sh
# rm -rf /lib/modules/3.8.13-bone41
# apt-get remove --purge -y linux-image-3.8.13-bone41
# apt-get clean all
_____________________________________________________________________________

1. Decide on which kernel you would like to install.  The keywords are STABLE, TESTING, or EXPERIMENTAL

Run the following to determine which kernel version are available to you.

cd ~/scriptdir
vim test.sh

(copy and paste the following into test.sh):


type in vim to quit and save - :wq

chmod +x test.sh

./test.sh
_____________________________________________________________________________

You should receive an output resembling the following:
--2014-09-26 15:06:58--  https://rcn-ee.net/deb/sid-armhf/LATEST-omap-psp
Resolving rcn-ee.net (rcn-ee.net)... 69.163.222.213
Connecting to rcn-ee.net (rcn-ee.net)|69.163.222.213|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 234 [text/plain]
Saving to: `./LatestBBBKernels.txt'

100%[=======================================================================================================>] 234         --.-K/s   in 0s    

2014-09-26 15:07:03 (659 KB/s) - `./LatestBBBKernels.txt' saved [234/234]

FINISHED --2014-09-26 15:07:03--
Total wall clock time: 4.7s
Downloaded: 1 files, 234 in 0s (659 KB/s)
root@beaglebone:~/Projects#     cat ./LatestBBBKernels.txt
ABI:1 TESTING https://rcn-ee.net/deb/sid-armhf/v3.16.3-bone6/install-me.sh
ABI:1 EXPERIMENTAL https://rcn-ee.net/deb/sid-armhf/v3.17.0-rc6-bone4/install-me.sh
ABI:1 STABLE https://rcn-ee.net/deb/sid-armhf/v3.8.13-bone67/install-me.sh
_____________________________________________________________________________

Notice the TESTING, EXPERIMENTAL, and STABLE.  Also notice their associated kernel versions.

2.  Run the scripts and modify accordingly.

Run test.sh

You should receive output that resembles the following:
_____________________________________________________________________________
--2014-09-26 15:06:58--  https://rcn-ee.net/deb/sid-armhf/LATEST-omap-psp
Resolving rcn-ee.net (rcn-ee.net)... 69.163.222.213
Connecting to rcn-ee.net (rcn-ee.net)|69.163.222.213|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 234 [text/plain]
Saving to: `./LatestBBBKernels.txt'

100%[=======================================================================================================>] 234         --.-K/s   in 0s    

2014-09-26 15:07:03 (659 KB/s) - `./LatestBBBKernels.txt' saved [234/234]

FINISHED --2014-09-26 15:07:03--
Total wall clock time: 4.7s
Downloaded: 1 files, 234 in 0s (659 KB/s)
root@beaglebone:~/Projects#     cat ./LatestBBBKernels.txt
ABI:1 TESTING https://rcn-ee.net/deb/sid-armhf/v3.16.3-bone6/install-me.sh
ABI:1 EXPERIMENTAL https://rcn-ee.net/deb/sid-armhf/v3.17.0-rc6-bone4/install-me.sh
ABI:1 STABLE https://rcn-ee.net/deb/sid-armhf/v3.8.13-bone67/install-me.sh
_____________________________________________________________________________

Analyzing the output, choose which type of kernel installation you would like.  Personally I like TESTING so I will modify the upgrade script to replace "STABLE" with "TESTING"

Once you modify upgrade.sh, run it.

./upgrade.sh

Once the upgrade is complete, run clean.sh

Reboot your system and the kernel is now updated! Enjoy!

Props to Marcos for the nice scripts.

Thursday, September 11, 2014

Removing or Editing File Associations through the Windows 7/8 registry

The registry is an incredibly sensitive file that contains a vast amount of highly unorganized data in the form of folders and keys.  My patience was really tested when a user decided to open a special file extension in MS word.  Now the file's properties displays an undesired program as the default.  Also, I've seen people try to open a file but the program doesn't open properly signifying that the parameters are incorrect.  If anyone has made this mistake before and would like to resolve it, I have some instructions and places to look.
I will be using the file extension ".ext" as an example for the steps below"

First, everyone should know about the "default programs" section in control panel.  Unfortunately, it doesn't paint the whole picture.

In command prompt, type "assoc .ext".  This will display the name of a program that it is associated with this extension.  This data comes from the "classroot" section in the registry.

Also in command prompt, type "ftype nameofprogram".  The "nameofprogram" is taken from the output of the command "assoc .ext".  This will display the command used to describe the behavior about how the file is opened.  Normally you will have a %1 next to it letting you know that it is taking in the file that is associated with it as a parameter.

If you don't get any clues from above and need to go deeper, then here is where the registry comes in.

***BACKUP THE REGISTRY BEFORE MODIFYING THE REGISTRY***

There are numerous places to look for a misbehaving file extension, all are taken from this very well written article:
 http://www.mydigitallife.info/how-to-unassociate-remove-or-delete-programs-from-open-with-or-recommended-programs-list/

The following places to look are:

HKEY_CURRENT_USER\Software\Microsoft\Windows\
CurrentVersion\Explorer\FileExts\.<extension>\OpenWithList

HKEY_CURRENT_USER\Software\Microsoft\Windows\
CurrentVersion\Explorer\FileExts\.<extension>\OpenWithProgIDs

HKEY_CLASSES_ROOT\.<extension>\OpenWithList

HKEY_CLASSES_ROOT\.<extension>\OpenWithProgIDs

HKEY_LOCAL_MACHINE\SOFTWARE\Clients\<Program Type>\
<Program Name>\Capabilities\FileAssociations

HKEY_CLASSES_ROOT\Applications\<application executable name>\SupportedTypes

HKEY_CLASSES_ROOT\SystemFileAssociations\<Perceived Type>\OpenWithList
HKEY_CLASSES_ROOT\SystemFileAssociations\.<extension>\OpenWithList

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

The most popular one would be this: HKEY_CURRENT_USER\Software\Microsoft\Windows\
CurrentVersion\Explorer\FileExts\.<extension>\OpenWithList

Remove the OpenWithList should fix the default "Open With" program listed in the file's properties.

If a file is not opening properly or if you're crafty and would like to modify how your specific program opens, this is in the "classroot" section of the registry.  This section will also modify this for every user of the computer, not just yourself.
HKEY_CLASSES_ROOT\.<application name>\Shell\Open\Command
Then edit the (default) key data.

Remember, every time you edit the registry, restarting the explorer.exe process doesn't always work as it depends on where you edit the registry that would be taking effect.  For all of the above, save yourself the headache and just reboot the computer.

Tuesday, July 22, 2014

Allow java swing to send all error messages to a JOptionPane

By default java swing will send error messages to the java console.  This would be ok if the java console would pop up from a runnable java application, but it does not and have not found a way to do so.  If otherwise instructed, java will hide all messages (even fatal ones) from the user during runtime.  This is not acceptable behavior, so I have found a solution.  Route the messages to JOptionPanes like a popup.

During the main(String[] args) procedure, insert the following code:

public static void main(String[] args) {
System.out.println(SwingUtilities.isEventDispatchThread());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
System.out.println(SwingUtilities.isEventDispatchThread());
try {
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
// TODO Auto-generated method stub
JOptionPane.showMessageDialog(null,
   e.toString(),
   "Error",
   JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
});
                                        ****START CODE HERE****


System.out.println(SwingUtilities.isEventDispatchThread());

} catch (Exception e) {
e.printStackTrace();
}
}
});
}

Create dynamically loading java swing objects

  I gotta say, java swing isn't the greatest framework for creating interfaces with objects that need to be updated depending on selections.  I came across this issue when I trying to create a panel that would dynamically allocate objects depending on the class that this panel was inheriting by the users choice from a radio button selection.  When a panel was created with the allocated objects, the containing panel would not recognize those changes even after repainting and revalidating.  The trick is knowing how the event driven swing framework works.  Since the objects were not originally created by the event dispatch thread a.k.a. AWT-EventQueue, they will not take effect until an EventQueue owned object "affects" it.  So how would the EventQueue thread "own" the interface objects that were not created in the first place?
  In comes the SwingWorker.  This is an abstract class that allows dynamic background processes to update the object being modified even if the process is a concurrent running process.  The SwingWorker can publish the object at any time even in the middle of a process since it publishes itself to the even dispatch thread which will then take ownership of the object in need of updating.  Now loading bars and live dynamic object allocation are possible.  I've created a class below that extends the SwingWorker class, but it can take any Swing parent component (the one that contains the object needed to be modified) and a method associated with a child Swing component.  Depending on what the child method does, this will update the interface of the parent that will be containing the childs actions.
  For example, I have a Jpanel that contains another Jpanel that will update some JComboBoxes with different values.  The kicker is that depending on the child class, there can different quantities of JComboBoxes.

Sample Code:

public class DocTypeContainPanel extends JPanel{

...

SwingObjectWorker temp1 = null;
SwingObjectWorker temp2 = null;

temp1 = new SwingObjectWorker(pnlSearchPropsContainer, pnlSearchProps.getPropsPanel());
temp1.execute();

temp2 = new SwingObjectWorker(pnlDocPropsContainer, pnlDocProps.getPropsPanel());
temp2.execute();

revalidate();

repaint();

...

}


class SwingObjectWorker extends SwingWorker<JComponent, Void> {
private JComponent parentComp;
private JComponent childComp;

public SwingObjectWorker (JComponent inparentComp, JComponent inchildComp){

parentComp = inparentComp;
childComp = inchildComp;
final SwingObjectWorker temp = this;

this.addPropertyChangeListener(new PropertyChangeListener() {

@Override
public void propertyChange(PropertyChangeEvent arg0) {
if (StateValue.DONE == temp.getState()) {
try {
parentComp.removeAll();
parentComp.add(get(), "cell 0 0,grow");
parentComp.setVisible(true);
parentComp.revalidate();
parentComp.repaint();
System.out.println("Swing Worker Done!");

// TODO: insert code to run on the EDT after move determined


} catch (InterruptedException e) {

e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}
});
}


  @Override
  public JComponent doInBackground() {
return childComp;
  }
   
  @Override
  public void done() {
     }
}

Friday, July 11, 2014

Using a TP-Link TL-WN725N USB Wifi Adapter on a Raspberry Pi

For those that purchased a TP-Link TL-WN725N because it was really cheap and didn't bother to check the linux driver support for it... oops

Well here's your fix.

This is been tested on raspbian on the rpi (raspberry pi), your mileage may vary on other operating systems and architectures.

First, in order to compile drivers for linux, we need the linux headers.  Running rpi-update does not provide the headers in with the update since the kernel is precompiled.  What we have to do is find the headers for the current commit of the kernel installed.  We do this by running an awesome tool called rpi-source which downloads the correct headers for your specific kernel version that is currently installed on your rpi.

run in a directory of your choice:
sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update

If you get a message that states "gcc version check: mismatch between gcc (4.6.3) and /proc/version (4.7.2) Skip this check with --skip-gcc", you can simply ignore it by running "rpi-source --skip-gcc"

What this will do is create and install the headers and modules in your /lib/modules/ folder.  Now that you have the kernel headers installed, we can move on to compiling the driver.  The following comes straight from the examples used for the "rpi-source" repository on github.

You may read and follow the directions here:
https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules#tp-link-tl-wn725n-version-2-lwfinger

Otherwise just follow the instructions below which is copied and pasted from the repository:
______________________________________________________________________________
$ uname -a
Linux raspberrypi 3.12.21+ #1 PREEMPT Sat Jun 14 13:44:18 CEST 2014 armv6l GNU/Linux

$ git clone https://github.com/lwfinger/rtl8188eu.git
$ cd rtl8188eu

$ make all

$ sudo make install

$ sudo depmod

$ sudo modprobe 8188eu

$ lsmod
Module                  Size  Used by
8188eu                796381  0
______________________________________________________________________________

After that, you should have a working TL-WN725N wifi adapter.

Major props goes to the developer of rpi-source and for the open source 8188eu driver for the wifi adapter.

Enjoy!

Wednesday, June 25, 2014

Resize partitions for SoC computers and other linux devices (raspberry pi, beaglebone black, etc...)

This only uses fdisk and resize2fs.  I ran out of space on the beaglebone black so I could not use parted for partition editing but the following works just as well.  The same procedure below applies to raspberry pi's too.  The bbb is running debian wheezy burned on a 32GB micro sd card.  Raspi-config simplifies the following with one step, but it also used parted for it's file recreation.  We don't have that package at our disposal so here is the alternative.

enter: df -h

root@beaglebone:/media/Angstrom# df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          1.6G  1.6G     0 100% /
udev             10M     0   10M   0% /dev
tmpfs           100M  3.1M   97M   4% /run
/dev/mmcblk0p2  1.6G  1.6G     0 100% /
tmpfs           249M     0  249M   0% /dev/shm
tmpfs           249M     0  249M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/mmcblk0p1   96M   70M   27M  73% /boot/uboot
/dev/mmcblk1p2  1.7G  1.1G  519M  68% /media/Angstrom
/dev/mmcblk1p1   70M   54M   16M  78% /media/

*************************************************************************
Clearly the rootfs has no more space available.  We want to find the partition that the rootfs is referencing by looking at the filesystems that start with "/dev/" and are mounted on the same location as the rootfs.  In this case (and it most cases with SoC computers) it appears here as /dev/mmcblk0p2.
*************************************************************************


enter: fdisk -l

root@beaglebone:~# fdisk -l

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes
4 heads, 16 sectors/track, 973968 cylinders, total 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048      198655       98304    e  W95 FAT16 (LBA)
/dev/mmcblk0p2          198656    62333951    31067648   83  Linux

Disk /dev/mmcblk1: 1920 MB, 1920991232 bytes
255 heads, 63 sectors/track, 233 cylinders, total 3751936 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk1p1   *          63      144584       72261    c  W95 FAT32 (LBA)
/dev/mmcblk1p2          144585     3743144     1799280   83  Linux

Disk /dev/mmcblk1boot1: 1 MB, 1048576 bytes
4 heads, 16 sectors/track, 32 cylinders, total 2048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mmcblk1boot1 doesn't contain a valid partition table

Disk /dev/mmcblk1boot0: 1 MB, 1048576 bytes
4 heads, 16 sectors/track, 32 cylinders, total 2048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mmcblk1boot0 doesn't contain a valid partition table

*************************************************************************
This will tell us where the /dev/mmcblk0p2 partition is located.  It appears under the disk /dev/mmcblk0 which makes sense because it has 31.9 GB of total usable space.  We have made a direct correlation with the disk needed to be modified and the 32GB card installed in the bbb.
*************************************************************************


enter: fdisk /dev/mmcblk0

root@beaglebone:/media/Angstrom# fdisk /dev/mmcblk0  

Command (m for help): p

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes
4 heads, 16 sectors/track, 973968 cylinders, total 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048      198655       98304    e  W95 FAT16 (LBA)
/dev/mmcblk0p2          198656     3481599     1641472   83  Linux

Command (m for help): d
Partition number (1-4): 2

Command (m for help): p

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes
4 heads, 16 sectors/track, 973968 cylinders, total 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048      198655       98304    e  W95 FAT16 (LBA)

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (198656-62333951, default 198656):  (press enter here)
Using default value 198656
Last sector, +sectors or +size{K,M,G} (198656-62333951, default 62333951):  (press enter here)
Using default value 62333951

Command (m for help): p

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes
4 heads, 16 sectors/track, 973968 cylinders, total 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048      198655       98304    e  W95 FAT16 (LBA)
/dev/mmcblk0p2          198656    62333951    31067648   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
root@beaglebone:/media/Angstrom# reboot

Broadcast message from root@beaglebone (pts/0) (Wed Jun 25 15:37:07 2014):
The system is going down for reboot NOW!

*************************************************************************
What we did was delete the partition from the partition table, not the actual partition itself so the data still remains intact when we create a new partition.  After the second partition has been deleted and recreated, we reboot.
*************************************************************************

log in again and reenter: df -h

root@beaglebone:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          1.6G  1.6G     0 100% /
udev             10M     0   10M   0% /dev
tmpfs           100M  540K   99M   1% /run
/dev/mmcblk0p2  1.6G  1.6G     0 100% /
tmpfs           249M     0  249M   0% /dev/shm
tmpfs           249M     0  249M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/mmcblk0p1   96M   70M   27M  73% /boot/uboot

*************************************************************************
We have free space! ... wait.... huh?
The available space is still 0???

... remember, we just modified the partition table, not the partition itself.  Now we have resize the actual partition in accordance with the partition table.
*************************************************************************

enter: resize2fs /dev/mmcblk0p2

root@beaglebone:~# resize2fs /dev/mmcblk0p2
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk0p2 is now 7766912 blocks long.
root@beaglebone:~# reboot

*************************************************************************
From the previous output of "df -h", we want to modify the partition itself which would be /dev/mmcblk0p2 since that is the rootfs described in the first step.  Now the physical partition is resized.
*************************************************************************

enter: df -h

root@beaglebone:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs           30G  1.6G   27G   6% /
udev             10M     0   10M   0% /dev
tmpfs           100M  540K   99M   1% /run
/dev/mmcblk0p2   30G  1.6G   27G   6% /
tmpfs           249M     0  249M   0% /dev/shm
tmpfs           249M     0  249M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/mmcblk0p1   96M   70M   27M  73% /boot/uboot

*************************************************************************
Bam! We have copious amounts of free space.  Enjoy!
*************************************************************************