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.
For more information about installing gcc compiler, refer to this page.
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/
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
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
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
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
$ 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
Goto their download page, and get brickos-0.2.6.10.
Goto their "patches"page, then download and apply the following patches:
You must stand in BrickOS source dir, so do this first.
$ cd brickos-0.2.6.10
Download it from our webpage and apply it.
$ patch -p2 < brickos-cyclone.patch
All the stuff needed is here.
IMPORTANT NOTE:
The current driver only works on PCs that have the "UHCI"
version of the USB host controller, these include motherboards
with Intel/VIA chipsets, and PCI cards with VIA chips.
It doesn't support "OHCI" host controllers.
You can confirm what you have by issue the following command:
$ /sbin/lspci -v | grep HCI
If "UHCI" shows up, you are good to go.
You will have to check it out from CVS.
$ cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/legousb login $ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/legousb co LegoUSB
You want to install the driver with the source from LegoUSB/drivers/linux.dep.
YES, it's the deprecated version! But this one works for me, while the so called new driver doesn't.
$ cd LegoUSB/drivers/linux.dep $ ./configure $ make
Install it as root,
# make install
Change to BrickOS source directory,
$ cd util $ patch -p0 < ../LegoUSB/patches/brickos/brickos_cvs_Nov212002.patch
$ 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.
See if "Hello world" runs:
$ util/dll --tty=/dev/usb/lego0 demo/helloworld.lx
Pree "Run" button ...
Source of Cyclone runtime and demo examples are already in the BrickOS source tree after brickos-cyclone.patch is applied.
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
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: