About a month ago I started to search for a bootloader for TI CC430 and MSP430 devices for remote firmware update(over the air) and was not able to find any good resources that is suitable for my needs.
My requirements were:
- To be able to use the full memory, not half
- To be able upgrade over the air and serial ports (i.e RF, RS232, RS485)
- Must be as safe as possible
- Must be very portable between the projects
After trying several scenarios and code pieces that make me crazy, I have managed to implement my bootloader. In fact I have 2 options now, one that works from BSL section, and one works on RAM, a ram-loader.
Both have advantages and disadvantages but I am happy with both of them, both are usable and suitable for different projects.
So from now I am starting a tutorial series of how to build your own bootloder and ramloader for MSP430 and CC430 (tutorial will go on CC430F6137) devices. I think it will be a long tutorial series but give you a good idea about the bootloaders and help you develop your own.
From host my firmware updater software send the new image binary to the microcontroller over one of the interfaces In fact in my case it is more complex:
Host program(over internet) -> gprs modem(uart) ->master CC430 (868 mhz) ->slave CC430(many of them) (to spi flash)
Microcontroller writes this image file to on-board flash memory or SDCARD(raw). Than upon the “update command” microcontroller starts the bootloader or ramloader to update itself.
Bootloader or ramloader start and checks the image file signature, check number of bytes and perform check-sum. If the image file is “ok”, they erase the main program memory and self-program the part again with the new firmware and restart.
To be able to this there are many things to consider in both custom bootloader and ramloader, and both have their own advantages and disadvantages:
For ramloader main issues are copying the ramloader to the RAM, the small memory space in ram, how to interact with the MSP430 flash memory and some potential problems caused by interrupt vector table, and being unable to use debugger for error hunting in ram functions.
No need to deal with linker command files or low level init functions written in assembly. You can add the bootloader to other projects only with a header and source file, but you waste space for ramloader in main program memory and dealing with variables and buffers in RAM without debugging is really annoying.
For our custom BSL section bootloader main issues are using the BSL section smartly because of the small memory space, problems caused by optimizations and modifying the linker command file per our needs.
You use the BSL section and protect it once so you do not need to reprogram it again and again, you do not use the main program space, you can use debugger and single step it. Disadvantage is, you have to make some adjustments in linker command file and use a low level init .asm file.
We will go through them step by step in the following tutorials and see some code. In the next part we will examine the memory of MSP430 family, talk about ram and flash memory, and I will show you how to run a small function on RAM.
Please use comment section for your questions and suggestions.