jtagonizer

yet another JTAG tool
git clone http://frotz.net/git/jtagonizer.git
Log | Files | Refs | README

mem.c (1209B)


      1 // Copyright 2014 Brian Swetland <swetland@frotz.net>
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 // http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #include <stdio.h>
     16 #include <stdlib.h>
     17 #include <string.h>
     18 
     19 #include <unistd.h>
     20 #include <fcntl.h>
     21 
     22 #include "dap.h"
     23 
     24 int main(int argc, char **argv) {
     25 	JTAG *jtag;
     26 	DAP *dap;
     27 
     28 	if (argc < 2) return -1;
     29 
     30 	if (jtag_mpsse_open(&jtag)) return -1;
     31 	if ((dap = dap_init(jtag, 0x4ba00477)) == NULL) return -1;
     32 	if (dap_attach(dap)) return -1;
     33 
     34 	if (argc == 2) {
     35 		u32 x;
     36 		if (dap_mem_rd32(dap, 0, strtoul(argv[1], 0, 0), &x)) return -1;
     37 		printf("%08x\n", x);
     38 	} else if (argc == 3) {
     39 		return dap_mem_wr32(dap, 0, strtoul(argv[1], 0, 0), strtoul(argv[2], 0, 0));
     40 	} else {
     41 		return -1;
     42 	}	
     43 	return 0;
     44 }
     45