Go Down

Topic: IDE uploads old sketch on compile error (Read 586 times) previous topic - next topic

RanHug

My forum and gooogle searches, as well as digging around in the IDE folders on Windows 10 produced nothing useful, so I'll ask:

Is there's any way to configure or hack the Arduino IDE (v1.8.7) to keep it from uploading (and burning flash life cycles) when the compile associated with the upload button fails?  I cannot imagine the wisdom of uploading the old binary when the newer code cannot compile.  Can't the IDE see the exit code from avr-gcc?

I had guessed the IDE would use a '.bat' or '.cmd' file that could be tweaked, but the avr-gcc and avrdude invocations appear hardwired inside the IDE.

Other than abandoning arduino IDE, and/or resorting to some kind of MAKEFILE implementation, are there any other viable approaches for Windows (besides of course habitually always verifying before uploading)?


Thanks.

spycatcher2k

The IDE will not upload if the compile fails, but at a minimum 10000 write limit before failure, you would have to be doing a lot of uploading to reach this.

I've got a 7 year old Arduino duemilenove, that I upload to almost every day (Often multiple times), and it has yet to fail. Even if it did, swapping out the 328 Chip is trivial.
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

RanHug

My IDE is *definitely* uploading (the old sketch) on compile failures.

pert

What makes you think it's uploading the old sketch?

spycatcher2k

Quote
My IDE is *definitely* uploading (the old sketch) on compile failures.
Please post the FULL output of your debug window, I can't understand how the IDE knows what your old sketch was?
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

RanHug

1) open a new sketch
2) put this line at the top of the sketch:
       bool doit=true;
3) put this line in setup():
       Serial.begin(2000000); Serial.println("RESET");
4) put this line in loop():
       if (doit)Serial.println(String("ert")+String(doit)); doit=false;
5) select Tools->Serial Monitor
6) click the 'upload' button
7) observe the arduino board serial LED(s) blink during download
8) observe that the Serial Monitor contains the expected:
     RESET
     ert1
9) remove the trailing semi-colon from any one of the lines you added.

A) while watching the aruino board serial LED(s), click upload again
B) observe the LEDS blink quickly (thrice?) then a brief pause before blinking an addition time.

C) observe that the Serial Monitor first clears and then displays the same output as before.

D) note how this differs from pressing the onboard reset button in that the serial monitor does not clear.

… Because it was requested, below is the *entire* content of the IDE output window:

C:\Users\726ah\Documents\Arduino\IDE_BUG\IDE_BUG.ino: In function 'void loop()':

IDE_BUG:5:1: error: expected ';' before '}' token

 }

 ^

exit status 1
expected ';' before '}' token

... To the inquiry about how the IDE would know the "old" download, I theorize that since the compile fails, the output from the prior 'ld' run is still laying around wherever it lives, suitable for [re]download.

For completeness, I have an OSEPP UNO R3 PLUS, not a genuine arduino board.  The IDE may be seeing something on the serial interface that differs from arduino hardware.

spycatcher2k

Quote
… Because it was requested, below is the *entire* content of the IDE output window:

C:\Users\726ah\Documents\Arduino\IDE_BUG\IDE_BUG.ino: In function 'void loop()':

IDE_BUG:5:1: error: expected ';' before '}' token

 }

 ^

exit status 1
expected ';' before '}' token
OK - so you have made an error in your code.


Quote
C) observe that the Serial Monitor first clears and then displays the same output as before.

D) note how this differs from pressing the onboard reset button in that the serial monitor does not clear.
This is correct, as the Serial monitor is cleared before the port is attempted to be opened.

There is no upload of code, So you are misunderstanding what you are seeing. There is NOTHING uploaded, so the last sketch (That is now on the Arduino) runs. The Serial monitor has NO way of knowing you have pressed the RESET button, so it does NOT clear the display, when you ask the IDE to upload, it clears the Serial monitor , when it deactivates it while getting ready to upload.
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

RanHug

I stand corrected.

I convinced myself that you are correct.  Its not downloading, but the IDE is resetting the board such that the old sketch restarts.  I changed my setup() to:

   void setup() { delay(10000); Serial.begin(2000000); Serial.println("RESET"); }

to hold off the sketch's interaction with the serial port for ten seconds.

With that, the observables that accompany the failed compile is the serial LEDS do not blink until the sketch does its writes.  However, the other onboard LED does blink at roughly the same time the serial monitor clears, the [old] sketch restarts, and the serial monitor displays my "RESET" ten seconds later, indicating the IDE was able to reset the board without me being able to see the serial LEDs do anything.

Thanks for challenging me to "think differently" so see things for what they really are.

spycatcher2k

Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

Go Up