Using pkgconf.tcl on UNIX

On UNIX systems the Configuration Tool is not yet available, but it is still possible to configure and build a kernel by editing some header files manually and using the pkgconf.tcl command (pkgconf.tcl is the underlying engine used by the Configuration Tool).

pkgconf.tcl is a Tcl script, invoked on UNIX with the tclsh interpreter. On Windows you should invoke the interpreter with cygtclsh80. The examples will use tclsh, as mentioned in Chapter 1.

Before invoking pkgconf.tcl you need to choose a directory in which to work. For the purposes of this tutorial, the default path will be BASE_DIR/ecos-work. Create this directory and change to it by typing:

$ mkdir BASE_DIR/ecos-work

$ cd BASE_DIR/ecos-work

To choose the targets to enable, the packages to set, and a few other configuration options for your kernel, type:

$ tclsh BASE_DIR/pkgconf.tcl --help

to see what options can be used with pkgconf.tcl. Useful commands to begin with are:

$ tclsh BASE_DIR/pkgconf.tcl --packages

to list available packages, and

$ tclsh BASE_DIR/pkgconf.tcl --targets

to list available targets.

Here is sample output from pkgconf.tcl showing you which options are available and enabled by default.

Example 14-1. Getting help from pkgconf.tcl


	    
$ tclsh <replaceable>BASE_DIR</replaceable>/pkgconf.tcl --help
Usage: pkgconf [options]
Available options are:
  --help               : display this text.
  --packages           : list all packages.
  --targets            : list all possible targets.
  --target=<arch>      : target the specified architecture.
  --platform=sim       : target the simulator rather than hardware.
  --startup=rom        : generate code suitable for ROMming.
  --disable-<pkg>      : disable a given package.
  --enable-<pkg>       : enable a given package.
  --<pkg>-version=v0.3 : use a specific version of a package.
  --defaults           : use default settings instead of the save file.
  --srcdir=<dir>       : specify location of the component repository.
  --builddir=<dir>     : specify location of the build directory.
  --prefix=<dir>       : specify location of the install directory.
$  

Example 14-2. Getting the list of targets from pkgconf.tcl


	    
$ tclsh <BASE_DIR>/pkgconf.tcl --targets
Known targets:
  mn10300 : aliases  MN10300 mn10300-elf am30 am30-elf am32 am32-elf 
    Required packages
        MN10300 common HAL (CYGPKG_HAL_MN10300)
    Platform stdeval1, supported startups  ram rom 
      Required packages
          MN10300 stdeval1 support (CYGPKG_HAL_MN10300_STDEVAL1)
          GDB Pseudo Device (CYGPKG_DEVICES_GDB)
          Common Serial Device Code (CYGPKG_DEVICES_SERIAL_RS232_COMMON)
          MN10300 Serial Device Code (CYGPKG_DEVICES_SERIAL_RS232_MN10300)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
    Platform sim, supported startups  ram 
      Required packages
          MN10300 simulator support (CYGPKG_HAL_MN10300_SIM)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
  tx39    : aliases  TX39 mips-tx39 mips-tx39-elf 
    Required packages
        TX39 common HAL (CYGPKG_HAL_TX39)
    Platform jmr3904, supported startups  ram rom 
      Required packages
          TX39 jmr3904 support (CYGPKG_HAL_TX39_JMR3904)
          Common Serial Device Code (CYGPKG_DEVICES_SERIAL_RS232_COMMON)
          TX39 Serial Device Code (CYGPKG_DEVICES_SERIAL_RS232_TX39)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
    Platform sim, supported startups  ram 
      Required packages
          TX39 simulator support (CYGPKG_HAL_TX39_SIM)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
  powerpc : aliases  PowerPC powerpc-eabi 
    Required packages
        PowerPC common HAL (CYGPKG_HAL_POWERPC)
    Platform cogent, supported startups  ram rom 
      Required packages
          PowerPC Cogent board support (CYGPKG_HAL_POWERPC_COGENT)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
    Platform sim, supported startups  ram 
      Required packages
          PowerPC simulator support (CYGPKG_HAL_POWERPC_SIM)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)  

To select the MN10300 target, the simulation platform, and RAM startup, type:

$ tclsh BASE_DIR/pkgconf.tcl --target=mn10300 --platform=stdeval1 --startup=ram

To select the TX39 target, the simulation platform, and RAM startup, type:

$ tclsh BASE_DIR/pkgconf.tcl --target=tx39 --platform=jmr3904 --startup=ram

To configure for a PowerPC target, the simulation platform, and RAM startup type:

$ tclsh BASE_DIR/packages/pkgconf.tcl --target=powerpc --platform=sim --startup=ram

You can now run make or make tests, after which you will be at the same point the graphical Configuration Tool leaves you — you can start developing your own applications, following the steps in Chapter 16.

The procedure shown above allows you to do very coarse-grained configuration of the eCos kernel: you can select which packages to include in your kernel, and give target and startup options. But you cannot select components within a package, or set the very fine-grained options.

To select fine-grained configuration options you will need to edit the header files in the directory BASE_DIR/pkgconf. For example, to select a different scheduler for the kernel, you would edit the file BASE_DIR/pkgconf/kernel.h and change the two lines

#define CYGSEM_KERNEL_SCHED_MLQUEUE
#undef  CYGSEM_KERNEL_SCHED_BITMAP  
to

#undef  CYGSEM_KERNEL_SCHED_MLQUEUE
#define CYGSEM_KERNEL_SCHED_BITMAP  
and then rebuild.

Caution

You should follow the manual configuration process described above very carefully, and you should read the comments in that file to see when one option depends on other options or packages being enabled or disabled. If you do not you might end up with an inconsistently configured kernel which could fail to build or might execute incorrectly.