Skip to content

Instantly share code, notes, and snippets.

@vankxr
Created March 10, 2019 16:44
Show Gist options
  • Save vankxr/1b5706b5b541c1671f59a22e4fbe144f to your computer and use it in GitHub Desktop.
Save vankxr/1b5706b5b541c1671f59a22e4fbe144f to your computer and use it in GitHub Desktop.
Notes on ARMv7 Debug access ports
// An AP has max 64 words
// Bits 3:2 (the X in 0b????XX00) of the address are sent within the command, i.e. "SWDReadAP 3" = read from 0b????1100
// Bits 7:4 (the X in 0bXXXX??00) of the address are set in the SELECT register, i.e. "SWDWriteDP 2 0x??0000F?" = read from 0b1111??00
// The AHB-AP is on APSEL = 0
// The AAP is on APSEL = 255
// APSEL is the MSB of the SELECT register, i.e. "SWDWriteDP 2 0xFF0000?0" = set APSEL to 255
// Read the AP IDR
SWDWriteDP 2 0xFF0000F0
SWDReadAP 3
SWDReadDP 3
// Calc CRC of the flash page at 0x00101000
SWDWriteDP 2 0xFF000010
SWDWriteAP 2 0x00101000
SWDWriteDP 2 0xFF000010
SWDWriteAP 0 0x00000001
SWDWriteDP 2 0xFF000010
SWDReadAP 1
SWDReadDP 3
Sleep 1000
SWDWriteDP 2 0xFF000010
SWDReadAP 3
SWDReadDP 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment