I am using a leonardo and for some reason I can only upload sometimes to it. I've noticed it happens usually only when I have serial communication happening, I am assuming its because leonardo continues to read serial even when window is closed.
I am on OSX and have tried two things:
adding delay in setup of 5seconds so I could try a reboot and upload right after its been rebooted.
Yeah, I wrote that with the Uno and Mega in mind. The Leonardo is different. Although, it would be good to use lsof to find out what is holding the port open (something has to be).
hilukasz:
nope, like i mentioned earlier, it only happens when I have serial communication it seems, simple sketches like blink don't seem to have an affect.
Okay then load something with serial communication and run lsof to find out what is keeping the port open. Again, if you're getting "serial port in use" that means some process is holding it open.