Checksum & Eprom Programmers

 

it is a simple
addition of the bytes in a 16 Bit Variable (or 32 Bit in the case of
conitec, dataio chiplab, advantech labtool-38). That's no CRC at all.. it is a checksum only.

~/src/checksum $ ./ctest 2716.bin
File 2716.bin: 2048 Bytes!
Memory allocated
file read
cksum=23054 5A0E

 

The simple C program, it's more filesystem operations then actual
work...
-----------------------------------------------------------------

#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <stdlib.h>
#include <malloc_np.h>
#include <sys/stat.h>


int main(int argc,char* argv[])
{

uint8_t ebyte;
int epaddr;
uint16_t cksum;
uint8_t * bufp;
struct stat infstat;
int fno;

FILE * fp;

if(argc < 2)
{
fprintf(stderr,"Error Filename required!\n");
fprintf(stderr,"usage: %s <infile>\n", argv[0]);
exit (-1);
}


if((fp=fopen(argv[1],"r"))==NULL)
{
fprintf(stderr,"Error, can't open infile!\n");
fprintf(stderr,"usage: %s <infile>\n", argv[0]);
exit (-1);
}
fno=fileno(fp);

if(fstat(fno,&infstat)!=0)
{
fprintf(stderr,"fstat on %s failed!\n", argv[1]);
fclose(fp);
exit (-1);
}

printf("File %s: %ld Bytes!\n",argv[1],infstat.st_size);


if((bufp=(uint8_t *)calloc((size_t)infstat.st_size,sizeof(char)))==NULL)
{
fprintf(stderr,"Error, can't allocate %ld memory!\n",infstat.st_size);
fclose(fp);
exit (-1);
}
printf("Memory allocated\n");

if(fread(bufp,sizeof(uint8_t),infstat.st_size,fp)!=infstat.st_size)
{
fprintf(stderr,"Error, can't read from file %s!\n",argv[1]);
fclose(fp);
exit (-1);
}
printf("file read\n");


for(epaddr=0; epaddr<infstat.st_size;epaddr++)
{
cksum+=*bufp++;
}
printf("cksum=%d %04X\n",cksum,cksum);

fclose(fp);
free(bufp);

return 0;
}

 


In the unlikely event you need a simple CRC for something else, I have seen this used. It's taken from a Chinese user manual for a barcode scanner. I needed to implement this crc on my end to match theirs. It takes a pointer to a buffer and the number of bytes to process.

 

/*
.------------------------------------------------------------------------------
| uint16_t crc_cal_by_bit(uint8_t *ptr, uint16_t len);
`------------------------------------------------------------------------------
*/
uint16_t crc_cal_by_bit(uint8_t *ptr, uint16_t len)
{
uint32_t crc;
uint8_t i;
uint8_t dat;

crc = 0;
while(len-- != 0)
{
dat = *ptr;

for(i=0x80; i!=0; i>>=1)
{
crc <<= 1;
if((crc & 0x10000) != 0) // Last CRC * 2 ,if the first one is 1,so divide 0x11021
crc ^= 0x11021;
if((dat & i) != 0) // If the standard is 1,so CRC = last CRC + standard CRC_CCITT
crc ^= 0x1021;
}

ptr++;
}

return (uint16_t)crc;
}

 

 


The only checksum algorithm I've ever found specific to EPROMs is the "Kontron CRC". most of them use an additive checksum, which is almost worthless really. The Kontron CRC was used in the prestigious Kontron line of programmers.

For that alogorithm, you will need to find Appendix "E.2 KONTRON CRC CHECKSUM ALGORITHM" of the MPP-80S/EPP-80/GPP-80. I have several of the PDFs, but none of them have that appendix. I do have notes from when I taught this back in the late 1980's and early 1990's though.

Kontron_MPP-80_EPP-80_programmer_resources.htm

 

 

 

If you look forward for other information about this topic, do not hesitate to contact me by e-mail at: matthieu.benoit@free.fr .
Important Notice: Also if you have any data about this topic, do not hesitate to contribute to this page.

Si vous recherchez des informations pour ce sujet, vous pouvez me contacter par e-mail : matthieu.benoit@free.fr . De même si vous avez des informations sur ce sujet, n'hésitez pas à contribuer à cette page.

Retour au sommaire

Retour à la Page d'accueil

M-à-j: 21 avril, 2024 .

matthieu.benoit@free.fr