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 Getting Stuck After Protect Function; Debugging Difficult in CCS

Other Parts Discussed in Thread: MSP430F6733

I'm implementing a custom BSL for the MSP430F6733 and have written a simple C++ program to set up the proper flash values and functions. I'm using SLAA450C as a guide for setting up the BSL. At this point I am simply trying to prove that the BSL hardware is getting engaged, so I have set the BSL Protect, BSL, and Main functions to each turn on a different LED on the target board:

#include <msp430.h>
#include <stdint.h>

#define BLINK_DELAY() for (uint16_t i = 0; i < 3100; i++) ;

#pragma location=0x17F6
#pragma RETAIN
extern const uint16_t bslUnlockSignature1 = 0xC35A;

#pragma location=0x17F4
#pragma RETAIN
extern const uint16_t bslUnlockSignature2 = 0x3CA5;

#pragma CODE_SECTION(".bsl")
#pragma RETAIN
uint16_t bslProtect()
{
	/** Turn on first LED */
	P6DIR |= 0x40;
	P6OUT &= ~0x40;

	return 0x02;  /** Enter the BSL */
}

#pragma location=0x17F2
#pragma RETAIN
extern uint16_t (*const bslProtectFunctionVector)() = &bslProtect;

#pragma CODE_SECTION(".bsl")
#pragma RETAIN
void bsl()
{
	/** Turn on second LED */
	PJDIR |= 0x08;
	PJOUT &= ~0x08;

	__asm("\n\tbr\t#main");
}

#pragma location=0x17FA
#pragma RETAIN
extern void (*const bslVector)() = &bsl;


int main()
{
	WDTCTL = WDTPW + WDTHOLD;  /** Stop the watchdog timer */

	P5DIR |= 0x20;

	/** Flash third LED */
	while (1)
	{
		P5OUT ^= 0x20;
		BLINK_DELAY();
	}
}

When I run this program, the LED indicator for the BSL Protect section comes on, but neither of the other two do. The program seems to get stuck after the BSL Protect function. Further evidence for this is that if I change the return value in BSL Protect to 0, the first LED turns on and the program enters main() properly. I have verified that the address of the the function bsl() is getting put at 0x17FA, and that all of the other BSL memory locations are getting initialized as expected.

The following is the disassmbly for bslProtect() and bsl():

TEXT Section .bsl, 0x1E bytes at 0x1000
001000:              _Z10bslProtectv:
001000:              .bsl:_Z10bslProtectv:
001000:              .bsl:
001000: F2D0             BIS.B   #0x0040,&PCDIR_H
001002: 4000            
001004: 4502            
001006: F2F0             AND.B   #0x00bf,&PCOUT_H
001008: BF00            
00100a: 4302            
00100c: 2C43             MOV.W   #2,R12
00100e: 3041             RET     
001010:              _Z3bslv:
001010:              .bsl:_Z3bslv:
001010: B2D2             BIS.W   #8,&PJDIR_L
001012: 2403            
001014: B2C2             BIC.W   #8,&PJOUT_L
001016: 2203            
001018: 3040             BR      #main
00101a: 6E40            
00101c: 3041             RET     

I'd like to be able to single step after the BSL Protect function and figure out where the program is derailing, but Code Composer seems to have trouble debugging BSL code. It never breaks at breakpoints in the BSL Protect function, even when that function has clearly been run. Furthermore, the program actually does enter main() while debugging, but not during standalone operation.

Thus I have two questions I'm hoping somebody can help me out with: 1) any ideas on what is causing the BSL function to not run? and 2) any advice on debugging BSL code in Code Composer?

**Attention** This is a public forum