Hello,
Here's how to do it:
- Compile the code below (you know what to change in the code for various memories)
- Get your NI GPIB adapter and attach it to the scope
- Put NVRAM protection switch (S1002) to forward position
- Turn the scope on
- Run the PC program
Hopefully the result of this is loads and loads of firmware and NVRAM backups uploaded somewhere safe like ko4bb-site.
Have fun.
...
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ni488.h"
void GpibError(const char * msg); /* Error function declaration */
int Device = 0; /* Device unit descriptor */
int BoardIndex = 0; /* Interface Index (GPIB0=0,GPIB1=1,etc.) */
int main(int argc, char *argv[])
{
FILE *outfile;
int f;
unsigned long addr, straddr, endaddr, data;
unsigned short lenght;
unsigned char checksum;
unsigned char str[0x100];
int PrimaryAddress = 29; /* Primary address of the device */
int SecondaryAddress = 0x7E; /* Secondary address of the device */
unsigned char Buffer1[0x500]; /* Read buffer */
Device = ibdev( /* Create a unit descriptor handle */
BoardIndex, /* Board Index (GPIB0 = 0, GPIB1 = 1, ...) */
PrimaryAddress, /* Device primary address */
SecondaryAddress, /* Device secondary address */
T3s, /* Timeout setting (T10s = 10 seconds) */
1, /* Assert EOI line at end of write */
0); /* EOS termination mode */
if (ibsta & ERR) { /* Check for GPIB Error */
GpibError("ibdev Error");
}
ibclr(Device); /* Clear the device */
if (ibsta & ERR) {
GpibError("ibclr Error");
}
/* Attempt to read TDS544A flash ROM contents */
outfile = fopen("KRNLdump.bin","wb");
printf("\n");
// straddr = 0x01000000L; /* Start of flash ROM */
// endaddr = 0x01FFFFFFL; /* End of flash ROM */
// straddr = 0x04000000L; /* Start of TDS544A NVRAM */
// endaddr = 0x0407FFFFL; /* End of TDS544A NVRAM */
straddr = 0x00000000L; /* Start of Kernel ROM */
endaddr = 0x0003FFFFL; /* End of Kernel ROM */
addr = straddr;
do {
/* Read memory message */
str[0] = 'm'; /* m - read memory command */
str[1] = 0x00; /* checksum - fill later */
str[2] = 0x00; /* message lenght MSB */
str[3] = 0x08; /* message lenght LSB */
str[4] = (unsigned char)(addr >> 24 & 0xFF);
str[5] = (unsigned char)(addr >> 16 & 0xFF);
str[6] = (unsigned char)(addr >> 8 & 0xFF);
str[7] = (unsigned char)(addr & 0xFF);
str[8] = 0x00; /* data lenght - try 16 bytes first */
str[9] = 0x00;
str[10] = 0x04;
str[11] = 0x00;
checksum = str[0] + str[2] + str[3];
for(f = 4; f < 12; f++) checksum += str[f];
str[1] = (unsigned char) checksum;
//printf("\nSending:\n");
//for(f = 0; f < 12; f++) printf("%02X ", str[f]);
ibwrt(Device, str, 12); /* Send */
if (ibsta & ERR) GpibError("ibwrt Error");
/* Read Acknowledge (plus-sign msg) */
ibrd(Device, Buffer1, 1); /* Read up to x bytes from the device */
if (ibsta & ERR) GpibError("ibrd Error");
//printf("\nAck reveiced:\n");
//for(f = 0; f < 1; f++) printf("%02X ", Buffer1[f]);
/* Read reply message */
ibrd(Device, Buffer1, 0x404); /* Read up to x bytes from the device */
if (ibsta & ERR) GpibError("ibrd Error");
//printf("\nReceived:\n");
//for(f = 0; f < 0x404; f++) printf("%02X ", Buffer1[f]);
/* Save buffer contents */
for(f = 4; f < 0x404; f++)
{
fputc(Buffer1[f], outfile);
}
/* Send Acknowledgement (plus-sign msg) */
str[0] = '+';
ibwrt(Device, str, 1); /* Send */
if (ibsta & ERR) GpibError("ibwrt Error");
addr += 0x400;
} while(addr <= endaddr);
fclose(outfile);
ibonl(Device, 0); /* Take the device offline */
if (ibsta & ERR) GpibError("ibonl Error");
system("PAUSE");
}
void GpibError(const char *msg) {
printf("%s\n", msg);
printf("ibsta = 0x%x <", ibsta);
if (ibsta & ERR ) printf(" ERR");
if (ibsta & TIMO) printf(" TIMO");
if (ibsta & END ) printf(" END");
if (ibsta & SRQI) printf(" SRQI");
if (ibsta & RQS ) printf(" RQS");
if (ibsta & CMPL) printf(" CMPL");
if (ibsta & LOK ) printf(" LOK");
if (ibsta & REM ) printf(" REM");
if (ibsta & CIC ) printf(" CIC");
if (ibsta & ATN ) printf(" ATN");
if (ibsta & TACS) printf(" TACS");
if (ibsta & LACS) printf(" LACS");
if (ibsta & DTAS) printf(" DTAS");
if (ibsta & DCAS) printf(" DCAS");
printf (" >\n");
printf ("Iberr() = %d", iberr);
if (iberr == EDVR) printf(" EDVR <Driver error>\n");
if (iberr == ECIC) printf(" ECIC <Not Controller-In-Charge>\n");
if (iberr == ENOL) printf(" ENOL <No Listener>\n");
if (iberr == EADR) printf(" EADR <Address error>\n");
if (iberr == EARG) printf(" EARG <Invalid argument>\n");
if (iberr == ESAC) printf(" ESAC <Not System Controller>\n");
if (iberr == EABO) printf(" EABO <Operation aborted>\n");
if (iberr == ENEB) printf(" ENEB <No GPIB board>\n");
if (iberr == EOIP) printf(" EOIP <Async I/O in progress>\n");
if (iberr == ECAP) printf(" ECAP <No capability>\n");
if (iberr == EFSO) printf(" EFSO <File system error>\n");
if (iberr == EBUS) printf(" EBUS <Command error>\n");
if (iberr == ESTB) printf(" ESTB <Status byte lost>\n");
if (iberr == ESRQ) printf(" ESRQ <SRQ stuck on>\n");
if (iberr == ETAB) printf(" ETAB <Table Overflow>\n");
if (iberr == ELCK) printf(" ELCK <Lock error>\n");
if (iberr == EARM) printf(" EARM <Ibnotify rearm error>\n");
if (iberr == EHDL) printf(" EHDL <Invalid Handle>\n");
if (iberr == EWIP) printf(" EWIP <Wait already in progress>\n");
if (iberr == ERST) printf(" ERST <Notification cancelled due to reset>\n");
if (iberr == EPWR) printf(" EPWR <Power error>\n");
printf("Ibcnt() = %u\n", ibcnt);
printf("\n");
/* Call ibonl to take the device and interface offline */
//ibonl(Device, 0);
//system("PAUSE");
//exit(1);
}