Configuring the LEGO USB Tower on Linux

If you are a Linux user and have a Robotics Invention System (RIS) version 1.0 or 1.5, you have a serial infrared (IR) tower, which is fairly easy to set up. RIS version 2.0 came with a USB tower however, and getting that to work isn’t as straightforward. Some of these steps might seem daunting to a novice, but if you follow them correctly you should be OK.


Current versions of the Linux kernel (2.6.*) include support for the LEGO USB Tower by default. There are many Linux distributions, and they’re not all configured the same way. Below instructions were created for Ubuntu version 12.04 TLS 32-bit, one of the most popular distributions at this time.

Step 1 – enable the LEGO USB IR Tower module (¨driver¨)

First make sure the USB IR Tower is connected to your computer. Now open a terminal window to determine if the module actually exists on your system, by running this command:

find /lib/modules -name *lego*

The output will show you one or more file names with long paths in front of them. Just as long as at least one of them ends with legousbtower.ko, you’re OK to continue. If not, this means your distribution doesn’t have this driver available as a module and you may need to actually recompile your kernel. This article does not cover that.

Now we need to make sure the module gets loaded at boot time. Open the file /etc/modules in an editor, for example with the command:

sudo gedit /etc/modules

Add a new line to the end of this file with just the name of the module: legousbtower (without the .ko suffix). My /etc/modules file looks like this.

# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.


Save the file and exit the editor. Now reboot the system.
After the reboot, open a terminal window again, and run the command:

ls -l /dev/usb

You should see output similar to this:

total 0
crw------- 1 root root 180, 0 Oct  2 18:39 hiddev0
crw------- 1 root root 180, 1 Oct  2 18:39 legousbtower1

It came up with number 1 for mine, it could have a different number for you, usually legousbtower0. We need to change the permissions on it, run this command:

sudo chmod 666 /dev/usb/legousbtower1
EDIT: the chmod command only changes the permissions temporarily. I found a more permanent solution.

All done! The USB Tower is ready to be used… But now what?

Step 2 – adding USB support to NQC.

The LEGO brick programming language of choice on Linux is NQC (at least with the standard LEGO firmware). It has support for the RCX, Scout and Spybotics pbricks. The latest official release doesn’t have USB support for Linux, but thankfully somebody has already made a patch for this, so we can simply get the source code, patch it and then compile it ourselves. This sounds harder then it is, really. I didn’t run into any errors at all (not even on the first attempt!), which probably says a lot about the quality of the code (kudos to David Baum and John Hansen).

Go back to the terminal and create a directory in which you’ll build NQC. For example, I named mine /develop/nqc.  Make sure this is your current directory and it is empty. Then run the below commands, in that order. They will download and extract the sources and patch:

mkdir nqc-3.1.r6 && cd nqc-3.1.r6
tar xfz nqc-3.1.r6.tgz
cd ..
ls -l

The output of that last command should look like:

-rw-rw-r-- 1 michiel michiel 13912 Jan  2  2013 nqc-01-Linux_usb_and_tcp.diff
drwxrwxr-x 9 michiel michiel  4096 Oct  2 21:52 nqc-3.1.r6

So now you have a directory containing the source code of NQC, and the patch to enable USB support on Linux. Now apply the patch like this:

patch -p0 < nqc-01-Linux_usb_and_tcp.diff

This should tell you it patched 9 files. Now on to compile NQC!

cd nqc-3.1.r6

This will start scrolling a huge list of scary-looking output. Just sit back and relax. When it’s all done, check if the binary files have been produced.
Run “ls -l bin/” as shown below, and the output should look  very similar:

michiel@Ubuntu13:~/develop/nqc/nqc-3.1.r6$ ls -l bin
total 636
-rwxrwxr-x 1 michiel michiel  12812 Oct  2 21:57 mkdata
-rwxrwxr-x 1 michiel michiel 618233 Oct  2 21:58 nqc

Now to install NQC, simply run:

sudo make install

This will install NQC, so afterwards you will be able to run the command “nqc” from any directory.

All done!

To compile and download an nqc program you wrote yourself and send it to the RCX using the USB tower, run:

nqc -Susb:/dev/usb/legousbtower1 -d helloworld.nqc



10 thoughts on “Configuring the LEGO USB Tower on Linux

  1. JT


    After speading days trying to get my old RCX 2.0 back up and running on anything, i managed to get the old RIS software installed and I think working on Linux Minth 16 through WineHQ. Except the software doesn’t seem to recognize the USB tower.

    I know the town works because I was able to use it on windows xp until I rebooted the laptop. This seems to be a known problem — RIS will work once on XP then never again after a reboot.

    So the tower works. The USB ports work. The port is sending power to the tower, as it does light green when first connected. But after rebuilding the PC with Linux Mint I can’t seem to communicate with the tower anymore.

    Is there anyway to just quickly test the connection in Linux?

    1. Michiel Post author

      Have you tried installing nqc as explained above? If not, try that first and see what it says. If it work, then you know the Linux part is working OK and the problem must be in the Wine emulation somehow. In that case you might try using Virtualbox on Linux instead and run a Windows VM inside that. That worked for me.

  2. mili

    hi there,

    thanks for the guide. I love to see a solution for this. Unfortunately I got stuck on the make command as you can see below. I am not sure how to continue? Thanks

    ubuntu@ubuntu01:~/Schreibtisch/NQC/nqc-3.1.r6$ make
    g++ -o bin/mkdata -Inqc/ -Iplatform/ mkdata/mkdata.cpp nqc/SRecord.cpp
    make: g++: Befehl nicht gefunden
    make: *** [bin/mkdata] Fehler 127

    1. Michiel Post author

      Hi! Looks like you are missing the g++ compiler on your Ubuntu.
      The build-essential package contains a list of packages which are essential for building Ubuntu packages including g++ compiler, make and other required tools.

      Please run the following three commands in your terminal.

      sudo apt-get update
      sudo apt-get upgrade
      sudo apt-get install build-essential

      That should solve it

  3. Justin


    Tjanks for that great post, I’m really looking forward to be able to program my RCXs (2.0 &1.0)

    Everything goes good until I run the patches. I got this
    “patch -p0 < nqc-01-Linux_usb_and_tcp.diff
    patching file nqc-3.1.r6/Makefile
    Reversed (or previously applied) patch detected! Assume -R? [n]
    Apply anyway? [n]
    Skipping patch.
    5 out of 5 hunks ignored — saving rejects to file nqc-3.1.r6/Makefile.rej
    patching file nqc-3.1.r6/nqc/nqc.cpp"

    It comes few times and I can only say "no"

    After few times I come back to the normal command line.

    Then I ran: cd nqc-3.1.r6

    And got the stacy looking lines. But at the end it says this:
    "compiler/lexer.o: dans la fonction « yy_init_buffer(yy_buffer_state*, _IO_FILE*) »:
    lexer.cpp:(.text+0x1c46): référence indéfinie vers « isatty(int) »
    collect2: error: ld returned 1 exit status
    make: *** [bin/nqc] Erreur 1"

    Do you have any idea what I could do to solve this?

    By the way I already managed to put the firmware on my RCX, I just need the patch between NQC and my USBtower.

    Thank you in advance 🙂


    1. Jack Foust

      Michiel –

      Thanks for the helpful instructions. I would like to pass along one suggestion – it may be a quirk of my particular set-up, but I eventually found that the only way I could get nqc to communicate with the tower was to rename /dev/usb/legousbtower1 to /dev/usb/legousbtower0. Presumably the package I am using (nqc_3.1.r6-1_amd64.deb) has a requirement for that hard-coded in somewhere. That solved the problem. It may be worth a try to anyone who has a loaded tower driver and a working nqc, has already tried chmod 666 and changing file ownership, but keeps getting the message (as I did) “could not open serial port of usb device.”

      BTW – I had trouble compiling nqc, so here’s the link to the package, in case anyone wants to try it:


    2. Christian

      @Justin … just ran into the same error and found the solution:

      1) unpack and patch everything as described above and then run make until the error occurs.

      2) Then edit the file compiler/lexer.cpp on line 1860 which looks like :

      extern int isatty YY_PROTO(( int ));

      and change this to

      extern “C” int isatty YY_PROTO(( int ));

      save and quit your editor.
      3) run make again

      Should now produce a workin nqc binary.

      Hope this works for you as it worked for me, regards


  4. Joseph

    Thanks for the instructions. I found a similar set on another blog (likely based on these instructions) for setting up nqc on my Raspberry Pi (running NOOBs). After years of neglect, I decided to try to reinvigorate my old Mindstorms set (once I cleared out the leaky batteries). It seems to work, and the green light on the tower lights when I try to communicate, but he RCX 2.0 just ignores it (no numbers appear on the screen when I download firmware, nqc just stuck waiting). Has anyone else had trouble getting the RCX to communicate?


Leave a Reply

Your email address will not be published. Required fields are marked *