FreeCalypso > hg > fc-usbser-tools
view fteeprom/ftee-fix-cksum.c @ 105:1e820ed0904e
Installed-binaries: list of binaries installed by this package
I am establishing a new convention for all FreeCalypso tools, across
different packages and source repositories: each FC tools package
will have a file name Installed-binaries listing all user-invokable
binaries that package installs in /opt/freecalypso/bin. These files
are to serve as an aid to users and distro package maintainers who
prefer to not add /opt/freecalypso/bin to their PATH. The alternative
to adding this directory to PATH is to create a symlink for every
installed binary in some standard location such as /usr/bin or
/usr/local/bin, pointing to the actual binary in /opt/freecalypso/bin;
having a list of all FC-installed binaries in a standardized format
will allow this process to be automated.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 29 Sep 2023 19:42:53 +0000 |
parents | 85256d5aa559 |
children |
line wrap: on
line source
/* * Sometimes it is useful to be able to edit FTDI EEPROM hex images * by hand, for special situations and experiments that are too unique * to automate. However, the need for passing checksum gets in the way. * This program reads an FTDI EEPROM image from a file (or from stdin), * recomputes a new checksum and re-emits the checksum-fixed EEPROM hex * image on stdout. */ #include <sys/types.h> #include <string.h> #include <strings.h> #include <stdio.h> #include <stdlib.h> extern unsigned eeprom_size; extern u_short eeprom[256]; static unsigned chksum_size; static void do_checksum() { u_short chksum = 0xAAAA; unsigned n; for (n = 0; n < chksum_size - 1; n++) { chksum ^= eeprom[n]; chksum = (chksum << 1) | (chksum >> 15); } eeprom[n] = chksum; } static void emit_output() { unsigned n, col; for (n = 0; n < eeprom_size; n++) { col = n & 7; if (col == 0) printf("%02X:", n * 2); printf(" %04X", eeprom[n]); if (col == 7) putchar('\n'); } } main(argc, argv) char **argv; { if (argc != 2) { fprintf(stderr, "usage: %s eeprom-image-file\n", argv[0]); exit(1); } if (strcmp(argv[1], "-")) read_eeprom_from_file(argv[1]); else read_eeprom_from_stdin(); switch (eeprom_size) { case 64: chksum_size = 64; break; case 128: case 256: chksum_size = 128; break; default: fprintf(stderr, "BUG: invalid EEPROM size not caught earlier\n"); exit(1); } do_checksum(); emit_output(); exit(0); }