Start of topic | Skip to actions

Loading C Programs onto TexBot

by Emily Fortuna

Abstract

LEGO has created a robot and software system called LEGO Mindstorms. I am trying to develop and extend the LEGO Mindstorms capability in order to load C programs from a Unix-type environment, and then write C programs utilizing the RCX hardware accomplishing a variety of tasks. The long term goal of this project is to develop the ability to program the RCX using RIDL.

I used two paths to try to reach this goal. C programs written for the RCX now compile correctly on the computer without any errors using the cross compiler that I built. I rewrote the steps used to build the cross compiler. However, these compiled programs will not download onto the RCX brick due to the USB tower driver issues. I downloaded a patch for our current version of Linux, used the mknod command, checked the permissions and var/log messages, and renamed the USB device and pathname. So far I have had limited success communicating with the RCX using Linux. For the second path, I built a Cyclone compiler. Currently, the Cyclone configure script cannot seem to locate the Hitachi gcc compiler. I also worked on building the cross-compiler using Cygwin, but it currently fails at the build native gcc step.

Introduction

LEGO has created a robot and software system called LEGO Mindstorms. The central processor block that forms the body of the robot is called the RCX. The RCX is a Hitachi h8300 microprocessor system. The LEGO Mindstorm system comes with software for programming in a specialized, but limited visual programming language operating in Windows.

The purpose of this investigation is to develop and extend the LEGO Mindstorms capability in order to load C programs from a Unix-type environment. With this capability, the next step is to construct a variety of tasks utilizing the RCX hardware (such as the touch sensor, light sensor, and external motors) and subsequently write C programs for the TexBot to accomplish these tasks. The long term goal of this project is to develop the ability to program the RCX using RIDL.

The GNU Compiler Collection (gcc) is a set of different programming language compilers used in Unix-based environments. A cross compiler is a type of compiler that can create executable code for a platform different than the one from which it is run. A cross compiler is necessary to write C programs for the TexBot on a PC that run on the Hitachi h8300 processor within the RCX brick.

One problem encountered during the investigation was the current Linux version on the PLT lab computers (2.4.20-31.9smp) does not recognize the USB connection of infrared tower used to download C programs on the RCX.

Procedure

In my first attempt I used the instructions from Adam Wulf and Travis Fischer's report to build the h8300 gcc cross-compiler. I encountered several errors and omissions in the original report so I extensively revised the report so that the information would be more accessible to newcomers and wrote corrections in the instructions. I also put Fischer's document proposing TexBot tasks online. In the second attempt I tried to build a Cyclone compiler.

Below is a diagram showing the instruction flow process when a user wishes to use the cross compiler to compile a file and download the executable image to the RCX. The arrows denote instruction flow. The last box, downloading to the RCX via the tower, is where the process fails because the operating system cannot communicate with the USB infrared tower.

compilerFlow.gif

Below is a diagram of the file organization and steps used to build the compiler. The numbers refer to the steps delineated in the cross compiler build instructions. The yellow circles represent the directories in which files are placed. The arrows indicate that those files are placed within that directory. The green rectangles represent files that are downloaded from the internet and placed in the specified directory. The hollow blue circles are files that are created or edited in that step by the user (the individual creating the cross compiler). All other shapes are simply action steps that do not change the file structure, but they are shaped with the intent of providing a mnemonic for the action taking place in that step.

compilerDiagram.gif

Results

As the project stands currently, C programs written for the RCX compile correctly on the computer without any errors using the cross compiler that I built. All the correct files are created for download onto the RCX. However, currently I have not been able to download these compiled programs onto the RCX brick.

The current Linux version on the PLT lab computers (2.4.20-31.9smp) does not recognize the USB connection of infrared tower used to download C programs on the RCX. I have tried downloading a patch for our current version of Linux (apparently Linux version 2.6 automatically contains built in support for the USB port), used the mknod command, checked the permissions on the tower, checked the var/log messages, and renamed the USB device and pathname, but so far have had limited success communicating with the RCX using Linux.

Under the modified plan of action to use Cylcone, I have worked on building a Cyclone compiler http://www.cs.utah.edu/~regehr/research/BrickOS-Cyclone/INSTALL.html . Currently, after I built the compiler, the Cyclone configure script cannot seem to locate the Hitachi gcc compiler. Because these instructions are relatively old as well and most likely written using the serial port tower, I would be concerned about the USB port interaction with this compiler as well.

I have also worked on building the cross-compiler using Cygwin, but it currently fails at the build native gcc step.

Information for Future Work on this Project

We need to make the computer communciate with the USB tower port so that we can download C programs onto the RCX. The we need to write C programs that complete the tasks outlined in Fischer's TexBot tasks. Alternatively if we get the Cyclone compiler completely functioning, we can write Cyclone programs that complete the tasks in Fischer's document.

The key to future progress on this project lies in getting the Linux system to recognize the USB Tower once it has been plugged in. The firmdl3.c file that Michael Dyrby Jensen specified downloading in his report is written for a tower that uses a serial port connection. In some form we need to adjust lines in the firmdl3.c file or adjust the environment variable to something similar to RCXTTY=USB.

Based on my work on this project, I believe it would be most beneficial to concentrate on getting the C cross compiler functional rather than the Cyclone cross compiler. We have the C cross compiler functional to the point that it compiles programs, but we just need the operating system to be able to locate the USB tower. Creating a Cyclone cross compiler will not solve this problem, however, I believe it still may be useful to study because it may indicate how to solve the driver problem. Below I specify other branches for potential research that will show how to rectify the driver issue. Researching these can make the C cross compiler functional.

Other potential methods to tackle this project:

  • Work with Cyclone and determine why the Cyclone configure script cannot seem to locate the Hitachi gcc compiler.
  • Work on building the cross compiler in Cygwin and see if it has the same hardware recognition issues with the USB port as Linux.
  • LeJOS is a Java based replacement firmware for the Lego Mindstorms RCX microcontroller, which may contain potential in investigating for this project.
  • BrickOS (formerly called LegOS) is an alternative operating system for the Lego Mindstorms RCX Controller and provides the best bet relating to our project in the future. It also provides a C/C++ development environment for RCX programs using gcc and g++ (the GNU C and C++ cross compilation tool chain), the necessary tools to download programs to the RCX, and is still being developed for additional operating systems. Currently the only Linux system it is written for is the Debian GNU Linux system (About installing on this system). Additional information about BrickOS/LegOS can be found here: http://legos.sourceforge.net/HOWTO/.
  • According to the O'Reilly book, some web-based cross compilers exist, however, I visited several of the listed websites, and many are no longer functional. A functional online compiler is available at https://voxan.mersenne.com/~dhm/compile-legOS.html. This idea is worth pursuing because it would prevent individuals working on the project from worrying about building a functioning compiler (they just need a system that will correctly communicate with the USB device).

I found the following resources helpful for my research:

  • Kekoa Proudfoot's extensive documentation: http://graphics.stanford.edu/~kekoa/rcx/
  • RCX Manual: http://legolab.daimi.au.dk/DigitalControl.dir/RCX/Manual.dir/RCXManual.html
  • Renesas's website: http://www.renesas.com/fmwk.jsp?cnt=h83297_root.jsp&fp=/products/mpumcu/h8_family/h8300_series/h83297_group/
  • Course Notes: http://www.lisha.ufsc.br/~guto/teaching/ish/processors/h8/overview.pdf
  • The LEGO USB Driver Patch: http://sourceforge.net/projects/legousb/
  • Knudsen, Jonathan B. The Unofficial Guild to LEGO Mindstorms Robots. Beijing: O'Reilly, 1999.
  • Patt, Yale N. and Sanjay J. Patel. Introduction to Computing Systems: From Bits and Gates to C and Beyond. McGraw-Hill Higher Education, 2004.
  • Harbison, Samuel and Guy Steele. C: A Reference Manual.
  • A variety of C test programs (some of which come from the above websites) are attached at the bottom of my progress reports page.

What I have learned from this project

I learned a tremendous amount about the Unix command shell environment and C programs. I learned about building cross compilers. This project gave me a different perspective on research and helped me understand how software works at a lower level.


End of topic
Skip to actions | Back to top
toggleopenShow attachmentstogglecloseHide attachments
Topic attachments
I Attachment Action Size Date Who Comment
gifgif compilerFlow.gif manage 10.6 K 05 Sep 2007 - 13:29 Main.EmilyFortuna  
Creative Commons LicenseThis work is licensed under a Creative Commons Attribution 2.5 License. Please follow our citation guidelines.