EiC and bzip2 ports to the Psion 5 EPOC32

Last actualization: Feb 12, 2001

Welcome. You'll find here our port of EiC and bzip2 to the Psion 5 running EPOC32 OS. The EiC port is not complete, but it is quite usable. It includes a port of readline to the EPOC. If you're interested in readline only, jump to the readline section . Reuben Thomas reported that the EiC port works fine on the Revo.

Contents

EiC installation on the Psion 5

By now, we provide no .SIS file, so the EiC installation must be done manually.

Obs. the .SIS is a package format that makes software installation easy on EPOC. If you never heard about it and your control panel does not contain an add/remove icon, extract the files from your Message Suite copy (got from the CD or from the Internet) and read about the INST_TE.EXE program.

1. Download and unzip the file EiC_4.2.6_EPOC32.zip . This is a binary distribution. It won't run on the Psion Emulator for windows distributed by Symbian, because the Emulator and the real Psion use different binary formats.

2. Upload to the Psion the file eic.exe to some directory where you put binaries (e.g. C:\bin). Upload the entire subtree EiC (that one with the "include" subdir) to the C:\lib directory on the Psion (the plptools package is good for that, see the references). All this stuff will alloc 270 kbytes on the Psion disk.

3. Install the Symbian libc. The Symbian libc is part of the Symbian C++ SDK (it's the file Epoc32/Release/marm/Rel/stdlib.sis). This file is generally distributed included in .SIS packages that require it (like the Perl port), but as I'm not providing a .SIS file, I've put here a copy of the stdlib.sis file from the Symbian SDK version that I'm using.

4. Try to start EiC double-clicking the eic.exe icon. You'll get an interactive interface. Try:

    printf("hello world\n");

To finish the session, issue the EiC exit command:

    :exit

Obs. Reuben Thomas reported:

    OK, I got it working, but not as per your instructions: I had to start it
    with "eic -IC:\lib" from eshell for things to work.

Warning: the readline module was not completely adapted yet to use this console, so some keys (like the arrows) won't work properly.

5. If you have a command-line interface like Symbian's eshell, it's possible to run scripts with parameters. For instance,

    C:\progs> \bin\eic hello.c 3

Obs. Daniel Smith reported that when the script is outside the current directory, backslashes must be quoted:

    C:\progs> \bin\eic c:\\lib\\hello.c 3

where hello.c is the file

    #include <stdio.h>
    #include <stdlib.h>

    int main(int argc, char ** argv)
    {
        int i,n;

        n = atoi(argv[1]);
        for (i=0; i<n; ++i)
            printf("hello world\n");
        return(0);
    }

Note that the Psion 5 does not have a native editor for text files, but you can create the file hello.opl using the OPL editor, and export its contents as text to the file hello.c. Or you can use the Symbian's text editor .

We provide the patch to the 4.2.6 version of EiC. If you wish to compile EiC for the Psion 5, you will need the Linux SDK. You'll need also an Intel Linux box with the native C development stuff installed (I'm using Red Hat 6.0). The steps are:

1. Install the Linux SDK on the Linux box. Note that you'll need the Symbian's SDK. Fix the file /usr/local/epoc/include/libc/stdlib.h (there is a semicolon on the definition of lval_t), or redefine lval_t (I'm not sure if the Symbian license forbids that).

2. Download the version 4.2.6 of EiC and extract the files on that same Linux box. For instance:

    # cd /usr/local/src
    # tar xzvf EiCsrc_V4.2.6.tgz

3. Download and apply the patch for EPOC:

    # cd /usr/local/src
    # zcat EiC_4.2.6_EPOC32.patch.gz | patch -Np0

4. Change the source code if desired, and compile it:

    # cd /usr/local/src/EiC
    # sh epoc_compile

This compilation will use both the native gcc of the linux box and the cross-compiler (arm-gcc) included on the Linux SDK. It will also require a working version of wine (the windows emulator) as explained on the Linux SDK pages.

5. The executable will be the file main/eicc.exe. The "include" subtree on the EiC root will that one present on the binary distribution.

Warning: some services (fork, exec, popen, sinal, raise and perhaps others) are absent from Symbian's libc. These services are not available on our port of EiC. As EiC itself uses signal and raise, we've added empty definitions for them on the absent.c module.

The patch we're providing is a bit large. The long runs within it are files added to the original distribution. Not all them are really required. In fact, some of them were created by the compilation process and just were there when I created the patch. To make the work easier for developers interested in dealing with this port of EiC, we're listing the really required files and describing them.

A. New files required to add the EPOC target to EiC. The contents of make.params is very EPOC specific. The shell script epoc_compile is a workaround to avoid complex changes on the makefiles, required to make work the two-steps cross compilation process (some tools are compiled for Linux and run before the real compilation to EPOC can start). The headers were merely copied from the LINUX target (directory module/stdClib/src/_LINUX).

    config/_EPOC32
    config/_EPOC32/make.params

    epoc_compile

    module/stdClib/src/_EPOC32/dirent.h
    module/stdClib/src/_EPOC32/fcntl.h
    module/stdClib/src/_EPOC32/ioctl.h
    module/stdClib/src/_EPOC32/signal.h
    module/stdClib/src/_EPOC32/stat.h
    module/stdClib/src/_EPOC32/termios.h
    module/stdClib/src/_EPOC32/time.h
    module/stdClib/src/_EPOC32/types.h

B. Really patched files, both makefiles and source code. Some changes were just to remove or select features depending on what is oferred by the EPOC libc. The file absent.c was added to provide empty definitions of some services used by EiC itself but not oferred by the EPOC libc.

    Makefile

    config/Makefile

    main/Makefile
    main/main.c

    module/stdClib/src/Makefile
    module/stdClib/src/absent.c
    module/stdClib/src/dirent.c
    module/stdClib/src/fcntl.c
    module/stdClib/src/stat.c
    module/stdClib/src/stdClib.c
    module/stdClib/src/stdio.c
    module/stdClib/src/stdlib.c
    module/stdClib/src/unistd.c

    src/eicval.h
    src/interpre.c
    src/metric.h
    src/readline.c

readline on the Psion 5

Readline support

Thanks to Dom Cobley for asking us about this stuff.

We've ported the readline implementation from Thomas Williams and Colin Kelley to the EPOC. This readline implementation is the one included on EiC itself. Our port is complete. The up and down arrow keys don't work for history purposes, use C-p and C-n instead.

WARNING: The copyright notice on the file readline.c informs that modifications must be distributed as patches to the original file. As I'm working on the version of that file included in EiC by Ed Breen, I distributing a patch relative to that version.

Our port honours the following features:

    C-A moves to the beginning of the line
    C-B moves back a single character
    C-E moves to the end of the line
    C-F moves forward a single character
    C-K kills from current position to the end of line
    C-P moves back through history
    C-N moves forward through history
    C-H and DEL delete the previous character
    C-D deletes the current character
    C-L/C-R redraw line in case it gets trashed
    C-U kills the entire line
    C-W kills last word
    ENTER return the entire line regardless of the cursor postition

Our patch to EiC will also patch readline.c, however we have a newer version that fix some problems, so if you're interested in readline only, download the file readline.tar.gz separately. Extract from it the files readline.c and epoc_patch, and apply the patch:

    patch -p0 <epoc_patch

Now you can add this file to your EPOC software that requires readline and build the executable.

bzip2 on the Psion 5

As handhelds don't have large disks, a file compressor utility is welcome, so we've compiled bzip2 version 1.0.1 using the Linux SDK. In order to install and use bzip2 on the Psion 5, follow the instructions:

1. Download the file bzip2-1.0.1_EPOC32.exe . This program won't run on the Psion Emulator for windows distributed by Symbian because the Emulator and the real Psion use different binary formats.

2. Upload it to some directory where you put binaries (e.g. C:\bin). Rename it to bzip2.exe. If you do not have a command-line interface on the Psion, download and install the Symbian's eshell.

3. Install the Symbian libc. The Symbian libc is part of the Symbian C++ SDK (it's the file Epoc32/Release/marm/Rel/stdlib.sis). This file is generally distributed included in .SIS packages that require it (like the Perl port), but as I'm not providing a .SIS file, I've put here a copy of the stdlib.sis file from the Symbian SDK version that I'm using.

4. Use bzip2 from the command line. You'll probably need to select a low compression rate to limit the size of the memory buffers. Example:

    C:\docs> \bin\bzip2 -2 \docs\faq.txt
    C:\docs> \bin\bzip2 -d \docs\faq.txt.bz2

Please use full paths just like the examples. See the bzip2 man page for more details on how to manage memory.

I've also compiled bzip2recover . Hopefully you will never need it. It works on the Psion, however because of some incompatibility between how bzip2recover generate filenames and the way that EPOC and/or ESHELL handle directories, the executable and the damaged file must reside on the same directory:

    C:\docs> copy c:\bin\bzip2recover.exe
    C:\docs> bzip2recover.exe faq.txt.bz2

We provide the patch to the 1.0.1 version of bzip2. If you wish to compile bzip2 for the Psion 5, you will need the Linux SDK. You'll need also an Intel Linux box with the native C development stuff installed (I'm using Red Hat 6.0). The steps are:

1. Install the Linux SDK on the Linux box. Note that you'll need the Symbian's SDK. Fix the file /usr/local/epoc/include/libc/stdlib.h (there is a semicolon on the definition of lval_t), or redefine lval_t (I'm not sure if the Symbian license forbids that).

2. Download the version 1.0.1 of bzip2 and extract the files on that same Linux box. For instance:

    # cd /usr/local/src
    # tar xzvf /b/s/bzip2-1.0.1.tar.gz

3. Download and apply the patch for EPOC:

    # cd /usr/local/src
    # zcat bzip2-1.0.1.patch.gz | patch -p0

4. Change the source code if desired, and compile it:

    # cd /usr/local/src/bzip2-1.0.1
    # make bzip2 bzip2recover

This compilation will use the cross-compiler (arm-gcc) included on the Linux SDK. It will also require a working version of wine (the windows emulator) as explained on the Linux SDK pages (and a Xserver where to connect). The file wine.conf must include the directory where the bzip2 files were installed, for instance

[Drive I]
Path=/usr/local/src/bzip2-1.0.1
Label=bzip2
Filesystem=win95

5. The executables will be the files bzip2.exe and bzip2recover.exe.

Obs. I'm still maintaining a copy of bzip2-0.1pl2_EPOC32.exe here. Unfortunately the patches for version 0.1pl2 were lost.

Licensing Information

The EiC 4.2.6 source code is available under the Artistic License. The bzip2 1.0.0 source code is available under a BSD-style license.

Credits

Ed Breen wrote EiC. Julian Seward wrote bzip2. Symbian distributes for free the EPOC SDK for windows. Parts of this SDK are from the FSF and Cygnus. The Linux SDK is due to Rudolf König and Olaf Flebbe (my apologies if not in this order). They also provide important hints on using it. Ricardo Ueda Karpischek (ueda@ime.usp.br) ported EiC and bzip2 to the Psion 5 and wrote this page.

References

For general information on Psion see http://www.psion.com

The SDK for windows may be downloaded from Symbian http://www.symbian.com , or you can order the media from them.

EiC can be found at http://www.kd-dev.com/~eic/

The Linux SDK is at http://www.science-computing.de/o.flebbe/sdk/ , and the notes by Rudolf König are at http://www.koeniglich.de/

Perl on the Psion 5 is at http://www.science-computing.de/o.flebbe/perl/perl5.html

bzip2 may be found at http://sourceware.cygnus.com/bzip2/index.html

CPOC is at http://www.starship.freeserve.co.uk/cpocmenu.htm

Psion-C is at http://www.gumbley.demon.co.uk/psion-c.html

The plptools (by Fritz Elfert) can be found at ftp://ftp.to.com/pub/psion/ . If you're interested on the PLP (Psion Link Protocol), see the Rudolf König page above, and the page http://www.btinternet.com/~thouky (by Alexander Thoukydides).

The page you're reading now is at http://www.ime.usp.br/~ueda/psion/eic.html