Other Parts Discussed in Thread: MSP430F5529
I am using CCS 10.4. Firmware is written in C, on the K2G ARM core, and compiled with GCC v7.3.1 (Linaro).
I have set a software breakpoint in a C function in the firmware, as follows:
/* main.c */ int gGelCommand __attribute__ ((section ("data"))) = 0; int gGelParam __attribute__ ((section ("data"))) = 0; int gGelReturnValue __attribute__ ((section ("data"))) = 0; void GelCommand_Service(void) { // At this breakpoint, the GEL script can populate the values of // global vars gGelCommand and gGelParam for the next iteration, // and read the value of global var gGelReturnValue from the // previous iteration. __asm__(" bkpt;"); int command = gGelCommand; gGelCommand = 0; switch (command) { case 0: default: break; case 1: gGelReturnValue = (int) myFunc1(gGelParam); break; case 2: gGelReturnValue = (int) myFunc2(gGelParam); break; } } int main() { while (1) { GelCommand_Service(); } return 0; }
Here is an excerpt of a GEL script I have written. The firmware is supposed to be halted at the breakpoint before calling one of the GEL script functions.
/* GEL script */ hotmenu Call_MyFunc1() { int retval; retval = GelCommand(1, 10); Gel_TextOut("MyFunc1(10) returned with value %u\n",,,,, retval); } hotmenu Call_MyFunc2() { int retval; retval = GelCommand(2, 20); Gel_TextOut("MyFunc2(20) returned with value %u\n",,,,, retval); } GelCommand (gelCommand, gelParam) { int retval = 0; GEL_TextOut("1\n"); // This prints. // Firmware should be already halted at the BKPT instruction in function // GelCommand_Service(). if (GEL_IsHalted()) { GEL_TextOut("2\n"); // This prints. // Copy the command and parameter into the global vars that are visible // to the firmware. gGelCommand = gelCommand; gGelParam = gelParam; // Execute one iteration of GelCommand_Service() in the firmware. // Execution should halt at the BKPT instruction. GEL_Run(); GEL_TextOut("3\n"); // This prints. // Try this... GEL_SrcStepOver(); GEL_TextOut("4\n"); // This prints. // Wait for the BKPT instruction to be reached. while (!GEL_IsHalted()) // GEL execution hangs here, while the firmware ; // is waiting at the BKPT. GEL_TextOut("5\n"); // This does not print. // Retrieve return value from the firmware. retval = gGelReturnValue; } else { GEL_TextOut("ERROR: Firmware is not halted.\nBefore executing a GEL command, the firmware must be halted at the BKPT instruction in function GelCommand_Service()"); } GEL_TextOut("6\n"); // This does not print. return retval; }
Summary of how this is supposed to work: When a user selects from the CCS Scripts menu either of the options Call_MyFunc1 or Call_MyFunc2, the GelCommand() function is supposed to populate two global variables in the target, then run the firmware. The firmware is supposed to call the selected firmware function (MyFunc1() or MyFunc2()), and then after returning from the function, halt again at the software breakpoint. The GEL script is then able to retrieve the return value from the function.
But the GEL script hangs on the line of code that waits for the firmware to be halted. Meanwhile, the firmware is in fact halted at the software breakpoint.
Please tell me how to accomplish what I am trying to do here.
Thank you.