<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>degrunt.org: Category hacking</title>
    <link>http://www.degrunt.org/articles/category/hacking</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>lego, mindstorms, technics, pneumatic</description>
    <item>
      <title>Lua on LEGO Mindstorm NXT</title>
      <description>&lt;p&gt;Wow! It&amp;#8217;s been a long time since I wrote here, but in the mean time cool things have happened. Firstly there&amp;#8217;s &lt;a href="http://www.hempeldesigngroup.com/lego/pbLua/"&gt;pbLua&lt;/a&gt;, secondly I bought myself a Lua book.&lt;/p&gt;


	&lt;p&gt;So, how now do you go about to install pbLua on your &lt;span class="caps"&gt;NXT&lt;/span&gt;? If you&amp;#8217;re using Windows, there&amp;#8217;s not really an issue, because that&amp;#8217;s all explained on the homepage. I&amp;#8217;m using a Mac, so here it is.&lt;/p&gt;


	&lt;h1&gt;Setup&lt;/h1&gt;


	&lt;p&gt;1) First download pbLua, I&amp;#8217;ve got a &amp;#8216;nxt-lua-beta-15b&amp;#8217; folder on my Desktop.&lt;/p&gt;


	&lt;p&gt;2) Start up &lt;span class="caps"&gt;LEGO&lt;/span&gt;&amp;#8217;s &lt;span class="caps"&gt;MINDSTORMS NXT&lt;/span&gt;&lt;/p&gt;


	&lt;p&gt;3) Use the Tools menu and use the &amp;#8220;Update &lt;span class="caps"&gt;NXT&lt;/span&gt; Firmware&amp;#8230;&amp;#8221; option, click &amp;#8220;Browse&amp;#8221; and navigate using the browser to the folder  &amp;#8216;nxt-lua-beta-15b&amp;#8217; on your Desktop. The window should show &amp;#8220;nxt-lua&amp;#8221; as &amp;#8220;Available Firmware Files&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;4) Now connect your &lt;span class="caps"&gt;NXT&lt;/span&gt;, click &amp;#8220;Download&amp;#8221; and wait &amp;#8230;.&lt;/p&gt;


	&lt;p&gt;5) If everything is correct, your &lt;span class="caps"&gt;NXT&lt;/span&gt; screen should show &amp;#8220;pbLua Beta 15b&amp;#8221;, the 15b depends on the version you downloaded.&lt;/p&gt;


	&lt;h1&gt;Okay now what?&lt;/h1&gt;


	&lt;p&gt;Now you&amp;#8217;ve got a Lua-enabled &lt;span class="caps"&gt;NXT&lt;/span&gt;, but it&amp;#8217;s not very clear how to continue further. Luckily it says &lt;a href="http://www.hempeldesigngroup.com/lego/pbLua/pbLuaStartupDisplay.html"&gt;somewhere on the homepage&lt;/a&gt; that there&amp;#8217;s a &lt;span class="caps"&gt;USB&lt;/span&gt; Console as well as a BT (BlueTooth) Console. 
Let&amp;#8217;s start with the &lt;span class="caps"&gt;USB&lt;/span&gt; Console.&lt;/p&gt;


	&lt;p&gt;1) Fire up Terminal.app&lt;/p&gt;


	&lt;p&gt;2) Do an &lt;code&gt;ls /dev/tty.usb*&lt;/code&gt;, in my case this shows a &lt;code&gt;/dev/tty.usbmodem1a21&lt;/code&gt;, but your results may vary.&lt;/p&gt;


3) Then do a &lt;code&gt;screen /dev/tty.usbmodem1a21&lt;/code&gt;, this should refresh your screen and show you:
&lt;pre&gt;
pbLua Beta 15b
&amp;gt; 
&lt;/pre&gt;

	&lt;p&gt;You&amp;#8217;re now in a Lua interpreter, type &lt;code&gt;print("Hello World!")&lt;/code&gt;, just for the kicks of it!&lt;/p&gt;


	&lt;p&gt;Basically you can now use the &lt;a href="http://www.hempeldesigngroup.com/lego/pbLua/nxtFunctionDefs.html"&gt;pbLua &lt;span class="caps"&gt;API&lt;/span&gt;&lt;/a&gt;, to do anything you want, try &lt;code&gt;nxt.SoundTone()&lt;/code&gt; for example, woohoo isn&amp;#8217;t that great?!&lt;/p&gt;


	&lt;p&gt;4) To quit the Console type Ctrl-a Ctrl-\.&lt;/p&gt;


	&lt;h1&gt;Enabling Bluetooth&lt;/h1&gt;


	&lt;p&gt;1) Basically you go about as you would connect any other Bluetooth device to your Mac, just select &amp;#8220;Any Device&amp;#8221;, find the &lt;span class="caps"&gt;NXT&lt;/span&gt; in the list of Devices and have the &amp;#8220;Use a specific passkey&amp;#8221; option selected for the Passkey Options.&lt;/p&gt;


	&lt;p&gt;2) During &amp;#8220;Gathering information about your device&amp;#8221; and while it&amp;#8217;s connecting, Mac &lt;span class="caps"&gt;OSX&lt;/span&gt; will ask you for a passkey, think of something, then go to your &lt;span class="caps"&gt;USB&lt;/span&gt; console and use the Lua function &lt;code&gt;nxt.BtSetPIN('something')&lt;/code&gt; (on your &lt;span class="caps"&gt;USB&lt;/span&gt; console) to confirm the bluetooth-passkey from your &lt;span class="caps"&gt;NXT&lt;/span&gt; end.
At some point Mac &lt;span class="caps"&gt;OSX&lt;/span&gt; will say &amp;#8220;Connected&amp;#8221;. Remember the device name!&lt;/p&gt;


	&lt;h1&gt;Bluetooth Console&lt;/h1&gt;


	&lt;p&gt;1) Reboot your &lt;span class="caps"&gt;NXT&lt;/span&gt; (by holding the grey button for some time) and start it again by clicking the orange button. Then you should see something like:&lt;/p&gt;


&lt;pre class="nxtDisplay"&gt;
USB Console
BT Console
. 
. 
. 
. 
. 
. 
00000 Button:0
&lt;/pre&gt;

	&lt;p&gt;Then use the dark grey button, to highlight BT Console, next use the arrow buttons to find the device name of your computer (which in my case is &amp;#8216;galactica&amp;#8217;).&lt;/p&gt;


&lt;pre class="nxtDisplay"&gt;
USB Console
BT Console
. 
.
galactica
AD:000000000000
CL:000000
ST:00 Idx: 00 
00000 Button:0
&lt;/pre&gt;

	&lt;p&gt;Once you&amp;#8217;ve got this selected, the screen should show:&lt;/p&gt;


&lt;pre class="nxtDisplay"&gt;
Wait for connect
Active: 00
Update:  0 
.
.
.
.
.
.
&lt;/pre&gt;

	&lt;p&gt;2) Fire up Terminal.app&lt;/p&gt;


	&lt;p&gt;3) Do an &lt;code&gt;ls /dev/cu.&amp;lt;bluetooth-device-name&amp;gt;*&lt;/code&gt;, in my case my &lt;span class="caps"&gt;NXT&lt;/span&gt; is called &amp;#8220;r2d2&amp;#8221; (yup!). So I did a &lt;code&gt;ls /dev/cu.r2d2*&lt;/code&gt;, this shows a &lt;code&gt;/dev/cu.r2d2-DevB-1&lt;/code&gt;, but your results may vary, depending on your device name.&lt;/p&gt;


3) Then do a &lt;code&gt;screen /dev/cu.r2d2-DevB-1&lt;/code&gt; (or whatever you found at step 2), this should refresh your screen and show you:
&lt;pre&gt;
pbLua Beta 15b
&amp;gt; 
&lt;/pre&gt;

	&lt;p&gt;Woohoo, wireless pbLua!!&lt;/p&gt;


	&lt;p&gt;More to follow, later, keep you posted &amp;#8211; check back!&lt;/p&gt;</description>
      <pubDate>Fri, 06 Jun 2008 00:39:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:00ba9a38-6c38-4f85-aa71-48953c2ec00a</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2008/06/06/lua-on-lego-mindstorm-nxt</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
      <category>hacking</category>
    </item>
    <item>
      <title>Cross-compile Ruby to ARM7</title>
      <description>&lt;p&gt;Okay, I had another go at cross-compiling Ruby to &lt;span class="caps"&gt;ARM7&lt;/span&gt;, which for me (a cross-compile newbee) is not very simple.&lt;/p&gt;


	&lt;p&gt;I found this site of &lt;a href="http://www.jstuber.net/lego/nxt-programming/arm-toolchain.html"&gt;Jürgen Stuber&lt;/a&gt; which helps a little, but just running &lt;code&gt;./configure --host powerpc-apple-darwin8.8.0 --target=arm-elf&lt;/code&gt; does not seem to do the trick. I also found this &lt;a href="http://www.cpjava.net/arm-ruby.txt"&gt;page by Richard Keene&lt;/a&gt; which also points me in the right direction.&lt;/p&gt;


	&lt;p&gt;Well you will know my intention: Getting Ruby to compile for running the Lego &lt;span class="caps"&gt;NXT&lt;/span&gt; brick. We&amp;#8217;ll probably don&amp;#8217;t need socket, curses and libruby (maybe more), which will safe a lot of space. The next thing is to find out how small we can actually make the interpreter.&lt;/p&gt;


	&lt;p&gt;So does anyone have any tips, can somebody help me out? Is somebody willing to help? I&amp;#8217;m aiming to create a Ruby interpreter, which will run on the &lt;span class="caps"&gt;LEGO NXT&lt;/span&gt; device, which will load zipped .rb files and run&amp;#8217;s them.&lt;/p&gt;</description>
      <pubDate>Sun, 14 Jan 2007 14:28:59 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:b93aedf5-3756-46a1-9389-06555ae014a7</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2007/01/14/cross-compile-ruby-to-arm7</link>
      <category>nxt</category>
      <category>hacking</category>
    </item>
    <item>
      <title>Java OS for LEGO NXT</title>
      <description>&lt;p&gt;They&amp;#8217;ve done it! Just like for the &lt;span class="caps"&gt;RCX&lt;/span&gt; there is now Java for the &lt;span class="caps"&gt;NXT&lt;/span&gt;: &lt;a href="http://lejos.sourceforge.net/"&gt;leJOS&lt;/a&gt; is a firmware replacement for the &lt;span class="caps"&gt;NXT&lt;/span&gt; device. It currently does not  have bluetooth, sound and &lt;span class="caps"&gt;I2C&lt;/span&gt; support. There is also no menu system (yet!). But you can upload Java programs via &lt;span class="caps"&gt;USB&lt;/span&gt; and have your but execute them. Excellent!&lt;/p&gt;


	&lt;p&gt;But as you know I&amp;#8217;m a big Ruby fan, so if only it was Ruby instead of Java &amp;#8230; :)
Also, how can you fit a Ruby interpreter on 256 Kbytes &lt;span class="caps"&gt;FLASH&lt;/span&gt; &amp;#38; 64 Kbytes &lt;span class="caps"&gt;RAM&lt;/span&gt;. I know there is already ruby for 32-bit &lt;span class="caps"&gt;ARM7&lt;/span&gt; microcontrollers so &amp;#8230;&lt;/p&gt;</description>
      <pubDate>Sun, 14 Jan 2007 13:19:34 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:8a214521-ace0-4304-91d4-54ded53b4591</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2007/01/14/java-os-for-lego-nxt</link>
      <category>nxt</category>
      <category>hacking</category>
    </item>
    <item>
      <title>Drag &amp;amp; Drop NBC/NXC to RXE</title>
      <description>&lt;p&gt;Yesterday, I&amp;#8217;ve put together Dropnbc2rxe, with the help of &lt;a href="http://www.wsanchez.net/software/"&gt;DropScript&lt;/a&gt;. If you put Dropnbc2rxe in your Applications folder (it &lt;span class="caps"&gt;NEEDS&lt;/span&gt; to be there, due to hardcoded paths). Then if you would drop .nbc or .nxc files onto the application, it will compile them to .rxe files, to be put on your &lt;span class="caps"&gt;LEGO NXT&lt;/span&gt; device.
Dropnbc2rxe can be downloaded &lt;a href="http://www.degrunt.org/media/Dropnbc2rxe.zip"&gt;here&lt;/a&gt;. It has nbc 1.0.1.b20 bundled with it, no need to download that separate.&lt;/p&gt;</description>
      <pubDate>Wed, 10 Jan 2007 22:02:44 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:4fb8540f-f48c-460f-9e11-f95a30dca98e</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2007/01/10/drag-drop-nbc-nxc-to-rxe</link>
      <category>nxt</category>
      <category>hacking</category>
    </item>
    <item>
      <title>Ruby &amp;amp; Mindstorms NXT</title>
      <description>&lt;p&gt;Using &lt;a href="http://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt; with your Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt; is easy using &lt;a href="http://ruby-nxt.rubyforge.org/"&gt;RubyNXT&lt;/a&gt;. But it still requires a bluetooth connection or &lt;span class="caps"&gt;USB&lt;/span&gt; connection.&lt;/p&gt;


	&lt;p&gt;How cool would it be if it was possible to write a Ruby program, upload it (in sourcecode) to your &lt;span class="caps"&gt;NXT&lt;/span&gt; brick and have a Ruby interpreter firmware running on the &lt;span class="caps"&gt;NXT&lt;/span&gt;? It wouldn&amp;#8217;t be needed to port the whole &lt;a href="http://www.ruby-doc.org/stdlib/"&gt;Ruby Standard Library&lt;/a&gt;, it wouldn&amp;#8217;t even be needed to convert the whole &lt;a href="http://www.ruby-doc.org/core/"&gt;Ruby Core Library&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;So what would be needed to get this to work? Cross-compilation of Ruby to &lt;span class="caps"&gt;ARM&lt;/span&gt;, someone already &lt;a href="http://www.caliban.org/ruby/ruby-zaurus.shtml"&gt;ported Ruby to his Zaurus&lt;/a&gt;. A new firmare is needed.&lt;/p&gt;


	&lt;p&gt;Maybe better yet is the use of a Ruby VM like &lt;a href="http://www.atdot.net/yarv/"&gt;&lt;span class="caps"&gt;YARV&lt;/span&gt;&lt;/a&gt; and get that to run on the Mindstorms brick. Still, that needs to be cross compiled and a new firmware is needed.&lt;/p&gt;


	&lt;p&gt;Ruby is a fully object oriented programming language and is fairly easy to learn, even easier to use. More and more programmers learn Ruby.&lt;/p&gt;</description>
      <pubDate>Sat, 14 Oct 2006 11:29:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:cef68423-5a6c-4e37-99a4-7a2179c6a006</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2006/10/14/ruby-mindstorms-nxt</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
      <category>hacking</category>
    </item>
    <item>
      <title>LibNxt on Mac OSX</title>
      <description>&lt;p&gt;Earlier I came across &lt;a href="http://nxt.natulte.net/trac/wiki/LibNxt"&gt;LibNxt&lt;/a&gt;, a project by David Anderson (one of the &lt;span class="caps"&gt;MDP&lt;/span&gt;&amp;#8217;s). As I&amp;#8217;m a Mac &lt;span class="caps"&gt;OSX&lt;/span&gt; user I tried to find out whether I could get &lt;strong&gt;fwflash&lt;/strong&gt; to run on &lt;span class="caps"&gt;OSX&lt;/span&gt;, well: &lt;span class="caps"&gt;IT DID&lt;/span&gt;!
What follows is a &lt;span class="caps"&gt;HOWTO&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Actually it&amp;#8217;s pretty easy if you have &lt;a href="http://www.macports.org/"&gt;MacPorts&lt;/a&gt; installed:&lt;/p&gt;


Just do the following, it will all install neatly in &lt;code&gt;/opt/local/&lt;/code&gt;:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo port install arm-elf-gcc
sudo port install scons
sudo port install libusb&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; 

	&lt;p&gt;If you&amp;#8217;ve downloaded LibNXT somewhere follow the instructions upto typing &lt;code&gt;scons&lt;/code&gt;, we need to change the &lt;code&gt;SConstruct&lt;/code&gt; file to this:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;from glob import glob

auto_libs = ''

# Detect the system's endianness
from sys import byteorder
if byteorder == 'big':
    endian = '_NXT_BIG_ENDIAN'
else:
    endian = '_NXT_LITTLE_ENDIAN'

BuildEnv = Environment(CCFLAGS=['-I/opt/local/include', '-Wall', '-std=gnu99',
                '-g', '-ggdb', '-D' + endian])
if auto_libs:
    BuildEnv.ParseConfig('pkg-config --cflags --libs ' + auto_libs)

BuildEnv.Command('flash_routine.h',
         ['flash_routine.h.base',
          'flash_write/flash.bin'],
         './make_flash_header.py')

Default(BuildEnv.Library('nxt',
             [x for x in glob('*.c')
              if not x.startswith('main_')],
             LIBS='usb'))

Default(BuildEnv.Program('fwflash', glob('main_fwflash.c'),
             LIBS=['usb', 'nxt'], LIBPATH=['.','/opt/local/lib']))
BuildEnv.Program('sambaget', glob('main_sambaget.c'),
         LIBS=['usb', 'nxt'], LIBPATH=['.','/opt/local/lib'])&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Once this is done you can type &lt;code&gt;scons&lt;/code&gt; and &lt;code&gt;scons sambaget&lt;/code&gt; which will give you the two utilities you were looking for: &lt;strong&gt;fwflash&lt;/strong&gt; and &lt;strong&gt;sambaget&lt;/strong&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Oct 2006 19:40:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:aef8754a-16ff-499c-a99b-27ef09b96366</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2006/10/12/libnxt-on-mac-osx</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>hacking</category>
    </item>
  </channel>
</rss>
