commit c998fef594732fd55cd8d5517162804486951cef
parent e00299f7a61645dc09d35123a7a8b881391c43ce
Author: Brian Swetland <swetland@frotz.net>
Date: Mon, 6 Oct 2014 18:09:54 -0700
mem: simple read/write phys word tool
Diffstat:
M | Makefile | | | 9 | +++++++-- |
A | mem.c | | | 45 | +++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -3,7 +3,7 @@ CFLAGS := -Wall -O0 -g
LIBS := -lusb-1.0 -lrt
-all: zynq fpga debug
+all: zynq fpga debug mem
JTAG_OBJS := jtag-mpsse-driver.o jtag-core.o jtag.o
$(JTAG_OBJS): jtag.h jtag-driver.h
@@ -30,5 +30,10 @@ $(DEBUG_OBJS): jtag.h jtag-driver.h
debug: $(DEBUG_OBJS)
$(CC) -o debug $(DEBUG_OBJS) $(LIBS)
+MEM_OBJS := mem.o dap.o jtag-core.o jtag-mpsse-driver.o
+$(MEM_OBJS): dap.h jtag.h jtag-driver.h
+mem: $(MEM_OBJS)
+ $(CC) -o mem $(MEM_OBJS) $(LIBS)
+
clean:
- rm -f *.o jtag dap-test zynq fpga debug
+ rm -f *.o jtag dap-test zynq fpga debug mem
diff --git a/mem.c b/mem.c
@@ -0,0 +1,45 @@
+// Copyright 2014 Brian Swetland <swetland@frotz.net>
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "dap.h"
+
+int main(int argc, char **argv) {
+ JTAG *jtag;
+ DAP *dap;
+
+ if (argc < 2) return -1;
+
+ if (jtag_mpsse_open(&jtag)) return -1;
+ if ((dap = dap_init(jtag, 0x4ba00477)) == NULL) return -1;
+ if (dap_attach(dap)) return -1;
+
+ if (argc == 2) {
+ u32 x;
+ if (dap_mem_rd32(dap, 0, strtoul(argv[1], 0, 0), &x)) return -1;
+ printf("%08x\n", x);
+ } else if (argc == 3) {
+ return dap_mem_wr32(dap, 0, strtoul(argv[1], 0, 0), strtoul(argv[2], 0, 0));
+ } else {
+ return -1;
+ }
+ return 0;
+}
+