From 1fe8fedea863b7ef4a43be07b2e1a469f725d2e4 Mon Sep 17 00:00:00 2001 From: Ikem Krueger Date: Thu, 21 Mar 2024 23:39:08 +0100 Subject: [PATCH 1/5] Update README.md --- README.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 55e97d2..33deb11 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,42 @@ -About +About ===== - Beta libusb code for EEPROM programmers based on the WinChipHead CH341a IC + Beta libusb code for EEPROM programmers based on the WinChipHead CH341a IC Author ====== - Written by asbokid and released under the terms of the GNU GPL, version 3, or later. - - Copyright Dec 2011, asbokid + Written by asbokid and released under the terms of the GNU GPL, version 3, or later. + + Copyright Dec 2011, asbokid Licence ======= - This is free software: you can redistribute it and/or modify it under the terms of - the latest GNU General Public License as published by the Free Software Foundation. + This is free software: you can redistribute it and/or modify it under the terms of + the latest GNU General Public License as published by the Free Software Foundation. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with this program. - If not, see . + You should have received a copy of the GNU General Public License along with this program. + If not, see . Requires ======== - gcc - GNU make - libusb-1.0 and the libusb library development files. See http://libusb.wiki.sourceforge.net/ + gcc + GNU make + libusb-1.0 and the libusb library development files. See http://libusb.wiki.sourceforge.net/ libusb-1.0-dev (on debian-based distros) Compiling ========= - gcc -o ch341eeprom ch341eeprom.c ch341funcs.c -lusb-1.0 - + gcc -o ch341eeprom ch341eeprom.c ch341funcs.c -lusb-1.0 + Running ======= @@ -45,7 +45,7 @@ Running ch341eeprom - an i2c EEPROM programming tool for the WCH CH341a IC Version 0.5 copyright (c) 2011 asbokid - This program comes with asbolutely no warranty; This is free software, + This program comes with absolutely no warranty; This is free software, and you are welcome to redistribute it under certain conditions: GNU GPL v3 License: http://www.gnu.org/licenses/gpl.html @@ -109,7 +109,7 @@ Running 0000060: 6666 6666 6666 6666 6666 6666 6666 6666 ffffffffffffffff 0000070: 7777 7777 7777 7777 7777 7777 7777 7777 wwwwwwwwwwwwwwww - asbokid@u50si1:$ sudo ./ch341eeprom -v -s 24c64 -w testimg24c64.bin + asbokid@u50si1:$ sudo ./ch341eeprom -v -s 24c64 -w testimg24c64.bin Searching USB buses for WCH CH341a i2c EEPROM programmer [1a86:5512] Found [1a86:5512] as device [7] on USB bus [2] @@ -147,12 +147,12 @@ Running 0000070: 7777 7777 7777 7777 7777 7777 7777 7777 wwwwwwwwwwwwwwww -Concluding Notes +Concluding Notes ================ The code handles the 3 byte addressing used by EEPROMS of 32kbit and greater (24c32-) It uses asynchronous USB transfers but should be portable to Microsoft Windows. - All comments and contributions welcomed! - - asbokid - Dec 2011 + All comments and contributions welcomed! + + asbokid - Dec 2011 From d995f8764bc6413d620743e54742185438909989 Mon Sep 17 00:00:00 2001 From: Ikem Krueger Date: Thu, 21 Mar 2024 23:42:47 +0100 Subject: [PATCH 2/5] Fix too many arguments for format --- ch341eeprom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ch341eeprom.c b/ch341eeprom.c index 61ef4c1..ded9be4 100644 --- a/ch341eeprom.c +++ b/ch341eeprom.c @@ -136,10 +136,10 @@ int main(int argc, char **argv) { } if(!(devHandle = ch341configure(USB_LOCK_VENDOR, USB_LOCK_PRODUCT))) { - fprintf(stderr, "Couldnt configure USB device\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT); + fprintf(stderr, "Couldn't configure USB device %x:%x\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT); goto shutdown; } - fprintf(verbout, "Configured USB device\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT); + fprintf(verbout, "Configured USB device %x:%x\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT); if(ch341setstream(devHandle, CH341_I2C_STANDARD_SPEED) < 0) { fprintf(stderr, "Couldnt set i2c bus speed\n"); From 7416377448a896bf1c2a1eff0baa57e20cc50b7e Mon Sep 17 00:00:00 2001 From: Ikem Krueger Date: Thu, 21 Mar 2024 23:43:11 +0100 Subject: [PATCH 3/5] Fix typos --- ch341eeprom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ch341eeprom.c b/ch341eeprom.c index ded9be4..731c110 100644 --- a/ch341eeprom.c +++ b/ch341eeprom.c @@ -41,7 +41,7 @@ int main(int argc, char **argv) { static char version_msg[] = "ch341eeprom - an i2c EEPROM programming tool for the WCH CH341a IC\n" \ "Version " CH341TOOLVERSION " copyright (c) 2011 asbokid \n\n" \ - "This program comes with asbolutely no warranty; This is free software,\n" \ + "This program comes with absolutely 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"; @@ -142,7 +142,7 @@ int main(int argc, char **argv) { fprintf(verbout, "Configured USB device %x:%x\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT); if(ch341setstream(devHandle, CH341_I2C_STANDARD_SPEED) < 0) { - fprintf(stderr, "Couldnt set i2c bus speed\n"); + fprintf(stderr, "Couldn't set i2c bus speed\n"); goto shutdown; } fprintf(verbout, "Set i2c bus speed to [100kHz]\n"); From dc6a549deedd93bfd64013dc8e00f2ad337c8088 Mon Sep 17 00:00:00 2001 From: Ikem Krueger Date: Thu, 21 Mar 2024 23:44:17 +0100 Subject: [PATCH 4/5] Fix 'libusb_set_debug' is deprecated --- ch341funcs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ch341funcs.c b/ch341funcs.c index 23c5236..6b8c3c5 100644 --- a/ch341funcs.c +++ b/ch341funcs.c @@ -59,7 +59,11 @@ struct libusb_device_handle *ch341configure(uint16_t vid, uint16_t pid) { return NULL; } - libusb_set_debug(NULL, 3); // maximum debug logging level +#if LIBUSB_API_VERSION <= 0x01000106 + libusb_set_debug(NULL, 3); // maximum debug logging level +#else + libusb_set_option(NULL, LIBUSB_OPTION_LOG_LEVEL, 3); // maximum debug logging level +#endif fprintf(verbout, "Searching USB buses for WCH CH341a i2c EEPROM programmer [%04x:%04x]\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT); From 330d09e00bdbf4f26ff4824b4153db778061866e Mon Sep 17 00:00:00 2001 From: Ikem Krueger Date: Thu, 21 Mar 2024 23:45:01 +0100 Subject: [PATCH 5/5] Fix multiple definition of 'readbuf' --- ch341eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch341eeprom.c b/ch341eeprom.c index 731c110..23b4236 100644 --- a/ch341eeprom.c +++ b/ch341eeprom.c @@ -29,7 +29,7 @@ #include "ch341eeprom.h" FILE *debugout, *verbout; -uint8_t *readbuf = NULL; +static uint8_t *readbuf = NULL; int main(int argc, char **argv) { int i, ret = 0, eepromsize = 0, bytesread = 0;