Booting RTEMS/GeSys on the PowerPC Simulator

The PowerPC simulator is a program (to be run on a host computer) that emulates a PowerPC CPU and some firmware system calls to perform basic I/O (console, disk). This bare-bones platform has no real networking support. Although rtems-networking is fully functional, the simulator provides no supported network device and therefore only the loopback interface is functional.

Because GeSys, the generic system application, usually loads add-on and application modules from remote filesystems the lack of a network device constitutes a severe restriction of operation. In particular, EPICS applications cannot be executed on the simulator (to be precise: they can but no client will be able to connect to a CA server executing on a PPC simulator IOC) since EPICS heavily relies on networking.

The simulator is still quite useful for training and evaluation purposes, however. The question is: how can files be copied to the simulator environment? Note that the simulator provides no access to the host file system either - the simulated CPU executes in a very basic environment with only very few I/O channels available ot the host environment (more powerful channels, such as a simulated network interface could be written, though).

Copying Files to the Simulator RAM

The RTEMS system running on the simulator has the usual IMFS ('in memory file system') support built in. The simulator is able to perform simple 'disk' I/O operations by means of firmware system calls. The simulated disk can either be a real disk or a file (to be specified in the 'device-tree file' for the simulation). Note that the firmware has no filesystem support and therefore providing access to a real disk device is pretty useless.

The 'loadTarImg()' Routine

A simple routine, loadTarImg(int verbose, int disk_no), was implemented which is able to extract a tar archive into the IMFS thus making all files in the archive accessible to RTEMS (note: they occupy RAM memory). The archive file must exist when the simulation is started and must only contain directories and/or ordinary files.

Here's how it works:

  1. User creates a tar archive with RTEMS objects and other files she wishes to use under RTEMS.
  2. Simulator is started
  3. Simulator finds a 'disk' in its device tree and learns from the device tree (defined in a file which is passed to the simulator command line) what file in the host filesystem is to be used as a 'disk' (up to 2 disks can be configured).
  4. Simulator opens all configured disk files and bails if this fails.
  5. GeSys starts up on the simulator
  6. GeSys calls 'loadTarImg(1,0)' (verbose operation, load disk 0) and unpacks the archive mapped to disk0 into the IMFS. This archive usually contains system specific files. Reading the archive is performed by means of 'simulated firmware system calls' to do block-read transfers.

Starting the Simulator

A shell script, gesys-psim, wraps proper arguments for calling the simulator and executing the generic system application:

/afs/slac/package/rtems/4.6.2/host/<host_arch>/bin/gesys-psim [user_tar_archive]

An optional tar archive argument may be provided which is mapped to 'disk 1' and hence accessible from the Cexp> prompt via the loadTarImg() routine (set the disk_no argument to 1).

Typical Development Cycle

The tar archive file may be overwritten and re-read with 'loadTarImg()':

  1. Build object file[s] with usual cross-make process (RTEMS_BSP=psim).
  2. Generage tar image:

    tar cf tst_img object_file

  3. Start simulation on host:

    gesys-psim tst_img

  4. Load object from the cexp prompt:

    Cexp> loadTarImg(1,1)

  5. Load module:

    Cexp> mod=cexpModuleLoad("path_in_IMFS")

  6. Test
  7. Unload module:

    Cexp> cexpModuleUnload(mod)

  8. Start over at 1) omitting 3) [can leave simulation running].

If desired, the simulator can be run from gdb (the DDD frontend [start with the --debugger powerpc-rtems-gdb option] is very nice):

  1. Gdb searches the PATH for executables, even if it is a cross-gdb, i.e., it tries to locate executables for the target in the PATH. Therefore, you want to add /afs/slac/package/rtems/4.6.2/target/ssrlApps/powerpc-rtems/psim/bin to PATH along with other directories where your object module is built (e.g., ./o-optimize)
  2. Create a device file: Copy the template and modify to reflect your disk/tar-archive mapping.
  3. Start GDB (it should find 'rtems.exe' in the PATH):

    powerpc-rtems-gdb rtems.exe

  4. In GDB issue

    (gdb) target sim -f my_psim_tree
    (gdb) load
    (gdb) run

    This should start GeSys in the debugger. Note that GeSys tries to send ANSI Esc. sequences to query your terminal size. This probably hangs in your debugger window and you might to have to hit the Return key a few times to get past this stage.