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 diff --git a/ch341eeprom.c b/ch341eeprom.c index 61ef4c1..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; @@ -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"; @@ -136,13 +136,13 @@ 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"); + fprintf(stderr, "Couldn't set i2c bus speed\n"); goto shutdown; } fprintf(verbout, "Set i2c bus speed to [100kHz]\n"); 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);