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 see what options can be used with pkgconf.tcl, type:

$ tclsh BASE_DIR/pkgconf.tcl --help

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 12-1. Getting help from pkgconf.tcl

$ tclsh BASE_DIR/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 12-2. pkgconf.tcl output — list of available targets

$ 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 stubs 
      Required packages
          PowerPC Cogent board support (CYGPKG_HAL_POWERPC_COGENT)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
    Platform fads, supported startups  ram rom 
      Required packages
          PowerPC Motorola FADS board support (CYGPKG_HAL_POWERPC_FADS)
          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)
  i386      : aliases  i386 i486 i586 i86 ix86 
    Required packages
        i386 common HAL (CYGPKG_HAL_I386)
    Platform linux, supported startups  ram 
      Required packages
          Linux Synthetic target support (CYGPKG_HAL_I386_LINUX)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
  arm       : aliases  ARM arm-elf 
    Required packages
        ARM common HAL (CYGPKG_HAL_ARM)
    Platform pid, supported startups  ram rom stubs 
      Required packages
          Arm Development board support (CYGPKG_HAL_ARM_PID)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
    Platform aeb, supported startups  ram rom stubs 
      Required packages
          Arm Evaluation board (AEB-1) support (CYGPKG_HAL_ARM_AEB)
          Wallclock Device Code (CYGPKG_DEVICES_WALLCLOCK)
          Watchdog Device Code (CYGPKG_DEVICES_WATCHDOG)
  sparclite : aliases  SPARClite sparclite-elf 
    Required packages
        SPARClite common HAL (CYGPKG_HAL_SPARCLITE)
    Platform sim, supported startups  ram 
      Required packages
          SPARClite ERC32 simulator support (CYGPKG_HAL_SPARCLITE_SIM)
$ 

Selecting a target

To select the MN10300 target, building for running under the simulator, type:

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

To select the TX39 target, building for running under the simulator, type:

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

To configure for a PowerPC target, building for running under the simulator, type:

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

To configure for a SPARClite target, building for running under the simulator, type:

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

To configure for the ARM7 target, the PID evaluation board platform, and RAM start-up type:

$ tclsh BASE_DIR/packages/pkgconf.tcl --target=arm --platform=pid --startup=ram

To configure for the ARM7 target, the AEB-1 evaluation board platform, and RAM start-up type:

$ tclsh BASE_DIR/packages/pkgconf.tcl --target=arm --platform=aeb --startup=ram

To configure for the i386 target, the synthetic Linux platform, and RAM start-up type:

$ tclsh BASE_DIR/packages/pkgconf.tcl --target=i386 --platform=linux --startup=ram

You can now run the command make or make tests, after which you will be at the same point you would be after running the Configuration Tool on Windows— you can start developing your own applications, following the steps in Chapter 14.

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 start-up 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 pkgconf/ subdirectory of your build tree. You could also edit the original files in the component repository, stored in each component’s include/pkgconf/ directory, in which case the change would be permanent and would also affect any other users of that component repository. For example, to select a different scheduler for the kernel, edit the file BASE_DIR/ecos-work/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 each 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.