The Linduino is Linear Technology’s Arduino compatible system for distributing firmware libraries and example code to customers of Linear Technology’s integrated circuits. The design is based on the Arduino Uno, using the Atmel ATmega328 processor, while adding a 14-pin QuikEval™ connector that can be plugged into nearly 100 daughter boards. These boards demonstrate Linear Technology's parts, including analog-to-digital converters, digital-to-analog converters, high-voltage power monitors, temperature measurement devices, RF synthesizers, battery stack monitors and more.
The original Arduino Uno (available from www.arduino.cc) includes a seldom-used feature that enables it to be paired with an Atmel hardware debugger after cutting a copper trace on the PCB. In this mode, the freely available Atmel Studio development environment, built around Microsoft Visual Studio, enables extensive debugging capabilities, including line-by-line code stepping, breakpoint support and the ability to easily view variable values. Unfortunately, after the Arduino Uno’s PCB trace is cut, only the hardware debugger can load new firmware (sketches) to the Arduino Uno; the standard Arduino IDE’s ability to load new firmware through the USB cable is lost until the trace is reconnected with a bit of solder.
When I designed the Linduino in 2013, I added a provision for the user to solder a 3-pin header in place, making it possible to choose between normal operation and hardware debugger-enabled operation at any time without requiring further soldering.
While the Arduino IDE is a wonderful environment to get a user up and running with a Linear Technology demo board and sample code in under 10 minutes, its simplicity comes at a cost. It does not provide the features of a more advanced IDE, like the ability to debug code in real-time. When I develop my own code on the Linduino, I use Atmel Studio and the Atmel-ICE hardware debugger. Until now, it was a fairly complex process to convert an Arduino sketch into an Atmel Studio project that can be debugged with a hardware debugger.
Recently, the Visual Micro add-in for Atmel Studio has simplified this process, so I created this tutorial to show the steps required to convert a Linduino (or Arduino) sketch into a form that can be debugged with the Atmel-ICE hardware debugger. The length of this blog may be intimidating, but the process is fairly simple, and I’ve made an effort to include all steps from start to finish.
That being said, I wouldn’t recommend this process to brand-new Arduino user. If you are writing less than 100 lines of code, the Arduino IDE is simple and just works. As your code grows larger and you accept that more time is spent debugging code than writing it, you’ll appreciate the capabilities provided by a hardware debugger. But, understand that if you mistakenly overwrite the Linduino’s bootloader, you may brick the Linduino. The bootloader can be restored with the Atmel-ICE, so the Linduino is not truly bricked, but if you are a novice user that is unfamiliar with the term bootloader, this might not be the tutorial for you.
Install the Linduino Library & Arduino IDE
While LTsketchbook.zip is extracting, download the Windows Installer for Arduino IDE version 1.6.7. At the time this was written, the latest versions, 1.6.10 and 1.6.11, do not work properly with this debugging method.
After the download completes, run the Windows installer and accept all default settings. When the installation is done, open the Arduino application and select File→Preferences.
Press the Browse button next to Sketchbook location and select the newly extracted LTsketchbook folder. Also, next to Show verbose output during check both compilation and upload, and then press OK.
Connect the Linduino to the USB port, and if prompted, allow the drivers to install. Then, select Tools→Port→COMx, where COMx corresponds to the COM port that has been assigned to your Linduino. In the image below, it is COM3. If more than one port is listed, it may be difficult to identify which port corresponds to your Linduino. In that case, disconnect the Linduino and select Tools→Port again to see which COM port was removed. Reconnect the Linduino and select that port.
Next, press the arrow button to compile and upload MyBlink to the Linduino. When it completes, you will see a Done uploading message in the Arduino IDE and the Linduino’s LED will begin blinking.
Configuring Visual Micro
Follow the next few steps carefully, even if you do not fully understand their purpose yet. These steps are important to the proper operation of Visual Micro for reasons that will become clear after you start using the hardware debugger.
Close any open Arduino IDE applications. With Windows File Explorer, navigate to Documents/LTsketchbook/Utilities/MyBlink. In that folder, copy MyBlink.ino to MyBlink.cpp.
Next, remove all contents from MyBlink.ino and leave it as an empty file. The easiest way to clear the contents is to double-click MyBlink.ino . The Arduino IDE opens MyBlink.ino with MyBlink.cpp loaded in a second tab. Clear all contents of MyBlink.ino (type Ctrl-A and press Delete on the keyboard). Save the file, and then, press the upload arrow again. The contents of MyBlink.cpp will be compiled and uploaded into the Linduino.
Although it is not shown here, it would be even better to add a comment inside the MyBlink.ino file.
/* This file, MyBlink.ino, is left intentionally blank, and the code has been moved to MyBlink.cpp. Removing all code from the ino file allows this project to work properly with the Arduino IDE and with the Atmel Studio, the Visual Micro add-in, and a hardware debugger. */
Close the Arduino IDE and download the Atmel Studio web installer.
Run the installer and accept all defaults. It may take a long time for the installer to complete, perhaps an hour or more. If Atmel Studio prompts that some Windows Updates are required, attempt to install the updates using the links it provides.
After the Atmel Studio installation finishes, open Atmel Studio and select Tools→Extenstions and Updates.
From the left panel of the Extensions and Updates window, select Available Downloads→All. From the center panel, download and install Arduino IDE for Atmel Studio 7. Atmel Studio may request that you sign up for an account. When it completes, press the “Restart Now” button.
After Atmel Studio restarts, a configuration window opens for Visual Micro, which was installed by the Arduino IDE for Atmel Studio 7 extension in the previous step. Accept the default values. Leave the sketch location and boards manager fields blank, and then press OK If the configuration window does not open automatically, choose vMicro→IDE and select Configuration Manager from the drop-down menu.
At this point, many USB drivers have been installed by the Arduino IDE and Atmel Studio. I recommend restarting Windows to ensure that all the new drivers are registered correctly.
After you have restarted Windows, insert the Atmel-ICE3’s cable into a USB port. You will see a message that a new device is being setup.
Modify Linduino for Hardware Debugging
This would be a good time to modify your Linduino for hardware debugging, if it is not already modified. Unplug all connections on your Linduino, turn it over and cut the trace shown below.
Then, solder a 1mm 3-pin header into the Linduino and place a jumper across the pins not labeled NORM.
When the jumper is in the position shown below, the Linduino is in debug mode and a hardware debugger and Atmel Studio are required to program the Linduino. The Arduino IDE will not be able to program the Linduino in debug mode. When the jumper is in the NORM position, the Linduino will function normally with the Arduino IDE but not the hardware debugger. If you do not have a 1mm 3-pin header available, the cut shown above enables debug mode. Soldering across the cut or the NORM pins on the jumper holes will re-enable normal operation.
Insert the Atmel-ICE’s 6-pin connector over the Linduino’s 6-pin ISP header in the orientation shown below.
For those familiar with Arduino circuitry and operation, in debug mode, the RESET pin of the ATmega328P is used to transfer all data about memory, register values, breakpoints, etc. without disrupting the IO pins. The Arduino’s automatic reset (AC coupled from the FTDI’s USB-to-Serial DTR pin) is disconnected from the ATmega328P. For the average user, it is not necessary to understand these details to use the hardware debugger effectively.
After you have restarted Windows, insert the Atmel-ICE3’s cable into a USB port. You will see a message that a new device is being setup.
If you have not already done so, reconnect the USB cable between the PC and the Linduino.
Restart Atmel Studio. Select vMicro→Open Existing Arduino Project.
Navigate to the Documents→LTsketchbook→Utilities→MyBlink folder, and choose the MyBlink file. As described above, before opening any Arduino project with Visual Micro, it is best to copy the *.ino file to a *.cpp file, and remove all contents from the *.ino file. We did that in a previous step of this tutorial for MyBlink. If you do not create a *.cpp file, Visual Micro will create a new temporary folder and copy your project there. The resulting copy is more difficult to use with the hardware debugger.
The Linduino is compatible with the Arduino/Genuino Uno board, so select vMicro→Board→Arduino/Genuino Uno.
Select vMicro→Compiler→Verbose to show more information during the compile step.
Select vMicro→Uploader→Programmer→Atmel Studio Device Programming to specify that the Atmel-ICE3 (or other Atmel Studio compatible hardware debugger) should be used to program the Linduino.
Also, select vMicro→Uploader→Always Use Programmer for Upload (Instead of Port/IP).
Select vMicro→Debugger→Atmel Studio Debugger to indicate that a hardware debugger will be used.
Select Debug→Start Debugging and Break.
A window should appear asking for Interface settings. Choose Atmel-ICE, ATmega328P, and ISP, and then, press Apply.
Please continue if you receive a message that says, Please select a connected tool and interface and try again.
In the next window to appear, choose Atmel-ICE3 and debugWire. debugWire is a debugging mode that enables all information to be communicated using the RESET pin of the microcontroller. Once enabled, firmware is loaded to the microcontroller using debugWire.
If you try to use the Arduino IDE to load firmware while debugWire is enabled, the upload will fail. For future reference, if you run into this issue, select “Debug→Disable debugWire and Close” to re-enable the Linduino’s default bootloader. If that menu option is greyed out, you might have to load a project in Atmel Studio to make it selectable.
Select Debug→Start Debugging and Break again. You may also have to close the Device Programming window if it reappears.
At this point, you will likely receive a message informing you that debugWire is about to be enabled. Although the message appears to be an error, it is Atmel Studio’s way of letting you know that it is about to enable debugWire. If a demo board is attached to the Linduino’s QuikEval connector, remove it before pressing the “Yes” button. You can reinsert the demo board after debugWire is enabled.
After debugWire is enabled, a message appears prompting you to toggle the target power. To toggle the power, remove the USB cable from the Linduino and then reinsert it. If you are using the 12V AC power, also disconnect it at the same time to remove all power sources from the Linduino.
The first time after enabling debugWire, you may have to select Debug→Start Debugging and Break again. You may also have to close the Device Programming window if it reappears. Wait for the build and write to complete as shown by the status bard at the bottom of the Atmel Studio window.
Load and Execute the Program
The MyBlink sketch loads into the Linduino and pauses at the init() statement. If you press F5, the program will execute. You can also place breakpoints or single step through MyBlink in the same manner as you would debug other software using Microsoft Visual Studio.
Note that debugWire is automatically disabled when you exit Atmel Studio. After debugWire is disabled, moving the 3-pin header to the NORM position restores normal operation, and the Linduino can be used with the standard Arduino IDE again. However, occasionally Atmel Studio fails to disable debugWire automatically. In that case, debugWire can be disabled manually by opening a project in Atmel Studio and selecting “Debug→Disable debugWire and Close”.
To avoid confusion, it is recommended that you always disable debugWire before closing Atmel Studio.
The Arduino IDE has simplified firmware development for novice users while simultaneously providing a common environment for more advanced users to exchange code. But the simplicity of the Arduino IDE is achieved by eschewing the features of a more advanced IDE. This tutorial shows how, with the addition of a jumper, the Linduino enables the advanced features provided by the Atmel Studio IDE, the Visual Micro add-in, and an Atmel-ICE3 hardware debugger.
Linear Technology’s Linduino is not affiliated with the official Arduino team, but Linear Technology recognizes that the Linduino is only possible because of the Arduino team's commitment to the open-source community. Please consider supporting them at www.arduino.cc.
- In the Device Programming Window, if you see the connection issue shown below when you click on Apply, one possible reason is that you chose the .cppproj instead of the .atsln file when opening the project.
The figure below shows the error message after closing the Device Programming window.
- If the device signature cannot be read, make sure the connector is plugged in correctly.
- If a firmware update is required, allow it to complete.