[Solved] Flashing problem

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

Moderators: 99jonathan, roger, imaqine

[Solved] Flashing problem

Postby zedex18 » Fri Jun 08, 2012 3:29 pm

Hello everyone.

I am trying to install the LeJOS software by my computer using Ubuntu 10.04. I think I have successfully installed everything but when I do :
Code: Select all
cedric@cedric-laptop:~$ nxjflash
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.
Ignoring device USB0::0x0694::0x0002::000000000000::RAW
No devices in firmware update mode were found.
Searching for other NXT devices.
Ignoring device USB0::0x0694::0x0002::000000000000::RAW
No NXT found. Please check that the device is turned on and connected.

And the "ignored devise" is my brick NXT :
Code: Select all
cedric@cedric-laptop:~$ lsusb
Bus 005 Device 008: ID 0694:0002 Lego Group
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 0a5c:219c Broadcom Corp.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 014: ID 04e8:6033 Samsung Electronics Co., Ltd
Bus 001 Device 003: ID 0ac8:c33f Z-Star Microelectronics Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I am out of ideas. How could I do ?
Thanks
Last edited by zedex18 on Sun Jun 10, 2012 9:36 am, edited 1 time in total.
zedex18
New User
 
Posts: 8
Joined: Fri Jun 08, 2012 3:13 pm

Re: flashing problem

Postby skoehler » Fri Jun 08, 2012 4:23 pm

nxjflash doesn't have the permission to open the USB device. I'm sure, as root nxjflash would work. In order to use it as non-root, you have to setup the udev rules.
Did you do that? Is your user is in the lego group?
skoehler
leJOS Team Member
 
Posts: 1350
Joined: Thu Oct 30, 2008 4:54 pm

Re: flashing problem

Postby zedex18 » Sat Jun 09, 2012 7:41 am

Thanks you for you help.

I do not know how to setup the udex rules. You said I have to use it as root, so when I do :
Code: Select all
cedric@cedric-laptop:~$ sudo nxjflash
sudo: nxjflash: command not found

But with the only "nxjflash" command, it "works" (command found, but no flashing).
Is your user is in the lego group?
What do you mean by ?
zedex18
New User
 
Posts: 8
Joined: Fri Jun 08, 2012 3:13 pm

Re: flashing problem

Postby skoehler » Sat Jun 09, 2012 12:09 pm

zedex18 wrote:Thanks you for you help.

I do not know how to setup the udex rules. You said I have to use it as root, so when I do :
Code: Select all
cedric@cedric-laptop:~$ sudo nxjflash
sudo: nxjflash: command not found


specify the absolute path to nxjflash when using sudo.

zedex18 wrote:
Is your user is in the lego group?
What do you mean by ?


Like on Windows or OSX, there are users and groups. Please follow the tutorial. It suggest to create a usergroup called "lego" and to add your login/username to that group.
http://lejos.sourceforge.net/nxt/nxj/tu ... dLinux.htm
skoehler
leJOS Team Member
 
Posts: 1350
Joined: Thu Oct 30, 2008 4:54 pm

Re: flashing problem

Postby zedex18 » Sat Jun 09, 2012 3:29 pm

I followed you advice and created the 70-lego.rules files and lego group. Now it recognize directly the command nxjflash, but does not see the NXT (It is connected and tuned ON, and the logo "usb" is showed in the top left corner of the NXT) :
Code: Select all
cedric@cedric-laptop:~$ nxjflash
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.
No NXT found. Please check that the device is turned on and connected.
Code: Select all
cedric@cedric-laptop:~$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 0a5c:219c Broadcom Corp.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0ac8:c33f Z-Star Microelectronics Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
zedex18
New User
 
Posts: 8
Joined: Fri Jun 08, 2012 3:13 pm

Re: flashing problem

Postby skoehler » Sat Jun 09, 2012 3:30 pm

zedex18 wrote:
Code: Select all
cedric@cedric-laptop:~$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 0a5c:219c Broadcom Corp.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0ac8:c33f Z-Star Microelectronics Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


The NXT was not connected/turned on. Or is the NXT running the original Lego firmware? The Lego firmware has problems with Linux. Put the NXT into firmware update mode manually.
skoehler
leJOS Team Member
 
Posts: 1350
Joined: Thu Oct 30, 2008 4:54 pm

Re: flashing problem

Postby zedex18 » Sat Jun 09, 2012 3:39 pm

Yes, it is still with the original firmware. To put it manually, should I use nxjflashg ?
zedex18
New User
 
Posts: 8
Joined: Fri Jun 08, 2012 3:13 pm

Re: flashing problem

Postby skoehler » Sat Jun 09, 2012 3:41 pm

zedex18 wrote:Yes, it is still with the original firmware. To put it manually, should I use nxjflashg ?

Is is explained here:
http://lejos.sourceforge.net/nxt/nxj/tu ... nux.htm#12
If your NXT has other firmware on it, or if nxjflash fails, you must manually put your NXT into firmware update mode. Press the reset button (at the back of the NXT, hidden in the hole near the USB port) for more than 4 seconds. A straightened paper clip could be useful for this. Your NXT will audibly tick when it is firmware update mode.
skoehler
leJOS Team Member
 
Posts: 1350
Joined: Thu Oct 30, 2008 4:54 pm

Re: flashing problem

Postby zedex18 » Sat Jun 09, 2012 3:52 pm

I'm in update mode (no screen and the "clik, clik, clik") but still the same error message when I execute nxjflash.
zedex18
New User
 
Posts: 8
Joined: Fri Jun 08, 2012 3:13 pm

Re: flashing problem

Postby skoehler » Sat Jun 09, 2012 3:53 pm

zedex18 wrote:I'm in update mode (no screen and the "clik, clik, clik") but still the same error message when I execute nxjflash.

Did you try sudo /path/to/nxjflash?
Which output does lsusb show?
skoehler
leJOS Team Member
 
Posts: 1350
Joined: Thu Oct 30, 2008 4:54 pm

Re: flashing problem

Postby zedex18 » Sat Jun 09, 2012 4:06 pm

By sudo it works. Now it is installed.
Thanks you a lot for your help fast and usefull.

I tried different tutorials in internet because I need a lot of example of "what to type in console", that is not in the LeJOS's.
Now let's work.

Thanks again.
zedex18
New User
 
Posts: 8
Joined: Fri Jun 08, 2012 3:13 pm

Re: flashing problem

Postby skoehler » Sat Jun 09, 2012 4:08 pm

zedex18 wrote:By sudo it works. Now it is installed.

If it works with sudo but not without, then your udev rules are imporpertly setup, udev hasn't been restarted, or your didn't create the user group/didn't add the user to the group or didn't logout and login to activate the new settings.
You will almost certainly have problem to use nxjbrowse/nxjupload/etc. via USB.
skoehler
leJOS Team Member
 
Posts: 1350
Joined: Thu Oct 30, 2008 4:54 pm

Re: flashing problem

Postby zedex18 » Sat Jun 09, 2012 4:24 pm

Yes I created the usergroup, but in fact, I didn't restarted.
zedex18
New User
 
Posts: 8
Joined: Fri Jun 08, 2012 3:13 pm

Re: [Solved] Flashing problem

Postby zbuhman » Sun Jun 17, 2012 11:58 pm

I thought I would comment because I think udev-rule debugging and particularly file permissions is something everyone should understand (particularly if you're writing the rules yourself).

You can watch udev add/remove devices by running "udevadm monitor" and then plug in the nxt; it'll look like this: http://sprunge.us/QLEJ

Then if you want to see what udev did with that event, you can do something like: http://sprunge.us/aPBi which tells you pretty much everything you'd need to know. Of particular interest would be line 27: "read rules file: /etc/udev/rules.d/70-lego.rules"; so we know it is in fact reading the rules from 70-lego.rules.

It also tells you semi-interesting things like the path to the device node, in this case: /dev/bus/usb/003/003 (which the tutorial halfway mentions exists, but never tells you how to calculate it). The other less-intuitive way to come up with that path is by doing lsusb; it would tell you something like, in this case "Bus 003 Device 003: ID 0694:0002 Lego Group Mindstorms NXT"; and then you'd have to just know that Bus 003 Device 003 corresponds to /dev/bus/usb/003/003

So if we look at the permissions of /dev/bus/usb/003/003, http://sprunge.us/DaRZ you'll see that in my case, the rules are obviously being applied. In that udevadm test, you can also see where the permissions came from on lines 60 and 61 of that second sprunge, "GROUP 1001 /etc/udev/rules.d/70-lego.rules:1" is particularly interesting to us.

Now, what I've seen frequently is where people follow ancient tutorials written by people who don't know what they are talking about, and/or run an ancient distribution with a dinosauric version of udev. You might see deprecated things like BUS=="usb" rather than SUBSYSTEM=="usb". There's another way to do ATTR iirc, one that's deprecated and still (halfway) works, and another completely broken way, but the way suggested in the tutorial is indeed the optimal way.

If I purposely broke my udev rules for example: http://sprunge.us/LMSS you'll see on lines 44 and 45, that it bus is completely deprecated/removed in favor of subsystem, and therefore udev doesn't recognize it at all. We're also missing that nice "GROUP 1001 /etc/udev/rules.d/70-lego.rules:1" line as you can see, because udev can't magically fix broken rules, and therefore can't apply them at all.

If we then examined the permissions of /dev/bus/usb/003/004 (again, udevadm told us what the path to the device node is), http://sprunge.us/gPHD you'll notice that the lego group no longer owns it.

If I tried nxjflash as my user now, I would be told the same thing you pasted earlier. Trying to fiddle with permissions manually is particularly painful: http://sprunge.us/diDR

But you could avoid all of that pain, if you just fixed your udev rules (no, running the nxjflash/nxjupload as root is most definitely not a valid solution). Also, the "lego" group, if you wanted to follow what the tutorial suggests, must firstly 1) exist in /etc/group and 2) your user must be a member of it in /etc/passwd and 3) the shell used to spawn nxjflash/upload must have been started after your user was added to the group, because the group membership of the parent process is inherited by its children. Re-logging in is the canonical way to accomplish this. You can also see group membership of your current shell by running "id".

I think calling the group "lego" originated from the lego usb tower used for infrared communications with the RCX; you would load the legousbtower module, and that would create a /dev/legousbtower0 device node, so it sort-of made sense to call the group allowed to use it "lego", to keeps things short. You could also call it something like "nxt-users" or something of that nature, but you'd need to update everything starting with your udev rules accordingly.

nxj toolchain developers: it might be worthwhile, instead of just saying "Ignoring device USB0::0x0694::0x0002::000000000000::RAW" to specify why it was ignored (no write permission in this case). Also, perhaps the tutorial should be expanded/updated with at least a subset of this information?

tl;dr: udev is your friend: use it.
zbuhman
New User
 
Posts: 22
Joined: Mon Aug 01, 2011 12:34 am
Location: Nebraska, USA


Return to NXJ Software

Who is online

Users browsing this forum: Baidu [Spider], ljdedseyrooov and 1 guest

more stuff