To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 826
825  |  827
Subject: 
Re: Windows NT Success Story!
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 10 Feb 2000 03:48:43 GMT
Viewed: 
1362 times
  
Thanks a lot for this really helpful and detailed post!
Especially thanks for making the result of your success story
available for download. This allowed me to simply download
the whole thing and start experimenting with legOS applications
rather than figuring out why things don't compile, etc. etc.
Last time I tried, I ran into similar issues as you did, but gave
up after a couple of hours....

....just wanted to say thanks, that's all.

Chris.


"John Lorenz" <fatfree@wcug.wwu.NOSPAM.edu> wrote in message
news:FpLuI4.56B@lugnet.com...
I'm pleased to announce that the NT boxes in our computer science lab has
LegOS installed and running under Cygwin!  I'd like to share this success
story in the hope that it might help those who are still battling the • Redmond
Behemoth.

In our lab we have Cygwin installed on all the local hard drives, but none • of
the students (including myself) have access rights to modify the • installation
(e.g. to install the Hitachi cross-compiler).  We have a couple of new
sysadmins because our cool sysadmin is graduating, and they are not • receptive
to "other people" making changes to their machines.  So, I created my own
Cygwin installation on a public network drive, installed the • cross-compiler,
and made it available to everyone.  Since ActivePerl is already installed • on
all the machines locally, I changed my Cygnus.bat file to include the • existing
ActivePerl executable in the PATH.

The installation of LegOS is very straightforward and easy.  I followed • Peter
Van der Beken's instruction page at:

     http://arthurdent.dorm.duke.edu/legos/archives/windows/legOS-0.2.2

The problems started when I typed "make" into the Cygwin shell the first
time.  Everything blew up!  The error messages were endless, and it took • an
entire week to read the LegOS newsgroup, find the errors, and make the
necessary corrections.

**************************************************************************

PROBLEM #1:  The Firmdl3 Program Won't Work:  "Permission Denied" Error
Messages.  The source code that Kekoa Proudfoot wrote is excellent, and • the
program displays a tremendous amount of patience waiting for packets from • the
RCX, but it assumes that packets are always written from the IR tower to • the
RCX successfully.  As it turns out, that isn't always true.  Writing to • the
RCX can be just as fragile an operation as reading from it. • Unfortunately, I
still don't know why the error was "Permission Denied" instead of "Write
Error" or something else as appropriate.

Solution: Paolo Masetti wrote a patch for the firmdl3 source files that
introduces some patience into the packet write routines.  Although I had • to
apply the patch manually, it worked perfectly and all the error messages
dissappeared on the very first try.  Thank you Paulo!!  Here's Paulo's • patch:

     http://www.lugnet.com/robotics/rcx/legos/?n=663

After the application of this patch, I was able to download the LegOS • firmware
to my RCX for the first time!  Now for some LegOS appz...

**************************************************************************

PROBLEM #2:  The Dll Program Won't Compile.  "Undefined symbol O_ASYNC" • Error.
This really threw me for a loop, because I really don't know the internals • of
LegOS; I'm just trying to install it.  Fortunately, Markus L. Noga himself
came up with the answer to this one, and it solved the problem for me:

     http://www.lugnet.com/robotics/rcx/legos/?n=439

After implementing this solution, the program compiled successfully • although
there were several compiler warnings.

**************************************************************************

PROBLEM #3:  The Dll Program Won't Run.  "Invalid Argument" Error Message.
This problem was more annoying than the last because the program wouldn't • even
attempt to communicate with the RCX before quitting.

Solution:  Paulo to the rescue.  This patch took care of the problem:

     http://www.lugnet.com/robotics/rcx/legos/?n=619

Not only that, but Paulo's dll patch got rid of all the warnings that were
appearing during compilation of the dll program.  Thanks again, Paulo!

**************************************************************************

PROBLEM #4:  Dll Is Still Broken:  Repeated displays of "keepaliveSend()"
followed by "error deleting program" and program termination.  This • appears to
be the same problem as Problem #1, but on a larger scale and involving • more
source files.  The lnp_assured_write() function in util/dll-src/loader.c • tries
up to five times to receive an acknowledgement from the RCX. • Unfortunately,
again only one write operation actually happens, and since it fails nearly
every time, the repeated attempts to receive an acknowledgement don't
accomplish anything.

There has been a lot of discussion about this problem:

     http://www.lugnet.com/robotics/rcx/legos/?n=415
     http://www.lugnet.com/robotics/rcx/legos/?n=416
     http://www.lugnet.com/robotics/rcx/legos/?n=458

Solution:  This time I made my own contribution to this effort.  Using the
idea behind Paulo's patch for the firmdl3 program, I made several changes • of
my own to make the dll program perform error checking during packet write
operations.  My initial change created a ripple effect, and for various
reasons (including the avoidance of potential infinite loops!) I ended up
making several other changes as well.

In the end, the dll program became much more RCX friendly, just like • Paulo's
changes made firmdl3 more friendly.  My dll program now downloads user
programs nearly every time.  Of course, interfering with the IR traffic • with
bright lights, long distances, or the IR transmitter in a remote control • (!)
can still cause communication difficulties and cause both firmdl3 and dll • to
fail.  However, when the hardware works properly, software errors are much
less likely to happen now.

Since I've had little luck using the patch program to apply patches found • on
this newsgroup, I've had to apply patches manually.  It's not such a big • deal,
but I'm not going to post a patch of my own.  Instead, if you would like • to
see the changes I've made to the dll source, the files I changed are
compressed into this 37KB zip archive:

     http://www.wcug.wwu.edu/~fatfree/LegOS/Happier_DLL.zip

After making the dll program work, I was able to download both the
helloworld.lx and rover.lx user programs that came with LegOS, and they • both
ran successfully.

The last step in this venture is to successfully compile an original user
program for the RCX.

**************************************************************************

PROBLEM #5: The Compiler Won't Compile an Original User Program.  The • linker
reports missing symbol errors, lots of them.  This was the error that kept • me
in the lab for more than 55 and a half hours one weekend.  I went nuts • trying
to find the cause of this error.  I spent lots of time going through the
documentation for LegOS, Cygwin, ActivePerl, and the GNU compiler.  After • a
lot of reading, I got nowhere, so I started tinkering.  Tinkering is the • most
enjoyable ways to find an error.

Sometimes the cause of an error isn't even remotely related to the
manifestation of the subsequent error messages.  Sure, it was the linker • that
was delivering the error messages, but the problem wasn't with the linker, • or
with the compiler for that matter.  No, this error had to do with what I
consider the real magic behind LegOS:  that of dynamic linking.

Here's the deal.  Every time you compile a new LegOS kernel, the makefile
turns on some extra options in the compiler which causes it to output a • pair
of disassembly (?) files.  These text files contain all the assembly • language
and symbols that will become the kernel after the final pass through the • cross-
assembler.  The makefile also launches a few Perl scripts which input • these
disassembly files and create the map file and the LDS files.  The map file
appears to be a sorted list of all the symbols in the kernel, and the LDS
files are Linker Description Scripts which control the way programs are • linked
together.

When you compile your own programs, the linker uses the map file and the • LDS
files from the kernel compilation to resolve references to the firmware • and
ROM routines into explicit offsets into the kernel.  OK, it may not • actually
be magical, but it's the first time I've ever seen this method of • compilation,
so it's magic to me.  My hat is off to Markus L. Noga.  Nice work, dude.

So what was the real problem that caused all these linker errors? • ActivePerl
wasn't launching correctly.  That meant the disassembly files were not
becoming map files and LDS files, so the linker had no basis with which to
resolve outstanding symbols during the linking process.  Mass bummer.

It seems that ActivePerl insists on having MS-DOS style file names with • colons
and backslashes, while Cygwin insists on unix style file names with • forward
slashes.  It's a very strange situation, especially when you factor in the
magic that Unix/Cygwin performs when you invoke Perl scripts by entering • the
file name alone in the Cygwin shell.  Unix/Cygwin examines the file,
determines that it is a Perl script, runs Perl, and hands Perl the name of • the
script it should process.  The problem with this process is with the path • to
where the Perl interpreter lives, which must always be the first line of • the
Perl script.  When Cygwin passes the name of the Perl script to • ActivePerl, it
uses a unix style filename and that makes ActivePerl puke.  This method
doesn't work at all.

This Unix/Cygwin magic can be bypassed by issuing an explicit Perl • command.
However, you have to use an MS-DOS style filename, even though you are • typing
the command into the Cygwin window.  Let's say I have a hello world Perl
script on my NT desktop.  Entering the command

     "perl file://c/winnt/profiles/username/desktop/hello.pl"

into the Cygwin shell results in a "Can't open perl script (snip): No such
file or directory" error message.  However, the command

     "perl c:\\winnt\\profiles\\username\\desktop\\hello.pl"

runs successfully.  Notice how the backslashes are all escaped.  This is • what
Cygwin requires to deliver a proper MS-DOS filename to Perl.  Finally, a
solution to this problem is at hand.

Solution:  Edit the make files to invoke Perl explicitly, with an MS-DOS • style
filename to identify the script to be run.

Finally, we have the ability to compile user programs, or do we?

**************************************************************************

PROBLEM #6: Make Displays "Invalid Separator" Error Message and Stops.
Here is one last little problem I encountered.  Even though Make is • running
under Cygwin in Windows, it is still a Unix program and it can't handle • text
files that have chr$(13) and chr$(10) separating lines of text.  The • normal
(Unix) way of doing things is to have a single chr$(13) at the end of each
line of text.  It appears that Make is quite strict about this.

Solution:  Edit the makefiles with WordPad or an equivalent text editor • that
retains the original separations between lines of text.  If you use • WordPad,
DON'T PRESS [ENTER].  Introducing a new break between lines of text will
always insert an unwanted chtr$(10).  I've also found success FTPing a
makefile to a Unix box, making the changes there using any text editor, • and
then FTPing the file back to the Windows box.

Finally, after fixing all these errors, LegOS finally works under Cygwin • in
Windows NT 4.0 SP 4.  Make is a little touchy with the makefiles it's • given,
but that's manageable.

I've typed in the Hello World program from the LegOS chapter of the • O'Reilly
book "The Unofficial Guide to LEGO Mindstorms Robots".  It compiled,
downloaded, and ran without incident.  I also compiled and ran Martin
Cornelius' program that plays "Wir sind die Roboter" on the RCX.

     http://www.lugnet.com/robotics/rcx/legos/?n=536

This program is an excellent example of what LegOS can make an RCX do.  At • the
same time, the ability to play music is completely out of reach of • something
like Not Quite C.  The song sounds great but the program doesn't exit
cleanly.  Finally, I wrote an original program to run a motor and play • around
with the LCD display a little.  The "Unofficial Guide" contains a • wonderful
reference to all the firmware calls and some of the ROM calls, too.  The
really good reading, of course, is in the header files for the RCX that • came
with LegOS.

This LegOS installation was built to serve the students of CS 402, • Artificial
Intelligence class at Western Washington University.  The goal was to make
LegOS simple and easy to use so the students could concentrate on their
software.  Inside the LegOS installation I created a new directory called
New_Project.  This directory contains a shortcut to the Cygwin.bat file on • the
public network drive, a default makefile for compiling user programs, and • some
demonstration source code, including Martin's music program.  I wrote some
instructions for the students on this web page:

     http://www.wcug.wwu.edu/~fatfree/LegOS/

The basic idea is that my fellow students can copy the New_Project • directory
from the public drive to some private directory of their choosing. • Following
the directions on the web page, the students simply open Cygwin, create a • C
program, carefully edit the makefile to add the name of the .lx file they • want
to compile, and then type "make" into the Cygwin shell.  Once the program • is
compiled, dll is used to download the executable into the RCX and start it
running.

In closing, I would like to offer a copy of my installation for anyone who • is
interested.  This installation represents everything that currently • resides on
the public network drive in WWU's computer lab.  The whole enchilada,
including all of LegOS, Cygwin, the Hitachi H8 cross-compiler, and all the
changes to all the source code and makefiles I've mentioned throughout • this
post, *BUT* with the exception of ActivePerl, has been compressed into a • 16.7
MB zip file:

     http://www.wcug.wwu.edu/~fatfree/LegOS/LegOS_022_NT.zip

I would also like to thank all the people whose posts to this newsgroup • made
this LegOS installation possible.  Without your help, I would never have • made
it through this tangled mess.

Thanks again,
John



Message is in Reply To:
  Windows NT Success Story!
 
I'm pleased to announce that the NT boxes in our computer science lab has LegOS installed and running under Cygwin! I'd like to share this success story in the hope that it might help those who are still battling the Redmond Behemoth. In our lab we (...) (25 years ago, 8-Feb-00, to lugnet.robotics.rcx.legos)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR