int main(int argc, char **argv) { unsigned bits; if (jtag_open() < 0) return -1; if (jtag_reset() < 0) return -1; if (jtag_dr(32, 0, &bits) < 0) return -1; fprintf(stderr,"IDCODE: %08x\n", bits); if (jtag_open_virtual_device(0xffffffff)) return -1; jtag_close(); return 0; }
static void romloader_openocd_close_instance(void *pvHandle) { command_context_t *cmd_ctx; target_t *target; int iResult; wxString strMsg; /* cast the handle to the command context */ cmd_ctx = (command_context_t*)pvHandle; strMsg.Printf(wxT("closing romloader openocd at %p"), cmd_ctx); wxLogMessage(strMsg); /* NOTE: this seems to work with ftd2xx, but not with libftdi */ if( jtag!=NULL && jtag->quit!=NULL ) { jtag->quit(); } /* close all subsystems */ iResult = jtag_close(cmd_ctx); if( iResult!=ERROR_OK ) { strMsg.Printf(wxT("failed to close jtag interface: %d"), iResult); wxLogWarning(strMsg); } iResult = target_close(cmd_ctx); if( iResult!=ERROR_OK ) { strMsg.Printf(wxT("failed to close target interface: %d"), iResult); wxLogWarning(strMsg); } // free commandline interface command_done(cmd_ctx); }
int main (void) { type_jtagnode node; int const probe_width = 16; UCHAR buffer [(probe_width >> 3) + 1]; int ret = 0, val = 0; int k = 0, n = 0; int const required_bytes = 100000; FILE * f = NULL; bool bad_sample = false; int next_status = 0; f = fopen ("c_probe.bin","wb"); if (!f) { fprintf (stdout,"Unable to write dump file\n"); return (1); } ret = jtag_init(0,0,0,0,C_PROBE_ID,0,"jtag_c_probe", 1, &node); if (ret < 0) { printf("\nfailed to find jtag node"); return 0; } fprintf (stdout,"\n\nCapturing %d bytes to c_probe.bin...\n",required_bytes); k=0; while (k<required_bytes) { if (k >= next_status) { fprintf (stdout,"%d pct complete\n", k * 100 / required_bytes); next_status += 2000; } // read from probe. To write reverse 0 and buffer args jtag_command(&node, 0, probe_width, 0, buffer); if (buffer[1] == 0 && buffer[0] == 0) { // probe isn't ready } else { bad_sample = false; for (n=0; n<2; n++) { if (buffer[n] >= 'A' && buffer[n] <= 'F') { buffer[n] = buffer[n] - 'A' + 10; } else if (buffer[n] >= 'a' && buffer[n] <= 'f') { buffer[n] = buffer[n] - 'a' + 10; } else if (buffer[n] >= '0' && buffer[n] <= '9') { buffer[n] = buffer[n] - '0'; } else { bad_sample = true; } } if (bad_sample) { fprintf (stdout,"Read bad sample - link is corrupt?\n"); } else { val = buffer[1]; val <<= 4; val |= buffer[0]; fprintf (f,"%c",val); k++; } } } jtag_close(&node); fclose (f); fprintf (stdout,"done\n"); return (0); }