Creating a bootloader for MSP430

Technical Note 13285

Architectures:

MSP430

Component:

general

Updated:

11/6/2015 1:44 PM

Introduction

This Technical Note discusses how to create a bootloader for MSP430.

Generic suggestion

Information

There are different ways to create a bootloader and application for MSP430. With IAR Embedded Workbench for MSP430, we recommend creating two separate projects:

One project for the bootloader and one for the application.

After that, it is possible to "merge" the bootloader and application projects for downloading, using the "--image_input" linker option.

To merge the bootloader code into the main application, you can use the --image_input and -g linker options, similar to (example):

-gbootsymbol
--image_input=$PROJ_DIR$\Debug\Exe\Bootloader.bin,bootsymbol,BOOTLOADER,1

In the linker configuration file, add:

-Z(CONST)BOOTLOADER=addr1-addr2

When the main application is built, a single output file including the bootloader (but without debug info) is generated.

Background

One of the reasons for creating separate projects for the bootloader and the application is that the compiler uses "support functions" (for example "?DivMod16u", "?ShiftLeft32"), and these functions cannot easily be manually placed or suppressed.

Extra information

See "--image_input" in Help -> IAR Linker and Library Reference Guide

This option corresponds to the "Raw binary image" option in Project -> Options -> Linker -> Config.

To load debug info, use Project -> Options -> Debugger -> Images -> Download extra image (Debug info only).

Alternative suggestion (debugging)

Applies to...

...debugging with the Simulator OR the FET Debugger Driver.

Background

Both drivers are able to download Extra Images. (This is used in the following steps).

Steps

  • (As above) Build one project for the bootloader and one for the application.
  • Don't "merge" the projects at link time!
  • Let the application project be the active project.
  • Add the bootloader project (to the application project) with Project -> Options -> Debugger -> Images -> Download extra image
  • Important - Make sure that the check box "Debug info only" isn't checked. (I.e the opposite to the 'Generic suggestion'.)
  • Download.
  • There are some extra considerations.
    • Disable "run to main" as there will exist 2 main function (one each in the bootloader and in the application).
    • Disable "Stack plug in" (in the Tools -> Options dialog).
    • When debugging - take advantage of the View > 'Images' window, where (using he context menu) debug information from either image can be suppressed.


All product names are trademarks or registered trademarks of their respective owners.

We do no longer support Internet Explorer. To get the best experience of iar.com, we recommend upgrading to a modern browser such as Chrome or Edge.