-------------------------------------------------------
Readme_nedk_germs.txt
-------------------------------------------------------
Purpose: This document describes how to build and use
the germs server and germs client applications.  When used together,
these applications enable a user workstation to talk to the NIOS GERMS
monitor over UDP.  


-------------------------------------------------------
UDP Germs: First Time Running
-------------------------------------------------------
Purpose: In this case, the UDP GERMS server is running out of system RAM
at the default program location (0x41000).  The monitor can be used to load and run
user applications. They must, however, be "moved" to a different address than
they are normally linked to.  This scenario is basically only good for testing
the germs server application...

Assumptions:
The hardware design that is being used has a working germs monitor in it.
One of the reference designs should do nicely.

Steps:
0) Copy off the source tree:
   To build the UDP GERMS server and client applications, you will be modifying
   the provided user libraries.  The easiest way to do this is to copy off and
   rename the top level user project directory.  The top level has the following
   structure:
   
   <project name>
	    |
	    \--inc
	    \--lib	
	    \--src
	    \--doc
	    
   (Note: From here on the copied project directory will be referred to as
   <project name>, and the original will be called <old project name>)

1) Recompile GERMS server:
   Goto the <project name>/src directory and execute the
   following command:
   > make -f Makefile_nedk all

   This command will build the GERMS server and client applications.
   
   Note: The Makefile_nedk Makefile script contains some #defines
   for defining the behavior of the client and server applications.
   This Makefile contains two useful defines for building the applications:
   SERVER_PORT		  <port number>
   BUILD_FOR_ETHERNET	  <1/0>
   TARGET		  <WINDOWS/SOLARIS/HPUX>

   Please select the necessary options for your UDP germs server and client.

2) Download File:
   After the GERMS server and client applications have been built, it is now
   time to program the NIOS evaluation board with the server application.
   You will first need to program the GERMS server application (germs_server)
   into the NIOS evaluation board.

   >nr germs_server.srec

   This should download the germs server application into the NIOS development board and 
   run it.
   
3) Test GERMS UDP server application
   To test the GERMS UDP server application, execute the client program with the following
   command:
   >germs_client -n <GERMS server IP> -t  (where IP is the programmed IP address of the
					   NIOS board (set by the hello_plugs application))
   
   After the application is running, you should hit the <RETURN> key on your keyboard to 
   make contact with the GERMS server.  After a small delay, you should be see a GERMS
   prompt.  
   
   Entering the following command at the prompt should bring up a help menu ?<RETURN>.

5) Build test application:
   Go back the <old project name> directory and try building one of the standard test
   applications.  In this case, we will do this with the hello_world application:
  
   >nios-build -b 0x60000 hello_world.c

   The hello_world application relies on printing characters to a built in serial port
   in the hardware design.  To see the output of the this program on a workstation, you 
   will need to open a serial connection to the NIOS evaluation board.  This 
   is easily accomplished through the use of the nios-run command, done as follows:
   >nios-run -t 
 
   To build the user application, do:
   >germs_client -n <GERMS server IP> hello_world.srec
   
   (Note:  You really do need to include the -b flag and address for the build.  
   Not doing so will result in the test application over writing the GERMS server 
   application (both linked to run at the same memory location).



-------------------------------------------------------
UDP Germs: Running From FLASH
-------------------------------------------------------

Purpose:  In the case where the UDP Germs monitor is expected
to be present all the time, the monitor can be made to execute
mostly out of FLASH.  A user can then create software which will
operate out of the "free" memory regions without having to modify 
the development flow cycle.

Assumptions:
The hardware design that is being used has a working germs monitor in it.
One of the reference designs should do nicely.


Steps:
0) Copy off the source tree:
   To build the UDP GERMS server and client applicaitons, you will be modifying
   the provided user libraries.  The easiest way to do this is to copy off and
   rename the top level user project directory.  The top level has the following
   structure:
   
   <project name>
	    |
	    \--inc
	    \--lib	
	    \--src
	    \--doc
	    
   (Note: From here on the copied project directory will be referred to as
   <project name>, and the original will be called <old project name>)

1) Rebuild libraries:
   Goto the <project name>/lib directory and modify both the 
   nios_map.h and nios_map.s files to the new memory map settings.

   --------------------------------------
   GERMS server memory map
   --------------------------------------
   **************  0x200000	     ---|
   *		*			|
   *		*			|
   *		*			| FLASH 
   **************  0x110000		| MEMORY
   *(TEXT SEG)	*			|
   **************  0x108000		|
   *		*			|
   **************  0x100000	     ---|
	\\	
   **************  0x80000	     ---|
   *(DATA SEG)	*		        |         
   **************  0x78000		|
   *		*			| SRAM 
   *		*			| MEMORY
	\\				|
   *		*			|
   **************  0x41000		|
   *(VECTOR TAB	*			|
   **************  0x40000	     ---|


   To match this memory map, make the following changes:
   nasys_program_mem	     -> 0x108000
   nasys_program_mem_end     -> 0x110000
   nasys_data_mem	     -> 0x78000
   nasys_data_mem_end	     ->	0x80000
   nasys_stack_top	     -> 0x80000
   nasys_vector_table	     -> 0x40000
   nasys_vector_table_end    -> 0x40100


   --------------------------------------
   Plugs size reduction
   --------------------------------------
   Modify the file plugs.h in the <project name>/inc directory
   to have the following settings:

   PLUGS_DEBUG		 0
   PLUGS_ADAPTER_COUNT	 2
   PLUGS_DNS		 0
   PLUGS_PING		 1
   PLUGS_TCP		 0

   These settings will reduce the plugs library size while preserving
   necessary functionality. 

   Recompile the user libraries.  Goto the <project name>/lib 
   directory and perform "make all" command.  This will rebuild 
   the user libraries with the new memory map and plugs library
   configuration.  This new library will be used in the creation
   of the GERMS server executable.

2) Recompile GERMS server:
   Now that the necessary library files have been rebuilt, 
   it is time to build the GERMS server application.
   Goto the <project name>/src directory and execute the
   following command:
   > make -f Makefile_nedk all

   This command will build the GERMS server and client applications.
   
   Note: The Makefile_nedk Makefile script contains some #defines
   for defining the behavior of the client and server applications.
   This Makefile contains two useful defines for building the applications:
   SERVER_PORT		  <port number>
   BUILD_FOR_ETHERNET	  <1/0>
   TARGET		  <WINDOWS/SOLARIS/HPUX>

   Please select the necessary options for your UDP germs server and client.

3) Download File
   After the GERMS server and client applications have been built, it is now
   time to program the NIOS evaluation board with the server application.
   You will first need to program the GERMS server application (germs_server)
   into the NIOS evaluation board.

   Two Step Programming:
   a)Erase FLASH sector for program storage
   Start the nios-run application to talk to the GERMS monitor (through serial):
   >nios-run -t

   This command should connect you to the standard (non ethernet) GERMS application
   running on the standard ethernet reference design.  Executing the following 
   GERMS monitor command should erase the FLASH sector for storing 
   the germs_server application:
   >e108000
   Exit the monitor (CTL-C) and return to the BASH (workstation) shell.

   b)Program FLASH sector with germs_server application.  This is done by executing
   the following command from the workstation shell:
   >nios-run germs_server.srec
   
   This should copy the germs_server application into the proper FLASH sector (0x108000).
   If the existing hardware design is one of the reference designs, you should be able to 
   type the following at the GERMS monitor (old, non-network aware GERMS):
   >g108000
   This should cause the new GERMS server to be executed.
   
4) Test GERMS UDP server application
   To test the GERMS UDP server application, execute the client program with the following
   command:
   >germs_client -n <GERMS server IP> -t  (where IP is the programmed IP address of the
					   NIOS board (set by the hello_plugs application))
   
   After the application is running, you should hit the <RETURN> key on your keyboard to 
   make contact with the GERMS server.  After a small delay, you should be see a GERMS
   prompt.  
   
   Entering the following command at the prompt should bring up a help menu ?<RETURN>.

5) Build test application:
   Go back the <old project name> directory and try building one of the standard test
   applications.  In this case, we will do this with the hello_world application:
  
   >nb hello_world.c

   The hello_world application relies on printing characters to a built in serial port
   in the hardware design.  To see the output of the this program on a workstation, you 
   will need to open a serial connection to the NIOS evaluation board.  This 
   is easily accomplished through the use of the nios-run command, done as follows:
   >nios-run -t 
 
   To build the user application, do:
   >germs_client -n <GERMS server IP> hello_world.srec
   
6) Making GERMS server self booting:									   
   In order to make the GERMS server application self booting, you will need to change the boot
   address of the hardware design.  This is done by going into the SOPC builder (under Quartus)
   and modifying the boot address to be address 0x108000 (or whereever the new germs server 
   has been linked to).  You will then need to download this new hardware design into the board
   following the steps of the Nios Development Board Guide.
	    
