Skip to content

Commit

Permalink
feat: add support for SWJ_Sequence and SWJ_Pins
Browse files Browse the repository at this point in the history
  • Loading branch information
windowsair committed Aug 20, 2024
1 parent 889bb2f commit 2f33126
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 86 deletions.
4 changes: 4 additions & 0 deletions common/rddi_dap_cmsis.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,8 @@ RDDI_FUNC int CMSIS_DAP_GetGUID(const RDDIHandle handle, int ifNo, char *str, co
*/
RDDI_FUNC int CMSIS_DAP_Capabilities(const RDDIHandle handle, int ifNo, int *cap_info);

RDDI_FUNC int CMSIS_DAP_SWJ_Sequence(const RDDIHandle handle, int num, unsigned char *request);

RDDI_FUNC int CMSIS_DAP_SWJ_Pins(const RDDIHandle handle, unsigned char pinselect, unsigned char pinout, int *res, int wait);

#endif
5 changes: 4 additions & 1 deletion elaphureLinkAGDI/DbgCM/AGDI.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -17565,6 +17565,7 @@ static U32 DapAcc_Pins(ACCDAP *pIn)
int status = 0;
U32 nE = ACCDAP_DONE;
bool bForce = false;
int res;

if (pIn == NULL) {
return (ACCDAP_BADPARM);
Expand Down Expand Up @@ -17593,7 +17594,6 @@ static U32 DapAcc_Pins(ACCDAP *pIn)
}

//---TODO: Write data to JTAG/SWD pins and wait for pins to stabilize
DEVELOP_MSG("Todo: \nWrite data to JTAG/SWD pins and wait for pins to stabilize");
// Members of pIn to use:
// - pIn->pOut8 : Value to Write
// - pIn->nMask : Pin mask to select pins for value change
Expand All @@ -17607,6 +17607,9 @@ static U32 DapAcc_Pins(ACCDAP *pIn)
// - Bit 4: nTRST (ACCDAP_PIN_nTRST)
// - Bit 5: nRESET (ACCDAP_PIN_nRESET)

status = rddi::CMSIS_DAP_SWJ_Pins(rddi::k_rddi_handle, pIn->nMask, *pIn->pOut8, &res, pIn->nDelay);
*pIn->pIn8 = static_cast<uint8_t>(res);

end:

if (status != 0 && nE == ACCDAP_DONE) {
Expand Down
2 changes: 1 addition & 1 deletion elaphureLinkAGDI/DbgCM/COLLECT.H
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

// Choose between this three #defines when developing the driver
#define DEVELOP_MSG(str) \
AfxMessageBox("elaphureLink does not implement this feature yet. If you see this message, please open an issue at https://github.com/windowsair/elaphureLink/issues" #str)
AfxMessageBox("elaphureLink does not implement this feature yet. If you see this message, please open an issue at https://github.com/windowsair/elaphureLink/issues\n" ##str)
//#define DEVELOP_MSG OutputDebugString
//#define DEVELOP_MSG txtout

Expand Down
2 changes: 2 additions & 0 deletions elaphureLinkAGDI/DbgCM/DbgCM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ inline BOOL LoadRddiDllFunction()
RDDILL_GetProcAddress(CMSIS_DAP_DetectNumberOfDAPs);
RDDILL_GetProcAddress(CMSIS_DAP_DetectDAPIDList);
RDDILL_GetProcAddress(CMSIS_DAP_Commands);
RDDILL_GetProcAddress(CMSIS_DAP_SWJ_Sequence);
RDDILL_GetProcAddress(CMSIS_DAP_SWJ_Pins);

return TRUE;
}
Expand Down
11 changes: 8 additions & 3 deletions elaphureLinkAGDI/DbgCM/SWD.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**************************************************************************/ /**
/**************************************************************************/ /**
* Cortex-M Middle/Upper layer Debug driver Template for µVision
*
* @version V1.1.13
Expand Down Expand Up @@ -3296,8 +3296,13 @@ int SWD_SwitchDP(DWORD id, bool force)
// - DBGCM_RECOVERY Feature
int SWD_SWJ_Sequence(int cnt, U64 val)
{
//...
DEVELOP_MSG("Todo: \nImplement Function: int SWD_SWJ_Sequence (int cnt, U64 val), required for\n - DBGCM_DBG_DESCRIPTION Feature\n - DBGCM_RECOVERY Feature");
unsigned char *p = reinterpret_cast<unsigned char *>(&val);
int ret;

ret = rddi::CMSIS_DAP_SWJ_Sequence(rddi::k_rddi_handle, cnt, p);
if (ret)
return EU08;

return (0);
}

Expand Down
2 changes: 2 additions & 0 deletions elaphureLinkAGDI/DbgCM/rddi_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ decltype(::CMSIS_DAP_Commands) *CMSIS_DAP_Commands = nullptr
decltype(::CMSIS_DAP_ConfigureDAP) *CMSIS_DAP_ConfigureDAP = nullptr;
//decltype(::CMSIS_DAP_GetGUID) *CMSIS_DAP_GetGUID = nullptr;
decltype(::CMSIS_DAP_Capabilities) *CMSIS_DAP_Capabilities = nullptr;
decltype(::CMSIS_DAP_SWJ_Sequence) *CMSIS_DAP_SWJ_Sequence = nullptr;
decltype(::CMSIS_DAP_SWJ_Pins) *CMSIS_DAP_SWJ_Pins = nullptr;


RDDIHandle k_rddi_handle;
Expand Down
2 changes: 2 additions & 0 deletions elaphureLinkAGDI/DbgCM/rddi_dll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ extern decltype(::CMSIS_DAP_Commands) *CMSIS_DAP_Commands;
extern decltype(::CMSIS_DAP_ConfigureDAP) *CMSIS_DAP_ConfigureDAP;
extern decltype(::CMSIS_DAP_GetGUID) *CMSIS_DAP_GetGUID;
extern decltype(::CMSIS_DAP_Capabilities) *CMSIS_DAP_Capabilities;
extern decltype(::CMSIS_DAP_SWJ_Sequence) *CMSIS_DAP_SWJ_Sequence;
extern decltype(::CMSIS_DAP_SWJ_Pins) *CMSIS_DAP_SWJ_Pins;

enum {
RDDI_DAP_ERROR = 0x2000, // RDDI-DAP Error
Expand Down
11 changes: 10 additions & 1 deletion elaphureLinkProxy/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,13 @@ void SocketClient::do_data_process()
p += 3;
break;
}

case ID_DAP_SWJ_Pins: {
k_shared_memory_ptr->consumer_page.data_len = 1;
k_shared_memory_ptr->consumer_page.data[0] = *(p + 1);
set_consumer_status(DAP_RES_OK);
p += 2;
break;
}
case ID_DAP_JTAG_Sequence: {
if (*(p + 1) != 0) { // status code
set_consumer_status(DAP_RES_FAULT);
Expand Down Expand Up @@ -308,7 +314,10 @@ void SocketClient::do_data_process()
break;
}
case ID_DAP_SWJ_Sequence: {
int status = *(p + 1);
p += 2;

set_consumer_status(status == 0 ? DAP_RES_OK : DAP_RES_ERROR);
break;
}
case ID_DAP_SWD_Configure: {
Expand Down
Loading

0 comments on commit 2f33126

Please sign in to comment.