I bought this 32u4 board on Amazon (https://www.amazon.it/gp/product/B019SXN84E/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1) that should be recognised as an Arduino Leonardo by the Arduino IDE. At first it totally worked as I was only trying to emulate keyboard and mouse USB input. I was searching for a code line that could stop the void loop(), so I tried using "exit(0);", as it was suggested in an other topic here. Now since that moment the board is stuck in a loop.

It continuously repeat the loop, while the red led is always on. I tried to upload a different code, but the IDE gives me alternatively two error messages:

  • "processing.app.debug.RunnerException at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:159) at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78) at processing.app.SketchController.upload(SketchController.java:707) at processing.app.SketchController.exportApplet(SketchController.java:680) at processing.app.Editor$DefaultExportHandler.run(Editor.java:2176) at java.lang.Thread.run(Thread.java:745) Caused by: processing.app.SerialException: Error touching serial port 'COM3'. at processing.app.Serial.touchForCDCReset(Serial.java:87) at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:143) ... 5 more Caused by: jssc.SerialPortException: Port name - COM3; Method name - openPort(); Exception type - Port busy. at jssc.SerialPort.openPort(SerialPort.java:164) at processing.app.Serial.touchForCDCReset(Serial.java:81) ... 6 more";

  • "Forcing reset using 1200bps open/close on port COM3". (Even waiting for hours didn't solve the "forcing")

I already tried uninstalling drivers, uninstalling the IDE and changing COM port. Nothing worked. Unfortunately the reset button is missing on this board.

Is possible to restore the board or is totally lost?

Thanks in advance!

My question is different from the one there (What happens when I call exit() from my program?) because I used that code and I need to solve a loop problem, it's not just a theorical question. I'm also using a different type of board.

  • You could try manually resetting the board before an upload, by pressing the reset button. – Gerben Oct 9 '16 at 11:06
  • SparkFun bootloader can be activated by pressing reset twice. So it's not waiting 8s in bootloader after every reset. – KIIV Oct 9 '16 at 11:10
  • 2
    Possible duplicate of What happens when I call exit() from my program? – Dat Ha Oct 9 '16 at 11:19
  • And if you have another Arduino, you can use it as an Arduino ISP programmer for burning Bootloader (this also cleans up sketch). – KIIV Oct 9 '16 at 11:20
  • This isn't really a duplicate of what happens when calling exit() from an Uno, as the consequences are different. On an Uno, entry into the bootloader is a hardware operation, but on a 32u4 based board it is typically a software one. Apparently calling exit() breaks the latter. It cannot break the former. – Chris Stratton Oct 9 '16 at 19:09

exit(0) basically shuts the board down. That includes the USB connection, which is managed by software. All functions stop - interrupts are disabled, etc.

You need to do a manual reset of the board when it's time to program. For that you need a reset button. If there isn't one on the board then just connect one between the RESET and GND pins. Press it just before programming (LED should glow for something like 8 seconds) and upload your new sketch.

exit(0) is only safe to use on boards with a UART interface (such as the Uno). Other boards you should use while(1); or for(;;);

  • Thanks for the answer. I didn't know about that. I will try to reset the board manually in that way. – mrcmlnr Oct 10 '16 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.