[new] An error occurred while uploading the sketch

  • It is an old topic on Arduino but even with 1.6.9 IDE, the same situation on my side.

  • The details: when clicking Upload button, the bottom console keeps at Uploading... status all the time and but the program is actually uploaded to the board (because the LED and Serial port output work as the program did.) After a few minutes, "an error occurred while uploading the sketch" appears.

Appendix:

  • If I run the upload command directly, everything works perfectly without any error.

ST-LINK_CLI.exe" -c SWD -P "full path of [filename].ino.bin" 0x8008000 -Rst -Run

  • The workaround: When at Uploading... status, I click Upload button again then press RESET button on board and if releasing the button at some perfect timing, the upload can finish successfully.

What board is this?

It looks like you're using a third party board definition package (is that a STM32 board?). You might get better results asking on a forum dedicated to that board definition package; It's an issue specific to that hardware package, and I don't see much discussion on STM32 boards here; I think the people using those use their own forums elsewhere.

Thanks for your reply. You are right and it is about STM32 board.

For the same ST-Link_Cli.exe execution, windows command window runs successfully however Arduino IDE performs with an error although the program has been flashed into the board.

So I believe it is a display issue in Arduino IDE consoleā€¦