annotate cp2102/patch_ee_file.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 915a6fa7723e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
92
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program reads a CP2102 EEPROM image from an Intel HEX file,
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * applies patches to it from a patch specification file, and writes out
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * a new Intel HEX image.
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "cp210x_defs.h"
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 u_char eeprom[SIZE_EEPROM];
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 main(argc, argv)
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char **argv;
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 FILE *outf;
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (argc != 4) {
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 fprintf(stderr,
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 "usage: %s input-hex-file patch-spec output-hex-file\n",
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 argv[0]);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 exit(1);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 read_intel_hex(argv[1]);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 apply_eeprom_patch_file(argv[2]);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 outf = fopen(argv[3], "w");
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (!outf) {
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 perror(argv[3]);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 exit(1);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 intel_hex_out(eeprom, outf);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 fclose(outf);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 exit(0);
915a6fa7723e cp2102-patch-ee-image program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }