Difference between revisions of "Connect to a modified router"

From Embedded Xinu
Jump to navigation Jump to search
m (Correct Linksys casing)
 
(26 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
[[Category:HOWTO]]
 
== Summary ==
 
== Summary ==
 
+
This will explain how to connect to the serial ports on a modified Linksys WRT54G using serial communication software. In our tutorial we will use Picocom for our serial communication software because it is free and easy to get with a front end or server running Linux.
This will explain how to connect to the serial ports on a modified LinkSys WRT54G using serial communication software such as the open source [http://www.columbia.edu/kermit/ Kermit].
 
  
 
== Before Starting ==
 
== Before Starting ==
Line 7: Line 7:
 
=== Expose a serial port on the router ===
 
=== Expose a serial port on the router ===
  
You must have successfully modified a LinkSys WRT54G to expose at least its first serial port in such a way that you can connect it to another machine with serial communications software.  If you have not done so yet, please see [[HOWTO:Modify the Linksys hardware]]
+
You must have successfully modified a Linksys WRT54G to expose at least its first serial port in such a way that you can connect it to another machine with serial communications software.  If you have not done so yet, please see [[HOWTO:Modify the Linksys hardware]]
  
 
=== Acquire serial communication software ===
 
=== Acquire serial communication software ===
  
A solid open source suite of communication software known as Kermit has served us well as a method of communicating with the WRT54GC-Kermit, the UNIX compatible implementation, is available for download at their website [http://www.columbia.edu/kermit/ck80.html].
+
There is a freely available software package for serial communication on almost every major platform. Picocom is one such piece of software that is easy to obtain on a machine running Linux. To get Picocom installed on your front end simply open a terminal and type <code> yum install picocom  </code> (or use your system's package install command if it does not support the <code> yum </code> command). '''NOTE:''' you may need ''root'' access to your front end machine in order to install packages. We installed Picocom on a front end machine running Fedora 9 and got the following output:
 +
<pre>[root@argolis ~]# yum install picocom
 +
Loaded plugins: refresh-packagekit
 +
Setting up Install Process
 +
Parsing package install arguments
 +
Resolving Dependencies
 +
--> Running transaction check
 +
---> Package picocom.i386 0:1.4-4.fc9 set to be updated
 +
--> Finished Dependency Resolution
 +
 
 +
Dependencies Resolved
 +
 
 +
=============================================================================
 +
Package                Arch      Version          Repository        Size
 +
=============================================================================
 +
Installing:
 +
  picocom                i386      1.4-4.fc9        fedora            29 k
 +
 
 +
Transaction Summary
 +
=============================================================================
 +
Install      1 Package(s)       
 +
Update      0 Package(s)       
 +
Remove      0 Package(s)       
 +
 
 +
Total download size: 29 k
 +
Is this ok [y/N]: y
 +
Downloading Packages:
 +
(1/1): picocom-1.4-4.fc9.i386.rpm                        |  29 kB    00:00   
 +
Running rpm_check_debug
 +
Running Transaction Test
 +
Finished Transaction Test
 +
Transaction Test Succeeded
 +
Running Transaction
 +
  Installing: picocom                      ######################### [1/1]
 +
 
 +
Installed: picocom.i386 0:1.4-4.fc9
 +
Complete!
 +
[root@argolis ~]# </pre>
 +
 
 +
Alternatively, if you are building multiple backends to be made available as a pool, our suite of XINU [[Console Tools]] includes a basic serial console utility called '''tty-connect'''. However it is recommended that you do '''not''' use the XINU [[Console Tools]]'s '''tty-connect''' utility for directly connecting a single back end router to a front end machine because this utility does not allow the user to send a  <code>ctrl-C</code>  command over the serial connection, which is necessary in the upcoming steps in order to properly communicate with your router.
 +
 
  
 
== Steps to Connect to the Router ==
 
== Steps to Connect to the Router ==
  
=== Task One: Power up the Router ===
+
=== Task One: Connect Serial (& Optionally Network) Cable(s) ===
 +
 
 +
Ensure that the connection is going from UART0 (the first serial port--if you followed our instructions on [[HOWTO:Modify the Linksys hardware|modifying the router]] it will be the '''DB9 Female''' serial port on the left) as this is where the console will be running.  If you are connecting a standard PC serial port (a DTE) to your router, use a straight serial cable.  Other arrangements may require a [[Null Modem]]; check your transmit/receive line polarities to be sure.
 +
 
 +
Also, because the goal is to upload custom code to the router, it would be a good idea to connect the router to your network by wiring it up via one of the numbered LAN ports on the back of the router (NOT the Internet/WAN port). This is not necessary to simply connect and communicate with the router, but it is necessary if you want to try and boot the router running your own custom code (which is the point of this Xinu lab after all).
 +
 
 +
=== Task Two: Configure your Serial Communication Software ===
 +
 
 +
The connection used by the router's serial port is fairly standard: 115200bps, with 8 data bits, no parity bit, and 1 stop bit, or 8N1.  Set your software to connect using these settings.
 +
 
 +
If you are following our tutorial and using Picocom as your serial connection software, the command to open Picocom with these settings is <code> picocom -b 115200 /dev/ttyS0 </code> (where <code> /dev/ttyS0 </code> is the name of your front end's serial communication device hooked up to the router). By default the other necessary settings are already set on picocom; it's default connection uses 8 data bits, no parity bits, and 1 stop bit. If you use picicom to set up a connection you should get output like the following:
 +
<pre>[root@argolis ~]# picocom -b 115200 /dev/ttyS0
 +
picocom v1.4
 +
 
 +
port is        : /dev/ttyS0
 +
flowcontrol    : none
 +
baudrate is    : 115200
 +
parity is      : none
 +
databits are  : 8
 +
escape is      : C-a
 +
noinit is      : no
 +
noreset is    : no
 +
nolock is      : no
 +
send_cmd is    : ascii_xfr -s -v -l10
 +
receive_cmd is : rz -vv
 +
 
 +
Terminal ready</pre>
 +
 
 +
=== Task Three: Power up the Router ===
  
 
Yes, that means plug it in.
 
Yes, that means plug it in.
  
=== Task Two: Connect Serial (& Optionally Network) Cable(s) ===
+
With serial communications software listening, you should see something like the following output:
 +
 
 +
<pre>CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
 +
Build Date: Mon Nov 14 18:06:25 CST 2005 (root@localhost.localdomain)
 +
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.
 +
 
 +
Initializing Arena
 +
Initializing Devices.
 +
 
 +
No DPN
 +
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 3.90.37.0
 +
CPU type 0x29008: 200MHz
 +
Total memory: 16384 KBytes
 +
 
 +
Total memory used by CFE:  0x80300000 - 0x803A39C0 (670144)
 +
Initialized Data:          0x803398D0 - 0x8033BFE0 (10000)
 +
BSS Area:                  0x8033BFE0 - 0x8033D9C0 (6624)
 +
Local Heap:                0x8033D9C0 - 0x803A19C0 (409600)
 +
Stack Area:                0x803A19C0 - 0x803A39C0 (8192)
 +
Text (code) segment:      0x80300000 - 0x803398D0 (235728)
 +
Boot area (physical):      0x003A4000 - 0x003E4000
 +
Relocation Factor:        I:00000000 - D:00000000
 +
 
 +
Boot version: v3.7
 +
The boot is CFE
 +
 
 +
mac_init(): Find mac [00:18:39:6F:78:15] in location 0
 +
Nothing...
 +
 
 +
eou_key_init(): Find key pair in location 0
 +
The eou device id is same
 +
The eou public key is same
 +
The eou private key is same
 +
Device eth0:  hwaddr 00-18-39-6F-78-15, ipaddr 192.168.1.1, mask 255.255.255.0
 +
        gateway not set, nameserver not set
 +
Loader:raw Filesys:raw Dev:flash0.os File: Options:(null)
 +
Loading: ...... 1601536 bytes read
 +
Entry at 0x80001000
 +
Closing network.
 +
Starting program at 0x80001000
 +
CPU revision is: 00029008
 +
Primary instruction cache 16kb, linesize 16 bytes (2 ways)
 +
Primary data cache 8kb, linesize 16 bytes (2 ways)
 +
Linux version 2.4.20 (root@localhost.localdomain) (gcc version 3.2.3 with Broadcom modifications)
 +
...
 +
(snip)
 +
...
 +
Hit enter to continue...
 +
</pre>
 +
 
 +
Pressing enter will give you a root shell:
 +
<pre>BusyBox v0.60.0 (2005.11.14-09:45+0000) Built-in shell (msh)
 +
Enter 'help' for a list of built-in commands.
 +
 
 +
#
 +
</pre>
  
Ensure that the connection is going from UART0 (the first serial port--you ''did'' label them didn't you?) as this is where the console will be running.
+
=== Task Four: Access the Common Firmware Environment CLI ===
  
Also, because the goal is to upload custom code to the router, it would be a good idea to connect the router to your network by wiring it up via one of the numbered LAN ports on the back of the router (NOT the Internet/WAN port).
+
If you reboot the router while holding CTRL+C on the serial console, you will get a [[CFE]] prompt.
  
=== Task Three: Configure your Serial Communication Software ===
+
<pre>
 +
CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
 +
Build Date: Mon Nov 14 18:06:25 CST 2005 (root@localhost.localdomain)
 +
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.
  
The connection used by the router's serial port is fairly standard: 115200bps, with 8 data bits, no parity bit, and 1 stop bit, or 8N1.
+
Initializing Arena
 +
Initializing Devices.
  
In our setup, once running Kermit on the external machine, we connected by typing in:<br/>
+
No DPN
{| border="0" cellspacing="0" cellpadding="0"
+
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 3.90.37.0
| <code>set line /dev/tty000</code>
+
CPU type 0x29008: 200MHz
| &nbsp;&nbsp;&nbsp;&nbsp;
+
Total memory: 16384 KBytes
| to select the serial device that is connected to the router.
 
|-
 
| <code>set serial 8n1</code>
 
| &nbsp;&nbsp;&nbsp;&nbsp;
 
| which is not really necessary since this is default.
 
|-
 
| <code>set speed 115200</code>
 
| &nbsp;&nbsp;&nbsp;&nbsp;
 
| as given to us in the router specifications.
 
|-
 
|}
 
  
=== Task Four: Connect to the OpenWRT Console ===
+
Total memory used by CFE: 0x80300000 - 0x803A39C0 (670144)
 +
Initialized Data:          0x803398D0 - 0x8033BFE0 (10000)
 +
BSS Area:                  0x8033BFE0 - 0x8033D9C0 (6624)
 +
Local Heap:                0x8033D9C0 - 0x803A19C0 (409600)
 +
Stack Area:                0x803A19C0 - 0x803A39C0 (8192)
 +
Text (code) segment:      0x80300000 - 0x803398D0 (235728)
 +
Boot area (physical):      0x003A4000 - 0x003E4000
 +
Relocation Factor:        I:00000000 - D:00000000
  
In Kermit, after the configuration commands have been entered, it was as easy as typing <code>connect</code>.  Once connected, press <code>Enter</code> to get a console from [[OpenWRT]].  This should function just about identically to the ssh console, and if it works correctly, it means that the serial port has been correctly installed.
+
Boot version: v3.7
 +
The boot is CFE
  
=== Task Five: Access to the Common Firmware Environment CLI ===
+
mac_init(): Find mac [00:18:39:6F:78:15] in location 0
 +
Nothing...
  
 +
eou_key_init(): Find key pair in location 0
 +
The eou device id is same
 +
The eou public key is same
 +
The eou private key is same
 +
Device eth0:  hwaddr 00-18-39-6F-78-15, ipaddr 192.168.1.1, mask 255.255.255.0
 +
        gateway not set, nameserver not set
 +
Automatic startup canceled via Ctrl-C
 +
CFE> ^C
 +
CFE> ^C
 +
CFE>
 +
</pre>
 +
 +
See the [[CFE]] page for more information about using this prompt.
  
 
== What to do next? ==
 
== What to do next? ==
 +
 +
Now that you have successfully modified and connected to your router, you are ready to [[HOWTO:Build XINU|Build and Deploy XINU]].
 +
 +
 +
<hr/>
 +
''This work is supported in part by NSF grant DUE-CCLI-0737476.''

Latest revision as of 23:30, 28 June 2009

Summary

This will explain how to connect to the serial ports on a modified Linksys WRT54G using serial communication software. In our tutorial we will use Picocom for our serial communication software because it is free and easy to get with a front end or server running Linux.

Before Starting

Expose a serial port on the router

You must have successfully modified a Linksys WRT54G to expose at least its first serial port in such a way that you can connect it to another machine with serial communications software. If you have not done so yet, please see HOWTO:Modify the Linksys hardware

Acquire serial communication software

There is a freely available software package for serial communication on almost every major platform. Picocom is one such piece of software that is easy to obtain on a machine running Linux. To get Picocom installed on your front end simply open a terminal and type yum install picocom (or use your system's package install command if it does not support the yum command). NOTE: you may need root access to your front end machine in order to install packages. We installed Picocom on a front end machine running Fedora 9 and got the following output:

[root@argolis ~]# yum install picocom
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package picocom.i386 0:1.4-4.fc9 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size 
=============================================================================
Installing:
 picocom                 i386       1.4-4.fc9        fedora             29 k

Transaction Summary
=============================================================================
Install      1 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         

Total download size: 29 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): picocom-1.4-4.fc9.i386.rpm                        |  29 kB     00:00    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: picocom                      ######################### [1/1] 

Installed: picocom.i386 0:1.4-4.fc9
Complete!
[root@argolis ~]# 

Alternatively, if you are building multiple backends to be made available as a pool, our suite of XINU Console Tools includes a basic serial console utility called tty-connect. However it is recommended that you do not use the XINU Console Tools's tty-connect utility for directly connecting a single back end router to a front end machine because this utility does not allow the user to send a ctrl-C command over the serial connection, which is necessary in the upcoming steps in order to properly communicate with your router.


Steps to Connect to the Router

Task One: Connect Serial (& Optionally Network) Cable(s)

Ensure that the connection is going from UART0 (the first serial port--if you followed our instructions on modifying the router it will be the DB9 Female serial port on the left) as this is where the console will be running. If you are connecting a standard PC serial port (a DTE) to your router, use a straight serial cable. Other arrangements may require a Null Modem; check your transmit/receive line polarities to be sure.

Also, because the goal is to upload custom code to the router, it would be a good idea to connect the router to your network by wiring it up via one of the numbered LAN ports on the back of the router (NOT the Internet/WAN port). This is not necessary to simply connect and communicate with the router, but it is necessary if you want to try and boot the router running your own custom code (which is the point of this Xinu lab after all).

Task Two: Configure your Serial Communication Software

The connection used by the router's serial port is fairly standard: 115200bps, with 8 data bits, no parity bit, and 1 stop bit, or 8N1. Set your software to connect using these settings.

If you are following our tutorial and using Picocom as your serial connection software, the command to open Picocom with these settings is picocom -b 115200 /dev/ttyS0 (where /dev/ttyS0 is the name of your front end's serial communication device hooked up to the router). By default the other necessary settings are already set on picocom; it's default connection uses 8 data bits, no parity bits, and 1 stop bit. If you use picicom to set up a connection you should get output like the following:

[root@argolis ~]# picocom -b 115200 /dev/ttyS0
picocom v1.4

port is        : /dev/ttyS0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
escape is      : C-a
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : ascii_xfr -s -v -l10
receive_cmd is : rz -vv

Terminal ready

Task Three: Power up the Router

Yes, that means plug it in.

With serial communications software listening, you should see something like the following output:

CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date: Mon Nov 14 18:06:25 CST 2005 (root@localhost.localdomain)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.

Initializing Arena
Initializing Devices.

No DPN
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 3.90.37.0
CPU type 0x29008: 200MHz
Total memory: 16384 KBytes

Total memory used by CFE:  0x80300000 - 0x803A39C0 (670144)
Initialized Data:          0x803398D0 - 0x8033BFE0 (10000)
BSS Area:                  0x8033BFE0 - 0x8033D9C0 (6624)
Local Heap:                0x8033D9C0 - 0x803A19C0 (409600)
Stack Area:                0x803A19C0 - 0x803A39C0 (8192)
Text (code) segment:       0x80300000 - 0x803398D0 (235728)
Boot area (physical):      0x003A4000 - 0x003E4000
Relocation Factor:         I:00000000 - D:00000000

Boot version: v3.7
The boot is CFE

mac_init(): Find mac [00:18:39:6F:78:15] in location 0
Nothing...

eou_key_init(): Find key pair in location 0
The eou device id is same
The eou public key is same
The eou private key is same
Device eth0:  hwaddr 00-18-39-6F-78-15, ipaddr 192.168.1.1, mask 255.255.255.0
        gateway not set, nameserver not set
Loader:raw Filesys:raw Dev:flash0.os File: Options:(null)
Loading: ...... 1601536 bytes read
Entry at 0x80001000
Closing network.
Starting program at 0x80001000
CPU revision is: 00029008
Primary instruction cache 16kb, linesize 16 bytes (2 ways)
Primary data cache 8kb, linesize 16 bytes (2 ways)
Linux version 2.4.20 (root@localhost.localdomain) (gcc version 3.2.3 with Broadcom modifications)
...
(snip)
...
Hit enter to continue...

Pressing enter will give you a root shell:

BusyBox v0.60.0 (2005.11.14-09:45+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.

#

Task Four: Access the Common Firmware Environment CLI

If you reboot the router while holding CTRL+C on the serial console, you will get a CFE prompt.

CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date: Mon Nov 14 18:06:25 CST 2005 (root@localhost.localdomain)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.

Initializing Arena
Initializing Devices.

No DPN
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 3.90.37.0
CPU type 0x29008: 200MHz
Total memory: 16384 KBytes

Total memory used by CFE:  0x80300000 - 0x803A39C0 (670144)
Initialized Data:          0x803398D0 - 0x8033BFE0 (10000)
BSS Area:                  0x8033BFE0 - 0x8033D9C0 (6624)
Local Heap:                0x8033D9C0 - 0x803A19C0 (409600)
Stack Area:                0x803A19C0 - 0x803A39C0 (8192)
Text (code) segment:       0x80300000 - 0x803398D0 (235728)
Boot area (physical):      0x003A4000 - 0x003E4000
Relocation Factor:         I:00000000 - D:00000000

Boot version: v3.7
The boot is CFE

mac_init(): Find mac [00:18:39:6F:78:15] in location 0
Nothing...

eou_key_init(): Find key pair in location 0
The eou device id is same
The eou public key is same
The eou private key is same
Device eth0:  hwaddr 00-18-39-6F-78-15, ipaddr 192.168.1.1, mask 255.255.255.0
        gateway not set, nameserver not set
Automatic startup canceled via Ctrl-C
CFE> ^C
CFE> ^C
CFE>

See the CFE page for more information about using this prompt.

What to do next?

Now that you have successfully modified and connected to your router, you are ready to Build and Deploy XINU.



This work is supported in part by NSF grant DUE-CCLI-0737476.