Previously the CRC error was quite annoying to recover because
the user needed to manually delete the corrupted file from the
staging folder (without knowing the exact path of the file to
remove).
Now the IDE tries autonomously to resolve the situation by
removing the file and downloading it again.
Fixes#5394#4303
This regression originates from:
8725bb1e Clean up sketch loading
before this commit the sketch name sanitization was made on the sketch
name without the extension.
After 8725bb1e instead the name sanitization is made on the filename, so
including the ".ino" extension.
This lead to a weird corner case, caused by the limit of 63 characters
on the sketch name: before 8725bb1e it would be possible to save a sketch
with a name of exactly 63 characters, but after 8725bb1e this sketch will
suddenly becomes invalid becuase the 63 chars name + extension would exceed
the 63 characters limit.
This commit fix this regression.
Fix#5431
Arduino AVR Boards 1.6.11 added the {upload.verify} property to the tools.avrdude.upload recipe and {program.verify} to the tools.avrdude.program recipe to support the File > Preferences > Verify code after upload setting.
In Arduino IDE versions 1.6.8 and previous upload.verify is set to true or false depending on the preferences setting which causes Upload to an AVR board with Arduino IDE 1.6.8 or older and Arduino AVR Boards 1.6.11 or newer to generate AVRDUDE commands like:
avrdude -CC:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino2/etc/avrdude.conf -v true -patmega328p -carduino -PCOM21 -b115200 -D -Uflash:w:C:\Users\per\AppData\Local\Temp\buildece560c1024a4a94b7c3b05be61aa2fc.tmp/sketch_sep28a.ino.hex:i
program.verify is unset, which causes Upload Using Programmer to an AVR board with Arduino IDE 1.6.8 or older and Arduino AVR Boards 1.6.11 or newer to generate AVRDUDE commands like:
avrdude -CC:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino6/etc/avrdude.conf -v {program.verify} -patmega328p -cusbasp -Pusb -Uflash:w:C:\Users\per\AppData\Local\Temp\build77ff2e21c5523c5895e8d065447461cb.tmp/sketch_sep28a.ino.hex:i
AVRDUDE 6.0.1 is able to ignore the spurious item in the command and successfully upload but when used with AVRDUDE 6.3.0 this causes upload to fail:
avrdude: no programmer has been specified on the command line or the config file
Specify a programmer using the -c option and try again
This means that Arduino AVR Boards 1.6.12 and 1.6.14 are not backwards compatible with Arduino IDE 1.6.8 and previous.
Setting a default empty value for the upload.verify and program.verify properties in platform.txt causes Arduino IDE 1.6.8 and older to generate an AVRDUDE command identical to that generated with Arduino AVR Boards 1.6.10 or older(meaning that, as previously, the preferences setting has no effect):
avrdude -CC:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino2/etc/avrdude.conf -v -patmega328p -carduino -PCOM21 -b115200 -D -Uflash:w:C:\Users\per\AppData\Local\Temp\buildece560c1024a4a94b7c3b05be61aa2fc.tmp/sketch_sep28a.ino.hex:i
Arduino IDE 1.6.9 and newer overrides the default values of upload.verify and program.verify, therefore this change has no effect on the AVRDUDE command generated and verification is controlled by the preferences setting as usual.
Tested back to Arduino IDE 1.6.2, the oldest IDE version that supports Boards Manager updates.
The snippet:
boolean wrapNeeded = false;
if (wrap && nextIndex == -1) {
// if wrapping, a second chance is ok, start from the end
wrapNeeded = true;
}
Can be moved inside the `if (nextIndex == -1)` that follows, this way:
if (nextIndex == -1) {
boolean wrapNeeded = false;
if (wrap) {
// if wrapping, a second chance is ok, start from the end
wrapNeeded = true;
}
[...CUT...]
if (wrapNeeded) {
nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search, 0);
}
}
but since `wrapNeeded` is used only at the very end of the `if` statement
we can move it forward:
if (nextIndex == -1) {
[...CUT...]
boolean wrapNeeded = false;
if (wrap) {
// if wrapping, a second chance is ok, start from the end
wrapNeeded = true;
}
if (wrapNeeded) {
nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search, 0);
}
}
and finally simplify it by removing `wrapNeeded` altogether:
if (nextIndex == -1) {
[...CUT...]
if (wrap) {
nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search, 0);
}
}
The snippet:
boolean wrapNeeded = false;
if (wrap && nextIndex == -1) {
// if wrapping, a second chance is ok, start from the end
wrapNeeded = true;
}
is present on both sides of the `if` statement so it can be factored out.
From: `Examples from Built-in Libraries`
To: `Examples for any board`
From: `Examples from Arduino AVR Boards Libraries` (selected platform)
To: `Examples for Arduino/Genuino Micro` (selected board)
From: `Examples from Arduino AVR Boards Libraries` (referenced platform)
To: `Examples for Arduino AVR Boards` (referenced platform)