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.

MSP430-FLASHER: I may have found a bug in MSP430 Custom BSL Package

Part Number: MSP430-FLASHER

I found that the write flash bit is not remove when buffer is not full.

Our MSP430 flash was “something” corrupted if I was using CHECK_CRC followed by a SET_PC. Its calling twice flushbuffer, which will force a set WRT which will never be unset until a reset.

I’m sharing for others…

 

/*******************************************************************************

* *Function:    flushBuffer

* *Description: Flushes any remaining data in the buffer

* *Returns:

*             SUCCESSFUL_OPERATION  Flash is now locked.

*******************************************************************************/

#ifdef RAM_BASED_BSL

char flushBuffer(void)

{

    unsigned long i;

    char exceptions = SUCCESSFUL_OPERATION;

    unsigned char* data = &BlockBuffer[0];

 

    if (LockedStatus == UNLOCKED)

    {

        if (((BlockBufferStart & 0x7F) == 0) && (BlockBufferPtr == 128)) //Buffer is full and

                                                                         // aligned

        {

            while (FCTL3 & BUSY) ;

            FCTL3 = FWKEY;                                               // Clear Lock bit

            FCTL1 = FWKEY + BLKWRT + WRT;                                // Set write/block bit

 

            for (i = BlockBufferStart; i < BlockBufferStart + 128; i += 4)

            {

                __data20_write_long(i, *((long*)data));

                data += 4;

                while ((FCTL3 & WAIT) == 0) ;

            } // for

            FCTL1 = FwRamKey;

            while (FCTL3 & BUSY) ;

            FCTL3 = FwRamKey + LOCK;

        } // if

        else

        {

            FCTL3 = FwRamKey;                                            // Clear Lock bit

            FCTL1 = FwRamKey + WRT;                                      // Set write bit

            for (i = BlockBufferStart; i < BlockBufferStart + BlockBufferPtr; i++)

            {

                if ((BlockBufferStart & 0x01) || i == BlockBufferStart + BlockBufferPtr - 1)

                {

                    exceptions = BSL430_writeByte(i, *data);

                    data += 1;

 

                }

                else

                {

                    exceptions = BSL430_writeWord(i, *(int *)data);

                    data += 2;

                    i++;

                }

                if (exceptions != SUCCESSFUL_OPERATION)

                {

                    return exceptions;

                } // if

            }     // for

            // GHE: Fix where flash is written unexpectedly on a set pc

            FCTL1 = FwRamKey;

            while (FCTL3 & BUSY) ;

            FCTL3 = FwRamKey + LOCK;

            // GHE: End of the fix

        }         // else

        BlockBufferStart = 0;

        BlockBufferNext = 0;

        BlockBufferPtr = 0;

    }

    else

    {

        exceptions = BSL_LOCKED;

    }

    return exceptions;

}

  • Germain,

    Thank you for your inquiry. We will look into this and get back to you.

    EDIT:

    We will perform tests on this scenario before the release of our next Custom BSL package update (coming soon). If this is a bug, the documentation of it and its corresponding fix and/or change will be documented in release notes. thank you for bringing this to our attention.

**Attention** This is a public forum