
Building the shell:

This directory contains a simple example to demonstrate the use of the
object loader from a simple shell.

The contents of this directory should be copied to a suitable working
location. It is also necessary to create and build an eCos
configuration for the desired target. This configuration may use any
template, but the shell requires the KERNEL, STDIO, SERIAL, FILEIO and
OBJLOADER packages.

To build the example shell simply execute the following make command
in the working directory:

$ make BUILD_DIR=/path/to/ecos/build/directory INSTALL_DIR=/path/to/ecos/install/directory

Replace "/path/to/ecos/build/directory" with the eCos configuration
build directory and replace "/path/to/ecos/install/directory" with the
eCos configuration install directory.

If the configuration is correct, then the executable "ecoshell" should
be built without error messages.

-----------------------------------------------------------------------
Overview:

The application consists of two source files. ecoshell.c provides the
main shell implementation plus built-in commands help, and echo.
main.c holds all the code that deals
with the objloader and IO integration. It starts up a separate thread for
the shell session, adds new built-in commands insmod, rmmod and lsmod, and
provides the I/O interface between the shell code and a serial line.
main.c contains a number of options near the top of the file:

  OLSH_SHELL_CONSOLE - This is the name of a serial device that will
  be used for the shell's console. It defaults to "/dev/ser0", and
  there may be additional ifdefs here to redefine it for certain
  platforms. If the platform does not have a working ser0, it may be
  necessary to either redefine it or change the default.

  OLSH_THREAD_STACK_SIZE - the stack for every shell thread. The
  default setting should suffice for most architectures, but if
  any new shell commands require additional stack space then this
  setting should be adjusted.

  OLSH_THREAD_PRIORITY - the priority for every shell thread. The
  default is zero, making the shell the highest prioirity thread in
  the system.

The application performs some initialization, and then spawns a thread
which prints out a banner, executes the help command, and then
executes the shell.

-----------------------------------------------------------------------
HTTPD example:

The eCos HTTPD server is capable of being built as a loadable module
which can be loaded via the shell from flash.

To configure the HTTPD server as a module, build eCos in the following way:

$ cd <ecos_build_directory>
$ ecosconfig new <target> net
$ ecosconfig import httpd_module.ecm
$ ecosconfig tree
$ make

The httpd_module.ecm file is at the end of this file. Before executing
"ecosconfig tree" it may be necessary to adjust things like DHCP
support and interface addresses as required by the target or environment.

When the make succeeds, the file "install/lib/httpd.o" is the
module. This should be downloaded as a raw binary to the target and
written to flash.

Now build the ecoshell application against this configuration.  This
may also be downloaded to flash, or may be executed via GDB. An
example session shows how the shell and module may be used:

RedBoot> fis list                                                                                                            
Name              FLASH addr  Mem addr    Length      Entry point                                                            
httpd             0x80000000  0xA000B000  0x00020000  0xA000B000                                                             
hello             0x80020000  0xA000B000  0x00020000  0xA000B000                                                             
ecoshell          0x80040000  0xA0100000  0x00060000  0xA0100040                                                             
FIS directory     0x803F0000  0x803F0000  0x0000F000  0x00000000                                                             
RedBoot config    0x803FF000  0x803FF000  0x00001000  0x00000000                                                             
RedBoot> fis load ecoshell                                                                                                   
RedBoot> go
INFO: <code from 0xa0100040 -> 0xa014a88c, CRC 56e2>                                                                         
                                                                                                                             
                                                                                                                             
Module Test Shell                                                                                                            
                                                                                                                             
help [command]     - provide help information.                                                                               
memory             - provide information about current resource usage.                                                       
echo [args]        - echo the arguments back to the user.                                                                    
# [text]           - comment.                                                                                                
insmod [file]      - install a module and execute it.                                                                        
rmmod [n]          - remove a module.                                                                                        
lsmod              - list current modules.                                                                                   
eCos> insmod httpd                                                                                                           
Installed as module #0
eCos>


At this point the module is loaded and has been initialized with a
call to it's module_open() function. A web browser can connect to
"/monitor" on port 80 of the target machine and see the HTTPD system
monitor.

This target also has a copy of the hello.o module used for objloader
testing, and this can be loaded too:

eCos> ins hello                                                                                                              
INFO:<Module initialized>                                                                                                    
Installed as module #1                                                                                                       
eCos> lsmod                                                                                                                  
 0 /dev/flash/fis/httpd                                                                                                      
 1 /dev/flash/fis/hello
eCos> rm 1                                                                                                                   
INFO:<Module closed> 
eCos>

Finally the HTTPD module can be unloaded. 

eCos> lsmod                                                                                                                  
 0 /dev/flash/fis/httpd                                                                                                      
eCos> rmmod 0

This will cause the module_close() function of the HTTPD module to be
called, which will shut the server down. The module will then be
unloaded.


-----------------------------------------------------------------------
httpd_module.ecm:


cdl_savefile_version 1;
cdl_savefile_command cdl_savefile_version {};
cdl_savefile_command cdl_savefile_command {};
cdl_savefile_command cdl_configuration { description hardware template package };
cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value };

cdl_configuration eCos {
    package CYGPKG_HTTPD current ;
    package CYGPKG_OBJLOADER current ;
    package CYGPKG_IO_FLASH current ;
};


cdl_component CYGPKG_IO_SERIAL_DEVICES {
        user_value 1 ;
};

cdl_component CYGPKG_IO_FLASH_BLOCK_DEVICE {
    user_value 1
};

cdl_component CYGPKG_HTTPD_MODULE {
    user_value 1
}
