Is there a way to make the micro-controller to program itself by accessing a hex/bin file on an SD card?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Is there a way to make the micro-controller to program itself by accessing a hex/bin file on an SD card?
Hello!
Yes, it's perfectly possible. There are many variants to make this functionality.
- Programming your own bootloader to replace the existing one;
- Reserving a part of your code for a bootloader which belongs to the firmware;
- Loading a program loader in RAM and running it from RAM.
I'm in favor of the second solution because in case of failure, you can still use the board and load
a program with TI utilities.
Pascal
Hello!
No, I don't have an example at hand but...
In fact, the principle is extremely simple.
For example if you compile any program, you can get an output of the executable in hexa codes (text format).
On MSP430 (not 432), I use IAR with which you can select "generate extra ouput" somewhere in your project
preferences. Then you select the format. I use MSP430 TXT format.
The format is as follows
@4000 // Some memory location, beginning of your program. Usually the very beginning of the flash
43 23 BF E5 .... // Hexa values of your program
@FFB0 // Interrupt vectors area
xx xx xx // Your interrupt vectors' memory locations
@FFFE // Location of the reset
00 40 // Because you have @4000 above
So basically what you do:
- Create a function that can write a buffer at some location of the flash (remember it has to erase a memory block first
before reprogramming it).
- Create a function that reads the MSP TXT format and converts it to binary, block by block
Once done, you have everything in place, so you can update your firmware from any source you like,
be it SD, UART, wireless.
NB: If you update wirelessly, you should use a checksum. In other cases, errors are very unlikely, but anyway it's better.
Pascal