APPLICATION NOTE. Atmel AT03304: SAM D20 I 2 C Slave Bootloader SAM D20. Description. Features

Similar documents
APPLICATION NOTE. Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices. Atmel AVR XMEGA. Features.

APPLICATION NOTE. AT03324: Atmel REB212BSMA-EK Quick Start Guide. Atmel MCU Wireless. Introduction

APPLICATION NOTE. Atmel AVR1638: XMEGA RTC Calibration. 8-bit Atmel Microcontrollers. Features. Introduction

Hardware Prerequisites Atmel Xplained Pro Evaluation Kit Atmel WINC1500 extension USB Micro Cable (TypeA / MicroB)

APPLICATION NOTE. Atmel AT01080: XMEGA E Schematic Checklist. Atmel AVR XMEGA E. Features. Introduction

Atmel AVR1619: XMEGA-B1 Xplained Demonstration. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR32847: Migration from/to the UC3L0 64/32/16 from/to the UC3L0 256/ bit Atmel Microcontrollers. Application Note.

APPLICATION NOTE. Atmel AT02260: Driving AT42QT1085. Atmel QTouch. Features. Description

APPLICATION NOTE. Atmel AVR057: Internal RC Oscillator Calibration for ATtiny4/5/9/10/20/40. 8-bit Atmel Microcontrollers. Features.

OLED display with pixels resolution Ambient light sensor CPU load Analog filter Quadrature Encoder with push button Digital I/O

APPLICATION NOTE. Atmel AVR3009: Driving QTouch Device with I 2 C Interface. Atmel QTouch. Introduction

AVR1518: XMEGA-A1 Xplained Training - XMEGA Clock System. 8-bit Atmel Microcontrollers. Application Note. Prerequisites.

USER GUIDE. Wireless Production Test Reference Protocol Specification Document. Atmel MCU Wireless. Description

STK521. User Guide B AVR 01/12

Section 5 SERCOM. Tasks SPI. In this section you will learn:

Atmel QT600 Quick Start Guide Touch Solutions

APPLICATION NOTE. Atmel AVR536: Migration from ATmega644 to ATmega644A. 8-bit Atmel Microcontrollers. Introduction

Atmel AVR ATxmega384C3 microcontroller OLED display with 128x32 pixels resolution Analog sensors. Ambient light sensor Temperature sensor

Atmel ATMXT143E touchscreen controller Capacitive touch ITO 320 x 240 pixel LCD display with SPI interface LED backlight

Atmel AT697F. Rad-Hard 32-bit SPARC v8 Processor ERRATA SHEET. Active Errata List

APPLICATION NOTE. Atmel AT03782: Using Low Power Modes in SAM4N Microcontroller. Atmel 32-bit Microcontroller. Features.

Atmel LF-RFID Kit Comparison Chart. Application Note. Atmel LF-RFID Kit Comparison Chart. 1. Description

APPLICATION NOTE. Atmel AVR116: Wear Leveling on DataFlash. 32-bit Atmel Microcontrollers. Features. Description. Wear leveling

APPLICATION NOTE. Atmel AVR2131: Lightweight Mesh Getting Started Guide. Atmel MCU Wireless. Features. Description

32Kbytes on-chip SRAM. Viterbi decoding and CRC PRIME compliant 128-bit AES encryption Channel sensing and collision pre-detection

Atmel AVR1926: XMEGA-B1 Xplained Getting Started Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

AVR1503: Xplain training - XMEGA Programmable Multi Interrupt Controller 8-bit Microcontrollers Application Note Prerequisites

AVR42789: Writing to Flash on the New tinyavr Platform Using Assembly

Atmel AVR1924: XMEGA-A1 Xplained Hardware User's Guide. 8-bit Atmel Microcontrollers. Application Note. Preliminary. Features.

OLED display Sensors readout. Light sensor Temperature sensor

Atmel CryptoAuthentication Starter Kit

Atmel AT697F. Rad-Hard 32-bit SPARC v8 Processor ERRATA SHEET. Active Errata List

Getting Started with the SAM4L-EK Demo

AVR1922: Xplain Board Controller Firmware 8-bit Microcontrollers Application Note Features 1 Introduction

AVR4018: Inertial Two (ATAVRSBIN2) Hardware User's Guide. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

a clock signal and a bi-directional data signal (SCL, SDA)

AVR1315: Accessing the XMEGA EEPROM. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AT32UC3A3256 microcontroller 64MBit SDRAM Analog input (to ADC) Temperature sensor RC filter

AVR1501: Xplain training XMEGA Timer/Counter 8-bit Microcontrollers Application Note Prerequisites 1 Introduction

AT09381: SAM D - Debugging Watchdog Timer Reset. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AT03975: Getting Started with SAM L21. Descripton. Features. SMART ARM-Based Microcontroller APPLICATION NOTE

Atmel AVR ATxmega384C3 microcontroller OLED display with pixels resolution Analog sensors. Ambient light sensor Temperature sensor

Atmel AVR473: ATAVRSB202 Hardware User Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

AVR1303: Use and configuration of IR communication module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

USER GUIDE EDBG. Description

Native route discovery algorithm

AVR32917: picopower Board getting started. 32-bit Microcontrollers. Application Note. Preliminary. Features. 1 Introduction

EDBG. Description. Programmers and Debuggers USER GUIDE

AVR32901: EVKLCD100/EVKLCD101 Hardware User's Guide. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR based 125kHz RFID Evaluation Kit (Re)Programming Guide ATA2270-EK1. Overview. Fuse Settings: ISP Programming

ATAES132A Firmware Development Library. Introduction. Features. Atmel CryptoAuthentication USER GUIDE

AVR097: Migration between ATmega128 and ATmega1281/ATmega bit Microcontrollers. Application Note. Features. 1 Introduction

Ethernet1 Xplained Pro

AVR1508: Xplain training - XMEGA DAC 8-bit Microcontrollers Application Note Features 1 Introduction

AVR32752: Using the AVR32 UC3 Static Memory Controller. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

SAM4 Reset Controller (RSTC)

APPLICATION NOTE. AT11008: Migration from ATxmega16D4/32D4 Revision E to Revision I. Atmel AVR XMEGA. Introduction. Features

AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro. Introduction. Features. AVR XMEGA Microcontrollers APPLICATION NOTE

AVR532: Migration from ATmega48/88/168 to ATmega48A/88A/168A. 8-bit Microcontrollers. Application Note. 1 Introduction

USER GUIDE. ZigBit USB Stick User Guide. Introduction

APPLICATION NOTE. AT04470: Differences between SAM D21 Variants A, B, and L. 32-bit Microcontroller. Introduction

USER GUIDE. Atmel OLED1 Xplained Pro. Preface

One-channel Toggle-mode Touch Sensor IC with Power Management Functions AT42QT1012. Summary

Non Volatile Rad Hard Reprogrammable FPGA. ATF280 SRAM-based FPGA AT69170 Serial EEPROM. 2x SRAM-based FPGA designed for Space use - ATF280

AT06467: Getting started with SAM D09/D10/D11. Features. Description. SMART ARM-based Microcontrollers APPLICATION NOTE

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AT21CS Series Reset and Discovery. Introduction. Serial EEPROM APPLICATION NOTE

CAN Microcontrollers. Application Note. Migrating from T89C51CC01 to AT89C51CC03. Feature Comparison

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATtiny87 ATtiny167 Automotive

AVR32401: AVR32 AP7 Linux Interfacing DataFlash. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

USER GUIDE. Atmel QT1 Xplained Pro. Preface

AT60142H/HT. Rad-Hard 512Kx8 Very Low Power CMOS SRAM ERRATA-SHEET. Active Errata List. Errata History. Abbreviations. 1.

AVR1512: XMEGA-A1 Xplained training - XMEGA Basics. 8-bit Atmel Microcontrollers. Application Note. Prerequisites. 1 Introduction

APPLICATION NOTE. AT05567: TC Capture on External Interrupt with the Event System on SAM D20. Preface ASF PROJECT DOCUMENTATION

AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Features. Introduction. AVR 8-bit Microcontrollers APPLICATION NOTE

APPLICATION NOTE. Atmel AT03261: SAM D20 System Interrupt Driver (SYSTEM INTERRUPT) SAM D20 System Interrupt Driver (SYSTEM INTERRUPT)

QT3 Xplained Pro. Preface. Atmel QTouch USER GUIDE

APPLICATION NOTE. AT6486: Using DIVAS on SAMC Microcontroller. SMART ARM-Based Microcontroller. Introduction. Features

QT2 Xplained Pro. Preface. Atmel QTouch USER GUIDE

WINC1500 Software. Release Notes VERSION : DATE : JULY Abstract

USER GUIDE. ATmega168 Xplained Mini User Guide. Introduction

USER GUIDE. Atmel QT6 Xplained Pro. Preface

This user guide describes how to run the Atmel ATWINC3400 Bluetooth Low Energy (BLE) Provisioning demo from out-of-box conditions.

32Kbytes on-chip SRAM Up to 256Kbytes external SRAM

ATDH2200E Programming Kit... User Guide

Embedded AVR Microcontroller Including RF Transmitter and Immobilizer LF Functionality for Remote Keyless Entry ATA5795. Summary.

Application Note. Microcontrollers. Using Keil FlashMon Emulator with AT89C51CC01/03 AT89C51CC01/ Summary. 2. Background overview

AT697E. Application Note. Checking AT697E Code for Occurrence of LDF/FPOPd Instructions Sequence with a dependency on an Odd-Numbered Register

8-bit Microcontroller. Application Note. AVR320: Software SPI Master

SBAT90USB162 Atmel. SBAT90USB162 Development Board User s Manual

USER GUIDE. ATWINC1500 Xplained Pro. Preface

8-megabyte, 4-megabyte, and 2-megabyte 2.7-volt Only DataFlash Cards AT45DCB008D AT45DCB004D AT45DCB002D. Not Recommended for New Design

LBAT90USB162 Atmel. LBAT90USB162 Development Board User s Manual

AT17F Series. Application Note. Programming Circuits for AT17F Series Configurators with Xilinx FPGAs. 1. Introduction

QTouch 8-key Touch Sensor IC AT42QT1085. Summary

AT91 ARM Thumb Microcontrollers. Application Note. AT91 Host Flash Loader. 1. Package Contents. 2. Definition of Terms. 3.

Asynchronous SRAM Operating Voltage: 5V Read Access Time: 40 ns Write Cycle Time: 30 ns Very Low Power Consumption (Pre-RAD)

AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AT91 ARM Thumb Microcontrollers. Application Note. Using the ECC Controller on AT91SAM9260/9263 and AT91SAM7SE Microcontrollers. 1.

USER GUIDE. Atmel Segment LCD1 Xplained Pro. Preface

Transcription:

APPLICATION NOTE Atmel AT03304: SAM D20 I 2 C Slave Bootloader SAM D20 Description As many electronic designs evolve rapidly there is a growing need for being able to update products, which have already been shipped or sold. Microcontrollers that support boot loader functionalities facilitates updating of the application flash section without the need of an external programmer, are of great use in situations where the application has to be updated on the field. The boot loader may use various interfaces like SPI, UART, I 2 C, Ethernet etc. This application note describes how to make use of the In-System programming capability of the Atmel SAM D20 series devices using an I 2 C slave interface. Features Application for self programming Uses I 2 C Slave interface I 2 C master sends the data to be programmed over I 2 C bus Resets the device after programming and starts executing application Figure 1. SAM D20 I 2 C Slave Bootloader

Table of Contents 1. Program Memory Organization... 3 2. Prerequisites... 3 3. Bootloader Process... 3 3.1 Boot Check... 3 3.2 Bootloader Process... 5 3.3 Start Application... 5 4. Hardware Setup... 5 4.1 I 2 C Slave Lines... 5 4.2 Bootloader Enable Pin... 5 5. Application Specific Configurations... 5 5.1 Clock Configuration... 5 5.2 Bootloader Configuration... 5 6. Doxygen Documentation... 6 7. Revision History... 7 2

1. Program Memory Organization The lower rows in the NVM main address space can be allocated as a boot section by using the BOOTPROT fuses of the device. The BOOT memory section is protected both by the lock bit(s) corresponding to this address space, and the BOOTPROT[2:0] fuse. Figure 1-1. EEPROM and BOOT Allocation NVM Memory Address Space pw-1 EEPROM pw-(eeprom rows) x wr allocation pw-1-(eeprom rows) x wr Program allocation (BOOTPROT rows) x wr (BOOTPROT rows) x wr - 1 BOOT allocation 0 NVM Base Address This bootloader implementation consumes approximately 8KB of Flash memory, which are 32 rows of Program Memory space starting from address 0x00000000. BOOTPROT fuses on the device can be set to protect first 32 rows of the program memory, which are allocated for the BOOT section. So, the end user application should be generated with a starting address of 0x00002000. 2. Prerequisites The end user application to be programmed into the program memory of the SAM D20 using the bootloader should be generated with starting address offset of 0x2000. 3. Bootloader Process 3.1 Boot Check The bootloader is located at the start of the program memory and it is executed at each reset/power-on sequence. The bootloader first checks the status of a user configurable BOOT_LOAD_PIN. If the pin is pulled low it continues execution in bootloader mode, otherwise it reads the first location of the application section (0x00002000), which contains the stack pointer address and checks whether it is set to 0xFFFFFFFF. If this is true, the application section is assumed to be empty and it enters an infinite loop. If not, it jumps to the application section and starts execution normally from the start of the loaded application. Configuration of the BOOT_LOAD_PIN and disabling of the Watchdog module in this boot mode check routine are made with direct peripheral register access to enable a quick decision to be made on the execution of the loaded application or bootloader. 3

Figure 3-1. Bootloader Process 4

3.2 Bootloader Process The NVM module, board hardware and system clocks are initialized according to the configurations in the conf_clocks.h and conf_board.h header files. Consequently, the I 2 C slave module is initialized with the configurations specified in the conf_bootloader.h header file. The bootloader then waits for the reception of four bytes of data from I 2 C master, which represent the length of the data to be programmed. After transferring the length value, the I 2 C master continues sending the data to be programmed in blocks of NVMCTRL_PAGE_SIZE. Data is received in the bootloader and programmed to Program memory starting from APP_START_ADDRESS. An acknowledgment byte s is transferred from I 2 C slave bootloader to I 2 C master to indicate it has received the data and finished programming it. This is repeated until the entire length of data is programmed to Program memory. 3.3 Start Application Once the programming is completed, the bootloader enables the Watchdog Timer with a timeout period of 256 clock cyles and waits in a loop for Watchdog to reset the device. 4. Hardware Setup 4.1 I 2 C Slave Lines The SAM D20 mounted on the SAM D20 Xplained Pro kit is used as the I 2 C slave. The I 2 C master should be connected to PIN11 and PIN12 on External header 2 (EXT2) of the SAM D20 Xplained Pro board. 4.2 Bootloader Enable Pin The SW0 on this kit will be configured as BOOT_LOAD_PIN and LED0 will be used to display the bootloader status. LED0 will be ON when the device is in bootloader mode. 5. Application Specific Configurations 5.1 Clock Configuration The SAM D20 Internal 8MHz Oscillator (OSC8M) is used as the system clock in this implementation, without any prescaling. The APBA and APBB bus also run at 8MHz without any prescaling. The Internal 32kHz Oscillator (OSC32K) is enabled and configured as clock source for the Generic Clock Generator 4 channel. The Watchdog timer is configured with Generic Clock Generator 4 as the clock source. These configurations should be made in the conf_clocks.h header file. 5.2 Bootloader Configuration The application starting address to program the user application is configured to 0x00002000, because the bootloader only uses first 32 rows of the program memory. The BOOT_LOAD_PIN and BOOT_LED are set to SW0 and LED0 on the kit. These configurations should be made in the conf_bootloader.h header file. In addition to the above configurations, I 2 C slave configurations are made in the conf_bootloader.h header file. SERCOM2 is to be used for I 2 C slave interface with slave address of 0x15. PIN11 and PIN12 on external header 2 (EXT2) are configured as SDA and SCL respectively. 5

6. Doxygen Documentation All source code is prepared for automatic documentation generation using Doxygen. Doxygen is a tool for generating documentation from source code by analyzing the source code and using special keywords. For more details about Doxygen, visit http://www.doxygen.org. 6

7. Revision History Doc. Rev. Date Comments 42205A 10/2013 Initial document release 7

Atmel Corporation 1600 Technology Drive San Jose, CA 95110 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Millennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369 Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621 Atmel Japan G.K. 16F Shin-Osaki Kangyo Building 1-6-4 Osaki, Shinagawa-ku Tokyo 141-0032 JAPAN Tel: (+81)(3) 6417-0300 Fax: (+81)(3) 6417-0370 2013 Atmel Corporation. All rights reserved. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, 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.