Mac OS X uploading troubles (a vague bug report)

I was working away with Arduino 07 on Mac OS X 10.4.8/PowerPC without
the macosx_setup.command. It was uploading the firmware even though
it would also give a stack trace beforehand. It just stopped
working, I don't really know what triggered it.

I ran macosx_setup.command, but it still doesn't work. It gives this
stack trace, even though nothing else is running that could open the
serial port:

Error inside Serial.()
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.app.Serial.(Serial.java:127)
at processing.app.Serial.(Serial.java:72)
at processing.app.Uploader.uisp(Uploader.java:156)
at processing.app.Uploader.uploadUsingPreferences(Uploader.java:78)
at processing.app.Sketch.upload(Sketch.java:1693)
at processing.app.Sketch.exportApplet(Sketch.java:1755)
at processing.app.Editor$40.run(Editor.java:1892)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy
(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy
(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
[VP 1] Device is not responding correctly.

After a reboot, it worked again, but I had already run the
macosx_setup.command. Below is what it looks like when it throws an
error, but still works. It actually doesn't throw this exception
until it's done burning the firmware, oddly enough.

Error inside Serial.()
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.app.Serial.(Serial.java:127)
at processing.app.Serial.(Serial.java:72)
at processing.app.Uploader.uisp(Uploader.java:156)
at processing.app.Uploader.uploadUsingPreferences(Uploader.java:78)
at processing.app.Sketch.upload(Sketch.java:1693)
at processing.app.Sketch.exportApplet(Sketch.java:1755)
at processing.app.Editor$40.run(Editor.java:1892)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy
(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy
(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Atmel AVR ATmega8 is found.
Uploading: flash
Firmware Version: 1.18
Firmware Version: 1.18

Here are the relevant drivers, AFAIK:

26 12 0x43e000 0x21000 0x20000
com.apple.iokit.IOUSBFamily (2.5.6) <11>
39 0 0x738000 0xb000 0xa000
com.apple.driver.AppleUSBHub (2.5.6) <26 11>
54 2 0x4bc000 0xb000 0xa000
com.apple.iokit.IOSerialFamily (9.0.0d30) <6 5 4 3 2>
83 0 0x4cc000 0xc000 0xb000
com.apple.iokit.IOUSBUserClient (2.5.0) <26 11>
94 0 0x2e391000 0x4000 0x3000
com.apple.driver.AppleUSBComposite (2.5.8) <26 11>
95 0 0x2e395000 0x6000 0x5000
com.apple.iokit.IOUSBHIDDriver (2.5.5) <26 19 11>
96 0 0x2de4d000 0xd000 0xc000
com.FTDI.driver.FTDIUSBSerialDriver (2.1.6) <54 26 11>
98 0 0x2e1f9000 0x3000 0x2000
com.apple.driver.AppleUSBMergeNub (2.5.5) <26 11>

There are two steps involved in uploading a sketch. First, Java code in the environment itself uses the RXTX library to flush the serial connection (read all available data). Second, the environment launches uisp, an external executable to actually upload the compiled sketch (a .hex file) to the board.

The exception is thrown by RXTX in the first step if it is not able to open the serial port. Previous to Arduino 0007, this could happen if it wasn't able to create a lock file (in /var/lock or /var/spool/lock) - which required running the macosx_setup.command to add your account to the uucp group which has permission to edit those directories. Arduino 0007 includes a version of RXTX that was compiled not to use lock files, so it shouldn't require the macosx_setup.command. It's possible, however, that old lock files in one of those directories are confusing RXTX and preventing it from opening the serial port. (You can check for them by using the Go > Go to a folder... command in the Finder; delete any you find.)

Even if RXTX fails to flush the serial port, uisp may still be able to upload your sketch. If, however, there's some incoming serial data that RXTX couldn't flush, uisp will get confused and say "Programmer not responding." or similar. One solution (besides getting RXTX to cooperate), is trying to reset the board and upload the sketch twice in succession, or resetting the board once and uploading twice - either way, using one upload attempt as a way to flush the incoming serial data and initiating the second one before the current sketch on the board has a chance to spit out more data.

When uploading stopped working was the sketch on the board doing serial communication? Did you run older versions of Arduino (and the macosx_setup.command) on the same computer? Do you have any other versions of RXTX installed?

i'm having the same problem. also ran macosx_setup.command, did not work. program can upload but serial monitor and serial comm don't work obviously. could not find any var or var/lock directories at all. there are many instances of RXTXcomm.jar:

Apps/Processing 0115/libraries/serial/code/
Apps/Processing 0115/libraries/serial/library/
HD/Library/Java/Extensions/

they all seem to be from rxtx-2.1-7pre17

You might need to delete the one in /Library/Java/Extensions. Arduino's using rxtx-2.1.7, which could conflict with the 2.1.7pre17 version.