APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features



Similar documents
SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

AT88CK490 Evaluation Kit

APPLICATION NOTE. AT16268: JD Smart Cloud Based Smart Plug Getting. Started Guide ATSAMW25. Introduction. Features

USER GUIDE EDBG. Description

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

AVR106: C Functions for Reading and Writing to Flash Memory. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

CryptoAuth Xplained Pro

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

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

USER GUIDE. ZigBit USB Stick User Guide. Introduction

APPLICATION NOTE. Authentication Counting. Atmel CryptoAuthentication. Features. Introduction

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

APPLICATION NOTE. AT12405: Low Power Sensor Design with PTC. Atmel MCU Integrated Touch. Introduction

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

AN10866 LPC1700 secondary USB bootloader

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

Software Prerequisites Linux Ubuntu LTS. Estimated completion time: 15min. The goal of this hands-on is to:

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

AT91SAM ARM-based Flash MCU. Application Note

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

SAMA5D2. Scope. Reference Documents. Atmel SMART ARM-based MPU ERRATA

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

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

AT11805: Capacitive Touch Long Slider Design with PTC. Introduction. Features. Touch Solutions APPLICATION NOTE

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

AN3354 Application note

Production Flash Programming Best Practices for Kinetis K- and L-series MCUs

AT12181: ATWINC1500 Wi-Fi Network Controller - AP Provision Mode. Introduction. Features. Atmel SmartConnect APPLICATION NOTE

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

Bootloader with AES Encryption

APPLICATION NOTE. Atmel AT02985: User s Guide for USB-CAN Demo on SAM4E-EK. Atmel AVR 32-bit Microcontroller. Features. Description.

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

SAM D21 Xplained Pro. Preface. SMART ARM-based Microcontrollers USER GUIDE

Section 1 Introduction to the AT91SAMD20 and the Development Environment

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

TWR-KV31F120M Sample Code Guide for IAR Board configuration, software, and development tools Rev.0

UM1680 User manual. Getting started with STM32F429 Discovery software development tools. Introduction

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

AT09333: USB Host Interface (UHI) for Communication Class Device (CDC) Introduction. Atmel Microcontrollers APPLICATION NOTE

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

APPLICATION NOTE. AT05558: Wireless Manufacturing Test Kit. Atmel ATmega256RFR2. Description. Features

AN10811 Programming SPI flash on EA3131 boards Rev May 2009 Application note Document information Info Content Keywords Abstract

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR127: Understanding ADC Parameters. Introduction. Features. Atmel 8-bit and 32-bit Microcontrollers APPLICATION NOTE

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel AT01095: Joystick Game Controller Reference Design. 8-/16-bit Atmel Microcontrollers. Features.

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

UM0985 User manual. Developing your STM32VLDISCOVERY application using the IAR Embedded Workbench software. Introduction

DSO138 oscilloscope program upgrade method

Block 3 Size 0 KB 0 KB 16KB 32KB. Start Address N/A N/A F4000H F0000H. Start Address FA000H F8000H F8000H F8000H. Block 2 Size 8KB 16KB 16KB 16KB

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT89C5131A Starter Kit... Software User Guide

Application Note. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

AN11008 Flash based non-volatile storage

udrive-usd-g1 Embedded DOS micro-drive Module Data Sheet

Adapting the PowerPC 403 ROM Monitor Software for a 512Kb Flash Device

Atmel Power Line Communications. Solutions for the Smart Grid

Using the RS232 serial evaluation boards on a USB port

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

SAM D20 Xplained Pro. Preface. SMART ARM-based Microcontrollers USER GUIDE

APPLICATION NOTE. AT17284: Proximetry Cloud Based Smart Plug User Guide. SMART ARM-based Microcontrollers. Introduction. Features

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AN Boot mode jumper settings for LPC1800 and LPC4300. Document information

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

UM1790 User manual. Getting started with STM32L053 discovery kit software development tools. Introduction

UART Boot Loader Design on the Kinetis E Series

Quick Start Guide. TWR-MECH Mechatronics Board TOWER SYSTEM

Figure 1. 8-Bit USB Debug Adapter

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

UG103.8 APPLICATION DEVELOPMENT FUNDAMENTALS: TOOLS

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AN AES encryption and decryption software on LPC microcontrollers. Document information

Dell Statistica Document Management System (SDMS) Installation Instructions

Introducing a platform to facilitate reliable and highly productive embedded developments

Dell Spotlight on Active Directory Server Health Wizard Configuration Guide

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

Atmel SMART ARM Core-based Embedded Microprocessors

SAM G55 Xplained Pro. Preface. SMART ARM-based Microcontrollers USER GUIDE

Spotlight Management Pack for SCOM

AN4128 Application note

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

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

General Porting Considerations. Memory EEPROM XRAM

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

Transcription:

APPLICATION NOTE AT07175: SAM-BA Bootloader for SAM D21 Atmel SAM D21 Introduction Atmel SAM Boot Assistant (Atmel SAM-BA ) allows In-System Programming (ISP) from USB or UART host without any external programming interface. Unlike existing SAM products, ROM monitor is not available in SAM D21 and SAM-BA will be loaded in Flash memory. This SAM-BA version is compatible with existing SAM-BA software tools but has some differences compared to other SAM devices. These differences are explained in this document. This application note complements the SAM-BA user guide and explains how the SAM-BA should be used on a SAM D21 design. Features Allows to program, verify and secure an Atmel SAM D21 device without debugger USB and UART connection Allows the end user to update application firmware from bootloader Configurable I/O start condition Source code available, can be customized to user s needs Compatible with SAM-BA v2.13 or above

1 Requirements 1.1 Hardware Requirements The Atmel SAM D21 SAM Boot Assistant (SAM-BA) supports serial communication via UART or USB device port. Table 1-1. UART Mode Requirements Signal name Recommended pin connection Description PA23 Connect to host (115200, 8, N, 1) SERCOM3 PAD1 (UART RXD) PA22 Connect to host (115200, 8, N, 1) SERCOM3 PAD0 (UART TXD) Table 1-2. USB Mode Requirements Signal name Recommended pin connection Description PA25 Connect to host USB D+ pin PA24 Connect to host USB D- pin Table 1-3. Hardware Bootloader Entry Signal name Recommended pin connection Description PA15 Connect to host or Bootloader access switch The bootloader will check PA15 on reset to determine if the bootloader monitor shall start. This feature allows the end user to reprogram the device even if the application is corrupted or unable to start the SAM-BA monitor 1.2 Software Requirements 1.2.1 Application Constraints Unlike existing SAM products using a ROM monitor, on the Atmel SAM D21 SAM-BA is stored in flash memory at 0x00000000 and started on reset. For SAM-BA with only one interface enabled (either USB or UART), it is stored in flash memory from 0x0000 0x1000. For SAM-BA with both USB and UART interfaces enabled, the firmware size exceeds 4kB. So flash region 0x0000 0x2000 (8kB) will be allocated for SAM-BA. SAM-BA bootloader is not factory programmed on SAM D21 devices and has to be programmed using an external programmer. Since SAM-BA will be stored in flash memory, if the application requires the entire flash space and does not need the bootloading feature, SAM-BA can be erased using external programmer. To use SAM-BA together with an application, the user needs to link the application starting at 0x1000 when only one interface (either USB or UART) is enabled and at 0x2000 when both USB and UART interfaces are enabled. The procedure to modify the start address in an IAR TM project and an Atmel Studio project is explained in Atmel AT04189: UART Based SAM-BA Bootloader for SAM D20. 2

Figure 1-1. Memory Map of ATSAMD21J18 with an Application and SAM-BA with both USB and UART 3

Figure 1-2. Memory Map of ATSAMD21J18 Device with an Application and SAM-BA with either USB or UART When loading the application binary image to the device, only the part of flash after the SAM-BA should be programmed. Any attempt to write the SAM-BA region using SAM-BA commands will be aborted and will throw an error. 4

2 Using the Bootloader 2.1 Programming the Bootloader Programming the Atmel SAM Boot Assistant can be done using SWD debugger: A. In Atmel Studio, open Tools\Device Programming, select debugger, and Apply. B. From the Memories tab, launch a chip erase. C. Fill the path to SAM-BA image in the Flash box and program. Note: SAM-BA images in folder load sam-ba in AT07175.zip are built for ATSAMD21J18 device. For other devices, the SAM-BA monitor has to be rebuilt. Refer Chapter 4 for more details. Figure 2-1. Device Programming Alternatively command-line programming tool atprogram can also be used for programming the hex file. Example: atprogram t edbg i swd d atsamd21j18a program f samd21_sam_ba_both_interfaces.hex. 2.2 Entering the Bootloader Like other Atmel SAM devices, the SAM D21 SAM-BA relies on a monitor; this monitor is entered according to the boot process conditions described in Figure 2-2, Figure 2-3, and Figure 2-4. 5

SAM-BA monitor activation can be requested in one of the following ways: External condition: Reset the part and make sure the Hardware Bootloader Entry pin (PA15) is pulled low when reset is released. A common usage is to use a push button accessible by the user as a bootloader trigger. The user simply has to hold the push button when powering up the device. Internal condition: On erased devices or when the application reset vector (@Application start address + 4) is blank (0xFFFFFFFF) Figure 2-2. Boot Process of Atmel SAM-BA using both USB and UART 6

Figure 2-3. Boot Process of Atmel SAM-BA using USB Figure 2-4. Boot Process of Atmel SAM-BA using UART Code security concerns: When SAM-BA monitor is entered, it allows read and write access to the entire memory map of the device. It also allows the host to upload and execute software (applets) on the device. 7

After these preliminary steps, the SAM-BA monitor will enter a loop and test whether an USB enumeration has succeeded or a # (sharp) character is received on PA23 (SERCOM3 PAD1) line. The first satisfied condition will start the monitor in the respective mode: UART or USB. 2.3 Bootloader Configuration SAM-BA monitor uses OSC8M as the system clock source (GCLK_GEN0). When USB interface option is selected, DFLL is enabled in USB Clock Recovery mode and is selected as clock source for USB module using GCLK_GEN1. SERCOM3 connected to EDBG is used for UART communication and uses OSC8M as its clock source from GCLK Generator 0. 2.4 Selecting the Communication Interface It is possible to compile SAM-BA monitor with one of the following options: Only UART interface enabled Only USB CDC interface enabled Both the UART and USB interfaces enabled and select the interface run-time Table 2-1. SAM-BA Communication interface Communication interface SAM_BA_INTERFACE define value Code footprint Application start address Only UART interface SAM_BA_UART_ONLY < 4kB 0x1000 Only USB CDC interface SAM_BA_USBCDC_ONLY < 4kB 0x1000 Both UART and USB CDC interfaces SAM_BA_BOTH_INTERFACES < 8kB 0x2000 Note: The application start address mentioned here is with SAM-BA monitor compiled in High (size) Optimization. Optimization setting must not be changed during compiling to maintain the bootloader size (and hence the application start address) SAM_BA_INTERFACE define should be added in: IAR Project Options -> C/C++ Compiler -> Preprocessor -> Defined symbols IAR Project Options -> Assembler -> Preprocessor -> Defined symbols SAM-BA monitor stores the application start address at 0x20000000. SAM-BA PC application reads the application start address from this location. 2.5 Using the Bootloader with SAM-BA GUI 2.5.1 Connecting from SAM-BA PC Application For using SAM-BA monitor with UART interface, connect SAM D21 Xplained Pro to the PC via DEBUG USB port using the micro-usb cable as the UART pins are connected to it. 8

Figure 2-5. Connecting from SAM-BA PC Application using UART For using SAM-BA monitor with USB interface, connect SAM D21 Xplained Pro to the PC via TARGET USB port using the micro-usb cable. Figure 2-6. Connecting from SAM-BA PC Application using USB CDC 2.5.2 Flash Loading Loading the flash contents is done by using the Flash tab. When uploading a program to flash memory, the start address needs to be above 0x1000 when using either USB or UART and above 0x2000 when using both USB and UART, otherwise the transfer will abort. 9

Figure 2-7. Flash Programming 2.5.3 Scripts Atmel SAM-BA application comes with the following predefined scripts (see Table 2-2): Table 2-2. Predefined Scripts Script name Set Security Bit Read Security Bit Erase application area Invalidate application Read Fuses Read Lock Fuses Read DeviceID Description Set the security bit to secure the device (Refer to NVMCTRL chapter in the device datasheet for more information) Read the current security state Erase all application code (SAM-BA part won t be erased) Erase first page of application Returns the values of fuse settings (Refer to NVM User Row Mapping section in the device datasheet for more information) Read the current lock settings Read the Device Identification register 10

Script name Set Lock Bit [0:15] Unlock all Description Set the specified lock bit to prevent any erasure of flash memory region (Refer to the NVMCTRL chapter in the device datasheet for more information) Unlock all flash memory regions 3 Re-building SAM-BA Monitor The SAM-BA monitor IAR project in AT07175.zip uses ATSAMD21J18A device by default. To use the SAM-BA monitor with other SAM D20 devices, the monitor IAR project has to be re-built with following changes in the project settings. 1. Open SAM-BA monitor IAR project and go to Project -> Options -> General Options -> Target -> Processor Variant -> select the required SAM D21 device. 2. Now go to C/C++ Compiler -> Preprocessor -> Defined Symbols -> edit the device name macro. For example, for ATSAMD21G18A device; change the macro to ATSAMD21G18A (Note: Double underscores should be used). 4 Supported Devices The following devices in SAM D21 family are supported by the SAM-BA version 2.13 or above. 1. ATSAMD21E15A 2. ATSAMD21E16A 3. ATSAMD21E17A 4. ATSAMD21E18A 5. ATSAMD21G15A 6. ATSAMD21G16A 7. ATSAMD21G17A 8. ATSAMD21G18A 9. ATSAMD21J15A 10. ATSAMD21J16A 11. ATSAMD21J17A 12. ATSAMD21J18A 5 Software Package Contents The software package with this application note contains the following: 1. Source code of SAM D21 SAM-BA monitor and the associated IAR project. 2. Example binary image of an application which starts at 0x1000 and 0x2000 The application continuously toggles LED0 on SAM D21 Xplained Pro. 3. SAM-BA monitor image hex with only UART interface enabled. 4. SAM-BA monitor image hex with only USB CDC interface enabled. 5. SAM-BA monitor image hex with both UART and USB interfaces enabled. Note: To ensure minimal size for the bootloader, the source code as well as the project file is available only for the IAR compiler. 11

6 References 6.1 Device Datasheet The device datasheet contains the block diagrams of the peripherals and details about implementing firmware for the device. It also contains the electrical specifications and expected characteristics of the device. Datasheet is available on www.atmel.com in the Documents section of Atmel SAM D21 product page. 6.2 Atmel SAM-BA User Guide The SAM-BA User Guide contains detailed reference information on how to use SAM-BA. The user guide comes with the SAM-BA package available on www.atmel.com. 6.3 ARM Documentation on Cortex-M0+ Core Cortex -M0+ Devices Generic User Guide revision r0p1 Cortex-M0+ Technical Reference Manual revision r0p1 6.4 Atmel SAM-BA In-system Programmer Latest Atmel SAM-BA In-system Programmer and related patches can be downloaded from http://www.atmel.com/tools/atmelsam-bain-systemprogrammer.aspx. 6.5 Atmel Studio The latest version of Atmel Studio can be downloaded from http://www.atmel.com/tools/atmelstudio.aspx. 12

7 Revision History Doc Rev. Date Comments 42366A 08/2014 Initial document release. 13

Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 www.atmel.com 2014 Atmel Corporation. / Rev.:. Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, SAM-BA, and others are registered trademarks or trademarks of Atmel Corporation in U.S. and other countries. ARM, ARM Connected logo, Cortex, and others are the registered trademarks or trademarks of ARM Ltd. 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. SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with any applications where the failure of such products would reasonably be expected to result in significant personal injury or death ( Safety-Critical Applications ) without an Atmel officer's specific written consent. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the operation of nuclear facilities and weapons systems. Atmel products are not designed AT07175: nor intended SAM-BA for use in military Bootloader or aerospace for applications SAM or D21 environments [APPLICATION unless specifically NOTE] designated by Atmel as military-grade. Atmel products are not designed nor intended for use in automotive applications unless specifically designated by Atmel as automotive-grade. 14