AVR42788: SD Card Bootloader for XMEGA A1U. Introduction. Feature. AVR 8-bit Microcontrollers APPLICATION NOTE

Similar documents
CryptoAuth Xplained Pro

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

USER GUIDE EDBG. Description

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

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

USER GUIDE. ZigBit USB Stick User Guide. Introduction

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

AT88CK490 Evaluation Kit

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

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

Hardware Development Kit

AN10866 LPC1700 secondary USB bootloader

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

USER GUIDE. ZigBit Extension User Guide. Introduction

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

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

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

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

General Porting Considerations. Memory EEPROM XRAM

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

AN3354 Application note

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

Two mechanical buttons Two user LEDs Four expansion headers. Board controller with USB interface. One power LED and one status LED

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

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

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

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

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

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

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

Introducing a platform to facilitate reliable and highly productive embedded developments

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

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

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

SAM4L Xplained Pro. Preface. SMART ARM-based MCUs USER GUIDE

AN3332 Application note

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91SAM ARM-based Flash MCU. Application Note

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

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

DATASHEET. ADAM Arduino Display Adaptor Module. Arduino Compatible Shield P/N: 4Display-Shield-FT843 For the 4D Systems 4DLCD-FT843 Display

AN3990 Application note

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

USER GUIDE. Atmel SAM4S Xplained Pro. Preface

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

AN2557 Application note

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

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

AN2680 Application note

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

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

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

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

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

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. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

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

Product Brief. 2.0 microtoled. Intelligent GOLDELOX Display Module. µtoled-20-g2. Rev 1.0

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

AN3265 Application note

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

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

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

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

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

AN4108 Application note

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

Spotlight Management Pack for SCOM

Figure 1. 8-Bit USB Debug Adapter

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

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

APPLICATION NOTE. Atmel AVR600: STK600 Expansion, Routing and Socket Boards. Atmel Microcontrollers. Introduction

Dell One Identity Cloud Access Manager How to Configure vworkspace Integration

How To Add A Usb Secondary Ipo Bootloader To An Lpc23Xx Flash Device To A Flash Device

AN4128 Application note

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

Transcription:

AVR 8-bit Microcontrollers AVR42788: SD Card Bootloader for XMEGA A1U APPLICATION NOTE Introduction The SD card bootloader implemented in this application note allows flashing image from an external SD card. The SD card bootloader will be loaded in the Boot Loader flash section. The user needs to write the image file to be flashed into the SD card and this bootloader will write the image to the Application flash section. This application note explains how the SD card bootloader is implemented and how it should be used with the Atmel XMEGA A1U Xplained Pro. Feature Application for self-programming on Atmel AVR XMEGA A1U devices The binary file in the SD card used for firmware update Configurable I/O start condition FatFs file access with SD card accessed by SPI

Table of Contents Introduction...1 Feature... 1 1. Overview...3 1.1. Hardware Interface...3 1.2. SD Card...4 1.3. Firmware Availability...4 2. Bootloader Implementation...5 2.1. Self-Programing...5 2.2. FATFS Based File Access...6 2.3. Bootloader Protocol...7 3. Setup Procedure...9 4. Revision History...10 2

1. Overview This application note describes a simple implementation of SD Card bootloader on ATxmega128A1U. The firmware runs on an XMEGA A1U Xplained Pro, connected by an I/O1 Xplained Pro holding a microsd card. The SD card is used as the SPI Slave and ATxmega128A1U acts as SPI Master. The binary file (test.bin) to be programmed is stored in the SD card. In Boot mode, the boot loader reads contents of the file and flashes image to the application section of the MCU flash memory. 1.1. Hardware Interface The I/O1 Xplained Pro board should be connected to the EXT1 connector of the XMEGA A1U Xplained Pro. ATxmega128A1U SPIC on EXT1 is used for SD card communication (see Table 1-1). In addition, PQ2 for user button SW0 is used as Boot mode detection pin, and LED0 controlled by PQ3 indicates the programming is ongoing (see Table 1-2) Table 1-1. Functions for Used Pins on EXT1 Pin on EXT1 XMEGA A1U pin Functions for used pins 1 ID - 2 GND - 3 ADC+ PA0 4 ADC- PA4 5 GPIO1 PE6 6 GPIO2 PE7 7 PWM+ PE1 8 PWM- PE0 9 IRQ/GPIO PR0 10 SPI_SS_B/GPIO PR1 SD card presence detection, input pin, low level stands for presence 11 TWI_SDA PC0 12 TWI_SCL PC1 13 USART_RX PC2 14 USART_TX PC3 15 SPI_SS_A PC4 SPIC SS, SPIC used for SD Card access 16 SPI_MOSI PC5 SPIC MOSI, SPIC used for SD card access 17 SPI_MISO PC6 SPIC MISO, SPIC used for SD card access 18 SPI_SCK PC7 SPIC SCK, SPIC used for SD card access 19 GND - 20 VCC - 3

Table 1-2. Control and Status Pins XMEGAA1U pin Function Description PQ2 PQ3 Input pin, connected to user button SW0 Output pin, connected to LED0 and LED0 lights on with low level output on this pin Detects this pin when starting from reset or power on. Low level: enter Boot mode High level: go on with other detections (flash content at starting address) If SD card is detected in Boot mode, LED0 lights on until re-programming is finished 1.2. SD Card A microsd card is used to store the binary file to be flashed. This binary file is required to be named by "test.bin" and placed at the root directory of the microsd card. It should be formatted with FAT file system (default) under Window OS and mounted onto the microsd card socket on the I/O1 Xplained Pro. 1.3. Firmware Availability The firmware source code of this application note can be found from Atmel START. Customization can be done with the source code by the users. 4

2. Bootloader Implementation 2.1. Self-Programing ATxmega128A1U flash program memory includes an application section of 120KB, an application table section of 8KB, and a boot loader section of 8KB. The flash map is shown in the figure below. For this application note, the bootloader implementation targets to re-program the application flash section. Figure 2-1. Flash Section Map Reading and writing (including erasing) the flash memory from the application code inside the device is referred to as self-programming for flash memory. A bootloader is such an application for this purpose. For ATxmega128A1U, to perform flash erase and write, the SPM instruction must be called and this instruction can only be performed from the boot loader flash section. 5

For this bootloader implementation, the code size is approximately 12KB, and the code is placed in the boot loader section and the application table section. When erasing or writing a page located inside the application section, only the boot loader section can be read while the application table section cannot be read. So the code relating to reading binary file and memory program must be placed at the boot loader section. To enable the code placement in the two sections, the linker options must be modified for an Atmel Studio project. Add the following linker options in the project property window, as shown in the figure below. Wl,--section-start=.mysection=0x1E000 -Wl,--section-start=.text=0x20000 Figure 2-2. Add Linker Options in Atmel Studio For the code to be located at application table section, add compilation attribute directives on functions definition. #if defined( GNUC ) void PMIC_SetVectorLocationToBoot( void ) attribute ((section(".mysection"))); #endif 2.2. FATFS Based File Access FatFs R0.09 is used to access the binary file on the SD card. It has been ported to Atmel devices and is ready for usage as the third party module through Atmel Software Framework (ASF), which is released with Atmel Studio or individually. The needed source files for the FatFs module are included in the firmware pack. In this bootloader implementation, only read operation is necessary while write operation is not. So to save memory space, the FatFs module should be configured to read-only and the table below lists some main settings. 6

Table 2-1. Main Settings of FATFS Module Setting name Value Description _FS_TINY 1 When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system object instead of the sector buffer in the individual file object for file data transfer. This reduces memory consumption 512 bytes each file object. _FS_READONLY 1 Only read operation is required for the binary file _FS_MINIMIZE 3 The minimized level to remove functions not used in this implementation _VOLUMES 1 Only 1 volume (logical drive) is used _MAX_SS 512 Always set 512 for memory card _USE_ERASE 0 Disable sector erase feature _WORD_ACCESS 0 Byte-by-byte access 2.3. Bootloader Protocol MCU executes from the bootloader section at each reset/power-on sequence. Initially it checks the status on a configurable BOOT_LOAD_PIN. The BOOT_LOAD_PIN needs to be configured as input with pull-up before checked. If the pin is pulled low, enter boot mode If the pin is high, read the address 0x0000 of application section If 0xFFFF is read out, the application section is empty and will enter boot mode If not, jump to the application section and run the application code Once entering boot mode, the following procedures are to be performed step by step. Initialize the on-board ports, system clock, SD MMC, FatFs, etc. Keep detecting SD card presence until a card is detected Turn on LED0 Mount the SD card for file system access Open the file test.bin Read file for a block of MAX_BUF_SIZE (configurable) Program the data to application flash section starting from 0x0000 Repeat read and program till the end of file Turn off LED0 Remap the reset vector to the application section Jump to the starting address at 0x0000 The firmware chart is shown in the figure below. 7

Figure 2-3. Firmware Chart 8

3. Setup Procedure This chapter describes the setup procedure from creating an example project based on firmware pack to running a bootloader demo. In the following, Atmel Studio is taken as an example to describe the setup procedure. 1. Download the example firmware package for Atmel Studio from Atmel START. 2. Create firmware project with the firmware package in Atmel Studio (7 or higher). 3. Set linker options and pre-defined symbles for the project in Atmel Studio. On the project property window, trace ToolChain--AVR/GNU Linker--Miscellaneous, and add the following line: -Wl,--relax -Wl,--section-start=.mysection=0x1E000 -Wl,--section-start=.text=0x20000 Trace ToolChain--AVR/GNU C Compiler--Symbols, and add the following symbols: BOARD=XMEGA_A1U_XPLAINED_PRO IOPORT_XMEGA_COMPAT SD_MMC_ENABLE 4. Build the firmware and generate a bootloader image file (.elf,.hex, etc). 5. Connect the I/O1 Xplained Pro board to the XMEGA A1U Xplained Pro board at EXT1 connector, and connect the latter to the PC by the EDBG USB port on the board. 6. Program the fuse bit BOOTRST, which makes the XMEGA A1U run from the bootloader section. 7. Program bootloader image into the flash memory. 8. Store test.bin to the SD card, and mount the card on the I/O1 Xplained Pro board. 9. If SW0 is pressed after reset or no application firmware in application flash section, the boot mode is triggered. It will try to find an SD card and re-program the application section with the test.bin file in the SD card. 9

4. Revision History Doc Rev. Date Comments 42788A 10/2016 Initial document release. 10

Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 www.atmel.com 2016 Atmel Corporation. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, AVR, XMEGA, and others are registered trademarks or trademarks of Atmel Corporation in U.S. and other countries. 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 nor intended for use in military or aerospace applications or environments unless specifically 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.