Skip to content

Commit

Permalink
atxmega: Created an initial implementation of breakpoint-based halt_r…
Browse files Browse the repository at this point in the history
…esume
  • Loading branch information
dragonmux committed Sep 20, 2023
1 parent f361b70 commit 9059969
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/target/atxmega.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,26 @@ static void atxmega_halt_resume(target_s *const target, const bool step)
continue;
pdi->halt_reason = TARGET_HALT_STEPPING;
} else {
/*
* To resume the processor we go through the following specific steps:
* Write the program counter to ensure we start where we expect
* Then we release the externally (PDI) applied reset
* We then poke the debug control register to indicate debug-supervised run
* Ensure that PDI is still in debug mode (r4 = 1)
* Read r3 to see that the processor is resuming
*/
/* Check that we are in administrative halt */
if (avr_pdi_reg_read(pdi, PDI_REG_R3) != 0x04U ||
/* Try to configure the breakpoints */
!atxmega_config_breakpoints(pdi, step) || avr_pdi_reg_read(pdi, PDI_REG_R3) != 0x04U ||
/* Set the program counter and release reset */
!avr_pdi_write(pdi, PDI_DATA_32, ATXMEGA_DBG_PC, pdi->program_counter) ||
!avr_pdi_reg_write(pdi, PDI_REG_RESET, 0U) ||
/* Configure the debug controller */
!avr_pdi_write(pdi, PDI_DATA_8, ATXMEGA_DBG_CTRL, 0U) || avr_pdi_reg_read(pdi, PDI_REG_R3) != 0x04U ||
/* And try to execute the request */
!avr_pdi_reg_write(pdi, PDI_REG_R4, 1U))
raise_exception(EXCEPTION_ERROR, "Error resuming device, device in incorrect state");
pdi->halt_reason = TARGET_HALT_RUNNING;
}
}

0 comments on commit 9059969

Please sign in to comment.