Difference between revisions of "Deploy Xinu"

From Embedded Xinu
Jump to navigation Jump to search
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
[[Category:HOWTO]]
 
By this point it is assumed you have [[List_of_supported_platforms| obtained a supported router]] to use as a back end, have [[HOWTO:Modify_the_Linksys_hardware| made the necessary modifications]] to use the serial port, have [[HOWTO:Connect_to_a_modified_router| connected to your backend router]] using serial communication software (such as PICOCOM), and have [[HOWTO:Build XINU#Cross-Compiler| built a cross-compiler]] (from your host computer's architecture to MIPS) and used it to [[HOWTO:Build XINU#Building the XINU Image|build a XINU boot image]] to run on the back end (a file called <code> xinu.boot </code> should be in your <code> compile </code> directory). If you have not it is suggested you visit http://mulug.mscs.mu.edu/xinu/ to understand what you need and why.
 
By this point it is assumed you have [[List_of_supported_platforms| obtained a supported router]] to use as a back end, have [[HOWTO:Modify_the_Linksys_hardware| made the necessary modifications]] to use the serial port, have [[HOWTO:Connect_to_a_modified_router| connected to your backend router]] using serial communication software (such as PICOCOM), and have [[HOWTO:Build XINU#Cross-Compiler| built a cross-compiler]] (from your host computer's architecture to MIPS) and used it to [[HOWTO:Build XINU#Building the XINU Image|build a XINU boot image]] to run on the back end (a file called <code> xinu.boot </code> should be in your <code> compile </code> directory). If you have not it is suggested you visit http://mulug.mscs.mu.edu/xinu/ to understand what you need and why.
  
Line 5: Line 6:
  
 
=== Installing the TFTP Server Package ===
 
=== Installing the TFTP Server Package ===
 +
 
The first step in running your XINU image is to run a '''TFTP Server''' on your front end so that it can transfer the boot image onto the back end via the network connection. Getting a '''TFTP Server''' running on your front end is a fairly simple process on Linux. Use your front end's package install commands to search for a tftp-server package and then install that package. Using Fedora 9 and the YUM package install command, we entered the command <code> yum list | grep tftp </code> and obtained the following output:
 
The first step in running your XINU image is to run a '''TFTP Server''' on your front end so that it can transfer the boot image onto the back end via the network connection. Getting a '''TFTP Server''' running on your front end is a fairly simple process on Linux. Use your front end's package install commands to search for a tftp-server package and then install that package. Using Fedora 9 and the YUM package install command, we entered the command <code> yum list | grep tftp </code> and obtained the following output:
<pre>[root@argolis compile]# yum list | grep tftp
+
 
tftp.i386                                0.48-6.fc9            mulugupdates     
+
[root@argolis compile]# yum list | grep tftp
tftp-server.i386                        0.48-6.fc9            mulugupdates     
+
tftp.i386                                0.48-6.fc9            mulugupdates     
[root@argolis compile]#</pre>
+
tftp-server.i386                        0.48-6.fc9            mulugupdates     
 +
[root@argolis compile]#
  
 
This command tells the package installer to find any packages with "tftp" in the title. We want the package called ''tftp-server.i386'' because this will allow us to run a '''TFTP-Server''' on our front end machine. Next, we need to actually install the package. Again we use our package install command to install the package. Using Fedora 9 and the YUM package install command, we entered the command <code> yum install tftp-server </code> and obtained the following output:
 
This command tells the package installer to find any packages with "tftp" in the title. We want the package called ''tftp-server.i386'' because this will allow us to run a '''TFTP-Server''' on our front end machine. Next, we need to actually install the package. Again we use our package install command to install the package. Using Fedora 9 and the YUM package install command, we entered the command <code> yum install tftp-server </code> and obtained the following output:
<pre>[root@argolis compile]# yum install tftp-server
 
Loaded plugins: refresh-packagekit
 
Setting up Install Process
 
Parsing package install arguments
 
Resolving Dependencies
 
--> Running transaction check
 
---> Package tftp-server.i386 0:0.48-6.fc9 set to be updated
 
--> Finished Dependency Resolution
 
  
Dependencies Resolved
+
[root@argolis compile]# yum install tftp-server
 +
Loaded plugins: refresh-packagekit
 +
Setting up Install Process
 +
Parsing package install arguments
 +
Resolving Dependencies
 +
--> Running transaction check
 +
---> Package tftp-server.i386 0:0.48-6.fc9 set to be updated
 +
--> Finished Dependency Resolution
 +
 +
Dependencies Resolved
 +
 +
=============================================================================
 +
  Package                Arch      Version          Repository        Size
 +
=============================================================================
 +
Installing:
 +
  tftp-server            i386      0.48-6.fc9      mulugupdates      35 k
 +
 +
Transaction Summary
 +
=============================================================================
 +
Install      1 Package(s)       
 +
Update      0 Package(s)       
 +
Remove      0 Package(s)       
 +
 +
Total download size: 35 k
 +
Is this ok [y/N]: yes
 +
Downloading Packages:
 +
(1/1): tftp-server-0.48-6.fc9.i386.rpm                  |  35 kB    00:00   
 +
Running rpm_check_debug
 +
Running Transaction Test
 +
Finished Transaction Test
 +
Transaction Test Succeeded
 +
Running Transaction
 +
  Installing: tftp-server                  ######################### [1/1]
 +
 +
Installed: tftp-server.i386 0:0.48-6.fc9
 +
Complete!
 +
[root@argolis compile]#
  
=============================================================================
+
=== Configuring the TFTP Server ===
Package                Arch      Version          Repository        Size
 
=============================================================================
 
Installing:
 
tftp-server            i386      0.48-6.fc9      mulugupdates      35 k
 
  
Transaction Summary
+
Now that your '''TFTP Server''' package is installed, you need to configure some settings to get it to run properly. ''xinetd'' is a server daemon that can run many different types of servers. Here, though, we're only interested in running a '''TFTP Server''', so we want to configure the daemon to run that. The following commands will configure the ''xinetd'' daemon to run a '''TFTP Server''' on the front end:
=============================================================================
+
The command <code> chkconfig xinetd on </code> will configure the ''xinetd'' daemon to run on the front end.
Install      1 Package(s)       
+
The command <code> chkconfig tftp on </code> configures the daemon to run a '''TFTP Server''' when it is running.
Update      0 Package(s)       
+
The next command, <code> service xinetd restart </code> actually restarts the ''xinetd'' daemon to make sure its up and running.
Remove      0 Package(s)       
+
After entering the previous commands we got the following output:
 +
<pre>[root@argolis trunk]# chkconfig xinetd on
 +
[root@argolis trunk]# chkconfig tftp on
 +
[root@argolis trunk]# service xinetd restart
 +
Stopping xinetd:                                          [  OK  ]
 +
Starting xinetd:                                          [  OK  ]
 +
[root@argolis trunk]# </pre>
  
Total download size: 35 k
+
To verify that things worked correctly it is a good idea to type in the command <code> chkconfig --list </code> and check to make sure ''xinetd'' is running and that it is running a '''TFTP Server'''. You should get output that looks like this:
Is this ok [y/N]: yes
+
<pre>
Downloading Packages:
+
[root@argolis compile]# chkconfig --list
(1/1): tftp-server-0.48-6.fc9.i386.rpm                  | 35 kB    00:00    
+
NetworkManager  0:off  1:off  2:off  3:off  4:off  5:off  6:off
Running rpm_check_debug
+
acpid          0:off  1:off  2:on    3:on    4:on    5:on    6:off
Running Transaction Test
+
anacron        0:off  1:off  2:on    3:on    4:on    5:on    6:off
Finished Transaction Test
+
atd            0:off  1:off  2:off  3:on    4:on    5:on    6:off
Transaction Test Succeeded
+
auditd          0:off  1:off  2:on    3:on    4:on    5:on    6:off
Running Transaction
+
avahi-daemon    0:off  1:off  2:off  3:on    4:on    5:on    6:off
  Installing: tftp-server                  ######################### [1/1]
+
...
 +
...
 +
...
 +
winbind        0:off  1:off  2:off  3:off  4:off  5:off  6:off
 +
wpa_supplicant 0:off  1:off  2:off  3:off  4:off  5:off  6:off
 +
xinetd          0:off  1:off  2:off  3:on    4:on    5:on    6:off
 +
xinu-consoled  0:off  1:off  2:off  3:on    4:on    5:on    6:off
 +
ypbind          0:off  1:off  2:off  3:off  4:off  5:off  6:off
 +
yum-updatesd    0:off  1:off  2:on    3:on    4:on    5:on   6:off
 +
 +
xinetd based services:
 +
        chargen-dgram:  off
 +
        chargen-stream: off
 +
        cvs:            off
 +
        daytime-dgram:  off
 +
        daytime-stream: off
 +
        discard-dgram:  off
 +
        discard-stream: off
 +
        echo-dgram:    off
 +
        echo-stream:    off
 +
        rsync:          off
 +
        tcpmux-server: off
 +
        tftp:          on
 +
        time-dgram:    off
 +
        time-stream:    off
 +
[root@argolis compile]# </pre>
  
Installed: tftp-server.i386 0:0.48-6.fc9
+
The important lines in this output are the ''xinetd'' line in the list of services and the ''tftp'' line at the bottom section of xinetd based services. Make sure that the ''xinetd'' line says "on" for 3 and 5. Also make sure that the ''tftp'' line says "on".
Complete!
 
[root@argolis compile]#</pre>
 
  
=== Configuring the TFTP Server ===
+
By default the '''TFTP Server''' running on ''xinetd'' uses the directory <code> /var/lib/tftpboot </code> as its directory that will contain files on your server that you wish to make accessible to tftp clients. We will simply refer to this directory as the ''tftp server directory'' for the remainder of the tutorial. Using this directory is fine, but if you wish to change your ''tftp server directory'' the process is simple. Opening up the tftp configuration file for ''xinetd'' (ours was found in the path <code> /etc/xinetd.d/tftp</code>) should give you the output:
Now that your '''TFTP Server''' package is installed, you need to configure some settings to get it to run properly. First open the file <code> /etc/xinetd.d/tftp</code>. ''xinetd'' is a server daemon that can run many different types of servers. Here, though, we're only interested in running a '''TFTP Server''', so we open the tftp configuration file for ''xinetd'' and make the necessary changes. At first, the file should look something like this:
 
 
<pre># default: off
 
<pre># default: off
 
# description: The tftp server serves files using the trivial file transfer \
 
# description: The tftp server serves files using the trivial file transfer \
Line 59: Line 114:
 
service tftp
 
service tftp
 
{
 
{
 +
        disable = no
 
         socket_type            = dgram
 
         socket_type            = dgram
 
         protocol                = udp
 
         protocol                = udp
Line 65: Line 121:
 
         server                  = /usr/sbin/in.tftpd
 
         server                  = /usr/sbin/in.tftpd
 
         server_args            = -s /var/lib/tftpboot
 
         server_args            = -s /var/lib/tftpboot
        disable                = yes
 
 
         per_source              = 11
 
         per_source              = 11
 
         cps                    = 100 2
 
         cps                    = 100 2
Line 71: Line 126:
 
}</pre>
 
}</pre>
  
You need to change the values of the <code> disable </code> and <code> server_args </code> variables. Change the value of <code> disable </code> to "no" and the value of <code> server_args </code> to point to the directory that will contain files you wish to share on your '''TFTP Server'''. In our lab we use the directory <code> /tftpboot </code>. You need to remember this directory because this is where you will need to put your <code> xinu.boot </code> file that you want to run on the back end. After you've made the necessary changes to the file <code> /etc/xinetd.d/tftp </code>, it should look like this:
 
<pre># default: off
 
# description: The tftp server serves files using the trivial file transfer \
 
#      protocol.  The tftp protocol is often used to boot diskless \
 
#      workstations, download configuration files to network-aware printers, \
 
#      and to start the installation process for some operating systems.
 
service tftp
 
{
 
        socket_type            = dgram
 
        protocol                = udp
 
        wait                    = yes
 
        user                    = root
 
        server                  = /usr/sbin/in.tftpd
 
        server_args            = -s /tftpboot
 
        disable                = no
 
        per_source              = 11
 
        cps                    = 100 2
 
        flags                  = IPv4
 
}</pre>
 
  
If you are going to use our approach you may need to create a <code> /tftpboot </code> directory. To do this execute the following command: <code> mkdir /tftpboot </code>. Then you'll want to check to make sure that the ''xinetd'' is running, and make sure that its running a '''TFTP Server'''. Execute the command <code> chkconfig --list </code>. You should get output that looks like this:
+
You need to change the value of the <code> server_args </code> variable. Change the value of <code> server_args </code> to point to the directory you wish to be your ''tftp server directory''. In our lab we use the directory <code> /tftpboot </code>. You will need to remember your ''tftp server directory'' because this is where you will need to put your <code> xinu.boot </code> file that you want to run on the back end. After you've made the necessary changes to the file <code> /etc/xinetd.d/tftp </code>, it should look like this:
<pre>[root@argolis compile]# chkconfig --list
+
<pre> # default: off
NetworkManager 0:off  1:off  2:off  3:off  4:off  5:off  6:off
+
# description: The tftp server serves files using the trivial file transfer \
acpid          0:off  1:off  2:on    3:on    4:on    5:on    6:off
+
#      protocol.  The tftp protocol is often used to boot diskless \
anacron        0:off  1:off  2:on    3:on    4:on    5:on    6:off
+
#      workstations, download configuration files to network-aware printers, \
atd             0:off  1:off  2:off  3:on    4:on    5:on    6:off
+
  #      and to start the installation process for some operating systems.
auditd         0:off  1:off  2:on    3:on    4:on    5:on    6:off
+
service tftp
avahi-daemon    0:off  1:off  2:off  3:on    4:on    5:on    6:off
+
{
...
+
        socket_type             = dgram
...
+
         protocol                = udp
...
+
        wait                    = yes
winbind        0:off  1:off  2:off  3:off  4:off  5:off  6:off
+
        user                    = root
wpa_supplicant  0:off  1:off  2:off  3:off  4:off  5:off  6:off
+
        server                  = /usr/sbin/in.tftpd
xinetd         0:off  1:off  2:off  3:on    4:on    5:on    6:off
+
        server_args            = -s /tftpboot
xinu-consoled  0:off  1:off  2:off  3:on    4:on    5:on    6:off
+
        disable                = no
ypbind         0:off  1:off  2:off  3:off  4:off  5:off  6:off
+
        per_source              = 11
yum-updatesd    0:off  1:off  2:on    3:on    4:on    5:on    6:off
+
         cps                    = 100 2
 +
         flags                  = IPv4
 +
}</pre>
  
xinetd based services:
+
If you are going to use our approach you may need to create a <code> /tftpboot </code> directory. To do this execute the following command: <code> mkdir /tftpboot </code>. Anytime you make changes to the <code> /etc/xinetd.d/tftp </code> file you will need to restart your ''xinetd'' daemon again with the command <code> service xinetd restart </code>.
        chargen-dgram:  off
 
        chargen-stream: off
 
        cvs:            off
 
        daytime-dgram:  off
 
        daytime-stream: off
 
        discard-dgram:  off
 
        discard-stream: off
 
        echo-dgram:    off
 
        echo-stream:    off
 
        rsync:          off
 
        tcpmux-server:  off
 
        tftp:          on
 
        time-dgram:    off
 
        time-stream:    off
 
[root@argolis compile]# </pre>
 
  
The important lines in this output are the ''xinetd'' line in the list of services and the ''tftp'' line at the bottom section of xinetd based services. Make sure that the ''xinetd'' line says "on" for 3, 4, and 5. Also make sure that the ''tftp'' line says "on".
+
There are a couple other configurations that you may need to set up in order to get your '''TFTP Server''' running. If your front end is running a ''SE Linux'' firewall (our front end with a fresh install of Fedora 9 came running this firewall by default) you may have to configure it to allow clients to access your front end's '''TFTP Server''' running through ''xinetd''. The simplest solution is to just tell the ''SE Linux'' firewall to allow any activity over the network connection your front end is using to connect to the back end. Our front end machine is set up with two network cards and configured so that <code>eth0</code> is our network connection to the outside world and <code>eth1</code> is our connection to our back end. To tell the firewall to accept all activity over our network connection with the backend we used the command <code> iptables -I INPUT -i eth1 -j ACCEPT</code>. If you do not want to run this command every time you restart your machine you can add the line to the <code> /etc/rc.local </code> file. This will automatically run that command every time the system boots up. '''NOTE:''' this could be very dangerous because the connection between your front end and back end is now '''insecure'''. This should only be done if you trust all possible users of the backend because they now have unchecked access to your frontend machine.
  
There are a couple other configurations that you may need to set up in order to get your '''TFTP Server''' running. If your front end is running a ''SE Linux'' firewall (our front end with a fresh install of Fedora 9 came running this firewall by default) you may have to configure it to allow clients to access your front end's '''TFTP Server''' running through ''xinetd''. The simplest solution is to just tell the ''SE Linux'' firewall to allow any activity over the network connection your front end is using to connect to the back end. Our front end machine is set up with two network cards and configured so that <code>eth0</code> is our network connection to the outside world and <code>eth1</code> is our connection to our back end. To tell the firewall to accept all activity over our network connection with the backend we used the command <code> iptables -I INPUT -i eth1 -j ACCEPT</code>. '''NOTE:''' this could be very dangerous because the connection between your front end and back end is now '''insecure'''. This should only be done if you trust all possible users of the backend because they now have unchecked access to your frontend machine.
+
Also, you may need to configure your frontend's IP address. If you are using a DHCP server for your frontend machine you can simply execute <code> ifconfig eth0 -auto </code> on your backend's CFE prompt to obtain an IP for your backend automatically. However, most likely this is not the case and you will have to make sure that the network connection that your front end machine is using to communicate with the backend is configured with a static IP address in the 192.168.1.[2-255] range because your backend router will have a default IP address of 192.168.1.1 when it reboots. If it is the case that the IP address of your frontend machine's network connection with the backend is set outside of this range, then check out our quick tutorial for [[HOWTO:Change your Frontend's IP Address |changing the IP address]] of your network connection.
  
Also, you may need to configure your frontend's IP address. If you are using a DHCP server for your frontend machine you can simply execute <code> ifconfig eth0 -auto </code> on your backend's CFE prompt to obtain an IP for your backend automatically. However, most likely this is not the case and you will have to make sure that the network connection that your front end machine is using to communicate with the backend is configured with a static IP address in the 192.168.1.[2-255] range because your backend router will have a default IP address of 192.168.1.1 when it reboots. If it is the case that the IP address of your frontend machine's network connection with the backend is set outside of this range, then click [[HOWTO:Change your Frontend's IP Address | here]] for a quick tutorial on changing the IP address of your network connection.
+
The last step before actually trying to boot your backend with a XINU image, is to copy the actual <code>xinu.boot</code> file to the ''tftp server directory''. This is the directory that the <code> /etc/xinetd.d/tftp </code> file's <code> server_args </code> variable points to. In our example we used the directory <code> /tftpboot</code>. This is the directory where you need to copy the <code> xinu.boot </code> file. This is easily done by using a command like <code> cp xinu.boot /tftpboot/xinu.boot</code>, assuming that your current working directory contains the <code> xinu.boot </code> file and that <code> /tftpboot </code> is your ''tftp server directory''.
 
 
The last step before actually trying to boot your backend with a XINU image, is to copy the actual <code>xinu.boot</code> file to the directory from which the '''TFTP Server''' allows clients to get files. This is the directory that the <code> /etc/xinetd.d/tftp </code> file's <code> server_args </code> variable points to. In our example we used the directory <code> /tftpboot</code>. This is the directory where you need to copy the <code> xinu.boot </code> file. This is easily done by using a command like <code> cp xinu.boot /tftpboot/xinu.boot</code>, assuming that your current working directory contains the <code> xinu.boot </code> file and that <code> /tftpboot </code> is the directory from which your '''TFTP Server''' allows clients to get files.
 
  
 
== Booting XINU on your Backend ==
 
== Booting XINU on your Backend ==
Line 139: Line 160:
  
 
To boot your backend router running XINU, first make sure you are connected to the backend with some serial communication software and are at the CFE prompt. If you are not looking at the backend router's CFE prompt follow the instructions on how to [[HOWTO:Connect_to_a_modified_router| connect to your backend router]]. In the CFE prompt type the command <code> boot -elf [host ip]:xinu.boot </code> where "[host ip]" is the IP address of the frontend machine's connection to the backend router. If all has gone correctly the router should now be running a XINU image and you will be greeted with a basic shell (xsh$ ). On our frontend machine running Fedora 9 with an IP address of <code> 192.168.1.2 </code> we optained the following output:
 
To boot your backend router running XINU, first make sure you are connected to the backend with some serial communication software and are at the CFE prompt. If you are not looking at the backend router's CFE prompt follow the instructions on how to [[HOWTO:Connect_to_a_modified_router| connect to your backend router]]. In the CFE prompt type the command <code> boot -elf [host ip]:xinu.boot </code> where "[host ip]" is the IP address of the frontend machine's connection to the backend router. If all has gone correctly the router should now be running a XINU image and you will be greeted with a basic shell (xsh$ ). On our frontend machine running Fedora 9 with an IP address of <code> 192.168.1.2 </code> we optained the following output:
<pre>CFE> boot -elf 192.168.1.2:xinu.boot
 
Loader:elf Filesys:tftp Dev:eth0 File:192.168.1.2:xinu.boot Options:(null)
 
Loading: 0x80001000/114724 0x8001d024/18480 Entry at 0x80001000
 
Closing network.
 
Starting program at 0x80001000
 
(Mips XINU) #0 (root@argolis.mscs.mu.edu) Mon Jun 23 17:47:42 CDT 2008
 
 
  16777216 bytes physical memory.
 
      4096 bytes reserved system area.
 
    133204 bytes XINU code.
 
    32764 bytes stack space.
 
  16607152 bytes heap space.
 
 
______________________________________
 
    _    _  _____  ______  _    _
 
  \ \  / /(_____)|  ___ \ | |  | |
 
    \ \/ /    _  | |  | || |  | |
 
    )  (    | |  | |  | || |  | |
 
    / /\ \  _| |_ | |  | || |___| |
 
  /_/  \_\(_____)|_|  |_| \______|
 
______________________________________
 
  
Welcome to the wonderful world of XINU!
+
CFE> boot -elf 192.168.1.2:xinu.boot
xsh$ </pre>
+
Loader:elf Filesys:tftp Dev:eth0 File:192.168.1.2:xinu.boot Options:(null)
 +
Loading: 0x80001000/114724 0x8001d024/18480 Entry at 0x80001000
 +
Closing network.
 +
Starting program at 0x80001000
 +
(Mips XINU) #0 (root@argolis.mscs.mu.edu) Mon Jun 23 17:47:42 CDT 2008
 +
 +
  16777216 bytes physical memory.
 +
      4096 bytes reserved system area.
 +
    133204 bytes XINU code.
 +
      32764 bytes stack space.
 +
  16607152 bytes heap space.
 +
 +
______________________________________
 +
    _    _  _____  ______  _    _
 +
    \ \  / /(_____)|  ___ \ | |  | |
 +
    \ \/ /    _  | |  | || |  | |
 +
      )  (    | |  | |  | || |  | |
 +
    / /\ \  _| |_ | |  | || |___| |
 +
    /_/  \_\(_____)|_|  |_| \______|
 +
______________________________________
 +
 +
Welcome to the wonderful world of XINU!
 +
xsh$  
  
 
Within the shell you have some basic commands: exit, gpiostat, help, kill, memstat, led, ps, reset, sleep, uartstat. Each can be described using [command] --help.  
 
Within the shell you have some basic commands: exit, gpiostat, help, kill, memstat, led, ps, reset, sleep, uartstat. Each can be described using [command] --help.  
<pre>xsh$ help
 
Shell Commands:
 
        clear
 
        ethstat
 
        exit
 
        gpiostat
 
        help
 
        kill
 
        led
 
        memstat
 
        memdump
 
        ps
 
        reset
 
        sleep
 
        test
 
        testsuite
 
        uartstat
 
        nvram
 
        ?
 
xsh$ </pre>
 
  
Congratulations, You now have a working backend running XINU! You can now make changes to the XINU code, recompile it using the <code> make </code> command to get a new <code> xinu.boot </code> image, copy that file into the <code> /tftpboot </code> directory (or whatever directory your '''TFTP Server''' uses to share files), and use the same <code> boot -elf [host ip]:xinu.boot </code> command to run your very own, modified version of the XINU operating system.
+
xsh$ help
 +
Shell Commands:
 +
        clear
 +
        ethstat
 +
        exit
 +
        gpiostat
 +
        help
 +
        kill
 +
        led
 +
        memstat
 +
        memdump
 +
        ps
 +
        reset
 +
        sleep
 +
        test
 +
        testsuite
 +
        uartstat
 +
        nvram
 +
        ?
 +
xsh$
  
 +
Congratulations, You now have a working backend running XINU! You can now make changes to the XINU code, recompile it using the <code> make </code> command to get a new <code> xinu.boot </code> image, copy that file into the ''tftp server directory'', and use the same <code> boot -elf [host ip]:xinu.boot </code> command to run your very own, modified version of the XINU operating system.
  
 
==  What to do next? ==
 
==  What to do next? ==
Line 196: Line 218:
  
  
<hr/>
+
----
 
''This work is supported in part by NSF grant DUE-CCLI-0737476.''
 
''This work is supported in part by NSF grant DUE-CCLI-0737476.''

Latest revision as of 03:35, 19 December 2008

By this point it is assumed you have obtained a supported router to use as a back end, have made the necessary modifications to use the serial port, have connected to your backend router using serial communication software (such as PICOCOM), and have built a cross-compiler (from your host computer's architecture to MIPS) and used it to build a XINU boot image to run on the back end (a file called xinu.boot should be in your compile directory). If you have not it is suggested you visit http://mulug.mscs.mu.edu/xinu/ to understand what you need and why.


TFTP Server

Installing the TFTP Server Package

The first step in running your XINU image is to run a TFTP Server on your front end so that it can transfer the boot image onto the back end via the network connection. Getting a TFTP Server running on your front end is a fairly simple process on Linux. Use your front end's package install commands to search for a tftp-server package and then install that package. Using Fedora 9 and the YUM package install command, we entered the command yum list | grep tftp and obtained the following output:

[root@argolis compile]# yum list | grep tftp
tftp.i386                                0.48-6.fc9             mulugupdates    
tftp-server.i386                         0.48-6.fc9             mulugupdates    
[root@argolis compile]#

This command tells the package installer to find any packages with "tftp" in the title. We want the package called tftp-server.i386 because this will allow us to run a TFTP-Server on our front end machine. Next, we need to actually install the package. Again we use our package install command to install the package. Using Fedora 9 and the YUM package install command, we entered the command yum install tftp-server and obtained the following output:

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

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size 
=============================================================================
Installing:
 tftp-server             i386       0.48-6.fc9       mulugupdates       35 k 

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

Total download size: 35 k
Is this ok [y/N]: yes
Downloading Packages:
(1/1): tftp-server-0.48-6.fc9.i386.rpm                   |  35 kB     00:00    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: tftp-server                  ######################### [1/1] 

Installed: tftp-server.i386 0:0.48-6.fc9
Complete!
[root@argolis compile]#

Configuring the TFTP Server

Now that your TFTP Server package is installed, you need to configure some settings to get it to run properly. xinetd is a server daemon that can run many different types of servers. Here, though, we're only interested in running a TFTP Server, so we want to configure the daemon to run that. The following commands will configure the xinetd daemon to run a TFTP Server on the front end: The command chkconfig xinetd on will configure the xinetd daemon to run on the front end. The command chkconfig tftp on configures the daemon to run a TFTP Server when it is running. The next command, service xinetd restart actually restarts the xinetd daemon to make sure its up and running. After entering the previous commands we got the following output:

[root@argolis trunk]# chkconfig xinetd on
[root@argolis trunk]# chkconfig tftp on
[root@argolis trunk]# service xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]
[root@argolis trunk]# 

To verify that things worked correctly it is a good idea to type in the command chkconfig --list and check to make sure xinetd is running and that it is running a TFTP Server. You should get output that looks like this:

 [root@argolis compile]# chkconfig --list
 NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
 acpid           0:off   1:off   2:on    3:on    4:on    5:on    6:off
 anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off
 atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
 auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
 avahi-daemon    0:off   1:off   2:off   3:on    4:on    5:on    6:off
 ...
 ...
 ...
 winbind         0:off   1:off   2:off   3:off   4:off   5:off   6:off
 wpa_supplicant  0:off   1:off   2:off   3:off   4:off   5:off   6:off
 xinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off
 xinu-consoled   0:off   1:off   2:off   3:on    4:on    5:on    6:off
 ypbind          0:off   1:off   2:off   3:off   4:off   5:off   6:off
 yum-updatesd    0:off   1:off   2:on    3:on    4:on    5:on    6:off
 
 xinetd based services:
         chargen-dgram:  off
         chargen-stream: off
         cvs:            off
         daytime-dgram:  off
         daytime-stream: off
         discard-dgram:  off
         discard-stream: off
         echo-dgram:     off
         echo-stream:    off
         rsync:          off
         tcpmux-server:  off
         tftp:           on
         time-dgram:     off
         time-stream:    off
 [root@argolis compile]# 

The important lines in this output are the xinetd line in the list of services and the tftp line at the bottom section of xinetd based services. Make sure that the xinetd line says "on" for 3 and 5. Also make sure that the tftp line says "on".

By default the TFTP Server running on xinetd uses the directory /var/lib/tftpboot as its directory that will contain files on your server that you wish to make accessible to tftp clients. We will simply refer to this directory as the tftp server directory for the remainder of the tutorial. Using this directory is fine, but if you wish to change your tftp server directory the process is simple. Opening up the tftp configuration file for xinetd (ours was found in the path /etc/xinetd.d/tftp) should give you the output:

# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        disable = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}


You need to change the value of the server_args variable. Change the value of server_args to point to the directory you wish to be your tftp server directory. In our lab we use the directory /tftpboot . You will need to remember your tftp server directory because this is where you will need to put your xinu.boot file that you want to run on the back end. After you've made the necessary changes to the file /etc/xinetd.d/tftp , it should look like this:

 # default: off
 # description: The tftp server serves files using the trivial file transfer \
 #       protocol.  The tftp protocol is often used to boot diskless \
 #       workstations, download configuration files to network-aware printers, \
 #       and to start the installation process for some operating systems.
 service tftp
 {
         socket_type             = dgram
         protocol                = udp
         wait                    = yes
         user                    = root
         server                  = /usr/sbin/in.tftpd
         server_args             = -s /tftpboot
         disable                 = no
         per_source              = 11
         cps                     = 100 2
         flags                   = IPv4
 }

If you are going to use our approach you may need to create a /tftpboot directory. To do this execute the following command: mkdir /tftpboot . Anytime you make changes to the /etc/xinetd.d/tftp file you will need to restart your xinetd daemon again with the command service xinetd restart .

There are a couple other configurations that you may need to set up in order to get your TFTP Server running. If your front end is running a SE Linux firewall (our front end with a fresh install of Fedora 9 came running this firewall by default) you may have to configure it to allow clients to access your front end's TFTP Server running through xinetd. The simplest solution is to just tell the SE Linux firewall to allow any activity over the network connection your front end is using to connect to the back end. Our front end machine is set up with two network cards and configured so that eth0 is our network connection to the outside world and eth1 is our connection to our back end. To tell the firewall to accept all activity over our network connection with the backend we used the command iptables -I INPUT -i eth1 -j ACCEPT. If you do not want to run this command every time you restart your machine you can add the line to the /etc/rc.local file. This will automatically run that command every time the system boots up. NOTE: this could be very dangerous because the connection between your front end and back end is now insecure. This should only be done if you trust all possible users of the backend because they now have unchecked access to your frontend machine.

Also, you may need to configure your frontend's IP address. If you are using a DHCP server for your frontend machine you can simply execute ifconfig eth0 -auto on your backend's CFE prompt to obtain an IP for your backend automatically. However, most likely this is not the case and you will have to make sure that the network connection that your front end machine is using to communicate with the backend is configured with a static IP address in the 192.168.1.[2-255] range because your backend router will have a default IP address of 192.168.1.1 when it reboots. If it is the case that the IP address of your frontend machine's network connection with the backend is set outside of this range, then check out our quick tutorial for changing the IP address of your network connection.

The last step before actually trying to boot your backend with a XINU image, is to copy the actual xinu.boot file to the tftp server directory. This is the directory that the /etc/xinetd.d/tftp file's server_args variable points to. In our example we used the directory /tftpboot. This is the directory where you need to copy the xinu.boot file. This is easily done by using a command like cp xinu.boot /tftpboot/xinu.boot, assuming that your current working directory contains the xinu.boot file and that /tftpboot is your tftp server directory.

Booting XINU on your Backend

By now your TFTP Server should be up and running correctly, your xinu.boot file should be in the correct directory so your backend can access it through the TFTP protocol, and your frontend machine should either be running as a DHCP server or (more likely) has a static IP address in the 192.168.1.[2-255] range on its network connection with the backend.

To boot your backend router running XINU, first make sure you are connected to the backend with some serial communication software and are at the CFE prompt. If you are not looking at the backend router's CFE prompt follow the instructions on how to connect to your backend router. In the CFE prompt type the command boot -elf [host ip]:xinu.boot where "[host ip]" is the IP address of the frontend machine's connection to the backend router. If all has gone correctly the router should now be running a XINU image and you will be greeted with a basic shell (xsh$ ). On our frontend machine running Fedora 9 with an IP address of 192.168.1.2 we optained the following output:

CFE> boot -elf 192.168.1.2:xinu.boot
Loader:elf Filesys:tftp Dev:eth0 File:192.168.1.2:xinu.boot Options:(null)
Loading: 0x80001000/114724 0x8001d024/18480 Entry at 0x80001000
Closing network.
Starting program at 0x80001000
(Mips XINU) #0 (root@argolis.mscs.mu.edu) Mon Jun 23 17:47:42 CDT 2008

  16777216 bytes physical memory.
      4096 bytes reserved system area.
    133204 bytes XINU code.
     32764 bytes stack space.
  16607152 bytes heap space.

______________________________________
    _    _  _____  ______   _     _ 
   \ \  / /(_____)|  ___ \ | |   | |
    \ \/ /    _   | |   | || |   | |
     )  (    | |  | |   | || |   | |
    / /\ \  _| |_ | |   | || |___| |
   /_/  \_\(_____)|_|   |_| \______|
______________________________________

Welcome to the wonderful world of XINU!
xsh$ 

Within the shell you have some basic commands: exit, gpiostat, help, kill, memstat, led, ps, reset, sleep, uartstat. Each can be described using [command] --help.

xsh$ help
Shell Commands:
        clear
        ethstat
        exit
        gpiostat
        help
        kill
        led
        memstat
        memdump
        ps
        reset
        sleep
        test
        testsuite
        uartstat
        nvram
        ?
xsh$ 

Congratulations, You now have a working backend running XINU! You can now make changes to the XINU code, recompile it using the make command to get a new xinu.boot image, copy that file into the tftp server directory, and use the same boot -elf [host ip]:xinu.boot command to run your very own, modified version of the XINU operating system.

What to do next?

Now that you have successfully booted and ran XINU on your backend router, you might want to try to build a pool of backends to allow multiple users to each run their own version of XINU on a different backend.

For more information on the XINU operating system check out the Embedded XINU wiki.



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