10.1. Reviving using the Arduino IDE
This section explains two special methods for programming an A-Star (or another of our 32U4 family of boards) using the Arduino IDE in case your usual method of programming is not working. These instructions were developed for the Arduino IDE versions 1.0.5-r2 and 1.6.0, and they might need to be modified for future versions.
If you have an A-Star 32U4 Micro, you should connect a momentary pushbutton between the GND and RST pins to serve as a reset button. Other boards in our 32U4 family have a reset button you can use. Alternatively, you can use a wire to temporarily connect GND and RST together instead of using a reset button.
Resetting the board twice within 750 ms makes the board go into bootloader mode. The bootloader will exit after 8 seconds and try to run the sketch again if it has not started receiving programming commands. To revive the device, you need to make sure you start sending it programming commands before the 8-second period is over.
In bootloader mode, the yellow LED (the one labeled LED 13) fades in and out. It is useful to look at this LED so you can know what mode the microcontroller is in. Also, we recommend enabling verbose output during upload using the Arduino IDE’s “Preferences” dialog. Looking at the LED and looking at the verbose output during the following procedures will help you understand what is going on.
The uploading-before-bootloader method
The goal of the uploading-before-bootloader method is to select a non-existent serial port in the Arduino IDE and then make sure the Arduino IDE enters the uploading phase before the microcontroller goes into bootloader mode. This method has been tested on Arduino 1.0.5-r2 and 1.6.0. This method does not work on Arduino 1.5.6-r2 or Arduino 2.0.0 because those versions of the IDE gives a fatal error message if the selected serial port is not present at the beginning of the uploading phase (e.g. “Board at COM7 is not available.” or “Upload error: Failed uploading: no upload port provided”).
- Connect the device to your computer via USB.
- In the “Tools” menu, open the “Board” sub-menu, and select “Pololu A-Star 32U4”.
- In the “Tools” menu, open the “Port” sub-menu, and check to see if any ports are selected. If the “Port” menu is grayed out or no ports in it are selected, that is good, and you can skip to step 6.
- Reset the board twice to get the board into bootloader mode. While the board is in bootloader mode, quickly select the new serial port that corresponds to the bootloader in the “Port” menu.
- After 8 seconds, the bootloader will exit and attempt to run the sketch again. Wait for the bootloader to exit. Verify that either the “Port” menu is grayed out or no ports in it are selected.
- Click the Upload button. The Arduino IDE will compile your sketch and start uploading it.
- As soon as the large status bar near the bottom of the IDE says “Uploading…”, reset the board twice to get into bootloader mode.
The Arduino IDE will stay in the uploading phase for 10 seconds, waiting for a new serial port to appear. Once the serial port of the bootloader appears, the Arduino IDE will connect to it and send programming commands.
The bootloader-before-uploading method
The goal of the bootloader-before-uploading method is to select the bootloader’s virtual serial port in the Arduino IDE and then make sure the board is in bootloader mode at the time when the Arduino IDE enters the uploading phase.
- Connect the device to your computer via USB.
- In the “Tools” menu, open the “Board” sub-menu and check to see if the “Pololu A-Star 32U4 (bootloader port)” entry is visible. If this entry is visible, you can skip to step 6.
- Using a text editor, open the file named boards.txt that provides the “Pololu A-Star” board entries. In Windows, you can typically find this file in %LocalAppData%\Arduino15\packages\pololu-a-star\hardware\avr\. In Linux, you can typically find this file in ~/.arduino15/packages/pololu-a-star/hardware/avr/. On macOS, you can typically find this file in ~/Library/Arduino15/packages/pololu-a-star/hardware/avr/. If you installed the boards manually instead of using the Board Manager, you can find it in [sketchbook location]/hardware/pololu/avr.
- In the boards.txt file that you opened, find the lines at the bottom of the file that start with
#a-star32U4bp. Uncomment each of those lines by deleting the “#” character, and then save the file.
- Close the Arduino IDE and restart it.
- In the “Tools” menu, open the “Board” sub-menu and select “Pololu A-Star 32U4 (bootloader port)”. This entry is configured so that the Arduino IDE will send programming commands directly to selected serial port, instead of trying to send a special USB command to the port to get it into bootloader mode and then waiting for the new port to appear. By selecting this entry, the timing of the programming process below becomes easier, especially on Windows.
- Prepare the computer to show you a list of its virtual serial ports. If you are using Windows, this means you should open the Device Manager. If you are on Linux or macOS, this means you should open a Terminal and type the command
ls /dev/tty*but do not press enter until the board is in bootloader mode in the next step.
- Reset the board twice to get the board into bootloader mode. While it is in bootloader mode, quickly look at the list of serial ports provided by your operating system in order to determine what port the bootloader is assigned to.
- Reset the board twice to get the board into bootloader mode again. While the board is in bootloader mode, quickly select the serial port of the bootloader in the Arduino IDE. The port can be selected in the “Port” sub-menu under “Tools”.
- In the Arduino IDE, click the “Verify” button to compile your sketch. This could make the timing easier during the next step.
- Press the reset button twice to get the board into bootloader mode again. As soon as you see the yellow LED fading in and out, press the Upload button.
The Arduino IDE will compile your sketch and then upload it to the selected serial port.
If the compilation of the sketch takes longer than 8 seconds, then this procedure will fail because the bootloader will time out and start trying to run the malfunctioning sketch again. If that happens, try the procedure again using a simpler sketch such as the Blink example that can be found under File > Examples > 01.Basics > Blink.
After reviving your device, be sure to change the Board setting back to “Pololu A-Star 32U4” and select the right Port.