TrueSTUDIO Success. Working with bootloaders on Cortex-M devices

Similar documents
An unrivalled feature-set and unprecedented integration

ATOLLIC TRUESTUDIO FOR ARM QUICK START GUIDE

ATOLLIC TRUESTUDIO FOR STM32 QUICK START GUIDE

atoll ic TrueSTUDIOPro Professional C/C++ IDE for ARM -based devices The essential toolkit for ARM development

Application Note. AN1205: Using P&E Micro Kinetis GDB Server

Important Upgrade Information. iii P a g e

White paper. ARM Cortex -M system crash analysis

Important Upgrade Information

STM32CubeProgrammer + Atollic TrueSTUDIO for STM32

Upgrade Information COPYRIGHT NOTICE TRADEMARK DISCLAIMER DOCUMENT IDENTIFICATION REVISION. 2 P a g e

AN3354 Application note

Boot Loader. Bootloader

UM1677 User manual. Getting started with STM32F030 Value Line Discovery development tools. Introduction

AN LPC1700 secondary USB bootloader. Document information. LPC1700, Secondary USB Bootloader, ISP, IAP

External memory code execution on STM32F7x0 Value line and STM32H750 Value line MCUs

Getting started with software and firmware environments for the

Using STM32 discovery kits with open source tools. STLINK development team

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

STM32F3 Hands-On Workshop

Atollic TrueSTUDIO for STMicroelectronics STM32. Quickstart Guide

Atollic TrueSTUDIO for ARM. Installation Guide Quick Start Guide

Hello, and welcome to this presentation of the STM32 Flash memory interface. It covers all the new features of the STM32F7 Flash memory.

Contents. Cortex M On-Chip Emulation. Technical Notes V

Load Position-Independent Code (PIC) on a Kinetis Platform Using the IAR EWARM Compiler

IAR EWARM Quick Start for. Holtek s HT32 Series Microcontrollers

UM1862 User manual. Getting started with STM32F411E Discovery software Development Tools. Introduction

STM32L100C-Discovery Board Projects

White paper. Embedded development using the GNU toolchain for ARM processors

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Hands-On with STM32 MCU Francesco Conti

Hello, and welcome to this presentation of the STM32F7 System Configuration Controller.

Using Code Composer Studio IDE with MSP432

Bootloader Design Techniques for MCUs. Jacob Beningo, CSDP

RTOS overview. Basic concepts and benefits

Keil TM MDK-ARM Quick Start for. Holtek s HT32 Series Microcontrollers

L2 - C language for Embedded MCUs

A brief intro to MQX Lite. Real work: hands-on labs. Overview, Main features and Code Size

Customizable Flashloader Solution for Synergy MCUs

AN4515 Application note

The board contains the connector for SWD bus to implement SWD method of programming. Fig. K190 VDD 2 GND 4

SmartFusion2 SoC FPGA Demo: Code Shadowing from SPI Flash to SDR Memory User s Guide

M2351 TrustZone Program Development

AN4045 Application note

VORAGO VA108x0 Bootloader application note

Atollic TrueINSPECTOR. Improve software quality with static source code inspection!

32F412GDISCOVERY. Discovery kit with STM32F412ZG MCU. Features. Description

Using TOPPERS/ASP (RTOS) on NUCLEO-F401RE (Cortex-M4) With Atollic TrueSTUDIO

Bootloader Design Techniques for Microcontrollers

QUICKSTART CODE COMPOSER STUDIO Stellaris Development and Evaluation Kits for Code Composer Studio

AN4491 Application note

AN5123 Application note

OUTLINE. STM32F0 Architecture Overview STM32F0 Core Motivation for RISC and Pipelining Cortex-M0 Programming Model Toolchain and Project Structure

Using TOPPERS/ASP (RTOS) on GR-PEACH (Cortex-A9) With Atollic TrueSTUDIO

AT91SAM9RL64 Hands-on 03: Deploy an application thanks to the AT91SAM9RL64 BootROM loaders and at91bootstrap

Getting Started in Assembly Programming with Keil uvision and MSP432

Implementing Bootloaders on Renesas MCUs

Engineer-to-Engineer Note

Advanced Operating Systems Embedded from Scratch: System boot and hardware access. Federico Terraneo

32F469IDISCOVERY. Discovery kit with STM32F469NI MCU. Features. Description

XMC4800 EtherCAT APP SSC Firmware Update Slave Example. Getting Started Version 3.0

ELC4438: Embedded System Design ARM Cortex-M Architecture II

VORAGO VA108x0 GCC IDE application note

Shedding too much Light on a Microcontroller s Firmware Protection. Johannes Obermaier, Stefan Tatschner, August 15, 2017

NET+Works with GNU Tools Getting Started Guide

If You Give A Mouse A Microchip

ELEC 3040/3050 Lab Manual Lab 2 Revised 8/20/14. LAB 2: Developing and Debugging C Programs in MDK-ARM for the STM32L100RC Microcontroller

If You Give A Mouse A Microchip

You have a PC with a USB interface, running Microsoft Windows XP (SP2 or greater) or Vista You have the Workshop Installation Software Flash Drive

An Introduction to e 2 studio

AN3154 Application note

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

ZAP Cross Debuggers for STMicroelectronics Microcontrollers

SPBT3.0DPx BT module. Firmware Update Procedure. Revision 1.0

ARM CORTEX-M4 HD AEC FULL DUPLEX DEMO. HD AEC Full Duplex ARM Cortex-M4 Demo (STM32F4) Quick Start Guide

Implementing In-Application Programming on the ADuC702x

AN3965 Application note

STM32 Cortex-M3 STM32F STM32L STM32W

EMBEDDED SOFTWARE DEVELOPMENT. George Hadley 2017, Images Property of their Respective Owners

MASTERs 2012 LAB Manual for 1658 BTL Bootloading, Application Mapping and Loading Techniques on PIC32. Table of Contents

STM32L4R9I-EVAL. Evaluation board with STM32L4R9AI MCU. Features

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

Note that FLIP is an Atmel program supplied by Crossware with Atmel s permission.

Pengwyn Documentation

HOW TO DIVIDE BOOT AND FLASH AREAS

AN4968 Application note

Getting Started with Kinetis SDK (KSDK) v.1.2

mbed Hello World! Introduction to mbed

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

UM1853 User manual. STM32CubeF1 Nucleo demonstration firmware. Introduction

IDE for medical device software development. Hyun-Do Lee, Field Application Engineer

Embedded Programming with ARM Cortex-M3 Basic Experiments 1

Armstrap Documentation

The Process for recovering QuadBus (Enterprise) KVMs is described in detail on the following pages.

Ethernut 3 Source Code Debugging

STM32SnippetsL0. STM32L0xx Snippets firmware package. Features. Description

LABORATORIO DI ARCHITETTURE E PROGRAMMAZIONE DEI SISTEMI ELETTRONICI INDUSTRIALI

STM32 F7xx Discovery Board Setup Guide

32F746GDISCOVERY. Discovery kit with STM32F746NG MCU. Features. Description

Support for RISC-V. Lauterbach GmbH. Bob Kupyn Lauterbach Markus Goehrle - Lauterbach GmbH

GRLIDE. LEON IDE plugin for Eclipse User's Manual. The most important thing we build is trust GR-LIDE-UM. August 2016, Version 1.

Transcription:

TrueSTUDIO Success Working with bootloaders on Cortex-M devices

What is a bootloader? General definition: A boot loader is a computer program that loads the main operating system or runtime environment for the computer after completion of the self-tests. - Wikipedia In microcontroller land (ARM Cortex-M0/M3/M4/M7): A bootloader enriches the capabilities of the microcontroller and makes it a self-programmable device This is our definition! 2016-04-20 2

Why use a bootloader? Enables a device/product to upgrade itself in the field. Firmware is rarely bug free! Need a method to upgrade a product s firmware when defects are found. New requirements Need a method to upgrade a product s firmware due to new functionality. A product recall might not be a feasible option! 2016-04-20 3

Coverage This document will cover the area of bootloaders from the perspective of Atollic TrueSTUDIO on ARM Cortex-M devices. Constructing and building the bootloader. Constructing and building the main application. Interaction between the bootloader and the main application. Use cases for debugging the above. 2016-04-20 4

Coverage It will not cover the actual self-update feature (downloading and flash reprogramming of the main application) Many methods exists and are highly application specific! Update via USB, USART, CAN, SPI,... Device capabilities. Device vendor support libraries. Etc. 2016-04-20 5

Example hardware & code STM32-F4-Discovery kit from STMicroelectronics Download the example projects with ready-made code from TrueSTORE (inside TrueSTUDIO). File New Download new example project from TrueSTORE STMicroelectronics STM32F4-Discovery STM32F4_Discovery_Bootloader_APP STM32F4_Discovery_Bootloader_BL BL = Bootloader. APP = Application. Both must be downloaded. 2016-04-20 6

Memory map Bootloader and application separated in flash (Important! Separated by flash pages!) Our example: First 3 16K flash pages allocated to the bootloader. 0x08000000-0x0800C000 Reset vector located at 0x08000000 Rest of the flash allocated to the application 0x0800C000 - Free space Application 0x080C000 0x08000000 Bootloader 2016-04-20 7

Constructing the bootloader Start with a project template generated by the project wizard. (STM32F4-Discovery board, code in flash memory.) Linker configuration file (stm32f4_flash.ld) will, by default, place the code at the start of flash at 0x08000000. This is what we want! 2016-04-20 8

Constructing the bootloader To avoid confusing the debugger when debugging the bootloader and the application in the same debug session: Use different symbolic names for critical functions Simplifies breakpoint handling etc. For instance the entry point for the bootloader will be the Reset_Handler function by default. You probably have another version with the same name in the application also! Rename Reset_Handler to Boot_Reset_Handler and update all references (7 in startup_stm32f40xx.s and 1 in stm32f4_flash.ld)! Rename main() to boot_main() and update all references! 2016-04-20 9

A basic boot_main() Performs a firmware update if requested (not implemented in this example!). Sets up the environment for the application: Locates and sets the application stack pointer address. (Stored at first entry in application vector table.) Locates the application entry point. (Stored at second entry in application vector table.) Configures the vector table offset register. (Exceptions/IRQ now finds its handlers here!) Starts the application. 2016-04-20 10

A basic boot_main() 2016-04-20 11

Constructing the application Start with a project template generated by the project wizard. (STM32F4-Discovery board, code in flash memory.) Linker configuration file (stm32f4_flash.ld) will, by default, place the code at the start of flash at 0x08000000 0x0800C000. We need to change this! You may also want to reduce LENGTH of FLASH 1024K- 3x16K = 976K 2016-04-20 12

Constructing the application NOTE! In this example we have chosen to let the bootloader set up the basic environment (stack pointer, vector table, etc.) for the application. Lookout for any application code that might circumvent this behavior! For instance the SystemInit in this example: #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ #else SCB->VTOR = FLASH_BASE VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ #endif 2016-04-20 13

Constructing the application Always a good idea to verify! 2016-04-20 14

Putting it all together Use cases during development Debugging the bootloader Debugging the application Debugging the bootloader & application Application programmed by debugger Application programmed by bootloader 2016-04-20 15

Debugging the bootloader Create a debug configuration, Download_and_debug_Bootloader, for the Bootloader project. Edit the debug startup script and instruct the debugger to set a breakpoint at boot_main. (or Boot_Reset_Handler if debugging prior boot_main) Start the debugger! 2016-04-20 16

Debugging the bootloader 2016-04-20 17

Debugging the bootloader No source level debugging after branching off to the application (appentry()) More on that later! 2016-04-20 18

Debugging the application Create a debug configuration, Download_and_debug_Application, for the Application project. The vector table offset register, stack pointer and program counter are setup just to be on the safe side! Might already be done by debugger or application startup code! Start the debugger! 2016-04-20 19

Debugging the application 2016-04-20 20

Debugging the application and bootloader In order to do source-level debugging through both the bootloader and the application project at the same time some configuration is needed. The debugger needs to have information regarding both of the ELF files! 2016-04-20 21

Debugging the application and bootloader - use case 1 Both the bootloader and application binary are to be programmed during a debug launch. Source-level debugging should work after the jump. 2016-04-20 22

Debugging the application and bootloader use case 1 Create a third debug configuration connected to the Bootloader project. 2016-04-20 23

Debugging the application and bootloader use case 1 Edit the debugger startup script and instruct the debugger to perform the following: Program the bootloader binary. Program the application binary. Since the application binary in this case was programmed last we need to readd the symbolic information for the bootloader binary. The debugger is now aware of both the binaries! Reset target. Set breakpoint at bootloader entry and start execution. 2016-04-20 24

Debugging the application and bootloader use case 1 2016-04-20 25

Debugging the application and bootloader - use case 2 Only the bootloader is to be programmed during a debug launch. The application is programmed by the bootloader (IAP). Source-level debugging should work after the jump. 2016-04-20 26

Debugging the application and bootloader use case 2 Create a fourth debug configuration connected to the Bootloader project. Use the Download_and_debug Bootloader configuration as template. 2016-04-20 27

Debugging the application and bootloader use case 2 Edit the debugger startup script with the following change: Add symbolic/debug information from the corresponding application s ELF file. 2016-04-20 28

More information: www.atollic.com EUROPE & WORLDWIDE Atollic AB Science Park Gjuterigatan 7 SE-553 18 Jönköping Sweden +46 36 19 60 50 USA & AMERICAS Atollic Inc. 241 Boston Post Road West Marlborough, Massachusetts 01752 +1 (617) 674-2655 sales.usa@atollic.com info@atollic.com