From DEW - Daniel's Electronic Wiki
Jump to: navigation, search

MSP430 Bootloader by Dylek for value line series (RS232)

Because I was not able to find Bootloader for MSP430 value line devices.
I decided to make it by myself and you can find below what I was able to achieve.



  • MCU - MicroController Unit (i.e. MSP430G2553).
  • Booting - is the initialization of a MCU Firmware.
  • Bootloader - Code in MCU which is run during booting at very beginning. It allows to flash new Firmware or to continue booting.
  • Firmware - Main code of application written for MCU which is started after booting.

Flash Memory organisation in MSP430G2553

On the very beginning I would like to talk a bit about flash organisation in MSP430G2553
and where I have placed Bootloader. Generally MSP430G2553 flash memory looks like that:

16-kbyte Flash Memory Organisation in MSP430G2553

Basic information we need to know is:

  • the smallest part of memory that can be deleted is 'Segment'
  • Segments 0-31 have 512-byte size
  • Segments A,B,C,D have 64-byte size
  • Segments A,B - are used by CPU to keep configurations
  • Segments C,D - are dedicated to use freely
  • The biggest part of memory that can be written at once is 'Block' or Segments A,B,C,D (64-byte size):
  • Blocks inside Segments 0-31 have 64-byte size
  • Interrupt vectors are stored in Segment 0 under addresses: 0xFFE4 - 0xFFFF

Bootloader location

I decided to place Bootloader in Segments 1-4.
Unfortunately we need to leave unused almost whole Segment 0 (addresses: 0xFE00-0xFFe2).
The reason is that, when we need to change interrupt vectors we must delete whole Segment 0
so if we would place some part of Bootloader in that space (0xFE00-0xFFe2) it would be erased.
Therefore Bootloader is located under addresses: 0xF800-0xFDFF and it is split in 3 parts:

  • 0xF800-0xF80B - this is jump to main() function of Bootloader code (safety reason)
  • 0xF80C-0xF87F - flash operation functions, which need to be copied to RAM
  • 0xF880-0xFDFF - rest of Bootloader code
  • Segment D - is used to keep interrupts therefore should not be used, use only Segment C
  • Since v1.1 you can use freely both Segment C and D

In summary we are going to decrease size of flash to 13824-byte.
Thanks to placing Bootloader in the end of Flash do not need to change any thing in Code Composer Studio
linker command file. We can build and compile programs as usual we need just to remember that we must fit to 13824-byte.
However if you would like to force CCS to keep attention about space you need to change
available memory size in 'lnk_msp430g2553.cmd'. The line to modify is in 'MEMORY {}' section
and it starts with 'FLASH' word. Its length should be changed from 0x3FE0 to 0x3600.
This makes compiler to check if code will fit to memory.

Important info

Here you can find few very important information if you want to use my Bootloader

  • On the very beginning the watch dog is turned off
  • All ports are set to outputs and grounded (logic 0) (except P1.3 which is set as input)
  • The Bootloader is waiting 2 seconds to press and hold switch (P1.3 to ground), then:
    • if P1.3 was grounded during this time, LED attached to P1.0 is turned on and it enters to
    • programming mode, then waits for RS232 data if not, it starts flashed code under 0xC000.
    • Basically Bootloader jumps to address stored in Firmware reset vector (saved in 0xFFDE).
    • However if flash is empty then MCU is restarting and checking everything from the beginning
  • You should not use Segments D if you do not really need it deprecated in v1.1
  • Be aware to write programs no bigger than 13824-byte
  • RS232 communication baud-rate is fixed at 500000
  • To generate '*.txt' file with bootloader or firmware you need to set this option in CCS:

      RightMouseClick on project -> Preferences -> Build -> MSP430 Hex Utility -> Output format options
      and there select: Output format: Output TI-TXT hex format (--ti_txt)


Flashing Bootloader

It is as simple as usage of any other Bootloader. Firstly you have to flash 'MSP430 Bootloader by Dylek' to MCU.
You can do it through 'MSP430 Flasher' provided by Texas Instruments on their WIKI
In our case the command would looks like:

DOS code
MSP430Flasher.exe -n MSP430G2553 -w "msp430_bootloader.txt" -v -z [VCC] -m SBW2 -e

The second way is by using Code Composer Studio. In this case you need to import project from downloaded
SVN repository. And just hit 'green bug' button in CCS.

Flashing Firmware

To check if Bootloader is properly programmed you need to connect RX and TX pins to some
USB->RS232 converter and open terminal session, Linux example:

BASH code
minicom -b 500000 -D /dev/ttyUSB1

If bootloader was compiled with EN_SEND_TXT in terminal you should see now text: 'MAIN:'. This means that MCU
is trying to run firmware. The firmware is still empty so MCU is in restart loop and if you press S2 on MSP430 Launchpad
for 2 seconds, LED1 attached to P1.0 should be set on, and if bootloader was compiled with EN_SEND_TXT
you should see on terminal text: 'BOOTLOADER:'. This indicates that MCU is now in Bootloader mode
and it is waiting for data on RS232. Now all we need to do is to upload firmware by using 'msp430_rsprog'.
Firstly you need to close any terminal client connected with MCU!
Next you need to copy "firmware.txt" file from your CCS project folder (CCS_Workspace/Your_project/Debug/firmware.txt)
to folder with 'msp340_rsprog'. After that you just need to enter this folder and run flashing process.
If you doesn't have any firmware for test, there is one in: msp430_rsprog/RS232_helloworld.txt
This is simple 'Hello world' displayed through RS232, and in addition it is echo. So all what you will send to MCU
you wil receive back. Flash command should looks like:

BASH code
cd ./msp430_rsprog
./rsprog -f ./RS232_helloworld.txt -d /dev/ttyUSB1

Work diagram

Bootloader works in loop described on diagram below:

MSP430 Bootloader by Dylek loop diagram
* If compiled with EN_LED
** If compiled with EN_SEND_TXT


First of all if you need some features or you found some bug please contact me and I will see
what I can do for you ;) If you are not fancy for it, here you can find some tips.
In version 1.1 I have added two macro definitions in 'msp430_bootloader/main.h' which you can use:

  • EN_LED - if is defined, it turns on LED1 when entered to Bootloader
  • EN_SEND_TXT - if is defined, sends MAIN: and BOOTLOADER: debug texts through UART.

The most important thing is to make sure that you need to compile proper interrupt vectors.
Therefore when you have finished all changes to the Bootloader you need it co compile (Ctrl+b in CCS)
Then you need to open text file located here: 'msp430_bootloader/Debug/msp430_bootloader.txt'
At the very end of file you can find this 3 interesting addresses you need to copy this values to 'msp430_bootloader/main.h':

Where to find interrupt vectors


This is very first version of Bootloader by Dylek, therefore please test it first before you decide
to use it in yours projects. Any advises, modifications and bugs please send me by using this form
You are using it on your own risk. I am not taking any responsibility for malfunctions!

Source code

Source code for 'MSP430 Bootloader by Dylek' and for 'msp430_rsprog' you can download from my SVN (login,pass: svn_read):

BASH code
svn --username svn_read --password svn_read co


31.01.2015 (bug003) - second recompilation needed

After compilation you need to read RESET and TX
Interrupt Vectors and set it in main.h file.
And you need to recompile it again.
(Described in Tweaking section above)
Solution: fixed in v1.1
Reported by: (myself)

30.01.2015 (bug002) - usage of Segment D

Usage of user accessible Segment D is unsafe.
And it could cause unexpected issues.
Solution: fixed in v1.1
Reported by: (myself)

29.01.2015 (bug001) - incorrect jump to firmware

After boot program is not jumping to _init() function
of programmed Firmware, but to 0xC000.
It makes more complex Firmwares to fail.
Solution: fixed in v1.1
Reported by: (myself)


01.02.2015 - Version 1.1 (SVN rev. 17)

  • LED indicator added
  • bug001 fixed
  • bug002 fixed
  • bug003 fixed

05.01.2015 - Version 1.0 (SVN rev. 16)

First version released:

  • Bootloader by Dylek
  • msp430_rsprog - RS232 flash programmer for linux



60 months ago
Score 0

Thanks. This is very helpful source code for MSP430. This source code is working properly with MSP430G2553 and also MSP430F67641 controller. We had done some changes to work with MSP430F67641.

Thanks Daniel. Thanks for your all support.


37 months ago
Score 0

Hi Dylek Thanks for your sharing Would you help send me "rsprog" exe file for Windows OS

my e-mail

You must be logged in to add comments