Upload freezes NXT Brick about 50% of time

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Upload freezes NXT Brick about 50% of time

Postby christhompson » Tue Mar 03, 2009 8:49 am

Hi,

I am using LeJOS NXJ 0.7 and NetBeans 6.5 on Vista with Bluetooth. All my environment variables and classpath variables are fine.

About 50% of the time when I am uploading files to the brick, it freezes up and I get the clicking sound. I'm not sure where to begin looking for a reason why.

Here's the program (super simple first iteration):

Code: Select all
import lejos.nxt.*;

/**
 * A program that operates on the Lego NXT Brick
 *
 * @author Christopher
 */
public class MainClass {

    private final TouchSensor touch;

    public MainClass() {
        touch = new TouchSensor(SensorPort.S1);
        SensorPort.S1.addSensorPortListener(new TouchListener());
    }

    public void run() {
        Motor.A.forward();
        while (Motor.A.isMoving()) {
        }
    }

    public static void main (String[] args) {

        MainClass test;

        // System.out.println("Press the Orange button to begin");
        // Button.waitForPress();

        test = new MainClass();
        Motor.A.getTachoCount();
        test.run();
    }

    private class TouchListener implements SensorPortListener {

        public void stateChanged(final SensorPort arg0,
                                 final int oldValue,
                                 final int newValue) {
            if (newValue < 900) {
                System.out.println("Press the Orange button to continue");
                Button.waitForPress();
                Motor.A.stop();
            }
        }
    }
}


And here's my build file:

Code: Select all
<project name="LeJOS_Brick_1" default="uploadandrun">
    <description>
       LeJOS Project build file for Project 001
    </description>

  <!-- set properties for this build -->
  <property environment = "env"/>
  <property file="template.properties"/>
  <property name="src" location="."/>
  <property name="program" value="MainClass"/>
  <property name="class" value="MainClass" />
  <property name="binary" value="${program}.nxj" />
   
  <!-- deletes class files -->
  <target name="clean" description="clean up all generated files">
    <delete>
      <fileset dir=".">
        <include name="**/*.class"/>
      </fileset>
     </delete>
  </target>

  <target name="compile" depends="clean"
        description="compile the source " >
    <!-- Compile the java code from ${src}  -->
    <javac srcdir="${src}" destdir="${src}">
      <bootclasspath>
        <pathelement location="${nxj.classes.home}/lib/classes.jar"/>
       </bootclasspath>
    </javac>
  </target>

  <target name="link" depends="compile"
        description="link the binary " >
    <!-- Link the binary and create a signature file -->
    <java classname="js.tinyvm.TinyVM">
      <arg value="--classpath"/>
      <arg path="${nxj.classes.home}/lib/classes.jar:." />
      <arg value="--writeorder" />
      <arg value="LE" />
      <arg value="${class}"/>
      <arg value="-o"/>
      <arg value="${binary}"/>
      <arg value="-v"/>
      <classpath>
        <pathelement location="${nxj.jtools.home}/lib/jtools.jar"/>
     <pathelement location="${nxj.jtools.home}/3rdparty/lib/commons-cli-1.0.jar"/>
     <pathelement location="${nxj.jtools.home}/3rdparty/lib/bcel-5.1.jar"/>
      </classpath>
    </java>
  </target>
   
  <target name="upload" depends="link"
        description="upload the binary " >
    <java classname="lejos.pc.tools.NXJUpload" fork="true">
      <jvmarg value="-Djava.library.path=${nxj.library.path}"/>
      <arg value="${binary}"/>
      <classpath>
        <pathelement location="${nxj.jtools.home}/lib/jtools.jar"/>
        <pathelement location="${nxj.pctools.home}/lib/pctools.jar"/>
         <pathelement location="${nxj.pccomm.home}/lib/pccomm.jar"/>
     <pathelement location="${nxj.jtools.home}/3rdparty/lib/commons-cli-1.0.jar"/>
     <pathelement location="${nxj.jtools.home}/3rdparty/lib/bcel-5.1.jar"/>
         <pathelement location="${nxj.pccomm.home}/3rdparty/lib/bluecove.jar"/>
      </classpath>
    </java>
  </target>
   
  <target name="uploadandrun" depends="link"
        description="upload and run the binary " >
    <java classname="lejos.pc.tools.NXJUpload" fork="true">
      <jvmarg value="-Djava.library.path=${nxj.library.path}"/>
      <arg value="${binary}"/>
      <arg value="-r"/>
      <classpath>
        <pathelement location="${nxj.jtools.home}/lib/jtools.jar"/>
        <pathelement location="${nxj.pctools.home}/lib/pctools.jar"/>
         <pathelement location="${nxj.pccomm.home}/lib/pccomm.jar"/>
     <pathelement location="${nxj.jtools.home}/3rdparty/lib/commons-cli-1.0.jar"/>
     <pathelement location="${nxj.jtools.home}/3rdparty/lib/bcel-5.1.jar"/>
         <pathelement location="${nxj.pccomm.home}/3rdparty/lib/bluecove.jar"/>
      </classpath>
    </java>
  </target>
</project>


My template.properties file:

Code: Select all
nxj.classes.home=${env.NXJ_HOME}
nxj.jtools.home=${env.NXJ_HOME}
nxj.pctools.home=${env.NXJ_HOME}
nxj.pccomm.home=${env.NXJ_HOME}
nxj.library.path=${env.NXJ_HOME}/bi


Does anyone have any suggestions? Thanks in advance,

Chris
christhompson
Novice
 
Posts: 34
Joined: Tue May 06, 2008 5:44 am

Postby gloomyandy » Tue Mar 03, 2009 9:07 am

Hi,
I've been doing some work to fix a problem that sounds very much like this with one of the other developers NXTs. If you can wait a few days I may have some code for you to try (You will have to switch to using the latest version of things though, so you may pick up some other problems)... It will be easy to switch between the two versions though so you can always go back... Let me know if you want to give it a go...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby christhompson » Tue Mar 03, 2009 9:06 pm

Hi GloomyAndy,

Yes I would be interested in giving it a go. Just tell me how to switch to the latest version and what other problems I might have. Also please let me know how to switch between the two versions.

Everything else is great, but this constant upload failure has been haunting me since I first started playing with LeJOS in the Spring of 08, and I was hoping 0.7 would have fixed it.

C
christhompson
Novice
 
Posts: 34
Joined: Tue May 06, 2008 5:44 am

Postby gloomyandy » Wed Mar 04, 2009 7:51 am

Hi Chris,
I hope to have something ready for you to try later today... So watch this space...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Wed Mar 04, 2009 2:18 pm

Hi,
OK I've created a copy of the current development snapshot, you can download it from here:
http://www.gloomy-place.net/lejos/snapshot.zip

NOTE: If you follow the steps below it will delete any programs you have on your nxt.

Once you have it downloaded you need to do the following...
1. Go to the directory that contains your current lejos install. This is probably in the "Program files" dir and is called "leJOS NXJ"
2. Rename that directory to be <name>.rel where <name> was the original name of the directory.
3. Unzip the snapshot file this should contain a directory called snapshot. Copy this dir into the directory that contains your release leJOS dir (i.e. "Program files").
4. Rename the snapshot to be <name> the original name of your release dir.
4a. If you have an nxj.properties file in your <name>.rel\bin dir copy this over to the new <name>\bin dir.
5. Turn on your nxt and attach it via USB.
6. go to a cmd window and run nxjflash -v -f. This will download the new firmware and reformat the nxt. It will also verify the download (so may take a little while). The size of the new firmware is 51136, the menu is 34680. If you do not see these sizes you are not using the updated firmware.
7. In the version menu it should show build number 2304 for the firmware.
8. Test downloading to the nxt and let me know how you get on.

Notes:
1. You can switch back to the old release by renaming the current <name> to <name>.new and <name>.rel to <name>
2. I'm not sure if this build will work with the Eclipse plugin, so please use the command line tools to test with (at least at first).
3. Some of the APIs may have changed so you may get errors with existing code...

Let me know how you get on

Andy

PS I edited the instructions to add step 4a
Last edited by gloomyandy on Wed Mar 04, 2009 10:16 pm, edited 1 time in total.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Some slightly different numbers but looks good so far

Postby christhompson » Wed Mar 04, 2009 8:41 pm

Hi Andy,

I downloaded and installed, but some of the numbers in the snapshot I downloaded are slightly different from what you said to expect (should I be at all concerned?):
    Version: Firmware 2295, Menu 2193
    File Size: Firmware VM 51120.

I have been flashing and uploading at the command line and also uploading using ant build files in NetBeans and I can see already that the output is more verbose and the upload via USB is faster and more dependable with both. I'm not sure what you changed but I'm really pleased, thanks!

As for uploading by Bluetooth? Worked like a charm the first time--let me fart around with it this afternoon and see if the improvement is consistent.

As an aside, I noticed in the src folder that in my original pre-snapshot install that there are a lot of C and C header files. I have a term of C and a term of C++ but we never learned how to convert C/C++ source to Java. Forgive the stupidity, but how do we get from C source to LeJOS?

Thanks again,

C

Addendum: I used SVN and just downloaded the latest snapshot from https://lejos.svn.sourceforge.net/svnro ... k/snapshot and now I have the same Firmware version number. All seems well... :D
christhompson
Novice
 
Posts: 34
Joined: Tue May 06, 2008 5:44 am

Postby gloomyandy » Wed Mar 04, 2009 10:01 pm

Hi Chris,
Oops I think I screwed up the creation of the snapshot that I pointed to earlier. I've now fixed it. So the files should now match my earlier post... If they do not match, please download again and use the new version...

As to the C source, well the C source is actually for the firmware of leJOS it is not converted to Java, it is compiled to native Arm code and run directly on the NXT...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Wed Mar 04, 2009 10:07 pm

Folks, I'm sorry about this I seem to be having some sort of caching problem with my web server. Please use this new link to get the updated file...
http://www.gloomy-place.net/lejos/snapshot2.zip

Oh and one other thing, you may need to copy over the property file nxj.properties (if you had one), from your old <name>\bin dir...

Thanks

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Wed Mar 04, 2009 10:28 pm

So just to be clear, the version number in the version menu on the nxt should show...
Code: Select all
0.7(rev. 2304)

If it does not could you please update from the (new) link given above...

Thanks

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Results

Postby christhompson » Wed Mar 04, 2009 11:29 pm

Code: Select all
Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\>nxjflash -v -f
Building firmware image.
VM file: C:\Java\leJOS\bin\lejos_nxt_rom.bin
Menu file: C:\Java\leJOS\bin\StartUpText.bin
VM size: 51136 bytes.
Menu size: 34680 bytes.
Total image size 85880/86016 bytes.
Building filesystem image.
Locating device in firmware update mode.
No devices in firmware update mode were found.
Searching for other NXT devices.
Found NXT: NXT 00165305CA2C
The following NXT devices have been found:
  1:  NXT  00165305CA2C
Select the device to update, or enter 0 to exit.
Device number to update: 1
Attempting to reboot the device.
Locating device in firmware update mode.
Found NXT: %%NXT-SAMBA%% 1
Connected to SAM-BA v1.4
Opened device in firmware update mode.
Unlocking pages.
Writing firmware image.
Verifying firmware.
Verified 86016 bytes ok.
Unlocking pages.
Writing filesystem image.
Verifying filesystem.
Verified 176128 bytes ok.
Restarting the device.

C:\>echo thanks Andy!
thanks Andy!

C:\>


And on the NXT:

Code: Select all
Firmware Version
 0.7(rev. 2304)
Menu Version
 0.7(rev. 2193)

Free flash176128
Battery    7.8
Free ram   42908
christhompson
Novice
 
Posts: 34
Joined: Tue May 06, 2008 5:44 am

Postby gloomyandy » Wed Mar 04, 2009 11:43 pm

Hi Chris,
Looks good... Let me know how you get on...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby Beezle Bug » Fri Mar 27, 2009 8:36 am

Hi,

Do I get it right that this snapshot2 just contains Windows binaries? I am having the same problems with a recent NXT and would like to test a Linux Version.

Greetings,
Beezle
Beezle Bug
New User
 
Posts: 2
Joined: Fri Mar 27, 2009 8:33 am

Postby Shawn » Fri Mar 27, 2009 11:41 am

Beezle Bug wrote:Hi,

Do I get it right that this snapshot2 just contains Windows binaries? I am having the same problems with a recent NXT and would like to test a Linux


Hi,

Andy knows for sure but I know that Andy has provided directions to me to use his snapshot with linux before. That was long ago...

Anyway, more recently he mentioned:

It will be a little more complex for you as a Mac user (the snapshot is setup for Windows) but not too bad... Here is how I would recommend you do things....

1. Download the snapshot dirs to a temporary location.
2. Make a copy of your existing lejos directories (call it lejos.rel).
3. Copy all of the files from the snapshot over the top of your lejos install allow it to overwrite any matching files.
4. Go to the (updated) lejos_nxj/bin dir and delete *.bat and *.dll
5. Flash your nxt with the new firmware
6. Let us know how you get on...

If you have problems and want to switch back simply delete your lejos_nxj directory and rename lejos.rel as lejos_nxj...

Hope the above makes some sort of sense....

Andy


I don't know how much the snapshot layout has changed. Anyway, just thought I'd post in case you are like me and like to try things before the definitive answer comes... especially about need to flash the firmware.
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby gloomyandy » Fri Mar 27, 2009 12:31 pm

Hi,
Yep the instructions that Shawn has posted should work with the more recent snapshot....

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby Beezle Bug » Sat Mar 28, 2009 8:15 pm

Thanks! Sorry for overlooking...

I can't test it right now because I don't have access to the NXT all the time. I'll report how it works as soon as I have tested it.

Hail Eris! All Hail Discordia!
Beezle
Beezle Bug
New User
 
Posts: 2
Joined: Fri Mar 27, 2009 8:33 am


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff