You are on page 1of 16

APPLICATION NOTE

Atmel AT03160: Migrating Bootloader from ATxmega128A1


to other Atmel XMEGA Devices

Atmel AVR XMEGA

Features

Atmel AVR XMEGA bootloader


Procedure application
C-code sample application for Self Programming
Read and Write Both Flash and EEPROM Memories
Read and Write Lock Bits
Read Fuse Bits

Description

As many electronic designs evolve rapidly there is a growing need to be able to


update products which have already been shipped or sold. The bootloader firmware
embedded in microcontrollers can facilitate the application flash update without the
need of a programmer.
This application note describes how to migrate bootloader from Atmel
ATxmega128A1 to other AVR XMEGA devices step by step. Before reading this
application note, AVR1605 XMEGA Boot Loader Quick Start Guide should be read
since this application note is an extended read for AVR1605. The project of AVR1605
is based on ATxmega128A1 and the entire project package could be downloaded
from Atmel website.
For more information about self programming please refer to the application note
AVR109: Self Programming.

42153AAVR07/2013
Table of Contents

1. Procedure .......................................................................................... 3
1.1 Step 1 - Start IAR .............................................................................................. 3
1.2 Step 2 - Open the project .................................................................................. 3
1.3 Step 3 - Change processor and xcl file ............................................................. 5
1.4 Step 4 - Change flash page size ....................................................................... 8
1.5 Step 5 - Change define information................................................................... 9
1.6 Step 6 - Compile the project.............................................................................. 9
1.7 Step 7 - Debug the bootloader ........................................................................ 11
1.8 Step 8 - Change the bat file ............................................................................ 13

2. Recommended reading .................................................................... 14


3. Revision History ............................................................................... 15

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 2
42153AAVR07/2013
1. Procedure
Here are the main procedures to migrate bootloader from ATxmega128A1 to other XMEGA devices. Before doing the
migration following the procedures, the original project which is based on ATxmega128A1 should be downloaded
through the link: http://www.atmel.com/Images/AVR1605.zip
IAR Embedded Workbench version 6.11 or later should be installed first before starting the migration procedure.
Optionally Atmel Studio version 6.0 or later is installed if the bootloader is programmed in Atmel Studio.

1.1 Step 1 - Start IAR


Click Windows start -> All Programs -> IAR Systems -> IAR Embedded Workbench for Atmel AVR -> IAR Embedded
Workbench.

Figure 1-1. Start IAR

1.2 Step 2 - Open the project


Click File -> Open -> Workspace.

Figure 1-2. Open workspace

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 3
42153AAVR07/2013
Browse to the project folder, select the project file bootloader.eww, and then click Open button.

Figure 1-3. Open bootloader

If the used IAR software version is newer, the conversion prompt will occur. Click Yes to continue.

Figure 1-4. Conversion prompt

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 4
42153AAVR07/2013
1.3 Step 3 - Change processor and xcl file
Select bootloader - Debug in the Workspace and then click Project -> Options.

Figure 1-5. Open options

Select General Options in the Category and then in the Target tab, change ATxmega128A1 to the target device.

Figure 1-6. Change processor

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 5
42153AAVR07/2013
Find the linker configuration file link_bootloader_Atxmega128A1.xcl in \code folder. And copy from it to get the target
linker configuration file and rename it with the target device name. In this target device.xcl file, change Segments in
program address space (internal Flash memory), Data (SRAM, external ROM or external NV RAM) memory and
Internal EEPROM part to the suitable values according to the datasheet of the target device. You can also refer to the
linker file for corresponding device from IAR for these details. IARs linker files are available in \IAR Systems\Embedded
Workbench 6.0\avr\src\template folder.

Figure 1-7. Change xcl file

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 6
42153AAVR07/2013
Select Linker in the Category and then in the Config tab, change link_bootloader_ATxmega128A1.xcl to the modified
target file.

Figure 1-8. Select xcl file

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 7
42153AAVR07/2013
1.4 Step 4 - Change flash page size
Select sp_driver.h file in Workspace and change the FLASH_PAGE_SIZE, 512, to the correct value corresponding to
the target device. The flash page size can be acquired in the datasheet.

Figure 1-9. Change flash page size in sp_driver.h

Select sp_driver.s90 file in Workspace and change the FLASH_PAGE_SIZE, 512, to the correct value depending on the
target device.

Figure 1-10. Change flash page size in sp_driver.s90

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 8
42153AAVR07/2013
1.5 Step 5 - Change define information
Select defines.h file in the Workspace. Change __ATxmega128A1__ to the target device and then change all the pre-
defined items to match the target device. All the information filled could be found in the datasheet.

Figure 1-11. Change pre-defined information

1.6 Step 6 - Compile the project


If everything is processed correctly, the project can be compiled successfully. Click Project -> Rebuild All and the new
debug file, bootldr.dbg, will be created in \Debug\Exe folder. This debug file will be used to debug the bootloader in
Atmel Studio.

Figure 1-12. Rebuild the project

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 9
42153AAVR07/2013
If the bootloader is debugged with IAR Embedded Workbench, the output format should be changed as shown in Figure
1-13. After the setting, click Project -> Rebuild All and the bootloader.d90 will be produced. This debug file will be used
to debug the bootloader with IAR Embedded Workbench.

Figure 1-13. Output format

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 10
42153AAVR07/2013
1.7 Step 7 - Debug the bootloader
The bootloader can be debugged on IAR Embedded Workbench. Select the debugger you are using in the Setup tab as
shown in Figure 1-14.

Figure 1-14. Select tool

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 11
42153AAVR07/2013
Click Project -> Download and Debug, and this will debug the bootloader to the target device shown in Figure 1-15.
After downloading, you could start debugging the bootloader.

Figure 1-15. Download and debug

Alternatively, bootldr.dbg file can make the bootloader to be debugged in Atmel Studio 6. After opening Atmel Studio 6,
click File -> Open -> Open Object File For Debugging, and then browse to \Debug\Exe folder to open bootldr.dbg file.
Please refer to Atmel Studio help file for more information on how to debug with the object file.

Figure 1-16. Open object file

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 12
42153AAVR07/2013
1.8 Step 8 - Change the bat file
Browse to \AVROSP_Test folder and open the bat file with Notepad. Change ATxmega128A1 to the target device.
The .hex file should be changed to the real image file name. The image file (.hex) should be placed in the same folder
with the bat file. The other bat files should be changed in the same way if they are used.

Figure 1-17. Change bat file

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 13
42153AAVR07/2013
2. Recommended reading
It is recommended to read the following application notes to get an overall idea about self programming and bootloader:
AVR109: Self Programming This application note explains how devices with the SPM instruction can be
configured for self programming. Though it is given for Atmel tinyAVR and Atmel megaAVR devices, it gives
general information about self programming.
AVR1316: XMEGA Self-programming This application note describes the basic functionality of Atmel AVR
XMEGA self programming.
AVR1622: TWI Boot Loader for XMEGA This application note describes how to use boot loader of the
XMEGA family of devices to update the application section and how XMEGA can be configured for self
programming.
AVR1605: XMEGA Boot Loader Quick Start Guide This application note describes how to use a boot loader
application with one of the XMEGA family devices (i.e. ATxmega128A1) and how an AVR with the Store
Program Memory (SPM) instruction can be configured for Self-programming.

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 14
42153AAVR07/2013
3. Revision History
Doc. Rev. Date Comments
42153A 07/2013 Initial revision

Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices
[APPLICATION NOTE] 15
42153AAVR07/2013
Atmel Corporation Atmel Asia Limited Atmel Munich GmbH Atmel Japan G.K.
1600 Technology Drive Unit 01-5 & 16, 19F Business Campus 16F Shin-Osaki Kangyo Building
San Jose, CA 95110 BEA Tower, Millennium City 5 Parkring 4 1-6-4 Osaki
USA 418 Kwun Tong Road D-85748 Garching b. Munich Shinagawa-ku, Tokyo 141-0032
Tel: (+1)(408) 441-0311 Kwun Tong, Kowloon GERMANY JAPAN
Fax: (+1)(408) 487-2600 HONG KONG Tel: (+49) 89-31970-0 Tel: (+81)(3) 6417-0300
www.atmel.com Tel: (+852) 2245-6100 Fax: (+49) 89-3194621 Fax: (+81)(3) 6417-0370
Fax: (+852) 2722-1369

2014 Atmel Corporation. All rights reserved. / Rev.: 42153AAVR07/2013

Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, AVR, XMEGA and others are registered trademarks or trademarks of Atmel
Corporation or its subsidiaries. Other terms and product names may be trademarks of others.

Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this
document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES
NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF
INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time
without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in,
automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.

You might also like