Skip to content Skip to sidebar Skip to footer

Samd21 Pleaseselect a Connected Tool and Interface and Try Again

Setting up Linduino, Visual Micro, & Atmel-ICE for Hardware Debugging

Introduction

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

Download the Linduino library here

Figure 1. Download the Linduino Library.

After the download completes, open the folder containing the *.zip file, and right-click LTsketchbook.zip to extract the contents to the user's Documents folder as shown below.

Figure 2. Extract Contents from LTsketchbook.

Figure 3. User Documents Folder.

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.

Figure 4. Arduino IDE.

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.

Figure 5. Open the Arduino.

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.

Figure 6. Extracted LTsketchbook.

Select Sketchbook→Utilities→MyBlink

Figure 7. MyBlink.

Figure 8. MyBlink Upload.

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.

Figure 9. Linduino to the USB 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.

Figure 10. Compile and Upload MyBlink.

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.

Figure 11. Copy MyBlink.ino.

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. */

Figure 12. Compiled and Uploaded MyBlink.cpp.

Close the Arduino IDE and download the Atmel Studio web installer.

Figure 13. Atmel Studio 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.

Figure 14. Extensions 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.

Figure 15. Arduino IDE for Atmel Studio 7.

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.

Figure 16. Accept the Default Values.

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.

Figure 17. Device Setup Installing.

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.

Figure 18. Cut the Trace.

Figure 19. Cut the Trace Detail.

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.

Figure 20. Soldering Across the NORM Pins.

Figure 21. JTAGICE3 Connector.

Insert the Atmel-ICE's 6-pin connector over the Linduino's 6-pin ISP header in the orientation shown below.

Figure 22. Atmel-ICE's 6-pin connector over the Linduino's 6-pin ISP header.

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.

Configuring MyBlink

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.

Figure 23. New Device 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.

Figure 24. 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.

Figure 25. Choose MyBlink.

The Linduino is compatible with the Arduino/Genuino Uno board, so select vMicro→Board→Arduino/Genuino Uno.

Figure 26. Arduino/Genuino Uno.

Select vMicro→Compiler→Verbose to show more information during the compile step.

Figure 27. Verbose Compiler Option.

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.

Figure 28. Atmel Studio Device Programming.

Also, select vMicro→Uploader→Always Use Programmer for Upload (Instead of Port/IP).

Figure 29. Always Use Programmer for Upload.

Select vMicro→Debugger→Atmel Studio Debugger to indicate that a hardware debugger will be used.

Figure 30. Atmel Studio Debugger.

Interface Settings

Select Debug→Start Debugging and Break.

Figure 31. Start Debugging and Break.

A window should appear asking for Interface settings. Choose Atmel-ICE, ATmega328P, and ISP, and then, press Apply.

Figure 32. Interface Settings.

Please continue if you receive a message that says, Please select a connected tool and interface and try again.

Figure 33. Connected Tool and Interface.

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.

Figure 34. Select Debugger/Programmer.

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.

Figure 35. Launch Failed.

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.

Figure 36. DebugWire Enabled.

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.

Figure 37. Status Bar.

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.

Figure 38. MyBlink Debugging AtmelStudio.

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.

Conclusion

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.

Troubleshooting

  1. 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.

Unable to Connect.

The figure below shows the error message after closing the Device Programming window.

Failed to Setup.

  1. If the device signature cannot be read, make sure the connector is plugged in correctly.

Device Cannot be Read.

  1. If a firmware update is required, allow it to complete.

Firmware Update Needed.

Об авторах

Dan-Eddleman

Dan Eddleman

Dan Eddleman is an analog engineer with over 15 years of experience at Linear Technology as an IC designer, the Singapore IC Design Center Manager, and an applications engineer.

He began his career at Linear Technology by designing the LTC2923 and LTC2925 Power Supply Tracking Controllers, the LTC4355 High Voltage Dual Ideal Diode-OR, and the LTC1546 Multiprotocol Transceiver. He was also a member of the team that designed the world's first Power over Ethernet (PoE) Controller, the LTC4255. He holds two patents related to these products.

He subsequently moved to Singapore to manage Linear Technology's Singapore IC Design Center, overseeing a team of engineers that designed products including Hot Swap controllers, overvoltage protection controllers, DC/DC switched-mode power supply controllers, power monitors, and supercapacitor chargers.

Upon returning to the Milpitas headquarters as an applications engineer, Dan created the Linduino, an Arduino-compatible hardware platform for demonstrating Linear Technology's I2C- and SPI-based products. The Linduino provides a convenient means to distribute C firmware to customers, while also providing a simple rapid prototyping platform for Linear Technology's customers.

Additionally, in his role as an applications engineer, he conceived of the LTC2644/LTC2645 PWM to VOUT DACs, and developed the XOR-based address translator circuit used in the LTC4316/LTC4317/LTC4318 I2C/SMBUS Address Translators. He has applied for patents related to both of these products. Dan has also developed multiple reference designs that satisfy the onerous MIL-STD-1275 28V military vehicle specification.

Dan continues to study Safe Operating Area of MOSFETs, and has created software tools and conducts training sessions within Linear Technology related to SOA. His SOAtherm model distributed with LTspice allows customers to simulate MOSFET SOA within their Hot Swap circuit simulations using thermal models that incorporate Spirito runaway.

He received an M.S. in Electrical Engineering from Stanford University and B.S. degrees in Electrical Engineering and Computer Engineering from the University of California, Davis.

Generic_Author_image

jaquesbachim.blogspot.com

Source: https://www.analog.com/ru/technical-articles/setting-up-linduino-visual-micro-atmel-ice-for-hardware-debugging.html

Post a Comment for "Samd21 Pleaseselect a Connected Tool and Interface and Try Again"