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.

MSP430F5342: BSL code retention during power cycle

Part Number: MSP430F5342
Other Parts Discussed in Thread: UNIFLASH, MSPBSL, MSP430F5418A

Hello,

I am trying to develop a custom BSL for the MSP430F5342. As a template I used the sample project CCS_v7_MSP430F543xA_TA_UART downloaded from

http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPBSL_CustomBSL430/latest/index_FDS.html

In the project, I changed the relevant header files to match my part and the project compiles and loads onto the device.

The issue I am having is that the BSL firmware (which should reside in flash starting at 0x1000) is not retained after power cycling, which I verify using Uniflash. If I read the flash memory starting at 0x1000 right after programming the new BSL, I can see code (meaning, I see various hex values in the memory fields at and after 0x1000.) After power cycling the controller, however, all the memory fields are reset to 0x3FFF. What do I need to do to make sure the BSL I load stays in the flash?

Thank you,

svl123

  • Hello svl123,

    If the memory is not being retained over a power cycle, then you have not programmed the device properly as this a FLASH device. Please double check your compilation and debug procedure to ensure you have written to the memory properly.

    Alternatively, it could be an issue with Uniflash reading that portion of memory from the device due to certain permissions. Can you cross check what is in the Flash fo the device with CCS or the Elprotonic Lite FET-Pro430 Software?

    You can also check to see if the BSL is working properly by testing out the interface with the BSLScripter.
  • Jace,

    I opened the .map file for the BSL project and it does not appear that my program is stored anywhere between 0x1000 and 0x1800 because these is hardly any memory used in those places. The ZAREA_CODE sector also has 0 bytes used which is wrong since, per document SLAA450F, the Z area is a gateway to the rest of the BSL code. Also there is nothing between 0x17f0 and 0x17fb whereas these locations should contain a bunch of important values (per the same document, page 3.)

    I assumed that, since I used a template project for custom BSL development, the memory would already be mapped for me - how do I do this manually?

    Thank you,
    svl123
  • Hello svl123,

    Most likely what happened here is the default linker file for you device was used instead the modified one contained within the code download. this makes sense as you are using a different device. You need to ensure the lnk430FXXXX_BSL_AREA.xcl is selected and used when downloading to your device. Please see section "1.3.2.3 lnk430FXXXX_BSL_AREA.xcl" in the Flash Custom BSL App note for more information (found on the MSPBSL webpage ).
  • Jace,

    I did use the default linker file and just added the following to the MEMORY section:

        ZAREA                   : origin = 0x1000, length = 0x0010
        BSL430_VERSION_VENDOR   : origin = 0x1010, length = 0x0001
        BSL430_VERSION_CI       : origin = 0x1011, length = 0x0001
        BSL430_VERSION_API      : origin = 0x1012, length = 0x0001
        BSL430_VERSION_PI       : origin = 0x1013, length = 0x0001
        ZAREA_CODE              : origin = 0x1014, length = 0x002E
        BSLSIG                  : origin = 0x17F0, length = 0x000C
        JTAGLOCK_KEY            : origin = 0x17FC, length = 0x0004

    and the following to the SECTIONS section:

        .ZAREA      : {} > ZAREA
        .BSL430_VERSION_VENDOR : {} > BSL430_VERSION_VENDOR
        .BSL430_VERSION_CI     : {} > BSL430_VERSION_CI
        .BSL430_VERSION_API    : {} > BSL430_VERSION_API
        .BSL430_VERSION_PI     : {} > BSL430_VERSION_PI
        .ZAREA_CODE : {} > ZAREA_CODE
        .BSLSIG     : {} > BSLSIG
        .JTAGLOCK_KEY : {} > JTAGLOCK_KEY

    I did this to make it look like the linker file that came with the template project for the msp430f5418a device (I checked the MSP430F5342 datasheet for the proper memory offsets.) Do I need to do something more? Regarding the lnk430FXXXX_BSL_AREA.cmd file, I did not find such a file anywhere in my installations (I also tried lnk430F5342_BSL_AREA.cmd to match my device.) Where can I find this file?

    Thank you,

    svl123

  • Hello svl123,

    Sorry for the confusion here. The documentation was written for when only IAR was available for custom BSL. You just need to use the linker file provided in the custom BSL code. The F5xxx family are close enough that it should th eBSL fine as you will not be loading anything in the application space. That being said, with compiling in CCS, even the provided BSLs may not compile under the 2kB limit for the BSL area. In this case, I would just modify the provided linker file. The modifications that would need to be done are basically changing the flash boundaries to match the device.

    As a side note, the XXXX for the file i mentioned above, the X's are placeholders for the device being used in the example.
  • Hi Jace,

    I think I understand what the problem is now. In the .map file, the main body of BSL code has the output section label .text which is placed in memory starting at 0x10000:

    .text      0    00010000    0000081c     
                      00010000    00000244     BSL430_Command_Interpreter.obj (.text:main)
                      00010244    000001a8     BSL430_PI_TA.obj (.text:PI_receivePacket)
                      000103ec    000000d0     BSL430_API.obj (.text:BSL430_writeMemory)
                      000104bc    00000086     BSL430_Command_Interpreter.obj (.text:sendDataBlock)
                      00010542    00000074     BSL430_Command_Interpreter.obj (.text:receiveDataBlock)
                      000105b6    00000054     BSL430_API.obj (.text:BSL430_crcCheck)
                      0001060a    00000054     rts430x_lc_rd_eabi.lib : autoinit.c.obj (.text:__TI_auto_init_nobinit_nopinit_hold_wdt:__TI_auto_init_nobinit_nopinit_hold_wdt)
                      0001065e    0000004e     BSL430_PI_TA.obj (.text:sendByte)
                      000106ac    00000048     BSL430_PI_TA.obj (.text:PI_sendData)
                      000106f4    00000046     BSL430_API.obj (.text:BSL430_readMemory)
                      0001073a    00000042     BSL430_API.obj (.text:BSL430_unlock_BSL)
                      0001077c    0000003e     rts430x_lc_rd_eabi.lib : lsl32.asm.obj (.text:l_lsl_const)
                      000107ba    0000002a     BSL430_API.obj (.text:BSL430_massErase)
                      000107e4    00000024     rts430x_lc_rd_eabi.lib : copy_zero_init.c.obj (.text:decompress:ZI:__TI_zero_init_nomemset:__TI_zero_init_nomemset)
                      00010808    0000000c     BSL430_API.obj (.text:_system_pre_init)
                      00010814    00000006     rts430x_lc_rd_eabi.lib : exit.c.obj (.text:abort)
                      0001081a    00000002                            : startup.c.obj (.text:_system_post_cinit)

    This code has length 0x81c which is too long for the 2kb allocated to the BSL area (as you mentioned in your last reply). Now, based on the .cmd file, the .text section wants to go into FLASH:

    #ifndef __LARGE_DATA_MODEL__
        .text       : {} > FLASH                // Code
    #else
        .text       : {} >> FLASH2 | FLASH      // Code
    #endif

    So I copied this line from the linker file that came with the template (in the MEMORY section of the .cmd):

    FLASH					: origin = 0x1042, length = 0x7AE

    But this gives me the memory overflow error, as before. To get rid of this error, how much freedom do I have to shuffle memory around? Can I move the BSLSIG & JTAGLOCK_KEY section to 0x1042, move the FLASH down (start at 0x1052) and then get rid of the .infoD section and allocate its space to FLASH as well? Then I would have one contiguous block of memory (from 0x1052 to 0x187F) which should give me enough space for my .text section.)

    I looked at the .map file and there doesn't seem to be anything written to the .infoD section of memory. Is it safe to get rid of it? Also, is it safe to move the BSLSIG & JTAGLOCK_KEY sections to a different address?

    Thank you,

    svl123

    multiple edits: fixed addresses of above memory sections

  • svl123,

    I would not move ht eJTAGLOCK_KEY or BSLSIG sections as doing so would lessen security measures around the device. I would just overflow the text portion to Flash. If it's only a small amount over the 2kB limit, then i would just overflow into the INFO MEM sections as these are free for you to use. Typically they are used for rarely changed constants or calibration data you may want to store. That being said, any part of the BSL that is outside ht eBSL memory has a potential for being erased during a MASS ERASE event, either triggered via wrong password or specifically commanded.

    Make sure to crank down the optimizations as well on the BSL to help with the size constraints.

    If possible, its recommended to compile your BSL in IAR as it does a better job on size constraints.
  • Ok, I understand. I'll leave the locations as they are.

    One last question regarding this topic: how do I tell the linker to "overflow"? Is the following an example of "write to FLASH and if not enough space overflow to FLASH 2":

    .text       : {} >> FLASH2 | FLASH

    Thanks,

    svl123

  • Found the answer, this link is very good at explaining the different parts of the .cmd file:

    software-dl.ti.com/.../sdto_cgt_Linker-Command-File-Primer.html

    Jace, thank you for your help. This thread has been very helpful to me.

**Attention** This is a public forum