Jump to: navigation, search

Serial Port Access and Firmware Recovery for MP-02

Author: Terry Gillett


The following describes how to get access to the serial port on the MP-02 router and how to recover the firmware on the device in the event that the device is not accessible by normal means.

The process requires a PC running a serial port, a level shifter adapter, a serial terminal program, and a tftp server program.

A Serial Adapter specifically built for the MP-02 is available and is used as the basis of this description. Generic serial adapters and USB Serial Adapters may also be used by accessing the appropriate pins for TX, RX and Gnd.


Using a MP-02 Serial Port Adaptor

A Serial Port adaptor board is available for the MP-02. This adapter board plugs in to the header between the power connector and the Ethernet connectors on the main MP-02 board, with the serial connector facing away from the board.

The adaptor board provides RS-232 level signals via a DB-9 connector. The connector is designed to be connected to the serial port on a PC via a straight DB-9 M-F serial cable.

NOTE: Ensure that the MP-02 device is powered OFF when fitting and removing the Adaptor to avoid damage.

Set Up Serial Terminal Program

To use the Serial interface on the MP-02, a Serial Terminal program is required on your PC.

Install a serial terminal program, e.g. GtkTerm for a Ubuntu PC. Set the configuration to be

 - 115kbps
 - no parity
 - 8 bits
 - 1 stop bit
 - No Flow Control

The serial port setting will typically be /dev/ttyS0 for the first serial port on the PC, or ttyUSB0 for a USB serial adapter.

Note 1: You need to add your user to the 'dialout' group to access the serial port:

 $ sudo  usermod  -a  -G  dialout  $USER

You *MUST* log out and log back in for this to become effective.

Check that the serial port is in the 'dialout' group

 $  ls -l /dev/ttyUSB0
       crw-rw---- 1 root dialout 188, 0 Apr 12 17:11 /dev/ttyUSB0

Note2: It may be necessary to run the terminal with root privileges if you have a problem with permissions to configure the ttyS0 or ttyUSB0 port. To do this, open a terminal and enter the command:

 $ sudo gtkterm

Connect the PC serial port to the serial port adapter on the MP-02 with a straight serial cable. A 'null modem' should not be required.

Using U-boot

Connect the serial port and power up the MP-02.

You should see the U-boot start up sequence, which includes two pauses to allow you to halt the normal startup process.

The first prompt allows you to press any key and invoke the U-boot prompt.

At the U-boot prompt, type '? <Enter>' to see a list of available commands.

 dr_boot> ?

The second prompt allows you to press the 'f' key, followed by 'Enter' to switch in to Failsafe mode.

If you do not interrupt the startup process, the normal boot sequence will continue until eventually you will get to a prompt to press 'Enter' to activate a terminal session. Pressing the Enter key at this point will take to to the system command line as the 'root' user.

Note that after this last prompt appears on screen, further output from the device will continue to appear on screen, and the prompt will scroll off screen. You may press Enter at any time to go to the command line.

Set up the TFTP Server

This section describes the installation and configuration of the tftpd-hpa software on a Ubuntu workstation.

(For a Windows workstation see e.g. http://tftpd32.jounin.net/)

A. Install tftpd-hpa

 $ sudo apt-get install tftpd-hpa

B. Configure tftpd-hpa for Daemon Operation

Configure the newly installed TFTP to run as a daemon by editing the /etc/default/tftpd-hpa file:

 $ gksudo gedit /etc/default/tftpd-hpa

Add the line:


C. Set the TFTP root directory

This config file also defines where your TFTP server is serving from ie the tftp root directory.

The default location is /var/lib/tftpboot but may be changed in this file if desired.

D. Start the TFTP service Start the newly configured TFTP service as follows:

For Ubuntu 10.04 and later, use:

 $ sudo service tftpd-hpa start

For earlier versions of Ubuntu use:

 $ sudo /etc/init.d/tftpd-hpa start

E. Test the TFTP server

Save a suitable small file 'myfile' in the TFTP Server root directory.

Use the 'tftp' command in a terminal session to copy the file to a working directory

 $ tftp
 tftp> ?  (for a list of commands)
 tftp> connect localhost  OR   connect <IP_address_of_PC>
 tftp> get myfile

You should see the file received with details of size and time.

Flashing Firmware via Serial Port and TFTP

Firmware can be loaded on to the device using the serial port and the U-boot firmware on the device to set up a TFTP transfer via the Ethernet port.

This is useful to replace a firmware that can not be recovered by other means such as the OpenWrt Failsafe mechanism.

The U-boot firmware provides a tftp client. To flash the device with new firmware, you must have a tftp server set up on your PC as described above, and the necessary files available to the tftp server to send to the device.

To set up a tftp server, see the section above on installing the TFTP Server software.

By default, the U-boot firmware is configured with the tftp client on, and expects to find the tftp server on with the file named '01FFA8C0.img'

These values can be viewed, changed and saved with the U-boot commands printenv/setenv/saveenv

To install new firmware via UBoot TFTP, proceed as follows:

A. Set up PC

Set up the PC with a static IP of on the Ethernet port and connect it to the LAN port of the MP-02 with an Ethernet cable.

Ensure that the TFTP server is correctly configured and running.

B. Set up the firmware file

Copy the required 'sysupgrade' firmware file in to the TFTP Server root directory and rename it to '01FFA8C0.img' This is the default filename that the UBoot tftp client looks for.

C. Start Serial Console

Connect the MP-02 serial port to the PC serial port.

Start up the Serial Terminal program and ensure it is correctly configured (115k,8,N,1).

Power up the MP-02 and interrupt the boot sequence to get to the U-boot prompt.

Try to ping the PC with the command:

 dr_boot>   ping

You should see a response indicating the the ping is successful.

NOTE: Make sure that the ping response indicates that the "eth0" port is alive. If the response indicates "eth1" then the Ethernet cable is in the wrong connector on the MP02. Change it and try again.

D. Restart the tftp server

Restart the tftp server to ensure it is correctly associated with the running network:

For Ubuntu 10.04 and later, use:

 $ sudo service tftpd-hpa restart

For earlier versions of Ubuntu use:

 $ sudo /etc/init.d/tftpd-hpa restart

E. Transfer the file

On the serial console of U-boot, enter the command to start the file transfer:

 dr_boot>  tftpboot

 *** Warning: no boot file name; using '01FFA8C0.img'
 Using eth0 device
 TFTP from server; our IP address is
 Filename '01FFA8C0.img'.
 Load address: 0x81000000
 Loading: #################################################################
 Bytes transferred = 6946820 (6a0004 hex)      **** Note this filesize  ***

F . Erase flash memory

Note the filesize number in hex from the transfer command (0x6a0004 above) to use in the 'erase' command.

 dr_boot>   erase 0x9f040000    +0x6a0004    *** Use the filesize number ***
 Erase Flash from 0x9f040000 to 0x9f6effff in Bank # 1 
 First 0x4 last 0x6e sector size 0x10000
 Erased 107 sectors

G. Copy new firmware into flash

Note the filesize number in hex from the transfer command (0x6a0004 above) to use in the 'copy' command.

 dr_boot> cp.b 81000000    0x9f040000    0x6a0004       *** Use the filesize number ***
 Copy to Flash... write addr: 9f040000

H. Reboot

Once this is finished, boot from uboot:

 dr_boot>   bootm

You should see the full boot sequence. Press Enter at the end of the sequence to enter terminal mode.

I. MP02 Running

The MP-02 device should now be running normally. Power down the device and remove the serial port adaptor.