Go Down

Topic: After uploading a program to send data on the USB I can't reprogram it anymore (Read 761 times) previous topic - next topic

lz1dsb

Hi guys,
I've just uploaded the sample program on from Massimo Banzi's book "Getting Started with Arduino"
// Example 07: Send to the computer the values read from
// analogue input 0
// Make sure you click on "Serial Monitor"
// after you upload
//
// Copy and paste this example into an empty Arduino sketch

#define SENSOR 0  // select the input pin for the
                  // sensor resistor

int val = 0; // variable to store the value coming
             // from the sensor

void setup() {

Serial.begin(9600); // open the serial port to send
                     // data back to the computer at
                     // 9600 bits per second
}

void loop() {

  val = analogRead(SENSOR); // read the value from
                            // the sensor

  Serial.println(val); // print the value to
                       // the serial port

  delay(100); // wait 100ms between
              // each send 
}

And off course it works. I can see the digits outputed from the ADC in the Serial Monitor. The issue is that I can't reprogram my Arduino anymore!  : :smiley-roll-sweat: When I try to do it from the Arduino IDE I get this error:
"Serial port '/dev/ttyACM0' already in use. Try quiting any programs that may be using it." I read on this site: http://itp.nyu.edu/physcomp/Labs/SerialOut that I  "... won't be able to re-program the Arduino module if you don't, because the serial terminal program will have control of the serial port." But how do I do that? I'm using Ubuntu 9.10. Any ideas? I can't imagine that nobody else has stumbled upon this problem...

Regards,
Boyan


sentryGun53

Well, first of all make sure you close the serial monitor before you try to upload the new code.
I've run into this once or twice with home brewed serial code. Still don't know what exactly causes it, but what solved the issue for me was holding the reset button on the Arduino, and then releasing it just before the new code was uploaded. Might take a couple tries to get the timing right. You want the Arduino to be on by the time the new code begins to upload, but not to have started running its own code yet.
Also, stick a 1-second delay in setup() so you can do this more easily next time.
Cheers,
~Bob
Build your own sentry gun! http://psg.rudolphlabs.com

lz1dsb

Thank you Bob,
I'll for sure be more carefull next time and use this delay you propose. I was just able to restore the system by installing the IDE on my Windows XP laptop. It seems like that from Windows environment there isn't any problem to upload a sketch. I found some info in this forum. Some people mention that there seems to be an issue with the original firmware when the Linux IDE is used. Have you heard about this?
http://arduino.cc/forum/index.php/topic,51592.0.html
http://arduino.cc/blog/2011/02/15/fix-to-uno-and-mega-2560-linux-serial-problems/
Do you know any details about this?

Regards,
Boyan

lz1dsb

All right. I found that other folks thet used Arduino UNO like me hat the very same problem. So I followed the instructions on:
http://www.strangeparty.com/2010/12/13/fix-your-arduino-uno-for-linux/ and
http://arduino.cc/forum/index.php/topic,52447.0.html
I can confirm that now the the problem is solved. I also tried out the latest version of the Arduino IDE 0022 and it seems to work fine from there. I was able to use the serial port and upload few sketches.
Just one note. When I installed the dfu-programmer from the repository (I'm using Ubuntu 9.10 Karmic Koala) I noticed that a lot of packages were removed. Be more exact:
Entferne avr-libc ...
Entferne avrdude ...
Entferne gcc-avr ...
Entferne binutils-avr ...
Entferne lsb ...
Entferne lsb-desktop ...
Entferne lsb-graphics ...
Entferne lsb-cxx ...
Entferne lsb-core ...
Entferne mailx ...
Entferne bsd-mailx ...
Entferne libqt4-gui ...
Entferne librxtx-java ...
Entferne mplayer-nogui ...
Entferne libsvga1 ...
Entferne mplayer-skins ...
Entferne ncurses-term ...
Entferne pax ...
Entferne postfix ...

And off course after I resetted the Arduino board I wasn't able to use the Arduino IDE. It gave me an error that the package avr-gcc was missing. So just followed the above list and installed back all previously removed packages.
Putting the board in DFU mode wasn't very hard. I just followed the instructions and there wasn't a need to use the soldering method. I just used two wires. It was easy to note that the system is in DFU mode, the L  SMD LED was flashing and I also checked the output of the "lsusb", it was showing "Atmel". Now I just need to find a way to mark this thread as closed...

Cheers,
Boyan

Go Up