From ff869bd768dcc9b86f4fc6a312b7b6e9ba883591 Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 9 Aug 2023 17:18:52 +0200 Subject: [PATCH] fv-1 specific defaults --- src/ch341eeprom.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/ch341eeprom.c b/src/ch341eeprom.c index cadb522..d29f63e 100644 --- a/src/ch341eeprom.c +++ b/src/ch341eeprom.c @@ -1,10 +1,10 @@ // -// ch341eeprom programmer version 0.1 (Beta) +// ch341eeprom programmer version 0.1 (Beta) // // Programming tool for the 24Cxx serial EEPROMs using the Winchiphead CH341A IC // -// (c) December 2011 asbokid -// +// (c) December 2011 asbokid +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or @@ -18,7 +18,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include +#include //#include #include #include @@ -32,52 +32,49 @@ FILE *debugout, *verbout; uint8_t *readbuf = NULL; int main(int argc, char **argv) { - int i, ret = 0, eepromsize = 0, bytesread = 0; - uint8_t debug = FALSE, verbose = FALSE; + int i, ret = 0, eepromsize = 4096, bytesread = 0; + uint8_t debug = FALSE, verbose = TRUE; struct libusb_device_handle *devHandle = NULL; char *filename = NULL, eepromname[12], operation = 0; FILE *fp; - static char version_msg[] = - "ch341eeprom - an i2c EEPROM programming tool for the WCH CH341a IC\n" \ + static char version_msg[] = + "fvflash - an i2c EEPROM programming tool for the WCH CH341a IC\n" \ "Version " CH341TOOLVERSION " copyright (c) 2011 asbokid \n\n" \ + "modified by for the specific use case of fv-1 programming on macos\n\n" \ "This program comes with asbolutely no warranty; This is free software,\n" \ "and you are welcome to redistribute it under certain conditions:\n" \ "GNU GPL v3 License: http://www.gnu.org/licenses/gpl.html\n"; - static char usage_msg[] = + static char usage_msg[] = "Usage:\n" \ " -h, --help display this text\n" \ - " -v, --verbose verbose output\n" \ " -d, --debug debug output\n" \ - " -s, --size size of EEPROM {24c32|24c64}\n" \ + " -s, --size size of EEPROM {24c32|24c64} default=24c32\n" \ " -e, --erase erase EEPROM (fill with 0xff)\n" \ " -w, --write write EEPROM with image from filename\n" \ " -r, --read read EEPROM and save image to filename\n\n" \ - "Example: ch341eeprom -v -s 24c64 -w bootrom.bin\n"; + "Example: fvflash bootrom.bin\n"; static struct option longopts[] = { {"help", no_argument, 0, 'h'}, - {"verbose", no_argument, 0, 'v'}, {"debug", no_argument, 0, 'd'}, {"erase", no_argument, 0, 'e'}, {"size", required_argument, 0, 's'}, {"read", required_argument, 0, 'r'}, - {"write", required_argument, 0, 'w'}, {0, 0, 0, 0} }; while (TRUE) { int32_t optidx = 0; - int8_t c = getopt_long(argc,argv,"hvdes:w:r:", longopts, &optidx); - if (c == -1) + int8_t c = getopt_long(argc,argv,"hdes:r:", longopts, &optidx); + if (c == -1) { break; + } switch (c) { case 'h': fprintf(stdout, "%s\n%s", version_msg, usage_msg); return 0; - case 'v': verbose = TRUE; - break; case 'd': debug = TRUE; break; case 's': if((eepromsize = parseEEPsize(optarg)) > 0) @@ -99,16 +96,16 @@ int main(int argc, char **argv) { goto shutdown; } break; - case 'w': if(!operation) { + default: + if(!operation) { operation = 'w'; - filename = (char *) malloc(strlen(optarg)+1); + filename = (char *) malloc(strlen(argv[optidx])+1); strcpy(filename, optarg); } else { fprintf(stderr, "Conflicting command line options\n"); goto shutdown; - } + } break; - default : case '?': fprintf(stdout, "%s", version_msg); fprintf(stderr, "%s", usage_msg); goto shutdown;