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.

MSP430F5244: Flash Based Firmware Updation

Part Number: MSP430F5244

Hi,

I am using MSP430F5244 with CCS 5.6 for the development. I am trying to update the mcu firmware using Flash based application.

I am following the procedure as:

1. Written a sample code and generate the TI.txt file in CCS.

2. Divide the Flash into two parts.

FLASH_MEM : origin = 0x4400, length = 0x0200
FLASH : origin = 0x4600, length = 0x5CC0
FLASH_X : origin = 0xA2C0, length = 0x5CC0

3. Made area for RAM function.

RAM_MEM : origin = 0x2400, length = 0x0200
RAM : origin = 0x2600, length = 0x1E00

4. Application is in first partition of Flash and in the Second partion I have stored the new image.

5. After that jump to the RAM function, by which we can copy the image from second partition to first partition.

6. After copying all the image data, Reboot the mcu.

WDTCTL = WDT_MRST_0_064;

I am having a problem with mcu booting, after restart instruction it halt.

Please help me to overcome the problem.

Thank you.

  • Hi Akshat,

    On a reset, the device uses the address stored at 0xFFFE, the reset vector location, to determine where to start code execution. In your code for copying in the new image, have you handled replacing the interrupt vector table 0xFF80-0xFFFF with the interrupt vector table for the new piece of code you just copied over? Otherwise, reset could still be pointing to the location for the start of your old code that is no longer in the part, and could cause problems.

    We do provide something called MSPBoot www.ti.com/.../slaa600 for creating a main memory bootloader, including dual-image support (which is essentially what you are doing). I would recommend working from this as an example. The concern with the way that I think you are doing it now (simply based on your brief description - I don't know all the details of your implementation) is that it sounds like the loader is running from RAM, but in that case if you lose power or something goes wrong during your copying from the one image location to the other, you could have an unrecoverable situation, because RAM will be lost. MSPBoot sets up a separate flash section just for the loader code ("boot area"), that is separate from the two images ("Download area" and "App area") and has provisions to recover from a failed or interrupted load situation.

    Regards,
    Katie
  • Hi Katie,

    Thanks for your response.

    Yes, I have handled the interrupt vector table 0xFF80-0xFFFF while copying, address stored on the 0xFFFE is 0x4600 which is new image address.

    Yes, you are right, implementation is a single bank, and I will look into the suggested implementation.

    Thanks.

  • One other thing I forgot to mention - because you are using MSP430F5244, this F5xx device does have a built-in BSL in a separate 2kB Flash area. While you may not want to use the default built-in BSL because it doesn't support dual-image, you could put your bootloader code there if it will fit in 2kB. There is more information on modifying the default BSL here: www.ti.com/.../slaa450. If 2kB is enough space, this may be an easier solution than using MSPBoot that I linked above.
  • Hi Katie,

    I am trying the RAM based solution for some reasons. My problem is that I am not able 

    to copy the interrupt vector table from the flash segment. Code snippet is like:

    #define APP_FLASH_VECTOR_TABLE 0xFF80

    void Copy_Vector_Table(void)
    {
    Flash_ptr = (char *) APP_FLASH_VECTOR_TABLE;
    FCTL3 = FWKEY;
    FCTL1 = FWKEY+ERASE;
    FCTL1 = FWKEY+WRT;

    for (j=0; j<128; j++)
    {
    *Flash_ptr++ = test_data[j];
    }

    FCTL1 = FWKEY;
    FCTL3 = FWKEY+LOCK;
    }

    Can you please suggest me for possible issues?

    Thank you.

  • Hi Akshat,

    I'm not sure that you are actually erasing the segment containing the IVT before you are writing to it - you need to do a dummy write to the segment you want to erase after setting the ERASE bit in order for the erase to actually occur. If you initiated the erase from RAM, you also then need to check the BUSY bit to see if the erase is finished before you try to write to the flash. See the user's guide Flash chapter www.ti.com/lit/pdf/slau208 - there is a section called "Initiating an erase from RAM". Can you try doing that and maybe also adding a read of a known occupied address in the segment (e.g. the reset vector 0xFFFE) to check for 0xFF before writing to it?

    I still would be concerned about if you could ever lose power during this time, as your reset vector might not have a correct value in it, and then you would be in an unrecoverable state. This is why I still would recommend using the built-in BSL area if at all possible because you can always re-enter it using the BSL HW entry sequence on TEST + RST, or using some other criteria you define inside the BSL, even if the part is 100% blank. There's a small piece of this that is always called at startup before main so you can get to the BSL even with nothing in the RESET vector

    Regards,
    Katie

  • Hi Katie,

    I have tried with Custom BSL implementation. you have suggested earlier.

    I am implementing this for MSP430F5244 MCU.

    I have successfully copied the data in the flash segment and in interrupt vector table region.

    After that, I have tried the API BSL430_callAddress(addr) with the new image start address, but I am not able to jump to the address.

    Also after resetting the mcu, it is in the undefined state.

    Can you please help me, what may be the issue.

  • Hi Akshat,
    Are you able to have the debugger connected so that you can set breakpoints, etc when the issue occurs? Can you put a breakpoint at the beginning of BSL430_callAddress() so that you can single step and observe if the code is entering the if statement "if(LockedStatus == UNLOCKED)", or bypassing it and therefore not actually performing the jump? Note that if the jump is successful you actually will not return from the function and therefore will get no return value at all...

    It could also be beneficial if you had a simple version of your code that you could share - but I understand if this is not possible in a public forum.

    Regards,
    Katie
  • Hi Katie,

    Thank you for your support.

    I am able to update the mcu firmware, I think the issue is with the compiler selection.

    I am getting a warning in linker file with TI 4.2.7, while the project is properly compiled with the TI 4.2.1.

    This implementation is a single bank, what should I do if want a dual bank implementation in msp430F5244.

    Once again thanks for your kind support.

  • Hi Akshat,

    Were you able to get the code to start now? I was unclear from your post if you are now able to jump to your application code and unsure how this would relate to compiler selection? Did you use the breakpoint and single-stepping as mentioned?

    Akshat Saraf said:
    I am getting a warning in linker file with TI 4.2.7, while the project is properly compiled with the TI 4.2.1.

    Can you share what the warning message is?

    For working with the Custom BSL in the BSL flash area, I usually actually recommend using IAR - we provide more IAR example source projects if you look in the code download in MSP430BSL_1_00_12_00\5xx_6xx_BSL_Source, and the IAR compiler actually tends to build it smaller to better fit in the BSL area. You can use the free code-size limited IAR for this because the BSL is limited to 2kB anyway because that is all the space available. CCS works too, but I'm wondering if your linker warning with different compiler versions would be due to running up against the code size limit of the BSL...

    As for dual bank implementation, we do not have an example for this, but you basically will need to add code to handle loading to one area of the device, and then after downloading all code to then copy it to the run area of the part. I would recommend you probably need to create a new command that the BSL can receive from the host, that indicates to the BSL that you have finished sending it all of the code required, and now it should copy it to the main application area rather than the download area. You may also want to modify the commands for receiving code to check the addresses being written to on commands from the host, in order to limit them to what you have specific for your download area. Any other considerations probably depend on how you want the code to behave and really are where you are going to "customize" your BSL.

    Regards,

    Katie

  • Hi Akshat,

    Any update? Can you share the warning message that you are getting?

    Regards,
    Katie
  • Hi Akshat,

    I'm closing the thread due to inactivity but you can post back if you are still needing help.

    Regards,
    Katie

**Attention** This is a public forum