Last updated : 06/25/2008
In this page, we will discuss about programming (flashing) a Texas Instrument MSP430F135 microcontroller, using MSP430 BSL (BootStrap Loader ) feature and the Altera system console tool, available in the latest Quartus version (8.0 at this time).
The BSL feature included in some MSP430 is a small ROM code which allows access to the MSP430 RAM/FLASH/REGISTERs, all this using a simple and standard UART communication scheme.
The purpose of this page is to describe how it is possible to access BSL capability from your PC, using the Altera system console tool,TCL scripts and an Altera JTAG probe (USB-Blaster for example).
Made simple, it allows in-situ programming of your MSP430 without needing any special MSP hardware probe. This is done by connecting the four dedicated BSL pins (MSP430F135 pins RX,TX, RESET and TCK) to some FPGA I/Os : 2 of them (RX/TX) will be connected to an UART component and the others (RESET,TCK) will be connected to a PIO component. Then we will use the new JTAG to Avalon bridge component to communicate (by using JTAG hub) with the Avalon UART and PIO components. The BSL protocol will be managed using TCL scripting.
Be aware that communications are rather slow. It is partly due to the poor baud rate used by BSL (9600 bauds) and probably mostly by the USB<-> JTAG <-> Avalon bridging overhead. However, I wrote this script only for R&D facility purposes, not for (mass) production programming purposes.
Note that FPGAs I/Os should reside in 3.3V powered bank, as the MSP430 is powered from a +3.3V source.
-------------------- -------------------
MSP430F135 | | FPGA
| P1.1/TX | --------------
pin 13 ->|------------------|->| |
| P2.2/RX | | FIFOed UART|
pin 22 <-|------------------|<-| |
| | --------------
| TCK | --------
pin 57 <-|------------------|<-| |
| RESET | | PIO |
pin 58 <-|------------------|<-| |
| | -------
-------------------- --------------------
In BSL mode and from an MSP430F135 point of view,
From an FPGA point of view, the RESET pin should be an open-drain pull-uped output, as the RESET line may be connected to an other device (reset controller in particular). Note that voltage level are 3.3V and not RS232 higher voltage level. Excepted that, communication format is a standard RS format : 9600 bauds, 8 bits, even parity and 1 stop bits.
You must build an SOPC system with at least the following components :
Here is a screenshot of my system, targeted for an Arrow LPRP Cyclone III board (see notes below) :
It includes a NIOS processor, a JTAG to Avalon bridge, a PIO, a FIFOed UART, a clock domain bridge and a PLL. The clock domain bridge is needed to run the FIFOed UART at 48MHz and some other components at a higher frequency (96 MHz). There is a bug in the FIFOed UART so that you must use a near 50 MHz input clock, otherwise baud rates will be false. As a workaround, I used a clock crossing bridge.
The project consist of the following files (see attachments):
The bsl430.tcl TCL script performs the following things:
To use this script, you must launch the Altera system console from an Altera command shell : system-console -cli
The -cli option is recommended, otherwise messages are not displayed in real time on you screen.
Currently, path to S-REC is hard-coded (line set srec_file "D:/User/Projet/msp430/work/test_f135/Debug/test_f135.s19"), and you will have to change path to the .s19 file to your local path. The S-REC parser currently support only S0,S3 and S7 record field. Moreover, due to BSL limitations, an S3 record field must have a maximum of 240 data bytes. Here is a screenshot of the system-console output:
--------------------------------------------------------------
MSP430F135 - BSL programmer.
(c) 2008/06 I. GEHIN
--------------------------------------------------------------
Initializing JTAG services...
Successfully opened JTAG service '/root/connections/USB-Blaster [USB-0]/EP3C25/[
MFG:70 ID:34 INST:0 VER:6]'.
Processor has been reset
Processor has been stopped
Entering BSL mode...
Resetting MSP430 (hardware reset) ...
MSP430 should be in BSL mode.
Executing 'Mass erase' command (will clear FLASH and reset password) ...
(debug info) command result : 0x90
(debug info) Applying BSL 1.1 patch' ...
(debug info) 'RX password' result : 0x90
(debug info) 'LOAD PC' result : 0x90
(debug info) 'RX password' result : 0x90
(debug info) ----------- PATCHING BSL ... ---------------
(debug info) 'RX DATA BLOCK' result : 0x90
(debug info) ----------- PROGRAMMING MSP430 ---------------
===============================================================================
** Writing SREC file 'D:/User/Projet/msp430/work/test_f135/Debug/test_f135.s19'
** WRITE : 0xC000 : '0x0A 0x12 0x09 0x12 0x0D 0x4C 0x3D 0x93 0x10 0x24 0x0C 0x3C
0x8F 0x12 0x2A 0x53 0x10 0x3C 0x3C 0x4D 0x09 0x4D 0x0E 0x4A 0xB0 0x12 0xCA 0xC0
0x09 0x5A'
** READ : 0xC000 : '0x0a 0x12 0x09 0x12 0x0d 0x4c 0x3d 0x93 0x10 0x24 0x0c 0x3c
0x8f 0x12 0x2a 0x53 0x10 0x3c 0x3c 0x4d 0x09 0x4d 0x0e 0x4a 0xb0 0x12 0xca 0xc0
0x09 0x5a'
** WRITE : 0xC01E : '0x0D 0x49 0x1D 0x53 0x1D 0xC3 0x3A 0x4D 0x0A 0x93 0xF4 0x23
0x3A 0x40 0xFF 0xFF 0x3A 0x93 0x03 0x24 0x2F 0x4A 0x0F 0x93 0xEA 0x23 0x30 0x40
0xE6 0xC0'
** READ : 0xC01E : '0x0d 0x49 0x1d 0x53 0x1d 0xc3 0x3a 0x4d 0x0a 0x93 0xf4 0x23
0x3a 0x40 0xff 0xff 0x3a 0x93 0x03 0x24 0x2f 0x4a 0x0f 0x93 0xea 0x23 0x30 0x40
0xe6 0xc0'
** WRITE : 0xC03C : '0x3E 0x40 0xFF 0xFF 0x3F 0x40 0xFF 0xFF 0x3F 0x93 0x05 0x20
0x3E 0x93 0x03 0x20 0x0C 0x43 0x0D 0x43 0x05 0x3C 0x1C 0x42 0xFF 0xFF 0x2D 0x43
0x3D 0x50'
** READ : 0xC03C : '0x3e 0x40 0xff 0xff 0x3f 0x40 0xff 0xff 0x3f 0x93 0x05 0x20
0x3e 0x93 0x03 0x20 0x0c 0x43 0x0d 0x43 0x05 0x3c 0x1c 0x42 0xff 0xff 0x2d 0x43
0x3d 0x50'
** WRITE : 0xC05A : '0xFF 0xFF 0xB0 0x12 0x88 0xC0 0x30 0x41 0x03 0x43 0xFF 0x3F
0x92 0x12 0x00 0x02 0x1F 0x42 0x06 0x02 0x0F 0x93 0x01 0x24 0x8F 0x12 0x1F 0x42
0x04 0x02'
** READ : 0xC05A : '0xff 0xff 0xb0 0x12 0x88 0xc0 0x30 0x41 0x03 0x43 0xff 0x3f
0x92 0x12 0x00 0x02 0x1f 0x42 0x06 0x02 0x0f 0x93 0x01 0x24 0x8f 0x12 0x1f 0x42
0x04 0x02'
** WRITE : 0xC078 : '0x0F 0x93 0x01 0x24 0x8F 0x12 0x92 0x12 0x02 0x02 0xB0 0x12
0x62 0xC0 0xFF 0x3F 0x21 0x83 0xB2 0x40 0x80 0x5A 0x20 0x01 0xE2 0xD3 0x22 0x00
0xE2 0xE3'
** READ : 0xC078 : '0x0f 0x93 0x01 0x24 0x8f 0x12 0x92 0x12 0x02 0x02 0xb0 0x12
0x62 0xc0 0xff 0x3f 0x21 0x83 0xb2 0x40 0x80 0x5a 0x20 0x01 0xe2 0xd3 0x22 0x00
0xe2 0xe3'
** WRITE : 0xC096 : '0x21 0x00 0xB1 0x40 0x10 0x27 0x00 0x00 0x91 0x83 0x00 0x00
0x81 0x93 0x00 0x00 0xFB 0x23 0xF5 0x3F 0x31 0x40 0x00 0x04 0xB0 0x12 0xFA 0xC0
0x0C 0x93'
** READ : 0xC096 : '0x21 0x00 0xb1 0x40 0x10 0x27 0x00 0x00 0x91 0x83 0x00 0x00
0x81 0x93 0x00 0x00 0xfb 0x23 0xf5 0x3f 0x31 0x40 0x00 0x04 0xb0 0x12 0xfa 0xc0
0x0c 0x93'
** WRITE : 0xC0B4 : '0x04 0x24 0x3C 0x40 0xFE 0xC0 0xB0 0x12 0x00 0xC0 0xB0 0x12
0x3C 0xC0 0x1C 0x43 0xB0 0x12 0x66 0xC0 0xFF 0x3F 0x0F 0x4C 0x0E 0x93 0x05 0x24
0x1F 0x53'
** READ : 0xC0B4 : '0x04 0x24 0x3c 0x40 0xfe 0xc0 0xb0 0x12 0x00 0xc0 0xb0 0x12
0x3c 0xc0 0x1c 0x43 0xb0 0x12 0x66 0xc0 0xff 0x3f 0x0f 0x4c 0x0e 0x93 0x05 0x24
0x1f 0x53'
** WRITE : 0xC0D2 : '0xFF 0x4D 0xFF 0xFF 0x1E 0x83 0xFB 0x23 0x30 0x41 0x34 0x41
0x35 0x41 0x36 0x41 0x37 0x41 0x38 0x41 0x39 0x41 0x3A 0x41 0x30 0x41 0x82 0x4C
0x02 0x02'
** READ : 0xC0D2 : '0xff 0x4d 0xff 0xff 0x1e 0x83 0xfb 0x23 0x30 0x41 0x34 0x41
0x35 0x41 0x36 0x41 0x37 0x41 0x38 0x41 0x39 0x41 0x3a 0x41 0x30 0x41 0x82 0x4c
0x02 0x02'
** WRITE : 0xC0F0 : '0x30 0x41 0x82 0x4C 0x00 0x02 0x30 0x41 0x30 0x41 0x1C 0x43
0x30 0x41'
** READ : 0xC0F0 : '0x30 0x41 0x82 0x4c 0x00 0x02 0x30 0x41 0x30 0x41 0x1c 0x43
0x30 0x41'
** WRITE : 0xC0FE : '0x02 0x00 0x00 0x02 0xF8 0xC0 0x02 0x00 0x02 0x02 0xF8 0xC0
0x02 0x00 0x04 0x02 0x00 0x00 0x02 0x00 0x06 0x02 0x00 0x00 0x00 0x00'
** READ : 0xC0FE : '0x02 0x00 0x00 0x02 0xf8 0xc0 0x02 0x00 0x02 0x02 0xf8 0xc0
0x02 0x00 0x04 0x02 0x00 0x00 0x02 0x00 0x06 0x02 0x00 0x00 0x00 0x00'
** WRITE : 0xFFFE : '0xAA 0xC0'
** READ : 0xFFFE : '0xaa 0xc0'
*** Total Elapsed time : 6 s.
(debug info) ----------- RESETTING MSP430 ----------------
Closing jtag service.
%
"Application Report
SLAA089D–December 1999–Revised August 2006
Features of the MSP430 Bootstrap Loader"
"Application Report
SLAA096D–September 2005–Revised August 2006
Application of Bootstrap Loader in MSP430
With Flash Hardware and Software Proposal"
For more complete information about compiler optimizations, see our Optimization Notice.