My favorites | Sign in
Project Home Wiki Issues
READ-ONLY: This project has been archived. For more information see this post.
Search
for
SetupLeJOS  
This is a guide on how someone can setup LeJOS NXJ for use in his PC
Updated Sep 17, 2013 by mrmarios97

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

  1. Create a file:
  2. $ sudo nano /etc/udev/rules.d/70-lego.rules
  3. Add in:
  4. # 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"
  5. Save
  6. Add a new group called "lego"
  7. $ sudo groupadd lego
  8. Add your user to "lego" group
  9. $ sudo gpasswd -a <user> lego
  10. Reboot

Obtain LeJOS

  1. 'cd' in your home directory
  2. $ cd /home/<user>
  3. Download LeJOS (0.9.1beta)
  4. $ wget http://sourceforge.net/projects/lejos/files/lejos-NXJ/0.9.1beta/leJOS_NXJ_0.9.1beta-3.tar.gz 
  5. Untar it in /opt and rename
  6. $ sudo tar xvf leJOS_NXJ_0.9.1beta-3.tar.gz /opt/ && cd /opt && sudo mv leJOS_NXJ_0.9.1beta-3/ leJOS_NXJ/
  7. Build
  8. $ 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

  1. Connect your NXT via USB to the PC
  2. Power on
  3. Execute
  4. nxtflashg
  5. Tada!

Troubleshooting

  1. 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.
Comment by NadirHaj...@gmail.com, Oct 11, 2012

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

Comment by project member mrmarios97, Nov 15, 2012

<user> is the field where you put your username. :)

Comment by matsterm...@gmail.com, Jul 13, 2013

are you using 32 or 64 bit ubuntu?

Comment by project member mrmarios97, Aug 16, 2013

both

Comment by federico...@gmail.com, Sep 15, 2013

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...

Comment by project member mrmarios97, Sep 16, 2013

Have you flashed leJOS NXJ?

Comment by federico...@gmail.com, Sep 16, 2013

No... NXT original firmware is on the brick, I can't flash leJOS firmware.

With lsusb I have this output

Bus 001 Device 002: ID 064e:c108 Suyin Corp. 
Bus 003 Device 002: ID 0694:0002 Lego Group Mindstorms NXT 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub 
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub 
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

and with nxjflash on terminal

Building firmware image.
VM file: /opt/leJOS_NXJ/bin/lejos_nxt_rom.bin
Menu file: /opt/leJOS_NXJ/bin/StartUpText.bin
Magic string found at offset 0x40
VM size: 55888 bytes.
Menu size: 47740 bytes.
Total image size 103804/104448 bytes.
Locating device in firmware update mode.
No devices in firmware update mode were found.
Searching for other NXT devices.
Found NXT: Unknown 0016530DF3EE
The following NXT devices have been found:
  1:  Unknown  0016530DF3EE
Select the device to update, or enter 0 to exit.
1
Device number to update (0 to exit): Attempting to reboot the device.
Locating device in firmware update mode.
Searching  40%

then search to 100% and nothing else...

Comment by federico...@gmail.com, Sep 16, 2013

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???

Comment by project member mrmarios97, Sep 16, 2013

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?

Comment by federico...@gmail.com, Sep 17, 2013

Yes, from groups command...

maria@maria-PC:~$ groups
maria adm cdrom sudo dip plugdev lpadmin sambashare lego
Comment by federico...@gmail.com, Sep 17, 2013

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

Comment by project member mrmarios97, Sep 17, 2013

Check the troubleshooting!

Powered by Google Project Hosting