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.
Hello,
I'm trying to debug a custom BSL with CCS5. I started out with the Custom BSL example for CCS from the app note package. I changed the project settings and link file slightly to account for my chip, a CC430F6137. I am able to compile link and program, but I'm not seeing the BSL_Protect function (or any other function from the low_level_init.asm) being run at all.
I can see that the code is there (disasm, memory browser), but the debugger stops for the first time on 0x1042:
_c_int00_noinit_noexit, c_int00: 001042: ...noexit, c_int00+0 4031 2BFC MOV.W #0x2bfc,SP
from there, i step thru, and eventually end up in my main. never get to any of the code from low_level_inti.asm, including the BSL_Protect.
could it be that this code runs even before the debugger is attached? and if so, what is the proper way to prevent that and get a chance to step thru there? maybe some delay loop?
i have included the disasm from the CCS5 window as i see it the moment the debugger stops for the first time after the download.
Can someone familiar with the matter please help?
Thanks,
-r
(sorry about the formatting, i tried to get it as readable as possible here in the text editor but it's still a bit hard to read, apologies)
17 JMP C_Branch
$../BSL430_Low_Level_Init.asm:17:25$, BSL_Entry_JMP:
001000: ..., BSL_Entry_JMP+0 3C04 JMP (C_Branch)
18 JMP BSL_ACTION0 ;BSL_ACTION0 unused
001002: 3FFE JMP ($../BSL430_Low_Level_Init.asm:17:25$)
19 JMP $ ;BSL_ACTION1 unused
001004: 3FFF JMP (0x1004)
20 JMP $ ;BSL_ACTION2 unused
001006: 3FFF JMP (0x1006)
21 JMP $ ;BSL_ACTION3 unused
001008: 3FFF JMP (0x1008)
22 C_Branch BR #_c_int00
C_Branch:
00100a: C_Branch+0 4030 1042 BR #_c_int00_noinit_noexit
00100e: FFFF 0201 AND.B @R15+,0x0201(R15)
001012: 0403 MOVA @R4,R3
37 CMP #0xDEAD, ARG2
$../BSL430_Low_Level_Init.asm:37:91$, BSL_ACTION0:
001014: ...1$, BSL_ACTION0+0 903D DEAD CMP.W #0xdead,R13
38 JNE RETURN_ERROR
001018: 2004 JNE (RETURN_ERROR)
39 CMP #0xBEEF, ARG3
00101a: 903E BEEF CMP.W #0xbeef,R14
40 JNE RETURN_ERROR
00101e: 2001 JNE (RETURN_ERROR)
47 JMP RETURN_TO_BSL ; 2 == return to BSL
001020: 3C03 JMP (RETURN_TO_BSL)
49 CLR RET_low
RETURN_ERROR:
001022: RETURN_ERROR+0 430C CLR.W R12
50 CLR RET_high
001024: 430D CLR.W R13
51 RETA
001026: 0110 RETA
61 POP.W RET_low ; remove first word from return addr
RETURN_TO_BSL:
001028: RETURN_TO_BSL+0 413C POP.W R12
62 POP.W RET_high ; remove second word from return addr
00102a: 413D POP.W R13
64 RETA ; should now return to the BSL location
00102c: 0110 RETA
79 CLR RET_low ;lock (keep JTAGLOCK_KEY state)
BSL_Protect:
00102e: BSL_Protect+0 430C CLR.W R12
81 BIC #SYSBSLPE+SYSBSLSIZE0+SYSBSLSIZE1 , &SYSBSLC ; protects BSL
001030: C0B2 8003 0182 BIC.W #0x8003,&SYS__System_Module_SYSBSLC
85 bit #SYSBSLIND,&SYSCTL ;check for BSL start request
001036: B0B2 0010 0180 BIT.W #0x0010,&SYS__System_Module_SYSCTL
86 jz BCC2BSL
00103c: 2401 JEQ (BCC2BSL)
88 BIS.W #BSL_REQ_APP_CALL, RET_low
00103e: D32C BIS.W #2,R12
89 BCC2BSL RETA
BCC2BSL:
001040: BCC2BSL+0 0110 RETA
_c_int00_noinit_noexit, c_int00:
001042: ...noexit, c_int00+0 4031 2BFC MOV.W #0x2bfc,SP
001046: 40B2 106C 1C00 MOV.W #0x106c,&.bss
00104c: 40B2 106C 1C02 MOV.W #0x106c,&unlock
001052: 12B0 1060 CALL #_system_pre_init
001056: 430C CLR.W R12
001058: 12B0 1068 CALL #main
00105c: 12B0 1064 CALL #abort
_system_pre_init:
001060: _system_pre_init+0 431C MOV.W #1,R12
001062: 4130 RET
C$$EXIT, abort:
001064: C$$EXIT, abort+0 4303 NOP
C$L1:
001066: C$L1+0 3FFF JMP (C$L1)
6 __no_operation();
main:
001068: main+0 4303 NOP
7 }
00106a: 4130 RET
_nop:
00106c: _nop+0 4130 RET
Hi Rene,
It looks to me that the code is working correctly. After reset, if the MSP430 is set in BSL mode, it branches to 0x1000, which in this case branches to C_Branch, and from there _c_int00_noinit_noexit and then to main(). The other assembly functions are used for calling functions outside BSL memory, protecting BSL, locking JTAG, etc.
If you want to debug code executed before main(), just disable the "run to main()" option in the debugger.
Tony
That's because the other code in BSL430_Low_Level_Init.asm were never executed; and they won't be executed unless specifically called. As I mentioned before, the program branches immediately to the C init functions, and then to main. This is typical C program flow as it initializes the stack/heap/variables/etc before main.
If your goal is to execute (and debug) some custom assembly routines before main, then comment out
JMP C_Branch
and modify JMP BSL_ACTION0 to suit your own needs. Otherwise no other code will be executed before main (well, unless you're using EABI and C++, then LOTS of other code will be executed...)
Tony
Also, from http://processors.wiki.ti.com/index.php/BSL_(MSP430) the BSL_Protect routine is run once during the device startup sequence where JTAG access is not available; presumably this is to prevent external interference to the boot-up process (end-user being able to hijack the bootloader).
Yes and no. It is because JTAG access is disabled after startup. Only after teh JTAG fuse has been checked (whcih is a software "fuse", a memory location inside the BSL area), the JTAG is enabled. Before this is done, the MSP is 'deaf' for the JTAG port.TonyKao said:presumably this is to prevent external interference to the boot-up process (end-user being able to hijack the bootloader).
Right, the JTAG fuse. Duh. I bow before your superior guru-hood, Jens-Michael. You're like a living MSP430 encyclopedia! =)
Tony
**Attention** This is a public forum