<?xml version="1.0"?>
<!-- name="generator" content="blosxom/2.0.2" -->
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">
  <channel>
    <title>peteg's blog   2005-11-12.autumn</title>
    <link>http://peteg.org/blog</link>
    <description></description>
    <language>en</language>

  <item>
    <title>&lt;!-- -*- HTML -*- --&gt;</title>
    <link>http://peteg.org/blog/2005/12/14#2005-12-14</link>
    <category>/hacking/mindstorms</category>
    <description>
&lt;p&gt;

Quick hack to fix the slow downloads: somehow the leading &lt;code&gt;0xf1&lt;/code&gt;
byte of a response packet from the &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt; is getting lost quite often, so I
simply make it seem that if the host gets a packet from the &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt; then
that packet starts with that byte. Things are a lot faster and more reliable
now. &lt;a href=&quot;/OSX_Mindstorms_Tools/&quot;&gt;The tarball has been updated&lt;/a&gt;.

&lt;/p&gt;
&lt;p&gt;

Using the light sensor and a circular 2x2 plate to simulate a rotation
sensor is a bit tricky, not the least because the (active) light sensor
readings don't seem to vary much - 50 to 54 for me. Secondly there's the
question of sampling frequency, and then relating the number of events to
the quantity we're really interested in (distance or angle in the case of
the &lt;a href=&quot;http://peteg.org/blog/hacking/mindstorms/2005-12-03.autumn&quot;&gt;turtle&lt;/a&gt;). Oh well, I'll see what I can do.

&lt;/p&gt;
&lt;p&gt;

From the point of view of interesting programming, the &lt;a href=&quot;http://peteg.org/blog/hacking/mindstorms/2005-12-03.autumn&quot;&gt;turtle&lt;/a&gt; isn't such a great
starting point. The robot is severely limited in the amount of concurrent
activity it can engage in; I think one could raise or lower the pen while
rotating or moving, but this is hardly useful. It seems to me that the
cleverer the mechanism the more limited the concurrency possibilities.

&lt;/p&gt;
&lt;p&gt;

&lt;a href=&quot;http://www.cs.brown.edu/courses/cs148/&quot;&gt;Brown&lt;/a&gt; has an
interesting course with some labs that help with getting started. Another
way to get into interesting-program-land is to &lt;a
href=&quot;http://ingenieur.kahosl.be/projecten/Advies/legobot/&quot;&gt;sophisticate the
task&lt;/a&gt;.

&lt;/p&gt;</description>
  </item>
  <item>
    <title>&lt;!-- -*- HTML -*- --&gt;</title>
    <link>http://peteg.org/blog/2005/12/13#2005-12-13</link>
    <category>/hacking/mindstorms</category>
    <description>
As always, I spoke a bit too soon. My hacked version of &lt;code&gt;dll&lt;/code&gt; is
pretty damn unreliable. (I began writing a control program for the &lt;a
href=&quot;http://peteg.org/blog/hacking/mindstorms/2005-12-03.autumn&quot;&gt;turtle&lt;/a&gt;,
see. That bit's easier than I thought.) Oh well, another problem for another
day.</description>
  </item>
  <item>
    <title>&lt;!-- -*- HTML -*- --&gt;</title>
    <link>http://peteg.org/blog/2005/12/03#2005-12-03</link>
    <category>/hacking/mindstorms</category>
    <description>
&lt;p&gt;

Wow, things start working. I ripped Markus Strickler's mostly-beautiful
&lt;code&gt;osx_usb.{ch}&lt;/code&gt; out of the aforementioned &lt;a href=&quot;http://peteg.org/blog/hacking/mindstorms/2005-11-12.autumn&quot;&gt;lejOS tree&lt;/a&gt; and started hacking it
into &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt;'s mangled &lt;code&gt;dll&lt;/code&gt; (dynamic linker and loader). The
code for all these sorts of tools starts out as a minor variant of &lt;a
href=&quot;http://graphics.stanford.edu/~kekoa/&quot;&gt;Kekoa Proudfoot&lt;/a&gt;'s seminal
work, is extended with various hacks to get things working under &lt;a href=&quot;http://www.microsoft.com/&quot;&gt;Windows&lt;/a&gt;, &lt;a href=&quot;http://www.kernel.org/&quot;&gt;Linux&lt;/a&gt; with that new &lt;a href=&quot;http://www.usb.org/&quot;&gt;USB&lt;/a&gt; driver, on Solaris, etc. etc. and
ends in &lt;a href=&quot;http://www.apple.com/macosx/&quot;&gt;Mac OS X&lt;/a&gt; users tearing their hair out. The code started out as a
proof-of-concept and is now more-or-less unmaintainable.

&lt;/p&gt;
&lt;p&gt;

Well, that's my excuse for ungently hacking out the bits I didn't need (viz
the old serial device mechanisms, and &lt;a href=&quot;http://www.microsoft.com/&quot;&gt;Windows&lt;/a&gt; and &lt;a href=&quot;http://www.kernel.org/&quot;&gt;Linux&lt;/a&gt; support). If
the &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt; website looked less dead I may have tried to do it tidily
and submitted a patch. As it is, I'm just going to package it up to save the
hair of my fellow &lt;a href=&quot;http://www.apple.com/macosx/&quot;&gt;Mac OS X&lt;/a&gt; users. Some notes:

&lt;/p&gt;

&lt;ul&gt;

&lt;li&gt; Things are slow; quad-rate download is unsupported.
&lt;/li&gt;

&lt;li&gt; My &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt; had a default LNP (&lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt;'s &quot;&lt;a href=&quot;http://www.lego.com/&quot;&gt;Lego&amp;trade;&lt;/a&gt; Network
Protocol&quot;) address of 2. You need to specify this when using
&lt;code&gt;dll&lt;/code&gt;. The following worked for me:

&lt;pre&gt;
&lt;code&gt;dll -v -p1 ../demo/helloworld.lx --rcxaddr=2&lt;/code&gt;
&lt;/pre&gt;

You can find the address by using the &lt;code&gt;View&lt;/code&gt; button: the address
is the number that comes up after &lt;code&gt;Addr&lt;/code&gt; when you cycle through
it, ignoring the final '0'. You can set it by pressing &lt;code&gt;Prgm&lt;/code&gt;
when it is displayed.
&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;

The tools are available &lt;a href=&quot;/OSX_Mindstorms_Tools/&quot;&gt;here&lt;/a&gt;. They are imperfect
but enough to get started. I may hack them a bit further into shape in the
future, and if you do please send me the results.

&lt;/p&gt;
&lt;p&gt;

With the confidence that I can now get my programs onto the &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt; I
started building the &lt;a href=&quot;http://el.media.mit.edu/logo-foundation/&quot;&gt;Logo&lt;/a&gt; turtle featured in the &lt;a href=&quot;http://syngress.com/&quot;&gt;Syngress&lt;/a&gt; &lt;span
class=&quot;title&quot;&gt;10 Cool Lego Mindstorms Robotics Invention System 2
Projects&lt;/span&gt; book. It's a mechanical marvel. I wonder if it's capable of
drawing a smooth curve.

&lt;/p&gt;</description>
  </item>
  <item>
    <title>&lt;!-- -*- HTML -*- --&gt;</title>
    <link>http://peteg.org/blog/2005/11/12#2005-11-12</link>
    <category>/hacking/mindstorms</category>
    <description>
&lt;p&gt;

Wow, some success. Back at my parents' place for the weekend, I had access
to a &lt;a href=&quot;http://www.microsoft.com/&quot;&gt;Windows&lt;/a&gt; machine. This allowed me to get the official &lt;a href=&quot;http://www.lego.com/&quot;&gt;Lego&amp;trade;&lt;/a&gt;
firmware onto the &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt;, and then, well! The wonders one can work with
known-good hardware.

&lt;/p&gt;
&lt;p&gt;

The only &lt;a href=&quot;http://www.apple.com/macosx/&quot;&gt;Mac OS X&lt;/a&gt; 10.4.3 / &lt;a href=&quot;http://www.usb.org/&quot;&gt;USB&lt;/a&gt; Lego tower firmware downloader that
worked for me is packaged with &lt;a href=&quot;http://lejos.sourceforge.net/&quot;&gt;leJOS&lt;/a&gt;. Indeed, if I was more charitable I
would try out their whole system, the core of which is an implementation of
most of the interpreter-part of a &lt;a href=&quot;http://java.sun.com/docs/books/vmspec/&quot;&gt;JVM&lt;/a&gt; on the &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt;, a nice piece of
engineering. That's more than I hope I'll need, but we'll see.

&lt;/p&gt;
&lt;p&gt;

The &lt;code&gt;lejosfirmdl&lt;/code&gt; program happily downloaded the &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt;
kernel to the &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt; for me. I have a minorly hacked version of it that I
can supply on request.

&lt;/p&gt;
&lt;p&gt;

Once the &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt; firmware is on the &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt; it doesn't take too kindly
to attempts to replace it. Apparently one must ask it to commit hara-kiri,
leaving only the &lt;a href=&quot;http://www.lego.com/&quot;&gt;Lego&amp;trade;&lt;/a&gt; ROM intact and in charge. To quote &lt;a
href=&quot;http://legos.sourceforge.net/HOWTO/x117.html&quot;&gt;the aging FAQ&lt;/a&gt;:

&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;
Because of a limitation in the &lt;a href=&quot;http://www.lego.com/&quot;&gt;Lego&amp;trade;&lt;/a&gt; firmware, &lt;code&gt;firmdl3&lt;/code&gt;
cannot delete &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt;. Instead, before downloading the new firmware, you
must first stop the old &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt; program, and then hold down the
&lt;code&gt;Prgm&lt;/code&gt; button while hitting the &lt;code&gt;On/Off&lt;/code&gt; switch. This
will delete the old &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt; firmware, allowing a new download.
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;

Next step: getting a &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt; program onto the &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt;. I observe at this
point that the linker and program downloader are fused together, and so I
cannot just hope that &lt;a href=&quot;http://www.baumfamily.org/nqc/&quot;&gt;NQC&lt;/a&gt; or &lt;a href=&quot;http://lejos.sourceforge.net/&quot;&gt;leJOS&lt;/a&gt; will save my bacon this time.

&lt;/p&gt;</description>
  </item>
  <item>
    <title>&lt;!-- -*- HTML -*- --&gt;</title>
    <link>http://peteg.org/blog/2005/11/02#2005-11-02</link>
    <category>/hacking/mindstorms</category>
    <description>
&lt;p&gt;

Lesson of the week: don't be heroic. There's a pre-packaged &lt;a href=&quot;http://gcc.gnu.org/&quot;&gt;GCC&lt;/a&gt; 3.2.2
and &lt;a href=&quot;http://www.gnu.org/software/binutils/&quot;&gt;binutils&lt;/a&gt; 2.13.2.1 available, linked from this rather intriguing &lt;a
href=&quot;http://www.cs.lth.se/home/Jacek_Malec/tne701/links.shtml&quot;&gt;summer class
at Lund&lt;/a&gt; (hello &lt;a href=&quot;http://www.cs.lth.se/home/Calle_Lejdfors/&quot;&gt;Calle&lt;/a&gt;!). Download and install. Trust me, it's much
easier than compiling things yourself.

&lt;/p&gt;
&lt;p&gt;

Compiling &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt; itself is still a bit fiddly. I did the following to a
virgin &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt; 0.9.0 tree:

&lt;/p&gt;

&lt;ul&gt;

&lt;li&gt; &lt;code&gt;util/firmdl/rcx_comm.c&lt;/code&gt; fails to compile. I later found the
&lt;code&gt;firmdl3&lt;/code&gt; program included with &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt; to be useless, so the
quickest &quot;get the compile to go through&quot; hack is just to add &lt;code&gt;#define
linux&lt;/code&gt; near the top of that file.
&lt;/li&gt;

&lt;li&gt; &lt;em&gt;blinks&lt;/em&gt; that seems to do it.
&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;

The tricky part is talking to the USB tower. Almost all the non-&lt;a href=&quot;http://www.lego.com/&quot;&gt;Lego&amp;trade;&lt;/a&gt; &lt;a href=&quot;http://www.mindstorms.com/&quot;&gt;Lego&amp;trade; Mindstorms&lt;/a&gt; projects appear to have stalled right about when the &lt;a href=&quot;http://www.usb.org/&quot;&gt;USB&lt;/a&gt;
tower became the only thing one could buy. I take that to mean that the
people who got all excited in 1998 or so and did all this wonderful work
never bothered with the newer &lt;a href=&quot;http://graphics.stanford.edu/~kekoa/rcx/&quot;&gt;RCX&lt;/a&gt;s, and that it seemed to have lost its
geek chic by 2001 (excepting the &lt;a href=&quot;http://www.kernel.org/&quot;&gt;Linux&lt;/a&gt; afficiandos, of course, who
appear to think that this device is worth a kernel driver... in
2.6.something... say no more.).

&lt;/p&gt;</description>
  </item>
  <item>
    <title>&lt;!-- -*- HTML -*- --&gt;</title>
    <link>http://peteg.org/blog/2005/10/29#2005-10-29</link>
    <category>/hacking/mindstorms</category>
    <description>
&lt;p&gt;

Picked up the &lt;a href=&quot;http://www.mindstorms.com/&quot;&gt;Lego&amp;trade; Mindstorms&lt;/a&gt; I ordered from &lt;a href=&quot;http://www.dse.com.au/&quot;&gt;Dick Smith Electronics&lt;/a&gt; from the post office
yesterday. (This courier company thoughtfully leaves one's package at the
post office if they can't deliver it.)

&lt;/p&gt;
&lt;p&gt;

The first step, beyond opening the box and aahing over all the bits in the
kit, is to get a decent development environment working on &lt;a href=&quot;http://www.apple.com/macosx/&quot;&gt;Mac OS X&lt;/a&gt; - and
that means &lt;a href=&quot;http://gcc.gnu.org/&quot;&gt;GCC&lt;/a&gt;, of course. I tried 4.0.2 with little joy, and from a
fair bit of googling I got the impression that 3.3.x is a goer.

&lt;/p&gt;
&lt;p&gt;

Some details: we need a cross-compiler to &lt;a href=&quot;http://gcc.gnu.org/&quot;&gt;GCC&lt;/a&gt;-target
&lt;code&gt;h8300-hitachi-hms&lt;/code&gt;. The &lt;a href=&quot;http://www.apple.com/macosx/&quot;&gt;Mac OS X&lt;/a&gt; internationalisation appears
to cause &lt;a href=&quot;http://gcc.gnu.org/&quot;&gt;GCC&lt;/a&gt; some grief, so I'm just going to have to read American
English for a while (shock horror). Using the various &lt;a href=&quot;http://fink.sourceforge.net/&quot;&gt;Fink&lt;/a&gt; and &lt;a href=&quot;http://darwinports.opendarwin.org/&quot;&gt;DarwinPorts&lt;/a&gt; tools lying about, and after a painless &lt;a href=&quot;http://www.gnu.org/software/binutils/&quot;&gt;binutils&lt;/a&gt; v2.16.1
installation, the following worked for me:

&lt;/p&gt;

&lt;pre&gt;
% tar xfj gcc-3.3.6.tar.bz2
% mkdir build-gcc
% cd build-gcc
% ../gcc-3.3.6/configure --target=h8300-hitachi-hms
    --prefix=/opt/local/crossgcc
    --exec-prefix=/opt/local/crossgcc/h8300-hitachi-hms --enable-target-optspace
    --enable-languages=&quot;c&quot; --disable-nls
% make
&lt;/pre&gt;

&lt;p&gt;

You can change that to &lt;code&gt;--enable-languages=&quot;c c++&quot;&lt;/code&gt; if you like
that sort of thing.

&lt;/p&gt;
&lt;p&gt;

My choice of putting everything in &lt;code&gt;/opt/local&lt;/code&gt; rather than
&lt;code&gt;/usr/local&lt;/code&gt; confuses &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt;'s (ad-hoc, not &lt;a href=&quot;http://www.gnu.org/software/autoconf/&quot;&gt;autoconf&lt;/a&gt;iscated) &lt;code&gt;configure&lt;/code&gt; script. The obvious change in that
script makes it work.

&lt;/p&gt;
&lt;p&gt;

Next step: build &lt;a href=&quot;http://brickos.sourceforge.net/&quot;&gt;brickOS&lt;/a&gt;.

&lt;/p&gt;</description>
  </item>
  </channel>
</rss>

