XJTAG 4.1 introduces enhancements to the ARM Serial Wire Debug (SWD) protocol to return protocol operation acknowledgement responses in XJEase.
Following on from the introduction of SWD support in XJTAG 3.11, XJTAG 4.1 provides a number of new functions to perform SWD protocol read and write operations with all acknowledgement responses and parity error checks returned to XJEase. Up to now if an SWD target returned a FAULT or unrecognised acknowledgement, or we found a parity bit error in read data then the test would immediately exit with a failure reported. The following API enhancements allow for more flexibility in SWD testing to react and respond to these errors.
The first thing new SWD XJEase code should do is tell XJEase to not exit on errors:
SWD_EXIT_ON_ERROR(FALSE);
SWD_READ and SWD_WRITE functions can still be used as before, but now the error counts should be periodically checked:
SWD_GET_RESPONSE_COUNTERS()(okCounter, timeoutOnWaitCounter, faultCounter, otherAcksCounter); SWD_GET_RESPONSE_COUNTERS()(okCounter, timeoutOnWaitCounter, faultCounter, otherAcksCounter, parityErrorCounter); SWD_RESET_RESPONSE_COUNTERS();
There are functions to retrieve the last SWD scan response:
SWD_GET_LAST_RESPONSE()(ack); SWD_GET_LAST_RESPONSE()(ack, parityError);
There is also a new overload for SWD_READ to return error details with the data:
SWD_READ(DP, DPIDR[3..2])(data, ack, parityError);
Other points to note:
For performance reasons the XJTAG hardware will always automatically retry after a WAIT acknowledgement response from the target a number of times with increasing delays before returning with a WAIT response to XJEase.
SWD is fully supported by all XJLink2-based JTAG controllers and the newly released XJLink-PF40.
To add SWD pins to a XJLink-PF40 pin mapping, open the SWD pins dialog using the button on the Pin Mapping tab of the Pin Mapping screen:
Define the SWD pins on the appropriate XJLink2-PF40 connector:
Once set the SWD pins should be highlighted on the connector in the diagram:
The following is an XJEase code example powering up the Kinetis flash device on a XJDemo v4.2 board using a few of the new functions:
CONST INT DPIDR := 0x0; CONST INT CTRL := 0x4; CONST INT DP := 0x0; CONST INT AP := 0x1; INT id, data; INT ack, parityError; INT okCounter, timeoutOnWaitCounter, faultCounter; INT otherAcksCounter, parityErrorCounter; INT pollEndTime; //disable exit on error SWD_EXIT_ON_ERROR(FALSE); //places the device into SWD mode SWD //read protocol operation with new return arguments SWD_READ(DP, DPIDR[3..2])(id, ack, parityError); PRINT("id: ", FORMAT(id, "%#08x"), ", ack: ", FORMAT(ack, "%#03b"), ", parityError: ", parityError, "\n"); IF ack != 0b001 || parityError = TRUE THEN PRINT("Device failed to acknowledge the id read request\n"); EXIT; END; IF id != 0x2ba01477 THEN PRINT("Device returned unexpected id code\n"); END; //request power up SWD_WRITE(DP, CTRL[3..2], 0x50000000); SWD_GET_LAST_RESPONSE()(ack); IF ack != 0b001 THEN PRINT("ack: ", FORMAT(ack, "%#03b"), "\n"); EXIT; END; //poll for acknowledgement pollEndTime := NOW() + 1000; DO SWD_READ(DP, CTRL[3..2])(data); //and read back WHILE (data[31..28] != 0xF) && (NOW() < pollEndTime) END; //example getting ok+error counts for all previous protocol operations SWD_GET_RESPONSE_COUNTERS()(okCounter, timeoutOnWaitCounter, faultCounter, otherAcksCounter, parityErrorCounter); PRINT("okCounter: ", okCounter, ", timeoutOnWaitCounter: ", timeoutOnWaitCounter, ", faultCounter: ", faultCounter, ", otherAcksCounter: ", otherAcksCounter, ", parityErrorCounter: ", parityErrorCounter, "\n"); PRINT("Data: ", FORMAT(data, "%#08x\n")); IF data[31..28] != 0xF THEN PRINT("Device failed to acknowledge system and debug powerup request\n"); EXIT; END; END; //switch the device back to JTAG mode
Leave A Comment