- Christophe Nowicki - http://www.csquad.org -

Build NXC programs under Debian GNU/Linux

Posted By cscm On 12th June 2008 @ 23:50 In Debian, NXT, NXC | No Comments

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

Introduction

Lego does not provide tools for building programs for the NXT under Linux.
I don’t like [2] 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 [3] Bricxcc web site. The compiler is writen in Pascal.

You need to install the [4] FreePascal Compiler and build the compiler :


$ wget http://downloads.sourceforge.net/bricxcc/nbc-1.0.1.b34.src.tgz
# 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 (1.0.1.34, 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 < task main() {
TextOut(0, 0, “Hello world!”);
Wait(1000);
}
EOF
$ nbc hello.nxc -O=hello.rxe

USB Transfert

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

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


# apt-get install g++ libusb-dev
$ wget http://www-verimag.imag.fr/~raymond/edu/lego/t2n/t2n-0.2.src.tgz
$ wget http://www.csquad.org/wp-content/t2n_amd64.diff
$ cd t2n-0.2.src
$ patch -p1 < ../t2n_amd64.diff
patching file src/usbmisc.cc
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
NXT Name: NXT
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…


Article printed from Christophe Nowicki: http://www.csquad.org

URL to article: http://www.csquad.org/2008/06/12/build-nxc-programs-under-debian-gnulinux/

URLs in this post:
[1] Lego Mindstoms NXT: http://www.csquad.org/go.php?http://mindstorms.lego.com/eng/Overview/default.aspx
[2] Bricxcc: http://www.csquad.org/go.php?http://bricxcc.sourceforge.net/
[3] Bricxcc: http://www.csquad.org/go.php?http://bricxcc.sourceforge.net/nbc/beta/index.html
[4] FreePascal Compiler: http://www.csquad.org/go.php?http://www.freepascal.org/
[5] T2N: http://www.csquad.org/go.php?http://www-verimag.imag.fr/~raymond/edu/lego/t2n/

Click here to print.