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.

CCS/MSP430F5659: How to unlock and write to iformation memory segment A ?

Part Number: MSP430F5659

Tool/software: Code Composer Studio

Hi,

What I need to to write to the information memeory segment A from the program ?

I can write to all other sements this way:

unsigned char *addr;

addr = 0x1980; //seg A

FCTL3 = FWKEY;

FCTL1 = FWKEY + WRT;

//write something

*addr = 0x55;

FCTL1 = FWKEY;

FCTL3 = FWKEY + LOCK;

This code is working in Code Composer V4 version.

What I need to do to solve it ?

  • You should use LOCKA (FCTL3). It is explained in 5xx/6xx family datasheet (slau208)...

    Segment A of the information memory is locked separately from all other segments with the LOCKA bit. If
    LOCKA = 1, segment A cannot be written or erased, and all information memory is protected from being
    segment erased. If LOCKA = 0, segment A can be erased and written like any other flash memory segment.
    The state of the LOCKA bit is toggled when a 1 is written to it. Writing a 0 to LOCKA has no effect. This
    allows existing flash programming routines to be used unchanged.

  • Alexander,

    If the above post solved your question then please go ahead and select the it resolved your issue so that we can close this thread out and log it. Thank you!

    Best regards,

    Matt Calvo
  • Hi Mat,

    I had read this information before the open this case, I still think that I have any problem with the silicone of this device or somethink that I does not exactly understand.

    I had solve this problem through the following way, in my origin code I copy the image of the segment to RAM, then update it's image in the RAM according to the requered data, then erase the segment in information memory, then write the updated image from the RAM to information memory:

    unsigned long address = 0x1900;//segment A

    char data = 0x55;

    FCTL4 = FWPW;

    if(FCTL3 & LOCKA)

    FCTL3 = FWPW + LOCKA;

    //clear segment

    FCTL3 = FWKEY;

    FCTL1 = FKEY + ERASE;

    *address = 0;

    FCTL1 = FWKEY;

    FCTL3 = FWKEY + LOCK;

    //write data

    if(FCTL3 & LOCKA)

    FCTL3 = FWPW + LOCKA;

    FCTL4 = FWPW + LOCKINFO;

    while(FCTL3 & BUSY){};

    FCTL4 = FWPW;

    if(FCTL3 & LOCKA)

    FCTL3 = FWPW + LOCKA;

    FCTL1 = FWKEY;

    FCTL3 = FWKEY + WRITE;

    *(char*)(address) = data;

    FCTL1 = FWKEY;

    FCTL3 = FWKEY + LOCK;

    if(FCTL3 & LOCKA)

    FCTL3 = FWPW + LOCKA;

    FCTL4 = FWPW + LOCKINFO;

    I dont know why, but only this a very stranger method is working, everytime I need to check the LOCKA bit to access to the segment A (to erase or to write) ?

    I think that I wrote in the code above unnecessary rows, but I don't understand it exactly, in my previous projects for another microcontrollers from this family it was more simple to implement.

  • After power up (known state, locked segment A), every time for writing to segment A, it can be unlocked (LOCKA) at the beginning, and locked back (LOCKA) at the end, with only one instruction (related to FCTL3) without checking if it is locked or not. FWKEY and FWPW have the same value 0xA500. I don't know what micro from this family you used before, but I didn't noticed any strange things related to Info A segment.
  • As Zrno stated, it should only take one instruction to allow you to alter segment A of info memory. The LOCKA bit controls the ability to write to the memory segment. You must check the status of the bit before writing to segment A to make sure it is the correct value. LOCKA=0 means the segment is unlocked and it can be written to while LOCKA=1 means the segment is locked and cannot be altered. If LOCKA=1 and you would like to unlock it, you must write a '1' to that bit to toggle the value. Once the writing is complete, write a '1' again to toggle the bit back to a locked state.

    -Matt Calvo
  • Hi All,

    I have error problem when using the TI download app, MSP430 USB Firmware Upgrade Example with data need to put in the information memory, infoD.

    My chips is MSP430F5659, and my data in TI-TEXT file are:

    @1800

    FF AA

    @8000

    4F 14 F1 03 C1 43 00 00 E2 B2 3E 09 7A 24 B1 13

    F6 6C C1 4C 00 00 E2 C2 3E 09 73 3C 03 43 C2 3C

    03 43 C0 3C 03 43 BE 3C 92 B3 2C 53 BB 24 B1 13

    24 84 C1 4C 00 00 B6 3C B1 13 38 65 A2 B3 2C 53

    I don’t have error without the two line (@1800, FF AA). My code is:

    case UPDATE_CODE_CMD:

     

           // set starting BSL process

           __disable_interrupt();

     

           if (FCTL3 & LOCKA) {

                  FCTL3 = FWKEY | LOCKA;

           }

           else {

     

                  FCTL3 = FWKEY;

           }

     

    USBKEYPID = 0x9628;                                  

    USBCNF &= ~PUR_EN;              

    USBPWRCTL &= ~VBOFFIE;                               

    USBKEYPID = 0x9600;                                  

    __delay_cycles(500000);

           ((void(*)())0x1000)();           // Call BSL

           break;

     

    Any idea to fix this problem?

    Thanks,

    Jack

  • Jack,

    It seems to be that you posted your issue on a new post ( e2e.ti.com/.../657941 ) so please refer there for help on resolving your specific problem.

    Alexander,

    Have you been able to resolve your issue?

    Best regards,

    Matt
  • Alexander,

    Please let us know if there are any updates to your issue and if you were able to solve it so we can close this thread out accordingly.

    Thanks and best regards,

    Matt Calvo
  • Alexander,

    It seems as though support for this thread is complete since we have not heard back about this issue in a few weeks. If the issue has been fixed please go ahead and select "Resolved" and I will close this thread out. Should you run into additional problems, feel free to make another E2E post so that they can be addressed.

    Thanks and best regards,

    Matt Calvo
  • Hi Mat,

    I had solve my problem as I wrote in my post from 18.01.2018, I did not change my code.
    I had find another problem which connected to this subject, it was memory overwritten problem, I don't know why the Code Composer V6 does not intepreters the following code according to my expectation:

    void WriteDataToFlash(unsigned long address, char* data, int length)
    {
    int i = 0;
    for(i = 0; i <length;i++)
    {
    //some code to check address and open flash to write
    *((char*)(address++)) = data[i];
    //some code to lock memory
    }
    }

    In this case of the code above compiler converts the address to the pointer to unsigned long, then increases it so each iteration of this loops jump four bytes of the memory space.
    If I change the problematic row to this one:

    *((char*)(address )+ i) =data[i];

    It works properly.

  • Alexander,

    I saw your request and your concern that a problem still persists. Please allow us to continue support on this thread so that we can track the progress. Describe in detail the problem you are now seeing and use the "insert code" tool to upload the problematic code fragment.

    Best regards,

    Matt Calvo
  • Hi Mat,

    This is my problem, I had write a simple code to write two symbols  'A' then 'B' to the information memory segment A to address 0x1980, in the first case it works properly but in the second case I have a problem, the program counter jumps to any statement outside of the current function, when I change the code at the first write 'B' then 'A' in the same manner the problem appears always in the case 'B':

    #define u8 unsigned char

    void main(void)

    {

        u32 addr = 0;

     

        FCTL4 = FWPW;

        if(FCTL3 & LOCKA)

               FCTL3 = FWPW + LOCKA;

        //clear segment

        while(FCTL3 & BUSY){};

     

        FCTL3 = FWPW;

        FCTL1 = FWPW + ERASE;

        *(u8*)(0x1980) = 0;

        while(FCTL3 & BUSY){};

     

        FCTL3 = FWPW + LOCK;

     

        if(!(FCTL3 & LOCKA))

               FCTL3 = FWPW + LOCKA;

        FCTL4 = FWPW;

     

        //write 'A'

        FCTL4 = FWPW;

        if(FCTL3 & LOCKA)

               FCTL3 = FWPW + LOCKA;

     

        FCTL3 = FWKEY;

        FCTL1 = FWKEY+WRT;

     

        *(u8*)(0x1980) = 'A';

        //write 'B'

        FCTL1 = FWKEY+WRT;

     

        addr = 0x1980;//I had try it with the address 0x1981 and get the same result

        *(u8*)(addr) = 'B';

     

        FCTL1 = FWKEY;

        FCTL3 = FWKEY+LOCK;

     

        if(FCTL3 & LOCKA)

               FCTL3 = FWPW + LOCKA;

        FCTL4 = FWPW;

     

        FCTL1 = FWKEY;

        FCTL3 = FWKEY+LOCK;

    }

    This problem appears because the following compiler's interpretation, I work with MSP430F5659 MCU, I suppose that is a silicon problem because I haven't the same problem with the other segments of information memory, I can write to the segment A using constant addresses under debug session, sometimes depend of the current code compilation (the sentence assignment in the code memory) it works properly (case 'B') under free running condition (no debug session) :

  • If I am in your situation, for clearing this issue (flash writing) I will use UART logging (during free running), and not breakpoint debugging. I will also try to write (after segment erase) at two different location inside Info segment A, for example 01980h and 01990h. I don't code in C for MSP430, so don't know about staff related to pointers / addresses, but produced code in assembler is OK.

    EDIT: I just tried my flasher for writing data to Info A segment of MSP430F5659. Block write executed from RAM is used.

    File test_infoa_5...

    org 01980h
    dw 00123h, 04567h, 089ABh, 0CDEFh, 01122h, 03344h, 05566h, 07788h
    ...
    end
    
    @1980
    23 01 67 45 AB 89 EF CD 22 11 44 33 66 55 88 77
    ...
    q

    Flashing...

    d:\msp430>flash -f test_infoa_5.txt -uinfoa -einfo -w -v
    
    File: "test_infoa_5.txt"
    @1980 128 bytes
    Total Size: 128 bytes
    
    Found SBW+ at COM7
    
    Get Device
    # JTID Fuse Device Core Hard Soft LotWafer DieX DieY
    1  91   OK   3081  2106  10   10  B7A50951 0A00 1100
    
    Unlock InfoA
    
    Erase Info
    Time: 135 ms
    
    Write
    Time: 132 ms  Speed: 0,9 KB/s
    
    Verify
    Time: 52 ms  Speed: 2,4 KB/s
    
    Release Device
    
    Total Time: 422 ms
    
    d:\msp430>flash -rq 1980
    
    Found SBW+ at COM7
    
    Get Device
    # JTID Fuse Device Core Hard Soft LotWafer DieX DieY
    1  91   OK   3081  2106  10   10  B7A50951 0A00 1100
    
    Read Quick
    #1
    1980: 0123 4567 89AB CDEF 1122 3344 5566 7788
    Time: 39 ms
    
    Release Device
    
    Total Time: 125 ms
    
    d:\msp430>
  • Alexander,

    I am going to run your code on a Launchpad similar to the MSP430F5659 and see if I can recreate the issue you are seeing so that I can debug the root cause of the problem. Could you please attach the source code you are using and provide detailed instructions on how I can recreate the issue on my laptop and Launchpad so that I can have a better chance of finding the bug. I see that you said that the code works properly during free run but does not work under debug session; could you please explain this further.

    -Matt
  • Alexander,

    I'll keep an eye out for your response, but I did copy at least the code snippet you provided in the comment above and was able to see 'A' and 'B' being written to their respective places in memory (See below). One thing I changed was that B was being written to addr which was set to 0x1980, but I changed it to 0x1981 so that I could see 'A' and 'B' both successfully written by setting a break-point in the code after 'B' was written and checking the contents of the memory. Is this comparable to what you are seeing?

    Best regards,

    Matt Calvo
  • Alexander,

    Are there any updates to this thread since I last posted a week ago?

    Best regards,

    Matt
  • Alex,

    Please update us on the status of this thread and if support is not needed anymore please select "Resolved" so we can close this thread out. Thank you for your help with this!

    Best regards,

    Matt Calvo

**Attention** This is a public forum