From 53c4181f7f211f1667f576c875bf2b8cb03047f0 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 30 Apr 2024 15:59:30 +0100 Subject: [PATCH] swd: Add debug script for GDB, and openocd command line --- 00-README-DEBUG | 27 +++++++++++++++++++++++++++ scripts/gdb-commands | 6 ++++++ 2 files changed, 33 insertions(+) create mode 100644 00-README-DEBUG create mode 100644 scripts/gdb-commands diff --git a/00-README-DEBUG b/00-README-DEBUG new file mode 100644 index 00000000..688b7586 --- /dev/null +++ b/00-README-DEBUG @@ -0,0 +1,27 @@ +# Run OpenCD: +~/install/bin/openocd -s ~/install/share/openocd/scripts/ -f interface/cmsis-dap.cfg -f target/at32f4xx.cfg + +# In another window, run GDB (note elf image name is hardcoded in the script): +gdb-multiarch -x scripts/gdb-commands + +# Telnet commands: +telnet localhost 4444 +mdb 0x1fffc000 512 # Read USD on 435 +mdb 0x1ffff800 512 # Read USD on 415 +reset init # FPEC operations need to be in reset state +at32f4xx mass_erase +at32f4xx usd_erase # NB. Enables RDP! +at32f4xx usd_write 0 0xa5 # Disable RDP -- Do this before resetting!!!!!! + +# If you reset after usd_erase, you can no longer read any flash including USD! +# To get out of this do the following: +at32f4xx usd_write 0 0xa5 # Slow (it mass erases main Flash) +reset init # Makes Flash and USD readable again + +# Oh no, after a USD erase, AT32F435 1MB+ Flash parts only have 128kB SRAM! +# To fix this: +at32f4xx usd_write 8 0xfa # Sets EOPB0 to 384kB SRAM mode + +# Some more general stuff: +flash write_image [erase] flashfloppy/out/at32f435/debug/floppy/target.hex +reset run|halt|init diff --git a/scripts/gdb-commands b/scripts/gdb-commands new file mode 100644 index 00000000..c2fb16eb --- /dev/null +++ b/scripts/gdb-commands @@ -0,0 +1,6 @@ +file /home/keir/flashfloppy/out/at32f435/debug/floppy/target.elf +target extended-remote localhost:3333 +# Reset the target and call its init script +monitor reset init +# Halt the target. The init script should halt the target, but just in case +monitor halt