Installing BrickOS/Cyclone

The following instruction will guide you through the steps to make Cyclone programs run on Lego Mindstorm RCX brick with BrickOS.

The instruction has only been verified to work on my desktop running Red Hat Linux 9.

1. Build/Install a cross H8300 gcc on Linux

For more information about installing gcc compiler, refer to this page.

a) Get the source tar balls of gcc and binutils and extract them.

You can get the sources of gcc and binutils from the following sites:

      ftp://ftp.gnu.org/pub/gnu/gcc
        
      ftp://ftp.gnu.org/pub/gnu/binutils
      

You may also want to download newlib, though it's not required for BrickOS.

      http://sources.redhat.com/newlib/
      

b) Symbolic link source of various binutils tools, newlib into gcc toplevel.

This will cause bintutils, newlib to be automatically compiled when gcc is being built.

Assuming gcc source is extracted to directory gcc-3.3.2, binutils in binutils-2.14, and newlib in newlib-1.11.0, do the following at the top level gcc directory.

      $ cd gcc-3.3.2

      $ ln -s ../binutils-2.14/bfd
      $ ln -s ../binutils-2.14/binutils
      $ ln -s ../binutils-2.14/gas
      $ ln -s ../binutils-2.14/gprof
      $ ln -s ../binutils-2.14/ld
      $ ln -s ../binutils-2.14/opcodes
      

I also suggest using libiberty of binutils in place of the one that comes with gcc. So,

      $ rm -rf libiberty
      $ ln -s ../binutils-2.14/libiberty
      

If you also use newlib,

      $ ln -s ../newlib-1.11.0/newlib
      $ ln -s ../newlib-1.11.0/libgloss
      

c) Build native gcc

You actually need a copy of native gcc alongside the cross h8300 one, because the system gcc typically doesn't work with the "-b" flag.

It's always preferred to build gcc in a dir other than the source dir.

These are the steps (change the value of "--prefix" below to a directory that you have write access):

      $ mkdir build-native
      $ cd build-native
      $ ../gcc-3.3.2/configure --enable-languages=c --prefix=/home/zxshen/brick
      $ make bootstrap
      $ make install
      

d) Build cross H8300 gcc

Again, please change "--prefix" to the same one you have chosen for native gcc.

      $ mkidr build-h8300
      $ cd build-h8300
      $ ../gcc-3.3.2/configure --enable-languages=c --target=h8300-hms --prefix=/home/zxshen/brick
        (add "--with-newlib" to the above, if want newlib)
      $ make
      $ make install
      

2. Install Cyclone

a) Check out source from CVS

Refer to here for more information.

The current version works for CVS version of Cyclone as of Nov. 20, 2003.

      $ cvs -d :pserver:anoncvs@source.cs.cornell.edu:/cvsroot login

      $ cvs -d :pserver:anoncvs@source.cs.cornell.edu:/cvsroot checkout -D 11/20/2003 cyclone
      

b) Build and install Cyclone

      $ cd cyclone
      $ ./configure --prefix=/home/zxshen/brick
      

IMPORTANT! Edit Makefile.inc generated so that variable CC equals "gcc" ONLY (without any flag!)

      $ make
      $ make install
      

3. Build BrickOS

a) Get brickos source & extract it

Goto their download page, and get brickos-0.2.6.10.

b) Apply patches

c) Build it & download new firmware to the RCX box

     $ cd brickos-0.2.6.10

     $ ./configure
     $ make
     

"make" will report error, but it should be only after it starts to build c++ examples. That's OK, we don't need those.

Now plug in IR tower, turn on RCX brick. Then,

     $ util/firmdl3 --tty=/dev/usb/lego0 boot/brickOS.srec
     
"--tty" usded to specify the port the tower is connected to, e.g.
       --tty=/dev/ttyS0        COM1 under Linux, default
       --tty=/dev/ttyS1        COM2 under Linux
       --tty=/dev/usb/lego0    USB IR tower under Linux

       --tty=com1              COM1 under Cygwin, default
       --tty=usb               COM1 under Cygwin
     

If "firmdl3" reports "delete firmware failed" (only happens when RCX has been loaded with an old version of BrickOS firmware), try to clear the firmware by doing the following and try again.

  1. press down "On-Off" (don't release yet)
  2. press down "Prgm", then release "On-Off"
  3. press "On-Off" to turn on again

d) Try out (examples already built during 'make')

See if "Hello world" runs:

     $ util/dll --tty=/dev/usb/lego0 demo/helloworld.lx
     

Pree "Run" button ...

4. Cyclone libs/examples for BrickOS

Source of Cyclone runtime and demo examples are already in the BrickOS source tree after brickos-cyclone.patch is applied.

a) Build runtime and libs

From top of BrickOS source directory

     $ cd cyc-lib
     

You need to tell the makefile where is the Cyclone source directory.

One way is by editing variable CYCLONE_SRC in the Makefile.

Or you can directly set CYCLONE_SRC when submitting "make" as the following.

     $ make CYCLONE_SRC=/home/zxshen/cyclone cyc-lib
     

b) Try demo programs

There are two demo programs, helloworld.cyc and rover.cyc, which are ported from their C versions pretty straight-forwardly.

For example, if we want to try out rover.cyc, from top of BrickOS source directory,

     $ cd demo/cyclone
     $ make rover.lx
     

Download it to RCX brick and put in slot 2.

     $ ../../util/dll --tty=/dev/usb/lego0 -p2 rover.lx 
     

Press "Prgm" button repeatedly to select program 2, then press "Run" ...


Author: Zhongxi Shen

Last modified: