CVS: jtag/msp430 JTAGfunc.c,1.5,1.6 MSP430mspgcc.c,1.9,1.10 MSP430mspgcc.def,1.3,1.4 funclets.c,1.8,1.9 funclets.h,1.5,1.6
Chris Liechti <[email protected]>
| Newsgroups | gmane.comp.hardware.texas-instruments.msp430.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mspgcc/jtag/msp430
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17021/jtag/msp430
Modified Files:
JTAGfunc.c MSP430mspgcc.c MSP430mspgcc.def funclets.c
funclets.h
Log Message:
- add the ability to run funclets for a given time
- new function MSP430_FuncletWait, internal API changes for executeCode
- add a counter funclet (can be used to determine DCO frequency)
- update msp430-jtag with the new feature
Index: JTAGfunc.c
===================================================================
RCS file: /cvsroot/mspgcc/jtag/msp430/JTAGfunc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- JTAGfunc.c 21 Dec 2005 23:08:15 -0000 1.5
+++ JTAGfunc.c 27 Dec 2005 01:12:11 -0000 1.6
@@ -194,12 +194,12 @@
HIL_JTAG_IR(IR_CNTRL_SIG_16BIT);
HIL_JTAG_DR(0x3401, F_WORD); // CPU has control of RW & BYTE.
HIL_JTAG_IR(IR_DATA_16BIT);
- HIL_TCLK(1); // F2xxx
+ HIL_TCLK(1); // F2xx
HIL_JTAG_DR(MOV_IMM_PC, F_WORD); // "mov #addr,PC" instruction
HIL_TCLK(POS_EDGE);
HIL_JTAG_DR(Addr, F_WORD); // Send addr value
HIL_TCLK(POS_EDGE);
- HIL_TCLK(0); // F2xxx
+ HIL_TCLK(0); // F2xx
HIL_JTAG_IR(IR_ADDR_CAPTURE);
if (Addr != HIL_JTAG_DR(0, F_WORD)) return STATUS_ERROR;//ERROR: SetPC failed!
HIL_JTAG_IR(IR_CNTRL_SIG_16BIT);
@@ -224,7 +224,7 @@
HIL_JTAG_IR(IR_CNTRL_SIG_16BIT);
HIL_JTAG_DR(0x3401, F_WORD); // CPU has control of RW & BYTE.
HIL_JTAG_IR(IR_DATA_16BIT);
- HIL_TCLK(1); // F2xxx
+ HIL_TCLK(1); // F2xx
HIL_JTAG_DR(MOV_IMM_RX | Regnum, F_WORD); // "mov #addr, Rx" instruction
HIL_TCLK(POS_EDGE);
HIL_JTAG_DR(Value, F_WORD); // Send addr value
@@ -252,7 +252,7 @@
HIL_JTAG_IR(IR_CNTRL_SIG_16BIT);
HIL_JTAG_DR(0x3401, F_WORD); // CPU has control of RW & BYTE.
HIL_JTAG_IR(IR_DATA_16BIT);
- HIL_TCLK(1); // F2xxx
+ HIL_TCLK(1); // F2xx
HIL_JTAG_DR(MOV_RX_MEM | (Regnum << 8), F_WORD); //"mov Rx, &a"
HIL_TCLK(POS_EDGE); // instr fetch
HIL_JTAG_DR(SAVE_ADDRESS, F_WORD); // Dummy addr value
Index: MSP430mspgcc.c
===================================================================
RCS file: /cvsroot/mspgcc/jtag/msp430/MSP430mspgcc.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -d -r1.9 -r1.10
--- MSP430mspgcc.c 20 Aug 2004 00:00:05 -0000 1.9
+++ MSP430mspgcc.c 27 Dec 2005 01:12:11 -0000 1.10
@@ -353,18 +353,24 @@
WORD segmentSize;
// Erase each of the segments.
for (segmentAddr = address; segmentAddr < (address + length); segmentAddr += segmentSize) {
+ MSP430_Log(3, "MSP430mspgcc: MSP430_Erase segment 0x%04x\n", segmentAddr);
if ((result = eraseFlash(ERASE_SEGMENT, (WORD) segmentAddr)) != STATUS_OK) {
break;
}
// The segment size is dependent upon the adress.
if (segmentAddr < 0x1100) {
+ if ((DEVICE & 0xff00) == 0xf200) { // is it a F2xx series device?
+ segmentSize = INFO_SEGMENT_SIZE_F2xx; // Information memory.
+ } else {
segmentSize = INFO_SEGMENT_SIZE; // Information memory.
+ }
} else if (segmentAddr < 0x1200) {
segmentSize = FIRST_60K_SEGMENT_SIZE; // The first segment of 60K devices is short.
} else {
segmentSize = MAIN_SEGMENT_SIZE; // Main memory.
}
+ MSP430_Log(3, "MSP430mspgcc: MSP430_Erase advance %u bytes\n", segmentSize);
}
if (result != STATUS_ERROR) {
//check the entire length for erasure.
@@ -657,7 +663,34 @@
*/
STATUS_T WINAPI MSP430_Funclet(CHAR* code, LONG sizeCode, BOOL verify, BOOL wait) {
MSP430_Log(1, "MSP430mspgcc: MSP430_Funclet...\n");
- return executeCode((WORD *)code, sizeCode/sizeof(WORD), verify, wait);
+ return executeCode((WORD *)code, sizeCode/sizeof(WORD), verify, wait ? 2000: 0, NULL);
+}
+
+/* ----------------------------------------------------------------------------
+Execute the 'funclet' provided in code.
+
+A funclet has the download address, start of main address and the end address as the
+first 6 bytes. Between these 3 words and the starting address a range of memory
+can be used to pass data to the funclet.
+
++-----+--------- +-------------------------------------------------------------+
+|wait | runtime | behaviour |
++-----+--------- +-------------------------------------------------------------+
+| 0 | n/v | start funclet and return, CPU keeps running |
++-----+--------- +-------------------------------------------------------------+
+| >0 | NULL | run funclet and wait up to "wait" milliseconds. return |
+| | | STATUS_OK only if the funclet succeds before the timeout. |
++-----+--------- +-------------------------------------------------------------+
+| >0 | set | run funclet and wait up to "wait" milliseconds. STATUS_OK |
+| | | is returned if the funclet either succeeds or the timeout |
+| | | was hit. the caller has to check the runtime (and/or other |
+| | | things like the CPU registers) and decide if the run was |
+| | | realy successful. |
++-----+--------- +-------------------------------------------------------------+
+*/
+STATUS_T WINAPI MSP430_FuncletWait(CHAR* code, LONG sizeCode, BOOL verify, ULONG wait, ULONG *runtime) {
+ MSP430_Log(1, "MSP430mspgcc: MSP430_FuncletWait...\n");
+ return executeCode((WORD *)code, sizeCode/sizeof(WORD), verify, wait, runtime);
}
/* ----------------------------------------------------------------------------
Index: MSP430mspgcc.def
===================================================================
RCS file: /cvsroot/mspgcc/jtag/msp430/MSP430mspgcc.def,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- MSP430mspgcc.def 26 Nov 2003 01:29:14 -0000 1.3
+++ MSP430mspgcc.def 27 Dec 2005 01:12:11 -0000 1.4
@@ -15,6 +15,7 @@
MSP430_VerifyMem@12
MSP430_EraseCheck@8
MSP430_Funclet@16
+MSP430_FuncletWait@20
MSP430_ReadRegister@8
MSP430_WriteRegister@8
MSP430_isHalted@0
@@ -32,6 +33,7 @@
MSP430_VerifyMem = MSP430_VerifyMem@12
MSP430_EraseCheck = MSP430_EraseCheck@8
MSP430_Funclet = MSP430_Funclet@16
+MSP430_FuncletWait = MSP430_FuncletWait@20
MSP430_ReadRegister = MSP430_ReadRegister@8
MSP430_WriteRegister = MSP430_WriteRegister@8
MSP430_isHalted = MSP430_isHalted@0
\ No newline at end of file
Index: funclets.c
===================================================================
RCS file: /cvsroot/mspgcc/jtag/msp430/funclets.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- funclets.c 26 Dec 2005 22:41:23 -0000 1.8
+++ funclets.c 27 Dec 2005 01:12:11 -0000 1.9
@@ -44,7 +44,7 @@
MSP430_Log(2, "funclets: programFlash: Flash write at 0x%04x %d bytes\n", address, blocksize);
//download data and start flash programing funclet in RAM, with retries
for (tries=3; tries; tries--) {
- res = executeCode(code, (sizeof(funclet_progFlash) + blocksize)/sizeof(WORD), 1, 1);
+ res = executeCode(code, (sizeof(funclet_progFlash) + blocksize)/sizeof(WORD), 1, 1000, NULL);
if (res != STATUS_OK) {
MSP430_Log(1, "funclets: programFlash: Flash write retrying in block 0x%04x\n", address);
GetDevice();
@@ -90,7 +90,7 @@
funclet_eraseFlashSegment[4] = 0xA502; //set FCTL1 contents
funclet_eraseFlashSegment[5] = address; //address within the segment to be erased
//download erase prog and execute
- return executeCode(funclet_eraseFlashSegment, sizeof(funclet_eraseFlashSegment)/sizeof(WORD), 1, 1);
+ return executeCode(funclet_eraseFlashSegment, sizeof(funclet_eraseFlashSegment)/sizeof(WORD), 1, 1000, NULL);
case ERASE_MAIN:
//fill in arguments
@@ -98,7 +98,7 @@
funclet_eraseFlash[4] = 0xA504; //set FCTL1 contents
funclet_eraseFlash[5] = address; //address within the segment to be erased
//download erase prog and execute
- return executeCode(funclet_eraseFlash, sizeof(funclet_eraseFlash)/sizeof(WORD), 1, 1);
+ return executeCode(funclet_eraseFlash, sizeof(funclet_eraseFlash)/sizeof(WORD), 1, 1000, NULL);
case ERASE_ALL:
//fill in arguments
@@ -106,7 +106,7 @@
funclet_eraseFlash[4] = 0xA506; //set FCTL1 contents
funclet_eraseFlash[5] = address; //address within the segment to be erased
//download erase prog and execute
- return executeCode(funclet_eraseFlash, sizeof(funclet_eraseFlash)/sizeof(WORD), 1, 1);
+ return executeCode(funclet_eraseFlash, sizeof(funclet_eraseFlash)/sizeof(WORD), 1, 1000, NULL);
default:
return STATUS_ERROR;
@@ -233,8 +233,10 @@
* - MCLK/TCLK is high
* - MAB selects a RAM address
* - A JTAG instruction is shifted in or a JTAG data is shifted in
+ *
+ * See executeCode for parameter documentation.
*/
-STATUS_T executeCodeSafe(const WORD* code, WORD sizeCode, BOOL verify, BOOL wait) {
+STATUS_T executeCodeSafe(const WORD* code, WORD sizeCode, BOOL verify, ULONG wait, ULONG *runtime) {
int i;
if (sizeCode == 0) {
@@ -319,19 +321,32 @@
HIL_TCLK(1);
if (wait) {
+ ULONG runtime_internal;
+ MSP430_Log(1, "funclets: executeCodeSafe: wait for up to %ums\n", wait); //DEBUG
+ HIL_StartTimer();
// Limit the number of cycles for the code to execute.
- for (i = 0; i < 20000; i++) {
+ while ((runtime_internal = HIL_ReadTimer()) < wait) {
// Poll the device until it is executing the final code instruction.
if ((readMab() == code[2]) && (readMab() == code[2]) && (readMab() == code[2])) {
+ HIL_StopTimer();
+ if (runtime != NULL) *runtime = runtime_internal;
// For F413P, F41xC, and F12x devices, the following step will likely corrupt RAM.
// However, we don't care about this as the RAM contents will be reloaded in necessary.
- MSP430_Log(5, "funclets: executeCodeSafe: wait OK\n"); //DEBUG
+ MSP430_Log(3, "funclets: executeCodeSafe: wait OK (%ums)\n", runtime_internal); //DEBUG
return syncCPU(); // Resume control of the CPU. Read/Write will be set.
}
}
- MSP430_Log(1, "funclets: executeCodeSafe: wait failed\n"); //DEBUG
+ HIL_StopTimer();
+ MSP430_Log(1, "funclets: executeCodeSafe: wait failed (%ums)\n", runtime_internal); //DEBUG
+ // if runtime out parameter is given, exit iwth success, the caller can
+ // test the runtime to see if its OK for him. Otherways fail.
+ if (runtime != NULL) {
+ *runtime = runtime_internal;
+ return STATUS_OK;
+ } else {
return STATUS_ERROR;
}
+ }
MSP430_Log(3, "funclets: executeCodeSafe: exec OK\n"); //DEBUG
return STATUS_OK;
}
@@ -340,8 +355,10 @@
/**
* This function downloads programs (funclets) into RAM, and starts their execution.
* F2xx compatible, but not withthe workaround.
+ *
+ * See executeCode for parameter documentation.
*/
-STATUS_T executeCodeUnsafe(const WORD* code, WORD sizeCode, BOOL verify, BOOL wait) {
+STATUS_T executeCodeUnsafe(const WORD* code, WORD sizeCode, BOOL verify, ULONG wait, ULONG *runtime) {
int i;
if (sizeCode == 0) {
@@ -429,36 +446,67 @@
HIL_TCLK(1);
if (wait) {
+ ULONG runtime_internal;
+ MSP430_Log(1, "funclets: executeCode: wait for up to %ums\n", wait); //DEBUG
+ HIL_StartTimer();
// Limit the number of cycles for the code to execute.
- for (i = 0; i < 20000; i++) {
+ while ((runtime_internal = HIL_ReadTimer()) < wait) {
// Poll the device until it is executing the final code instruction.
if ((readMab() == code[2]) && (readMab() == code[2]) && (readMab() == code[2])) {
+ HIL_StopTimer();
+ if (runtime != NULL) *runtime = runtime_internal;
// For F413P, F41xC, and F12x devices, the following step will likely corrupt RAM.
// However, we don't care about this as the RAM contents will be reloaded in necessary.
- MSP430_Log(5, "funclets: executeCode: wait OK\n"); //DEBUG
+ MSP430_Log(3, "funclets: executeCode: wait OK (%ums)\n", runtime_internal); //DEBUG
return syncCPU(); // Resume control of the CPU. Read/Write will be set.
}
}
- MSP430_Log(1, "funclets: executeCode: wait failed\n"); //DEBUG
+ HIL_StopTimer();
+ MSP430_Log(1, "funclets: executeCode: wait failed (%ums)\n", runtime_internal); //DEBUG
+ // if runtime out parameter is given, exit iwth success, the caller can
+ // test the runtime to see if its OK for him. Otherways fail.
+ if (runtime != NULL) {
+ *runtime = runtime_internal;
+ return STATUS_OK;
+ } else {
return STATUS_ERROR;
}
+ }
MSP430_Log(3, "funclets: executeCode: OK\n"); //DEBUG
return STATUS_OK;
}
/**
- * We dont have the correct code for a execute code that works with F1xx series
- * with the JTAG bug AND F2xx devices. Solution: choose one or the other
- * executeCode implementation, depending on CPU type.
+ * Execute a peace of code, a funclet, in the MSP430s RAM.
+ *
+ * We dont have the correct code for a execute code that works with F1xx/F4xx
+ * series with the JTAG bug AND the F2xx devices. Solution: choose one or the
+ * other executeCode implementation, depending on CPU type.
+ *
+ * @param code [in] pointer to the array containing MSP430 machine code
+ * @param sizeCode [in] number of bytes in the code array
+ * @param verify [in] if true, the funclet is verified in the targets
+ * RAM before its executed (recomended)
+ * @param wait [in] time in milliseconds to wait for the funclet to
+ * complete. If zero, the funclet is started and the
+ * function returns with succcess - the CPU keeps running.
+ * @param runtime [out] if not NULL, then the actual run time of the
+ * funclet is returned here. Note that the function returns
+ * with STATUS_OK if the funclet completes or not if this
+ * parameter is not NULL!
+ * @return STATUS_OK on success, STATUS_ERROR if the funclet could
+ * not be executed successfully.
*/
-STATUS_T executeCode(const WORD* code, WORD sizeCode, BOOL verify, BOOL wait) {
+STATUS_T executeCode(const WORD* code, WORD sizeCode, BOOL verify, ULONG wait, ULONG *runtime) {
+ STATUS_T status = STATUS_ERROR;
if ((DEVICE & 0xff00) == 0xf200) { //is it a F2xx series device?
//yes F2xx: use new variant
- return executeCodeUnsafe(code, sizeCode, verify, wait);
+ status = executeCodeUnsafe(code, sizeCode, verify, wait, runtime);
} else {
//no, F1xx or F4xx series, use old variant with support for bad JTAGs
- return executeCodeSafe(code, sizeCode, verify, wait);
+ status = executeCodeSafe(code, sizeCode, verify, wait, runtime);
}
+ return status;
}
/**
Index: funclets.h
===================================================================
RCS file: /cvsroot/mspgcc/jtag/msp430/funclets.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- funclets.h 26 Nov 2003 01:29:14 -0000 1.5
+++ funclets.h 27 Dec 2005 01:12:11 -0000 1.6
@@ -8,6 +8,6 @@
STATUS_T programFlash(WORD address, const CHAR* buffer, WORD count);
STATUS_T eraseFlash(WORD type, WORD address);
STATUS_T syncCPU(void);
-STATUS_T executeCode(const WORD* code, WORD sizeCode, BOOL verify, BOOL wait);
+STATUS_T executeCode(const WORD* code, WORD sizeCode, BOOL verify, ULONG wait, ULONG *runtime);
int isHalted(void);
#endif //FUNCLETS_H
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click