APPLICATION NOTE. AT04189: UART Based SAM-BA Bootloader for SAM D20. Atmel SAM D20. Description. Features

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

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

AT88CK490 Evaluation Kit

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

USER GUIDE EDBG. Description

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

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

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

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

CryptoAuth Xplained Pro

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

USER GUIDE. ZigBit USB Stick User Guide. Introduction

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

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

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

AN10866 LPC1700 secondary USB bootloader

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

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

AT91SAM ARM-based Flash MCU. Application Note

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

AN3354 Application note

Bootloader with AES Encryption

Section 1 Introduction to the AT91SAMD20 and the Development Environment

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

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

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

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

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

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

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

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

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

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

UG103.8 APPLICATION DEVELOPMENT FUNDAMENTALS: TOOLS

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

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

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

AT89C5131A Starter Kit... Software User Guide

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

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

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

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

DSO138 oscilloscope program upgrade method

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

Using the RS232 serial evaluation boards on a USB port

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

Spotlight Management Pack for SCOM

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

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

Zynq-7000 Platform Software Development Using the ARM DS-5 Toolchain Authors: Simon George and Prushothaman Palanichamy

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

Temperature & Humidity SMS Alert Controller

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

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

QSG105 GETTING STARTED WITH SILICON LABS WIRELESS NETWORKING SOFTWARE

AN11008 Flash based non-volatile storage

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

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

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

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

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

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

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

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

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

Capacitive Touch Technology Opens the Door to a New Generation of Automotive User Interfaces

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

Dell Statistica Statistica Enterprise Installation Instructions

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

UG103.8: Application Development Fundamentals: Tools

AN4128 Application note

Atmel Power Line Communications. Solutions for the Smart Grid

AN3265 Application note

Dell InTrust Preparing for Auditing Microsoft SQL Server

4.0. Offline Folder Wizard. User Guide

USER GUIDE. ATWINC1500B Hardware Design Guidelines - IEEE b/g/n IoT Module. Atmel SmartConnect. Introduction

Dell One Identity Cloud Access Manager How to Configure vworkspace Integration

USER GUIDE Programming Adapter Cable for Fujitsu Flash Microcontroller- F²MC-16LX/FR Family Fujitsu Microelectronics America, Inc.

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

Transcription:

APPLICATION NOTE AT04189: UART Based SAM-BA Bootloader for SAM D20 Atmel SAM D20 Description Atmel SAM Boot Assistant (Atmel SAM-BA ) allows In-System Programming (ISP) from UART host without any external programming interface. Unlike existing SAM products, ROM monitor is not available in Atmel SAM D20 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 D20 design. Features Allows to program, verify, and secure a SAM D20 device without debugger UART connection (RS232) Allows the end user to update firmware in application Configurable I/O start condition Source code available, can be customized to user s needs Compatible with SAM-BA v2.12 with patch 7 or above

1 Requirements 1.1 Hardware Requirements The Atmel SAM D20 SAM-BA Boot Assistant supports serial communication via the UART interface. Table 1-1. UART Mode Requirements Signal name Recommended pin connection Description PA25 Connect to host: (115200 8,N,1) SERCOM3 PAD3 (UART RXD) PA24 Connect to host: (115200 8,N,1) SERCOM3 PAD2 (UART TXD) Table 1-2. 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 D20 SAM-BA is stored in flash memory at [0x0 0x800] and started on reset. Since SAM-BA is 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 a SWD debugger. To use SAM-BA together with an application, the user needs to link the application starting at 0x800. The below procedure explains how to modify the start address in an IAR project and an Atmel Studio project. 2

Figure 1-1. Changing.intvect start in IAR Figure 1-2. Changing ROM Start and Length in IAR 3

To change the linker script under IAR project: Menu Project, Options Go to linker tab -> Config Select Edit Set.intvect start in Vector Table tab to 0x00000800 as in Figure 1-1 Set ROM start in Memory Regions tab to 0x00000800 and end to original ROM length minus 0x800. Figure 1-2 shows modified example for ATSAMD20J18 Rebuild the project Figure 1-3. Changing Start Address in Atmel Studio To change the linker script under Atmel Studio: Menu Project, Properties Toolchain Tab, ATM/GNU Linker, Miscellaneous Include -Wl,--section-start=.text=Desired start address (For e.g., -Wl,--section-start=.text=0x800) 4

Figure 1-4. Memory Map of ATSAMD20J18 Device with an Application and SAM-BA When loading the application binary image to the device, only the part of flash starting from 0x800 address should be programmed. Any attempt to write to the SAM-BA region using SAM-BA commands will be aborted and will throw an error. 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 samd20_sam-ba_image.hex in the Flash box and program. Note: The samd20_sam-ba_image.hex file in folder load sam-ba in AT04189.zip is built for ATSAMD20J18 device. For other devices the SAM-BA monitor has to be re-built. Refer Chapter 4 for more details. 5

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 atsamd20j18 program f samd20_sam-ba_image.hex. 2.2 Entering the Bootloader Like other Atmel SAM devices, the SAM D20 SAM-BA relies on a monitor; this monitor is entered according to the boot process conditions described in Figure 2-2. 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 (@0x804) is blank (0xFFFFFFFF) 6

Figure 2-2. Boot Process of Atmel SAM-BA 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. After these preliminary steps, the monitor will enter a loop and test whether a # (sharp) character is received on PA25 (SERCOM3 PAD3) line. PA24 (SERCOM3 PAD2) becomes an output driven by the SAM D20 device according to the MUX setting. 2.3 Using the Bootloader with SAM-BA GUI 2.3.1 Connecting from SAM-BA PC Application Connect SAM D20 Xplained Pro to the PC to USB DEBUG port using the micro-usb cable as the UART pins are connected to it. 7

Figure 2-3. Connecting from SAM-BA PC Application 2.3.2 Flash Loading Loading the flash content is done by using the Flash tab. When uploading a program to flash memory, the start address needs to be above 0x800, otherwise the transfer will abort. Figure 2-4. Flash Programming 8

2.3.3 Scripts Atmel SAM-BA application comes with the following predefined scripts (see Table 2-1): Table 2-1. Predefined Scripts Script name Set Security Bit Read Security Bit Erase application area Invalidate application Read Fuses Read Lock fuses Read DeviceID Set Lock Bit [0:15] Unlock all 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 Set the specified lock bit to prevent any erasure of flash memory region (Refer to NVMCTRL chapter in the device datasheet for more information) Unlock all flash memory regions 3 Software Package Contents The software package with this application note contains the following: 1. Source code of SAM D20 SAM-BA monitor and the associated IAR project. 2. Example binary image of an application which starts at 0x800 The application continuously toggles LED0 on SAM D20 Xplained Pro. 3. SAM-BA monitor image in hex format. Note: To ensure minimal size for the bootloader, the source code as well as the project file is available only for the IAR compiler. 4 Re-building SAM-BA Monitor The SAM-BA monitor IAR project in AT04189.zip uses ATSAMD20J18 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 to be done in the project settings. 1. Open SAM-BA monitor IAR project and go to Project -> Options -> General Options -> Target tab -> Processor Variant -> select the required SAM D20 device. 2. Now go to C/C++ Compiler -> Preprocessor tab -> under Defined Symbols box, edit the device name macro. For example, for ATSAMD20G18 device, change the macro to SAMD20G18 (Note: Double underscores should be used). 3. Now go to Linker -> Config tab -> Linker Configuration File -> change the file name to required device. For example, for ATSAMD20G18 device, use $PROJ_DIR$\linker\samd20g18_flash.icf. 9

5 Supported Devices Following devices in SAM D20 family are supported by the SAM-BA version 2.12 patch 7 or above. 1. ATSAMD20E15 2. ATSAMD20E16 3. ATSAMD20E17 4. ATSAMD20E18 5. ATSAMD20G15 6. ATSAMD20G16 7. ATSAMD20G17 8. ATSAMD20G18 9. ATSAMD20J15 10. ATSAMD20J16 11. ATSAMD20J17 12. ATSAMD20J18 ATSAMD20E14/G14/J14 devices are not supported by SAM-BA. 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 D20 product page. 6.2 Atmel SAM-BA User Guide The SAM-BA User Guide contains detailed reference information on how to use SAM-BA. This 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. 10

7 Revision History Doc Rev. Date Comments 42238B 06/2014 1. Changed all entries of application start address from 0x2000 to 0x800 2. Modified Figures 1-1, 1-2, 1-4, 2-1, 2-2, and 2-4 3. Section 2-1: elf has been changed to hex 4. Chapter 4 Re-building SAM-BA Monitor and Chapter 5 Supported Devices are added 5. New template. 42238A 01/2014 Initial document release. 11

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 AT04189: nor intended UART for use in Based military or SAM-BA aerospace applications Bootloader or environments for SAM unless D20 specifically [APPLICATION designated by Atmel NOTE] as military-grade. Atmel products are not designed nor intended for use in automotive applications unless specifically designated by automotive-grade. 12 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.