Christophe Nowicki

June 12, 2008

Build NXC programs under Debian GNU/Linux

This document explain how to build and load an Not eXactly C program for the Lego Mindstoms NXT Robot under Debian GNU/Linux.


Lego does not provide tools for building programs for the NXT under Linux.
I don’t like Bricxcc, because :

  • It looks like Visual Studio ;
  • runs only on Microsoft Windows ;
  • I’m more familiar with VIM, make and GCC ;0)

Install the compiler

Ths NXC compiler can be downloaded on the Bricxcc web site. The compiler is writen in Pascal.

You need to install the FreePascal Compiler and build the compiler :

$ wget
# apt-get install fp-compiler fp-units-fcl fp-units-base
$ mkdir nbc
$ tar xzf nbc-1.0.1.b34.src.tgz -C nbc
$ cd nbc/nxt
$ make -f nbclinux.mak
$ ./nbc
Next Byte Codes Compiler version 1.0.1.b34 (, built Thu Jun 12 21:21:22 CEST 2008)
Copyright (c) 2006, John Hansen
Use "nbc -help" for more information.
# mv nbc /usr/local/bin/

Hello world

Let’s try to build and send a simple hello world program to the robot :

$ cat > hello.nxc <

USB Transfert

In order to send the program to the robot, you need the Talk 2 NXT program : T2N.

Warning: on amd64, you need to patch the source code.

# apt-get install g++ libusb-dev
$ wget
$ wget
$ cd t2n-0.2.src
$ patch -p1 < ../t2n_amd64.diff patching file src/ patching file src/usbmisc.h $ make # mv obj/t2n /usr/local/bin/

Now you can plug, turn on your NXT and send the program via the USB port.

# t2n -i
#### NXT INFOS ###############
protocol version=1.124 firmware version=1.1
Blutooth address: 16:53:06:37:ffffffbc:00
Blutooth signal: 0
Free user flash: 44416
# t2n -v -put hello.rxe
nxt brick found, usb initialized
testing for existing file "hello.rxe"
deleting for existing file "hello.rxe"
upload hello.rxe (376 bytes) from /goinfre
that's all folks...

That’s all folks…

Filed under: Debian,Robotics — Tags:, , , — cscm @ 23:50

Powered by WordPress