From d86fef92e2180ac0aa6064df2c0b9b1e3ac0e53c Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 8 Mar 2022 09:18:19 +0000 Subject: [PATCH] Enable gdb by openocd. --- demo/jtag/Makefile | 6 ++++-- demo/jtag/gdbinit | 4 ++-- demo/jtag/link.ld | 4 ++-- demo/jtag/link_pro.ld | 16 ++++++++++++++++ soc/ahb_sif.sv | 2 +- soc/swerv.config | 20 ++++++++++---------- 6 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 demo/jtag/link_pro.ld diff --git a/demo/jtag/Makefile b/demo/jtag/Makefile index cd3b236..76d5217 100644 --- a/demo/jtag/Makefile +++ b/demo/jtag/Makefile @@ -16,6 +16,7 @@ ifdef debug endif LINK = $(DEMODIR)/link.ld +LINKPRO = $(DEMODIR)/link_pro.ld # CFLAGS for verilator generated Makefiles. Without -std=c++11 it complains for `auto` variables CFLAGS += "-std=c++11" @@ -61,8 +62,9 @@ sim: program.hex: $(TEST).o $(LINK) @echo Building $(TEST) - $(GCC_PREFIX)-gcc $(ABI) -Wl,-Map=$(BUILD_DIR)/$(TEST).map -lgcc -T$(LINK) -o $(BUILD_DIR)/$(TEST).bin $(BUILD_DIR)/$(TEST).o -nostartfiles $(TEST_LIBS) + $(GCC_PREFIX)-gcc $(ABI) -Wl,-Map=$(BUILD_DIR)/$(TEST).map -lgcc -T$(LINKPRO) -o $(BUILD_DIR)/$(TEST).bin $(BUILD_DIR)/$(TEST).o -nostartfiles $(TEST_LIBS) $(GCC_PREFIX)-objcopy -O verilog $(BUILD_DIR)/$(TEST).bin $(BUILD_DIR)/program.hex + $(GCC_PREFIX)-gcc $(ABI) -Wl,-Map=$(BUILD_DIR)/$(TEST).map -lgcc -T$(LINK) -o $(BUILD_DIR)/$(TEST).bin $(BUILD_DIR)/$(TEST).o -nostartfiles $(TEST_LIBS) $(GCC_PREFIX)-objdump -S $(BUILD_DIR)/$(TEST).bin > $(BUILD_DIR)/$(TEST).dis @echo Completed building $(TEST) @@ -76,7 +78,7 @@ openocd: openocd -f swerv.cfg gdb: - $(GDB_PREFIX) -x gdbinit + $(GDB_PREFIX) -x gdbinit ./build/jtag.bin help: @echo Possible targets: verilator help clean all verilator-build program.hex diff --git a/demo/jtag/gdbinit b/demo/jtag/gdbinit index da9dc18..6bca41d 100644 --- a/demo/jtag/gdbinit +++ b/demo/jtag/gdbinit @@ -1,3 +1,3 @@ -set debug remote 1 +# set debug remote 1 target extended-remote :3333 -set remotetimeout 5000 \ No newline at end of file +set remotetimeout 2000 \ No newline at end of file diff --git a/demo/jtag/link.ld b/demo/jtag/link.ld index f6d03cc..468c21d 100644 --- a/demo/jtag/link.ld +++ b/demo/jtag/link.ld @@ -4,11 +4,11 @@ ENTRY(_start) SECTIONS { - . = 0; + . = 0x80000000; .text_init : { *(.text_init*) } .text : { *(.text*) } _end = .; - . = 0x4000; + . = 0x80004000; .data : ALIGN(0x800) { *(.*data) *(.rodata*) STACK = ALIGN(16) + 0x2000; } .bss : { *(.bss) } . = 0xd0580000; diff --git a/demo/jtag/link_pro.ld b/demo/jtag/link_pro.ld new file mode 100644 index 0000000..5adbb40 --- /dev/null +++ b/demo/jtag/link_pro.ld @@ -0,0 +1,16 @@ + +OUTPUT_ARCH( "riscv" ) +ENTRY(_start) + +SECTIONS +{ + . = 0x0000; + .text_init : { *(.text_init*) } + .text : { *(.text*) } + _end = .; + . = 0x4000; + .data : ALIGN(0x800) { *(.*data) *(.rodata*) STACK = ALIGN(16) + 0x2000; } + .bss : { *(.bss) } + . = 0xd0580000; + .data.io : { *(.data.io) } +} diff --git a/soc/ahb_sif.sv b/soc/ahb_sif.sv index 50efd39..a80b50c 100644 --- a/soc/ahb_sif.sv +++ b/soc/ahb_sif.sv @@ -53,7 +53,7 @@ module axi_slv #( output reg [TAGW-1:0] bid ); - parameter MEM_DEPTH = 17; // memory size = 0x8000 = 32k + parameter MEM_DEPTH = 15; // memory size = 0x8000 = 32k bit [7:0] mem[(1<