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.

Custom BSL with Application

Hello All,

I am developing a custom BSL with the user Application as one project.  I am publishing the code here:

https://github.com/sittim/msp430-OTP

How can I get the compiler to add the BSL code to the BSL reginon?  It is possible that the compiler is not adding the code because it does not believe that it needs it.  So the following is the BSL430_ Low_Level_Init.asm

https://github.com/sittim/msp430-OTP/blob/master/otp/BSL430_Low_Level_Init.asm

Take a look at the line #28, I am referencing c_BSL_main, but the compiler is still not adding the function into the memory.  If you look in the otp directory, I am specifying to place code into the BSL area by using CODE_SECTION pragma, but once I load the code, I cannot find it.

  • Hi Silver Diamond,

    Does the BSL code show up in the TI-Txt file that you generate when you build your project? You can generate a TI-txt binary file in CCS following the steps here: http://processors.wiki.ti.com/index.php/Generating_and_Loading_MSP430_Binary_Files?keyMatch=msp430 binary&tisearch=Search-EN#Using_CCS_v6.x

    I'm wondering how you are viewing the BSL area after loading - if you use CCS to load the code and are then viewing this area in the Memory browser of a debug session, I think that you might only see 0x3FFF in that area because of the BSL protection being set by SYSBSLPE - I think you'd have to clear that bit before the actual values would show up. A better way to check that your BSL is properly loaded in the BSL area might be to use the Elprotronic Fet-Pro430 Lite software to read back the memory of the device, including the protected BSL memory. I think that this software will clear the SYSBSLPE bit before reading the area so that it reads back the actual stored values so you can compare.

    Hope this helps,

    Katie

  • Hi Kate,

    First, I did generate the hex file it is here:

    https://github.com/sittim/msp430-OTP/blob/master/Debug/msp430-OTP.txt

    I thought of another way to infer what is in the BSL region by looking at the .map file:

    https://github.com/sittim/msp430-OTP/blob/master/Debug/msp430-OTP.map

    It looks like the BSL has 0x7B1 bytes of code in it.

    So to look at the code, I do use the MSP430-FET430UIF with the CCS6.  The SYSBSLPE is off:

    But can anything be wrong with the JTAG lock key which is set at the end of this file:

    github.com/.../BSL430_Low_Level_Init.asm

    Also, here is what I see using CCS, my code supposed to start at highlighted location:

  • OK so found the answer, in order for the linker to place a piece of code into the memory, it has to be somehow tied to main() function. Since I have two applications running on the system, one is the user application, the other one is the BSL, pragrma needs to be used, so adding:

    #pragma RETAIN(cBSL_main)

    told the compiler to include the cBSL_main function and everthing that the function needs.


    (The new code has been pushed to github)

  • So glad to hear you got it working, and thanks for posting the answer where everyone can see if they run into the same thing later on.
    -Katie
  • " it has to be somehow tied to main() function"
    Not specifically to the main function, but yes, the linker will discard code that is not referenced by anything that is referenced itself.
    (a common problem when writing ISRs in assembly - neither the ISR nor its interrupt vector table entry are refefrenced)
    It basically spans a referencing tree starting with the reset vector (or any other named entry point).
    The pragma tells the compiler to fake a reference that the linker will obey.

**Attention** This is a public forum