Hey guys,
Been fighting with this for a while on my quest to be a better baremetal dev. First thing for me was getting a flashing/debugging interface, which we have in the Xilinx SDK, but if you're like me, you detest Eclipse with a passion bordering on murderous. So, I went through for a while and tried to figure out how to get GDB remote debugging over JTAG working with the Cortex-A9.
This is definitely not going to be a 1-size-fits-all solution, and there will absolutely need to be some modifications, so just be aware YMMV.
Anyway, my hardware:
-Snickerdoodle Black
-AchyBreaky Breakout Board, rev 2.0
-Xilinx Platform Cable USB II
This was all done using tools made available in the vivado free edition on Ubuntu 16.10
Instructions:
1. Navigate to your install directory (default /opt/Xilinx/.... iirc), henceforth called <install_dir>. Run the following command:
$ . <install_dir>/Vivado/2017.1/settings64.sh
This sets up the environment variables and path's needed to run the software used. Yes, the "dot space" is necessary. Informs the bash shell to run the script, save environment variable changes, and then return to allowing user input.
2. Enter the following in the bash shell:
$ HW_SERVER_ALLOW_PL_ACCESS=1 hw_server -Llogfile.txt -l0xFC00 &
This spins up the hardware communication server needed by xsdb to communicate over the JTAG interface.
3. You're going to want to copy the following to a TCL script somewhere as <tcl_script_name>.tcl and modify paths to correctly access your files. Mine is currently referencing a modified example project from the snickerdoodle examples repo, so you may need to run the xilinx eclipse fork once to get this working.
source <project_dir>/<project_dir>.sdk/base_block_design_wrapper_hw_platform_0/ps7_init.tcl
targets -set -nocase -filter {name =~"APU*" && jtag_cable_name =~ "Platform Cable USB II 000013bd55ee01"} -index 0
stop
ps7_init
ps7_post_config
targets -set -nocase -filter {name =~ "ARM*#0" && jtag_cable_name =~ "Platform Cable USB II 000013bd55ee01"} -index 0
rst -processor
targets -set -nocase -filter {name =~ "ARM*#0" && jtag_cable_name =~ "Platform Cable USB II 000013bd55ee01"} -index 0
dow <project_dir>/<project_dir>.sdk/hello_test/Debug/hello_test.elf
bpadd -addr &main
4. In your bash shell where you ran hw_server, run:
Which starts the Xilinx Shell Debugger, and then in that shell run:
xsdb% source <tcl_script_name>.tcl
This resets the board, spins up the debugging layer, adds the initial breakpoint, and flashes your .elf file. Once done, run:
xsdb% xmd
<initialization messages>
XMD% connect arm hw
5. With that, you should have your JTAG chain all initialized and your GDB target server open! Now, all you have to do is open another terminal, run this again:
$ . <install_dir>/Vivado/2017.1/settings64.sh
and finally, you can run the following to get your GDB shell:
$ arm-xilinx-eabi-gdb hello_test.elf
(gdb) target remote :1234
And you're all set! Let me know if there's anything I can do to make this clearer or clean things up. I know I was really frustrated with getting this set up so I hope it helps someone.
--hedge