SLAA450G April 2010 – April 2020
The TI-supplied BSL is written in such a way that it is extremely modular. Depending on the level of customization needed, various source files can be reused or replaced.
The three main sections of BSL code are:
Peripheral Interface
This section of code has responsibility for receiving and verifying a BSL Core Command. To accomplish this, the code can use any hardware or protocol (wrapper bytes or other options). The actual transmission mechanism and protocol are irrelevant for the rest of the BSL. What is important is that when the BSL is called upon to receive a packet, it does not return until it has correctly received all data sent to it. Because the BSL is used for erasing and programming user memory, the Peripheral Interface cannot use flash-based interrupt vectors. Either event polling or RAM-based interrupt vectors must be used.
Command Interpreter
This section of code interprets the supplied BSL Core Command bytes. The code can assume that the Peripheral Interface has successfully received the bytes without error but not necessarily that the bytes are correct for the BSL protocol (for example, if an incorrect command is sent). This code interprets the received Core Command according to the BSL Core Command list (see the MSP430™ Flash Device Bootloader (BSL) User's Guide) and executes received commands by calling the BSL API.
BSL API
This section of code provides an abstraction layer between the command interpreter and the memory being written to or read from. It handles all aspects of unlocking memory, writing to it, reading from it, and CRCs. It also, whenever possible, is the section of code where security is handled. This allows the command interpreter to simply make requests and send responses without being concerned with security issues. This model also allows for extremely secure custom BSLs to be made, as it is assumed the BSL API is the least likely section to be replaced in any custom BSL, so any custom BSL benefits from TI-supplied security checks and measures.