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.

Can BSL code execution be triggered internally on F5529?

Expert 1140 points

Other Parts Discussed in Thread: MSP430F5529

Hi,

I'd like to develop a custom BSL but I need no additional hardware to be involved except from the MSP430F5529 microcontroller being under question. Is that possible that the BSL enter decition is made by some flash range contents?

Best Regards,

tml

  • Hi,

    I believe you are looking another way to invoke the BSL after reset. Please refer here:

    http://processors.wiki.ti.com/index.php/Custom_MSP430_BSL#Device_Startup_Sequence

    basically the decision to run BSL or application after reset is done in the BSL Protect function.

  • OK, then this is clear that the BSL cannot be invoked without external action. It is the boot code that decides whether to start BSL or not and "[...] the boot code will be only executed on hardware reset (pulling down the /RST signal). Software reset such as using watchdog timer, setting the PMMSWBOR or PMMSWPOR of PMMCTL0 will not trigger the boot code."

    That is not what I wanted to hear :)

  • Hi tml,

    so do you mean you want to invoke BSL from your application? This is taken from the BSL User's Guide:

    3.8.1 Starting the BSL From an External Application
    Setting the program counter to the memory location 0x1000 starts the BSL. The stack is always reset, and RAM is cleared. It should be noted that the GIE bit is not disabled, so this should be done by the calling application if interrupts are not desired and appropriately returned from "Return to BSL" if they are used. Because the stack is reset, the location 0x1000 may also be called as a C function, as in the following example code:
    ((void (*)())0x1000)();

  • I think you may be able to implement a "wormhole" in your custom BSL so that it can be invoked by you application program too. The "TI factory BSL" seems to have that with "DEAD" & "BEEF" as password. 

  • Hi Leo,

    This is not going to help. I cannot rely on the application because it may not be working after the programming. My point was to do the remote flashing using the BSL and the main flash memory (starting from 0x4400) the following way:

    1. the BSL is loaded on POR/BOR if the application previously sets the BSL entry criteria (some flash content?)

    2. the application checks for new application image and downloads it on the flash area (say to Bank B), saves the new image flag at the Info memory sets the BSL entry criteria and resets the msp430

    3. step 1 is executed, the entry criteria is met therefore the BSL starts, copies the Bank A to Bank C (backup of a working application) and Bank B to Bank A (new application image), clears the new image flag and executes the application without the reset

    4. application either works or does not work.
    4a IF it does then it clears the BSL entry criteria from flash so that the next time BSL is not loaded.
    4b ELSE the watchdog resets the radio, step 1 executes and the BSL restores Bank A from Bank C (new image flag not set, it's interpreted as faulty image in Bank A i.e image restoration from Bank C to Bank A).

    In case I cannot reset by software in step 2 and step 4b. Also, is that possible to jump from BSL to main memory code (step 3)?

    Best Regards,

    tml

  • You can call the BSL form inside your app (but you should reset all modules used by the BSL to default before you do). But if you want to write your own BSL anyway, you can change the BSL entry test function, which normally checks for the BSL entry sequence bit, but may as well perform any other test (I/O pin state, RTC time, whatever you like).

    Note that the default test implicitly ensures that you're not coming from LPMx.5. If you make a different test, you'll have to take care for it (like unlocking the port pins, which may interfere with the application expecting or even requiring the registers still locked)

    tml said:
    setting the PMMSWBOR or PMMSWPOR of PMMCTL0 will not trigger the boot code."

    I don't think (though I never tried myself) that this is the whole story. Software-triggering BOR will initialize the MSP just like a real power-on or reset. It makes no sense that the boot code would execute this then skip the BSL check. Or execute a socond, independent INIT sequece that doesn't have the BSL check.
    I rather guess, this means that a software BOR won't trigger the BSL start sequence detection (which would involve triggering RST anyway).
    If your BSL code checks for a different criteria, it may well be that the boot code sall sthe BSl entry sequence check function, which now will check for your self-defined criteria and call the BSL.

  • Jens-Michael Gross said:
    If your BSL code checks for a different criteria, it may well be that the boot code sall sthe BSl entry sequence check function, which now will check for your self-defined criteria and call the BSL.

    I am not quite sure but from the http://processors.wiki.ti.com/index.php/Custom_MSP430_BSL#Device_Startup_Sequence I read that this startup procedure (preceded by hardware reset) is common for all BSLs, more precisely it is something that happens before any BSL is in action.

  • tml said:
    this startup procedure (preceded by hardware reset) is common for all BSLs, more precisely it is something that happens before any BSL is in action.

    Right. But the boot code just calls a function in the BSL (which can be replaced by your own). This function decides whether to start the BSL or not. By default, it simply checks the SYSBSLIND flag, which indeed can only be set by the BSL entry sequence (which is checked by hardware while RST is low and the CPU is in reset state). But it could  instead check for anything else too.

    e.g. AFAIK the USB bootloader enters BSL mode if it doesn't find an application software (reset vector is 0xffff), in addition to the BSL entry sequence trigger.

**Attention** This is a public forum