Created
February 16, 2020 09:43
-
-
Save SteveAmor/36c53be9cfc1fae8b89a25f0adf8653c to your computer and use it in GitHub Desktop.
Using OpenOCD and GDB with nRF52832 (PineTime)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Based on the build from lupyuen/pinetime-rust-mynewt | |
| Uses a Raspberry Pi to run OpenOCD which connects to the nRF52 with SMD | |
| If required, GDB then runs on top of OpenOCD (OpenOCD has quite a few commands without GDB) | |
| Start OpenOCD in a terminal window | |
| Currently, I am using the lupyuen/pinetime-rust-mynewt script to flash the nRF52 app which then leaves OpenOCD running, wiating for connections on port 3333 & 4444 | |
| TODO - add instrutions to start OpenOCD on its own | |
| pi@raspberrypi:~/pinetime-rust-mynewt $ openocd/bin/openocd -f scripts/nrf52-pi/swd-pi.ocd | |
| Interacting with OpenOCD | |
| Once OpenOCD is running, it is expecting a telnet session on port 4444 so you can issue commands | |
| At a terminal prompt on the Raspberry Pi, type the command: telnet 127.0.0.1 4444 | |
| This will open a telnet session to type commands into OpenOCD (see commands below) | |
| Interacting with GDB | |
| Once OpenOCD is running, it is expecting a session on port 3333 so you can use GDB on top of OpenOCD | |
| At a terminal prompt on the Raspberry Pi, type the command: arm-none-eabi-gdb | |
| At the gdb prompt, type the command: target extended-remote 127.0.0.1:3333 | |
| OpenOCD commands | |
| reset halt | |
| reset | |
| halt | |
| init | |
| exit (quit?) | |
| flash fillw 0x10001208 0xffffff00 0x01 | |
| flash banks | |
| flash list | |
| nrf5 mass-erase | |
| flash write_image image.bin | |
| reg | |
| reg pc 0x12b9a | |
| reg r3 0x0x00000004 | |
| mdw 4 # view reset vector | |
| gdb commands | |
| x 0x0 | |
| x 0x4 # view reset vector | |
| x 0x10001208 # view APPROTECT register | |
| monitor reset halt | |
| i r # view registers | |
| i r r3 | |
| set $pc = 0x12b9a | |
| set $r3 = 0x4 | |
| si # step instruction | |
| layout asm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment