Below a guide for setting up LeJOS NXJ v.0.9 on Linux (Ubuntu 12.04) is demonstrated
Dependencies
JDK (Java Development Kit)
A major depencency for LeJOS to operate is JDK. Obtain it by:
$ sudo apt-get install openjdk-6-jdk
LibUSB - bluecove
Obtain LibUSB by:
$ sudo apt-get install libusb-dev
Setup driver
Setting up a catholic system setting for the driver is highly recommended
- Create a file:
$ sudo nano /etc/udev/rules.d/70-lego.rules
- Add in:
# Lego NXT brick in normal mode
SUBSYSTEM=="usb", DRIVER=="usb", ATTRS{idVendor}=="0694", ATTRS{idProduct}=="0002", GROUP="lego", MODE="0660"
# Lego NXT brick in firmware update mode (Atmel SAM-BA mode)
SUBSYSTEM=="usb", DRIVER=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="6124", GROUP="lego", MODE="0660"- Save
- Add a new group called "lego"
$ sudo groupadd lego
- Add your user to "lego" group
$ sudo gpasswd -a <user> lego
- Reboot
Obtain LeJOS
- 'cd' in your home directory
$ cd /home/<user>
- Download LeJOS (0.9.1beta)
$ wget http://sourceforge.net/projects/lejos/files/lejos-NXJ/0.9.1beta/leJOS_NXJ_0.9.1beta-3.tar.gz
- Untar it in /opt and rename
$ sudo tar xvf leJOS_NXJ_0.9.1beta-3.tar.gz /opt/ && cd /opt && sudo mv leJOS_NXJ_0.9.1beta-3/ leJOS_NXJ/
- Build
$ cd /opt/leJOS_NXJ/build && ant
Environment variables
leJOS NXJ needs to know the locations of java and javac. There are several possibilities to achieve that: (1) add the bin directory of the JDK to your PATH environment variable so that commands such as java and javac can be called from a command prompt or (2) set the LEJOS_NXT_JAVA_HOME environment variable to the directory of an installed JDK. Note that you can use JAVA_HOME instead of LEJOS_NXT_JAVA_HOME, however setting JAVA_HOME might intefere with other applications.
Furthermore, the NXJ_HOME variable should be set to the directory where leJOS NXJ is installed. It allows other applications, e.g. the Ant scripts, to locate the leJOS Development Kit. Also, for easy exececution of the leJOS commands on the command line, the bin folder of the leJOS distribution should be added to the PATH variable.
Examples:
in /etc/profile
$ sudo nano /etc/profile
variable=location
| Variable | Value | Examples |
| NXJ_HOME | The folder you installed leJOS NXJ into | /opt/leJOS_NXJ |
| LEJOS_NXT_JAVA_HOME | The folder where the JDK is installed | /opt/sun-jdk-1.6.0.30 or /usr/lib/jvm/java-6-sun-1.6.0.06 |
| PATH | Prepend the bin of the leJOS Development Kit | opt/leJOS_NXJ/bin:$PATH |
Using Eclipse IDE Plugin
Click here.
Flash Firmware
- Connect your NXT via USB to the PC
- Power on
- Execute
nxtflashg
- Tada!
Troubleshooting
- You must reset your NXT Intelligent Brick by pushing the small button at the rear of it with a screwdriver, unless you're able to flash the leJOS firmware.
Hi. I got a problem. After creating lego group by
sudo groupadd lego
I used command
sudo gpasswd -a <user> lego
but I got an error somethig like <user> is not recognized. Could you help me? I don`t understand what is going on
<user> is the field where you put your username. :)
are you using 32 or 64 bit ubuntu?
both
Hi! I follow all steps but I have some problems after "Found NXT: Unknown 0016530DF3EE". In the window the log says: "Attempting to reboot the device. Locating device in firmware update mode." and then go searching till 100% with no effect.
I have Xubuntu based on Ubuntu 13.04 and java-6 or java-7 openjdk-amd64...
any help?? thanks...
Have you flashed leJOS NXJ?
No... NXT original firmware is on the brick, I can't flash leJOS firmware.
With lsusb I have this output
and with nxjflash on terminal
then search to 100% and nothing else...
I try also with nxjbrowse in a terminal after sudo su taking root privileges and find in the window the brick in status DISCONNECTED... so I try to click on Connect button and the program crash (Ctrl+C in terminal to block...)
I see also this video http://www.youtube.com/watch?v=ICSAMFicx8I but is referred to Ubuntu 12.04 ...maybe a newer version 13.04 or Java-7 on 64bit block the process???
Any help???
Maybe. I still use 12.04 LTS so I don't keep track of the new modifications. Last Check Although: Have you added your user to the lego group?
Yes, from groups command...
Oooo! ...I find a solution (an hardware solution)
I try to flash in command line mode with nxjflash and when blocked I forced the small button behind USB connector with a small long screwdriver... the brick reset itself and then the firmware was updated...
I try also in Eclipse with leJOS NXJ / Upload Firmware and now go well without button resetting...
Thanks and maybe update your guide with this hint FeD
Check the troubleshooting!