Arduino Genuino Zero Atmel Studio Can Not Upgrade Firmware

Arduino Genuino Zero Atmel Studio can not upgrade firmware after trying to connect to target microcontroller using device programming dialog box or start without debugging icon. How to fix the firmware upgrade problem when the firmware won’t upgrade. A failed firmware upgrade prevents the use of the target board with Atmel Studio 7. The firmware appears to upgrade, but does not, as described below.

Genuino Zero Atmel Studio can’t Upgrade Firmware Problem

After opening the Programming Dialog box in Atmel Studio 7, or trying to program or debug the board, the Firmware Upgrade dialog box opens. After clicking the Upgrade button in the dialog box, the firmware appears to upgrade immediately. When trying to connect to the board again with Atmel Studio, the Firmware Upgrade dialog box appears again saying that the firmware needs upgrading. The dialog box appears as follows after the attempted upgrade that does not work. Here the Firmware Upgrade dialog box appears after the Apply button was clicked in the Device Programming dialog box.

Arduino Genuino Zero Atmel Studio Can Not Upgrade Firmware

Arduino Genuino Zero Atmel Studio Can Not Upgrade Firmware

This problem occurred on my Genuino Zero board, but I have read reports of it happening on Arduino M0 Pro boards and Atmel SAMD21 Xplained boards as well. The firmware that Atmel Studio is attempting to upgrade is the firmware in the embedded debugger (EDBG) chip found on Arduino Genuino Zero, Arduino M0 Pro and SAMD21 Xplained Pro boards.

Arduino Genuino Zero Atmel Studio Can Not Upgrade Firmware Solution

This solution simply stops stops Atmel Studio from automatically checking if the firmware needs upgrading. It does not actually upgrade the firmware on the EDBG chip.

The following steps describe how to bypass the firmware upgrade in Atmel Studio.

1. Open the Device Programming Dialog Box

Start Atmel Studio and then click the Device Programming icon as shown in the image below. The icon is found on the top toolbar. This opens the Device Programming dialog box.

Atmel Studio Device Programming Icon

Atmel Studio Device Programming Icon

2. Open the Device Programming Settings

In the Device Programming dialog box, select EDBG as the tool and SWD for the interface. In the Device field, select the target microcontroller on the board. For Arduino / Genuino Zero / M0 Pro boards this is ATSAMD21G18A. For the Atmel SAMD21 Xplained Pro, it is ATSAMD21J18A.

When clicking the Apply button in the Device Programming dialog box, the Firmware Upgrade dialog box appears and then fails to properly upgrade the firmware. Instead of clicking the Apply button, click the Settings icon at the right of the Device Programming dialog box as shown in the image below.

Device Programming Settings

Device Programming Settings

3. Disable the Check Firmware Setting

In the Options dialog box, find Tools near the bottom of the left pane and expand it. Click the Tool settings item to select it. In the right pane, double click True at the right of Check firmware to change it to False. These steps are shown in the image below.

Disable Check Firmware

Disable Check Firmware

Click the OK button to close the dialog box.

4. Test the Changes

Finally test the changes. Back in the Device Programming dialog box, with the correct tool, device and interface selected, click the Apply button. This time the Firmware Upgrade dialog box should not appear and it should be possible to program and debug the target microcontroller. Click the Read button next to Device Signature to make sure that the communications with the target microcontroller is working. These steps are shown in the image below.

Read Device Signature

Read Device Signature

Conclusion

After completing the above steps, I was able to program my Arduino Genuino Zero board using Atmel Studio. I first backed up the bootloader using the Device Programming dialog box and then loaded a C program that blinks the on-board LED. This proved that the EDBG interface could be used to read and write without upgrading the firmware.

Although this solution may not be ideal because the EDBG firmware is not updated to the latest version, it still solved the problem of having an endless firmware upgrade loop that fails to upgrade the firmware and then prevents use of the target board with Atmel Studio.

 

Atmel Software Framework Tutorial

The final part of the Atmel Software Framework tutorial is now available. It covers how to use the ASF help documentation and how to find and use example ASF code. The tutorial uses an Atmel ARM Cortex on an Atmel Xplained evaluation board.

A previous blog post listed the current articles in the tutorial at the time of posting. The tutorial series is now complete.

ASF – Atmel Software Framework Tutorial

The first part of the ASF tutorial series introduces ASF and shows the basic structure of ASF. Each part of the tutorial series explains various parts and usage of the ASF in easy to follow steps.

The final part of this series shows how to use the ASF documentation and ASF example projects in Atmel Studio 7.

 

Atmel Software Framework Tutorial – ARM Cortex

An Atmel Software Framework Tutorial series that shows how to use Atmel Software Framework (ASF) to program ARM Cortex microcontrollers using Atmel Studio and the C programming language.

About ASF

Atmel Software Framework (ASF) consists of a number of modules that can be added to a C language project in Atmel Studio. Adding ASF modules to a project makes various functions available for initializing and using hardware and software services, cutting down development time.

As an example, adding the IOPORT ASF module to a project allows pins and ports of a microcontroller to be initialized and accessed using functions from the IOPORT module. Functions from the IOPORT module can then be called to set up pins or ports as inputs or outputs and other functions allow the pins or ports to be read or written to without having to use the hardware at a register level.

Atmel Software Framework Tutorial Contents

The ASF tutorial series consists of the following parts thus far. More parts are being added to the tutorial series each week.

INTRODUCTION TO ASF

Introduces the Atmel software framework tutorial and shows how ASF is structured.

BLINKING AN LED ON AN ATMEL DEVELOPMENT BOARD

How to create a new ASF project for an Atmel Evaluation board. The example project blinks the on-board LED.

BLINKING AN LED ON A CUSTOM OR USER BOARD

How to create an ASF user board project. If you are going to use ASF on your own custom or user board, you will need to know how to write ASF user board projects from scratch. This type of project can still be created and tested on an Atmel evaluation board. Most of this tutorial series shows how to create various projects from scratch using an ASF user board project as this is what is needed in real world applications that use a custom board.

ADDING ASF TO AN EXISTING PROJECT

How to add ASF to an existing project that was not started as an ASF project.

COMPARING ATMEL BOARD AND USER BOARD ASF PROJECTS

There are slight differences between ASF projects created for Atmel evaluation boards and user board ASF projects. This part of the tutorial shows the differences between the project types such as which files are different and where to changes settings in the files.

USING EXTERNAL CRYSTALS IN AN ASF PROJECT

How to enable the on-chip oscillators of the microcontroller to use the external crystals instead of the internal R/C oscillators in ASF.

ASF PROJECT QUICK START CHECKLIST

A quick start checklist for creating new ASF user board projects. Where to add code and to change settings in a new ASF project.

READING AND WRITING PINS USING ASF

Using ASF functions to read and write individual microcontroller pins used for general purpose input/output.

WRITING TO A PORT USING ASF

How to write to a microcontroller port or group of pins from a port using ASF functions.

READING AND WRITING A PORT USING ASF

Reading and writing a port or group of port pins rather than individual port pins.

USING A UART FOR C STANDARD I/O FUNCTIONS

How to configure C standard input/output functions such as printf() and scanf() to use a UART for input/output.

Further Parts of the Tutorial Series

Further parts will be added to the tutorial series until it is complete. Check the index and menu of the tutorial for additional parts.

Floating Point Numbers don’t Print with sprintf in Atmel Studio AVR C

When writing C program code for 8-bit Atmel AVR microcontrollers and using Atmel Studio, functions such as printf() and sprintf() do not print floating point numbers of type float. Instead of printing a float to a string or standard output, a question mark is printed.

Question Mark is Printed from the sprintf Function Instead of Float Number

The image below shows the output from the serial port of an AVR microcontroller that printed a floating point number to a string using the sprintf() function. The string was then sent to a terminal program running on a PC. The C program was built in Atmel Studio 7 using the default project settings. As can be seen, floating point numbers don’t print with sprintf, but a question mark is printed instead of the expected number.

Floating Point Numbers don't Print with sprintf in Atmel Studio AVR C

Floating Point Numbers don’t Print with sprintf in Atmel Studio AVR C

Cause of the float Printing Problem

The problem occurs because Atmel Studio 7 uses the minimal version of the function that all the printf family of functions rely on. Using the minimal function reduces code size of the printf family of functions which is desirable when using microcontrollers, especially the smaller 8-bit AVR microcontrollers that have small amounts of memory. Floating point numbers are not supported by the minimal function, causing the question mark to be printed instead of the floating point number.

Printing float Numbers with sprintf using AVRs and Atmel Studio

To fix the floating point printing problem, the full function that the printf family uses must be linked into the program instead of the minimal function. The article on how to print floating point numbers in AVR C code with Atmel Studio 7 shows how to include the full function by changing linker settings in Atmel Studio.

After changing setting in Atmel Studio, the sprintf function works properly and prints the floating point number to the terminal as shown in the image below.

Printing float Numbers with an AVR Microcontroller using sprintf

Printing float Numbers with an AVR Microcontroller using sprintf

Burning the Arduino Uno Bootblock with Atmel Studio and the AVRISP mkII

If you have loaded Atmel Studio to your computer and you try to burn a bootloader to an Arduino board using the AVRISP mkII, you will get an error message like this:

Error while burning bootloader.
avrdude: usbdev_open(): did not find any USB device “usb”

The solution to burning the bootloader in this case is to use Atmel Studio to burn the bootloader. The hexadecimal bootloader file can be found in the Arduino IDE folder. This can then be burned to the ATMEGA328P on the Arduino Uno board. Finally, the correct fuses must be set on the microcontroller which is also done in Atmel Studio.

Read the tutorial and watch the video on how to burn the bootloader to an Arduino Uno using Atmel Studio 6 and the AVRISP mkII USB AVR programmer.