Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix software reset by writing in SYSRESETQ register when a reset is requested #73

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions components/DAP/source/DAP.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,22 @@ static uint32_t DAP_Disconnect(uint8_t *response) {
// return: number of bytes in response
static uint32_t DAP_ResetTarget(uint8_t *response) {

#if (USE_MANUAL_SYSRESETQ_AFTER_FLASH)
if (DAP_Data.debug_port == DAP_PORT_SWD) {
/* Workaround for software reset when nRESET is not connected */
uint8_t ack;
uint32_t AIRCR_REG_ADDR = 0xE000ED0C;
uint32_t AIRCR_RESET_VAL = 0x05FA << 16 | 1 << 2; /* Vector key | SYSRESETREQ bit */
uint8_t req = DAP_TRANSFER_APnDP | 0 | DAP_TRANSFER_A2 | 0;
ack = SWD_Transfer(req,&AIRCR_REG_ADDR);
if (ack == DAP_TRANSFER_OK) {
dap_os_delay(2);
req = DAP_TRANSFER_APnDP | 0 | DAP_TRANSFER_A2 | DAP_TRANSFER_A3;
SWD_Transfer(req,&AIRCR_RESET_VAL);
}
}
#endif

*(response+1) = RESET_TARGET();
*(response+0) = DAP_OK;
return (2U);
Expand Down
6 changes: 6 additions & 0 deletions main/dap_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@
#endif


/**
* @brief Workaround for single core Cortex-M, manual write to AIRCB core register
*/
#define USE_MANUAL_SYSRESETQ_AFTER_FLASH 0


#endif