I have been working getting the msp430 to do software updates.. using msp430fr5959
I cut my fram in half so that i have a place to store the code.
FRAM : origin = 0x4400, length = 0x4000
FRAMX : origin = 0x8400, length = 0x7A00
FRAMBL : origin = 0xFE00, length = 0x0180
FRAM2 : origin = 0x10000,length = 0x4000
FRAMX is where i store the code
FRAMBL is where store my function.
I can successful deliver a software pack to the device.
my main loop looks like this
while (!deploy_flag) {
// normal code
}
if (deploy_flag) {
deploy();
}
I trigger the reprogram with deploy_flag. It breaks out the program loop and runs deploy.
#pragma CODE_SECTION(deploy, ".BL") void deploy() { __disable_interrupt(); // disable interrupts unsigned int line; unsigned int i; for (line = 0; line < 900; line++) { if (code[line][0] == code_Address) { //address address = (((unsigned long) code[line][1]) << 16) + (((unsigned long) code[line][2] << 8)) + code[line][3]; add = (unsigned int*) address; } else if (code[line][0] == code_FullLine) { size = 16; for (i = 0; i < 16; i++) { codeblock[i] = code[line][i + 1]; } writeblock(); } else if (code[line][0] == code_ShortLine) { size = code[line][1]; for (i = 0; i < size; i++) { codeblock[i] = code[line][i + 2]; } writeblock(); } else if (code[line][0] == code_EOF) { WDTCTL = 0; break; } } } #pragma CODE_SECTION(writeblock, ".BL") void writeblock() { unsigned int i; for (i = 0; i < size; i += 2) { *add++ = (codeblock[1 * i + 1] << 8) + codeblock[1 * i]; } }
As you can see the first thing i do is kill the interrupts.. then i read my code that is in a format i created to build a block of code to write..
Also memory protection is off
I guarantee that i never write in the FRAMX and FRAMBL areas..
It seems to work fine.. i successful deployed an update.
after im finish writing i call WDTCTL = 0; to reset the device
But i noticed before i call the reset that interrupts came on. I was not expecting this.
My question is am i doing something dangerous here? unsafe?
Is there areas of code that i should not be writing?
I do have checks that verifies the integrity of the package. so we can assume im writing what im expecting to write.
Anything i should be looking out for?