APPLICATION NOTE Atmel AVR2054: Serial Bootloader User Guide Features • • • Firmware programming over USART/SPI/TWI and other serial interfaces BitCloud® and RF4CE Over-the-Air Upgrade (OTAU) functionality support Atmel® Bootloader PC tool for loading firmware from PC Introduction The serial bootloader is a stand-alone package consisting of two parts: embedded bootloader that should be loaded to the flash memory of a supported MCU and the PC based application that sends data to the embedded bootloader ov
Table of Contents 1. Overview ............................................................................................ 3 1.2 1.3 Supported platforms and interfaces .................................................................. 3 Package content and structure ......................................................................... 4 1.3.2 Precompiled bootloader firmware ....................................................... 5 2. Installation and getting started ...................................
1. Overview The serial bootloader allows loading of firmware images to an MCU over the serial connection. It is intended for use with Atmel® wireless stacks, such as IEEE® 802.15.4 MAC [1] , RF4CE [2], BitCloud® [3] and LwMesh [5], but can also be used with non-wireless applications. The package content is given in Section 1.3 while Chapter 2 gives brief starting instructions on how to use the serial bootloader tool. The concept of firmware programming with the serial bootloader is shown on Figure 1-1.
Table 1-1. Atmel MCUs and corresponding interfaces, boards and modules supported by Serial Bootloader tool. Supported serial interfaces Atmel MCU 1.
1.3.2 Path Description \Embedded_Bootloader_src\ Embedded bootloader sources \Embedded_Bootloader_src\application\ Embedded bootloader source code \Embedded_Bootloader_src\iar_projects\ IAR Embedded Workbench project files for embedded bootloader. Project files for RF4CE version are not provided.
Used MCU port MCU Precompiled image(s) Comment ATmega2564RFR2 Bootloader_.hex Bootloader__BitCloud_OTAU.hex USART1 Expects ext. flash AT25DF041A on SPI port ATXmega256A3 Bootloader_.hex USARTD0 No board-specific behavior. Can be used on STK600, REBCBB and custom boards Bootloader__TWI.hex TWIE No board-specific behavior (SDA-PE0 SCL-PE1) ATXmega256D3 Bootloader_.hex USARTD0 No board-specific behavior Bootloader__TWI.
2. Installation and getting started Serial bootloader is typically used in the following way: 1. Unpack the package to a folder on the PC hard drive. 2. If embedded bootloader is not present on the target MCU device: a. Connect JTAG/ISP adapter to the target MCU device. b. If needed, configure on the MCU device the fuse bits for the corresponding bootloader feature support (see Section 2.2). c. Select or build a .
Table 2-1. Default COM port settings for embedded bootloader host Baud rate 38400 Data bits Parity Stop bits Flow control 8 None 1 None For Atmel PC Bootloader tool to operate correctly as a host over UART it shall get the connection enumerated as a COM port and configured as described in Table 2-1. 2.1.2 USB-FIFO interface USB-FIFO interface is a special connection to a PC via USB cable on the Sensor Terminal Board [9].
Table 2-2. Fuse bits on ATmega1281, ATmega128RFA1 and ATmega256(4)RFR2 . Option Common bootloader Bootloader for RF4CE applications BODLEVEL Disabled Brown-out detection at VCC = 1.
Option Required value EESAVE OFF BODLVL 1.
3. Embedded bootloader Embedded bootloader occupies a little amount of memory and serves the only purpose, to load an application image from a serial interface and write it to the MCU’s internal flash and/or EEPROM. A simple communication protocol described in Sections 3.5 and 3.6 is used to ensure proper programming. Figure 3-1 illustrates bootloader organization. The embedded bootloader application is provided as a set of pre-compiled firmware images for various configurations and the source code.
#define USE_USB_FIFO 0 //#define USE_USB_FIFO 1 // Use TWI #define USE_TWIS 0 //#define USE_TWIS 1 #ifdef USE_TWIS // Use TWID //#define USE_TWIS_D 0 #define USE_TWIS_D 1 #endif #endif //#ifdef ATMEGA128RFA1 • 3.3 External flash device used to store the application image during an over-the-air upgrade procedure. This is done via TYPE_EXTERNAL_MEMORY parameter and is applicable only to configurations with BitCloud OTA feature enabled.
Setting fuse bits incorrectly may cause improper device functionality. Caution: 3.5 Bootloader UART/SPI/TWI programming sequence The embedded bootloader handles data received over UART/SPI/TWI interfaces using algorithm illustrated on Figure 3-2 and described in steps below. 1. After the device is reset, the embedded bootloader waits 200ms on each enabled interface for a HANDSHAKE_REQ data sequence to arrive.
Figure 3-2. Embedded serial bootloader programming algorithm.
3.6 Bootloader USB DFU specifics The embedded bootloader for Atmel SAM3S microcontrollers operates in a different way than shown on Figure 3-2 to conform to certain features of the SAM3S microcontroller and development boards, on which it is hosted. Embedded bootloader for SAM3S uses Device Firmware Upgrade (DFU) standard. A DFU component should be included in the application (see Section 3.6.2.1). The procedure of uploading a new firmware image does not change for the user (see Section 4.1.2).
#define DFU_SUPPORT 1 3.6.2.2 Not-responding application or absent DFU The application loaded to the flash by embedded bootloader may not include a DFU component as well as any special code to deal with PC tool’s requests. In other cases when the DFU component is installed, it may stop responding due to application failure. In these cases the device will not be able to process commands from the PC tool and thus initiate reset and perform the firmware upgrade.
3.8 Bootloader configuration for Atmel RF4CE The embedded bootloader configuration to support Atmel RF4CE [2] applications is primarily the same as for the common embedded bootloader, but it also provides additional APIs to support Over-the-Air upgrade and the persistent data storage feature that can be used by RF4CE applications. The APIs provided by the serial bootloader and the additional APIs for RF4CE, both make use of self-programming functions.
4. Bootloader PC tool The Bootloader PC tool is a PC application that is used to load a firmware image to a device programmed with the embedded bootloader code. Connection to the MCU shall be enumerated as a COM or USB port depending on the interface used. Source firmware images shall be in the Motorola S-record (SREC) format. Such images are created during compilation further to .hex and .elf images.
4.1.2 Loading application firmware to an MCU To program an MCU using serial bootloader the following steps shall be done: 1. Connect an MCU with the embedded bootloader firmware on it to a PC via serial connection. For detail refer to Section 2.1 as well as documentation of the development kit or the software provided with it. 2. 3. For the GUI version of serial bootloader run the application by double-clicking the bootloadergui.exe file and the control dialog as shown on Figure 4-1 will appear.
4.1.3 Using the command line MCU programming with PC Bootloader tool can be also done via command line interface as follows: bootloader –f –p [-e ] For example following line: bootloader –f C:\work\SerialNet_ZigBit_Rf230B.srec –p COM4 can be used to load C:\work\SerialNet_ZigBit_Rf230B.srec image via port enumerated as COM4. Figure 4-2 shows a screenshot with an example of successful firmware upload using command line control.
5. Reference [1] Atmel IEEE 802.15.
6. Document revision history Doc. Rev. Date Comment 8390A 8390B 8390C 8390D 02/2011 11/2011 06/2013 03.2015 First release. Document for separate package with OTA , RF4CE and DFU support. Updated with 256RFR2 and TWI support. Updated with SAMR21 support and minor clean-up on BitCloud OTA support. Updated address page (last page).
Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 │ www.atmel.com © 2015 Atmel Corporation. / Rev.:8390D−WIRELESS−03/2015 ® ® ® ® 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. ARM® is a registered trademark of ARM Ltd. Other terms and product names may be trademarks of others.