├── pics
├── DSCF2542.JPG
├── DSCF2544.JPG
├── DSCF2546.JPG
├── DSCF2547.JPG
└── programmer.jpg
├── ch341docs
├── CH341DS1.PDF
├── CH341EVT.ZIP
├── ch341_productbrief-en.pdf
├── CH341DLL.H
└── ch341_i2c_example_in_english.c
├── windowsonlysoftware
├── USB 24Cxxx.exe
├── chineseonly.jpg
├── USB_24cxx_programmer.doc
├── USB_24cxx_programmer.pdf
├── englishbuttonlabels.jpg
├── USB programer driver
│ ├── SETUP.EXE
│ ├── USBIOX.DLL
│ ├── USBIOX.SYS
│ └── USBIOX.INF
└── Screenshot at 2011-11-05 01:29:57.png
├── wiresharkusbsniffing
├── 24c01_read.pcap
├── 24c02_read.pcap
├── ch341a_windriver_24c64_read.pcap
└── sniffed.txt
├── ch341eeprom.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── 99-CH341.rules
├── .gitignore
├── mktestimg.c
├── README.md
├── Makefile
├── ch341eeprom.c
├── ch341funcs.c
├── ch341eeprom.h
└── COPYING
/pics/DSCF2542.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/pics/DSCF2542.JPG
--------------------------------------------------------------------------------
/pics/DSCF2544.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/pics/DSCF2544.JPG
--------------------------------------------------------------------------------
/pics/DSCF2546.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/pics/DSCF2546.JPG
--------------------------------------------------------------------------------
/pics/DSCF2547.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/pics/DSCF2547.JPG
--------------------------------------------------------------------------------
/pics/programmer.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/pics/programmer.jpg
--------------------------------------------------------------------------------
/ch341docs/CH341DS1.PDF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/ch341docs/CH341DS1.PDF
--------------------------------------------------------------------------------
/ch341docs/CH341EVT.ZIP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/ch341docs/CH341EVT.ZIP
--------------------------------------------------------------------------------
/windowsonlysoftware/USB 24Cxxx.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/USB 24Cxxx.exe
--------------------------------------------------------------------------------
/ch341docs/ch341_productbrief-en.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/ch341docs/ch341_productbrief-en.pdf
--------------------------------------------------------------------------------
/windowsonlysoftware/chineseonly.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/chineseonly.jpg
--------------------------------------------------------------------------------
/wiresharkusbsniffing/24c01_read.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/wiresharkusbsniffing/24c01_read.pcap
--------------------------------------------------------------------------------
/wiresharkusbsniffing/24c02_read.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/wiresharkusbsniffing/24c02_read.pcap
--------------------------------------------------------------------------------
/windowsonlysoftware/USB_24cxx_programmer.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/USB_24cxx_programmer.doc
--------------------------------------------------------------------------------
/windowsonlysoftware/USB_24cxx_programmer.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/USB_24cxx_programmer.pdf
--------------------------------------------------------------------------------
/windowsonlysoftware/englishbuttonlabels.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/englishbuttonlabels.jpg
--------------------------------------------------------------------------------
/windowsonlysoftware/USB programer driver/SETUP.EXE:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/USB programer driver/SETUP.EXE
--------------------------------------------------------------------------------
/windowsonlysoftware/USB programer driver/USBIOX.DLL:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/USB programer driver/USBIOX.DLL
--------------------------------------------------------------------------------
/windowsonlysoftware/USB programer driver/USBIOX.SYS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/USB programer driver/USBIOX.SYS
--------------------------------------------------------------------------------
/wiresharkusbsniffing/ch341a_windriver_24c64_read.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/wiresharkusbsniffing/ch341a_windriver_24c64_read.pcap
--------------------------------------------------------------------------------
/windowsonlysoftware/Screenshot at 2011-11-05 01:29:57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/command-tab/ch341eeprom/HEAD/windowsonlysoftware/Screenshot at 2011-11-05 01:29:57.png
--------------------------------------------------------------------------------
/ch341eeprom.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/99-CH341.rules:
--------------------------------------------------------------------------------
1 | /* This file should be copyed on /etc/udev/rules.d on GNU/Linux OS and derived */
2 | /* Add permission to all user to have complete acces to eeprom programmer CH341 */
3 | SUBSYSTEM=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="5512", MODE:="0666"
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ._*
2 | .DS_Store
3 | ch341eeprom
4 | mktestimg
5 |
6 | *~.nib
7 | DerivedData/
8 | build/
9 | !xcshareddata
10 | *.moved-aside
11 | profile
12 | .idea/
13 |
14 | *.bin
15 |
16 | # Ignore user-specific Xcode settings
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | # Whitelist default Xcode settings
23 | !default.pbxuser
24 | !default.mode1v3
25 | !default.mode2v3
26 | !default.perspectivev3
27 |
28 | # Ignore Xcode 4 semi-personal settings, often included in workspaces
29 | xcuserdata
30 |
31 | # Vim
32 |
33 | .*.swp
34 | tags
35 |
36 |
--------------------------------------------------------------------------------
/windowsonlysoftware/USB programer driver/USBIOX.INF:
--------------------------------------------------------------------------------
1 | ; USBIOX.INF
2 | ; Driver for USB=>EPP/I2C/SPI... chip V2.1
3 | ; WDM/DLL for Windows 98/Me/2000/XP
4 | ; Copyright (C) W.ch 2001-2008
5 | ;
6 |
7 | [Version]
8 | Signature = "$Chicago$"
9 | Class = WCH
10 | ClassGuid = {77989ADF-06DB-4025-92E8-40D902C03B0A}
11 | Provider = %WinChipHead%
12 | DriverVer = 10/15/2008, 2.1.2008.10
13 |
14 | [ControlFlags]
15 | ExcludeFromSelect = USB\VID_1A86&PID_5512
16 | ExcludeFromSelect = USB\VID_4348&PID_5512
17 | ;ExcludeFromSelect = USB\VID_1A86&PID_7523
18 | ;ExcludeFromSelect = USB\VID_1A86&PID_5523
19 | ;ExcludeFromSelect = USB\VID_4348&PID_5523
20 |
21 | [ClassInstall32]
22 | Addreg = WCHReg
23 |
24 | [ClassInstall]
25 | Addreg = WCHReg
26 |
27 | [WCHReg]
28 | HKR, , , 0, %ClassName%
29 | HKR, , Icon, , -5
30 | HKR, , NoInstallClass, , 1
31 |
32 | [Manufacturer]
33 | %WinChipHead% = WinChipHead
34 |
35 | [WinChipHead]
36 | %USBIOX.DeviceDesc% = USBIOX.Install, USB\VID_1A86&PID_5512
37 | %USBIOX.DeviceDesc% = USBIOX.Install, USB\VID_4348&PID_5512
38 | ;%USBIOX.DeviceDesc% = USBIOX.Install, USB\VID_1A86&PID_7523
39 | ;%USBIOX.DeviceDesc% = USBIOX.Install, USB\VID_1A86&PID_5523
40 | ;%USBIOX.DeviceDesc% = USBIOX.Install, USB\VID_4348&PID_5523
41 |
42 | [USBIOX.Install]
43 | CopyFiles = USBIOX.CopyFiles.SYS, USBIOX.CopyFiles.DLL
44 | AddReg = USBIOX.9X.AddReg
45 |
46 | [USBIOX.Install.NT]
47 | CopyFiles = USBIOX.CopyFiles.SYS, USBIOX.CopyFiles.DLL
48 | AddReg = USBIOX.NT.AddReg
49 |
50 | [USBIOX.CopyFiles.SYS]
51 | USBIOX.SYS, , , 2
52 |
53 | [USBIOX.CopyFiles.DLL]
54 | USBIOX.DLL, , , 2
55 |
56 | [USBIOX.9X.AddReg]
57 | HKR, , DevLoader, , *NTKERN
58 | HKR, , NTMPDriver, , USBIOX.SYS
59 |
60 | [USBIOX.NT.AddReg]
61 |
62 | [USBIOX.Install.NT.Services]
63 | AddService = USBIOX, 2, USBIOX.Service
64 |
65 | [USBIOX.Service]
66 | DisplayName = "USBIOX"
67 | ServiceType = 1
68 | StartType = 3
69 | ErrorControl = 1
70 | ServiceBinary = %10%\System32\Drivers\USBIOX.SYS
71 |
72 | [DestinationDirs]
73 | DefaultDestDir = 10, System32\Drivers
74 | USBIOX.CopyFiles.SYS = 10, System32\Drivers
75 | USBIOX.CopyFiles.DLL = 11
76 |
77 | [SourceDisksFiles]
78 | USBIOX.SYS = 1
79 | USBIOX.DLL = 1
80 |
81 | [SourceDisksNames]
82 | 1 = "USB Parallel Installation Disk", USBIOX.SYS, ,
83 |
84 | [Strings]
85 | ClassName = "USB-IO"
86 | WinChipHead = "WCH"
87 | USBIOX.DeviceDesc = "USB-IO"
88 |
--------------------------------------------------------------------------------
/mktestimg.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | mktestimg is a program to make a 'rolling' file for test ch341eeprom programmer
4 |
5 | Originally written by asbokid
6 |
7 | Minor improvements made by Paolo Caroni
8 |
9 | This program is free software: you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation, either version 3 of the License, or
12 | (at your option) any later version.
13 |
14 | This program is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with this program. If not, see .
21 |
22 | */
23 |
24 | #include
25 |
26 | int main(int argc, char **argv)
27 | {
28 | int ret;
29 |
30 | FILE *out=fopen( "test.bin", "w" );
31 | /*create and open file test.bin*/
32 |
33 | int i, j, k;
34 | char chip;
35 | static char *hex = "\00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff";
36 |
37 | printf("Select chip type:\n\na for 24c01\nb for 24c02\nc for 24c04\nd for 24c08\n"\
38 | "e for 24c16\nf for 24c32\ng for 24c64\nh for 24c128\ni for 24c256\n"\
39 | "l for 24c512\nm for 24c1024\n\nInsert a letter:");
40 | ret = scanf("%c",&chip);
41 | if (ret != 1)
42 | return 1;
43 | getchar();
44 |
45 | switch(chip) { /* switch cycle*/
46 |
47 | case 'a': /* 24c01*/
48 | k=128;
49 | break;
50 |
51 | case 'b': /* 24c02*/
52 | k=256;
53 | break;
54 |
55 | case 'c': /* 24c04*/
56 | k=512;
57 | break;
58 |
59 | case 'd': /* 24c08*/
60 | k=1024;
61 | break;
62 |
63 | case 'e': /* 24c16*/
64 | k=2048;
65 | break;
66 |
67 | case 'f': /* 24c32*/
68 | k=4096;
69 | break;
70 |
71 | case 'g': /* 24c64*/
72 | k=8192;
73 | break;
74 |
75 | case 'h': /* 24c128*/
76 | k=16384;
77 | break;
78 |
79 | case 'i': /* 24c256*/
80 | k=32768;
81 | break;
82 |
83 | case 'l': /* 24c512*/
84 | k=65536;
85 | break;
86 |
87 | case 'm': /* 24c1024*/
88 | k=131072;
89 | break;
90 |
91 | default:
92 | printf("Error, wrong letter\n"); /* in the other case*/
93 | return 1;
94 | break;
95 | }
96 |
97 | for (j = 0; j < k/16; j++)
98 | {
99 | for (i = 0; i < 16; i++)
100 | {
101 | fputc(hex[j%16], out);
102 | /* create a binary file with 'rolling'*/
103 | }
104 | }
105 |
106 | fflush(out);
107 | fclose(out);
108 | /* clean and close file test.bin*/
109 |
110 | printf("saved test image as test.bin\n");
111 |
112 | return 0;
113 | }
114 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ch341eeprom
2 | ===
3 |
4 | A libusb based programming tool for 24Cxx serial EEPROMs using the WinChipHead CH341A IC
5 |
6 | This fork adds the ability to specify the value of the part of the I2C address set by the chip select pins using the `--chip-select` argument.
7 |
8 | 
9 |
10 | **Requirements**
11 |
12 | * `clang`, `llvm`, and `make` (via Xcode or Xcode Command Line Tools)
13 | * `libusb` (perhaps via [Homebrew](http://mxcl.github.io/homebrew/): `brew install libusb`)
14 |
15 | **Compiling**
16 |
17 | After installing the necessary tools and libusb, building `ch341eeprom` is as simple as running the included Makefile:
18 |
19 | ```
20 | make
21 | ```
22 |
23 | **Usage**
24 |
25 | Using `ch341eeprom` is straightforward:
26 |
27 | ```
28 | Usage:
29 | -h, --help display this text
30 | -v, --verbose verbose output
31 | -d, --debug debug output
32 | -s, --size size of EEPROM {24c01|24c02|24c04|24c08|24c16|24c32|24c64|24c128|24c256|24c512|24c1024}
33 | -e, --erase erase EEPROM (fill with 0xff)
34 | -p, --speed i2c speed (low|fast|high) if different than standard which is default
35 | -c, --chip-select the part of the i2c address set by the chip select pins (default: 0)
36 | -w, --write write EEPROM with image from filename
37 | -r, --read read EEPROM and save image to filename
38 | -V, --verify verify EEPROM contents against image in filename
39 | ```
40 |
41 | For example:
42 |
43 | ```
44 | $ ./ch341eeprom -v -s 24c64 -e
45 |
46 | Searching USB buses for WCH CH341a i2c EEPROM programmer [1a86:5512]
47 | Found [1a86:5512] as device [7] on USB bus [2]
48 | Opened device [1a86:5512]
49 | Claimed device interface [0]
50 | Device reported its revision [3.03]
51 | Configured USB device
52 | Set i2c bus speed to [100kHz]
53 | Erased [8192] bytes of [24c64] EEPROM
54 | Closed USB device
55 | ```
56 |
57 | **Author**
58 |
59 | Originally written by [asbokid](http://sourceforge.net/projects/ch341eepromtool/) and released under the terms of the GNU GPL, version 3, or later. Modifications by [command-tab](https://github.com/command-tab) to make it work under OS X.
60 |
61 | **License**
62 |
63 | This is free software: you can redistribute it and/or modify it under the terms of
64 | the latest GNU General Public License as published by the Free Software Foundation.
65 |
66 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
67 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
68 | See the GNU General Public License for more details.
69 |
70 | You should have received a copy of the GNU General Public License along with this program.
71 | If not, see .
72 |
73 |
74 | **Tested**
75 |
76 | | Name | Write | Read |
77 | |-------------------|-------|------|
78 | | CAT24M01WI | OK | OK |
79 | | AT24C256 | OK | OK |
80 | | Microchip 24LC256 | OK | OK |
81 | | AT24C32N | OK | OK |
82 | | AT24C08 | OK | OK |
83 |
84 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | CC = clang
2 | CFLAGS = -Wall -O2
3 |
4 | default:
5 | $(CC) $(CFLAGS) -o ch341eeprom ch341eeprom.c ch341funcs.c -lusb-1.0
6 | $(CC) $(CFLAGS) -o mktestimg mktestimg.c
7 |
8 | clean:
9 | rm -f ch341eeprom mktestimg
10 |
11 | test01: default
12 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=1
13 | ./ch341eeprom -v -s 24c01 -w tmp_random.bin
14 | ./ch341eeprom -v -s 24c01 -r tmp_random_readed.bin
15 | cmp tmp_random.bin tmp_random_readed.bin
16 | rm -f tmp_random.bin tmp_random_readed.bin
17 | @echo "Test 1Kbit/128bytes EEPROM done"
18 |
19 | test02: default
20 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=2
21 | ./ch341eeprom -v -s 24c02 -w tmp_random.bin
22 | ./ch341eeprom -v -s 24c02 -r tmp_random_readed.bin
23 | cmp tmp_random.bin tmp_random_readed.bin
24 | rm -f tmp_random.bin tmp_random_readed.bin
25 | @echo "Test 2Kbit/256bytes EEPROM done"
26 |
27 | test04: default
28 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=4
29 | ./ch341eeprom -v -s 24c04 -w tmp_random.bin
30 | ./ch341eeprom -v -s 24c04 -r tmp_random_readed.bin
31 | cmp tmp_random.bin tmp_random_readed.bin
32 | rm -f tmp_random.bin tmp_random_readed.bin
33 | @echo "Test 4Kbit/512bytes EEPROM done"
34 |
35 | test08: default
36 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=8
37 | ./ch341eeprom -v -s 24c08 -w tmp_random.bin
38 | ./ch341eeprom -v -s 24c08 -r tmp_random_readed.bin
39 | cmp tmp_random.bin tmp_random_readed.bin
40 | rm -f tmp_random.bin tmp_random_readed.bin
41 | @echo "Test 8Kbit/1Kbyte EEPROM done"
42 |
43 | test16: default
44 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=16
45 | ./ch341eeprom -v -s 24c16 -w tmp_random.bin
46 | ./ch341eeprom -v -s 24c16 -r tmp_random_readed.bin
47 | cmp tmp_random.bin tmp_random_readed.bin
48 | rm -f tmp_random.bin tmp_random_readed.bin
49 | @echo "Test 16Kbit/2Kbyte EEPROM done"
50 |
51 | test32: default
52 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=32
53 | ./ch341eeprom -v -s 24c32 -w tmp_random.bin
54 | ./ch341eeprom -v -s 24c32 -r tmp_random_readed.bin
55 | cmp tmp_random.bin tmp_random_readed.bin
56 | rm -f tmp_random.bin tmp_random_readed.bin
57 | @echo "Test 32Kbit/4Kbyte EEPROM done"
58 |
59 | test64: default
60 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=64
61 | ./ch341eeprom -v -s 24c64 -w tmp_random.bin
62 | ./ch341eeprom -v -s 24c64 -r tmp_random_readed.bin
63 | cmp tmp_random.bin tmp_random_readed.bin
64 | rm -f tmp_random.bin tmp_random_readed.bin
65 | @echo "Test 64Kbit/8Kbyte EEPROM done"
66 |
67 | test128: default
68 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=128
69 | ./ch341eeprom -v -s 24c128 -w tmp_random.bin
70 | ./ch341eeprom -v -s 24c128 -r tmp_random_readed.bin
71 | cmp tmp_random.bin tmp_random_readed.bin
72 | rm -f tmp_random.bin tmp_random_readed.bin
73 | @echo "Test 128Kbit/16Kbyte EEPROM done"
74 |
75 | test256: default
76 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=256
77 | ./ch341eeprom -v -s 24c256 -w tmp_random.bin
78 | ./ch341eeprom -v -s 24c256 -r tmp_random_readed.bin
79 | cmp tmp_random.bin tmp_random_readed.bin
80 | rm -f tmp_random.bin tmp_random_readed.bin
81 | @echo "Test 256Kbit/32Kbyte EEPROM done"
82 |
83 | test512: default
84 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=512
85 | ./ch341eeprom -v -s 24c512 -w tmp_random.bin
86 | ./ch341eeprom -v -s 24c512 -r tmp_random_readed.bin
87 | cmp tmp_random.bin tmp_random_readed.bin
88 | rm -f tmp_random.bin tmp_random_readed.bin
89 | @echo "Test 512Kbit/64Kbyte EEPROM done"
90 |
91 | test1024: default
92 | dd if=/dev/urandom of=tmp_random.bin bs=128 count=1024
93 | ./ch341eeprom -v -s 24c1024 -w tmp_random.bin
94 | ./ch341eeprom -v -s 24c1024 -r tmp_random_readed.bin
95 | cmp tmp_random.bin tmp_random_readed.bin
96 | rm -f tmp_random.bin tmp_random_readed.bin
97 | @echo "Test 1024Kbit/128Kbyte EEPROM done"
98 |
--------------------------------------------------------------------------------
/ch341docs/CH341DLL.H:
--------------------------------------------------------------------------------
1 | //****************************************
2 | //** Copyright (C) W.ch 1999-2005 **
3 | //** Web: http://www.winchiphead.com **
4 | //****************************************
5 | //** DLL for USB interface chip CH341 **
6 | //** C, VC5.0 **
7 | //****************************************
8 | //
9 | // CH341-DLL V1.9
10 | // support USB chip: CH341, CH341A
11 |
12 | #ifndef _CH341_DLL_H
13 | #define _CH341_DLL_H
14 |
15 | #ifdef __cplusplus
16 | extern "C" {
17 | #endif
18 |
19 | #define mOFFSET( s, m ) ( (ULONG) & ( ( ( s * ) 0 ) -> m ) )
20 |
21 | #ifndef max
22 | #define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
23 | #endif
24 |
25 | #ifndef min
26 | #define min( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
27 | #endif
28 |
29 | #ifdef ExAllocatePool
30 | #undef ExAllocatePool
31 | #endif
32 |
33 | #ifndef NTSTATUS
34 | typedef LONG NTSTATUS;
35 | #endif
36 |
37 |
38 | typedef struct _USB_SETUP_PKT {
39 | UCHAR mUspReqType;
40 | UCHAR mUspRequest;
41 | union {
42 | struct {
43 | UCHAR mUspValueLow;
44 | UCHAR mUspValueHigh;
45 | };
46 | USHORT mUspValue;
47 | };
48 | union {
49 | struct {
50 | UCHAR mUspIndexLow;
51 | UCHAR mUspIndexHigh;
52 | };
53 | USHORT mUspIndex;
54 | };
55 | USHORT mLength;
56 | } mUSB_SETUP_PKT, *mPUSB_SETUP_PKT;
57 |
58 |
59 | #define mCH341_PACKET_LENGTH 32
60 | #define mCH341_PKT_LEN_SHORT 8
61 |
62 |
63 | typedef struct _WIN32_COMMAND {
64 | union {
65 | ULONG mFunction;
66 | NTSTATUS mStatus;
67 | };
68 | ULONG mLength;
69 | union {
70 | mUSB_SETUP_PKT mSetupPkt;
71 | UCHAR mBuffer[ mCH341_PACKET_LENGTH ];
72 | };
73 | } mWIN32_COMMAND, *mPWIN32_COMMAND;
74 |
75 |
76 |
77 | #define IOCTL_CH341_COMMAND ( FILE_DEVICE_UNKNOWN << 16 | FILE_ANY_ACCESS << 14 | 0x0f34 << 2 | METHOD_BUFFERED )
78 | #define mWIN32_COMMAND_HEAD mOFFSET( mWIN32_COMMAND, mBuffer )
79 | #define mCH341_MAX_NUMBER 16
80 | #define mMAX_BUFFER_LENGTH 0x1000
81 | #define mMAX_COMMAND_LENGTH ( mWIN32_COMMAND_HEAD + mMAX_BUFFER_LENGTH )
82 | #define mDEFAULT_BUFFER_LEN 0x0400
83 | #define mDEFAULT_COMMAND_LEN ( mWIN32_COMMAND_HEAD + mDEFAULT_BUFFER_LEN )
84 |
85 | #define mCH341_ENDP_INTER_UP 0x81
86 | #define mCH341_ENDP_INTER_DOWN 0x01
87 | #define mCH341_ENDP_DATA_UP 0x82
88 | #define mCH341_ENDP_DATA_DOWN 0x02
89 |
90 | #define mPipeDeviceCtrl 0x00000004
91 | #define mPipeInterUp 0x00000005
92 | #define mPipeDataUp 0x00000006
93 | #define mPipeDataDown 0x00000007
94 |
95 | #define mFuncNoOperation 0x00000000
96 | #define mFuncGetVersion 0x00000001
97 | #define mFuncGetConfig 0x00000002
98 | #define mFuncSetTimeout 0x00000009
99 | #define mFuncSetExclusive 0x0000000b
100 | #define mFuncResetDevice 0x0000000c
101 | #define mFuncResetPipe 0x0000000d
102 | #define mFuncAbortPipe 0x0000000e
103 |
104 | #define mFuncSetParaMode 0x0000000f
105 | #define mFuncReadData0 0x00000010
106 | #define mFuncReadData1 0x00000011
107 | #define mFuncWriteData0 0x00000012
108 | #define mFuncWriteData1 0x00000013
109 | #define mFuncWriteRead 0x00000014
110 | #define mFuncBufferMode 0x00000020
111 | #define mFuncBufferModeDn 0x00000021
112 |
113 | #define mUSB_CLR_FEATURE 0x01
114 | #define mUSB_SET_FEATURE 0x03
115 | #define mUSB_GET_STATUS 0x00
116 | #define mUSB_SET_ADDRESS 0x05
117 | #define mUSB_GET_DESCR 0x06
118 | #define mUSB_SET_DESCR 0x07
119 | #define mUSB_GET_CONFIG 0x08
120 | #define mUSB_SET_CONFIG 0x09
121 | #define mUSB_GET_INTERF 0x0a
122 | #define mUSB_SET_INTERF 0x0b
123 | #define mUSB_SYNC_FRAME 0x0c
124 |
125 | #define mCH341_VENDOR_READ 0xC0
126 | #define mCH341_VENDOR_WRITE 0x40
127 |
128 | #define mCH341_PARA_INIT 0xB1
129 | #define mCH341_I2C_STATUS 0x52
130 | #define mCH341_I2C_COMMAND 0x53
131 |
132 | #define mCH341_PARA_CMD_R0 0xAC
133 | #define mCH341_PARA_CMD_R1 0xAD
134 | #define mCH341_PARA_CMD_W0 0xA6
135 | #define mCH341_PARA_CMD_W1 0xA7
136 | #define mCH341_PARA_CMD_STS 0xA0
137 |
138 | #define mCH341A_CMD_SET_OUTPUT 0xA1
139 | #define mCH341A_CMD_IO_ADDR 0xA2
140 | #define mCH341A_CMD_PRINT_OUT 0xA3
141 | #define mCH341A_CMD_SPI_STREAM 0xA8
142 | #define mCH341A_CMD_SIO_STREAM 0xA9
143 | #define mCH341A_CMD_I2C_STREAM 0xAA
144 | #define mCH341A_CMD_UIO_STREAM 0xAB
145 |
146 | #define mCH341A_BUF_CLEAR 0xB2
147 | #define mCH341A_I2C_CMD_X 0x54
148 | #define mCH341A_DELAY_MS 0x5E
149 | #define mCH341A_GET_VER 0x5F
150 |
151 | #define mCH341_EPP_IO_MAX ( mCH341_PACKET_LENGTH - 1 )
152 | #define mCH341A_EPP_IO_MAX 0xFF
153 |
154 | #define mCH341A_CMD_IO_ADDR_W 0x00
155 | #define mCH341A_CMD_IO_ADDR_R 0x80
156 |
157 | #define mCH341A_CMD_I2C_STM_STA 0x74
158 | #define mCH341A_CMD_I2C_STM_STO 0x75
159 | #define mCH341A_CMD_I2C_STM_OUT 0x80
160 | #define mCH341A_CMD_I2C_STM_IN 0xC0
161 | #define mCH341A_CMD_I2C_STM_MAX ( min( 0x3F, mCH341_PACKET_LENGTH ) )
162 | #define mCH341A_CMD_I2C_STM_SET 0x60
163 | #define mCH341A_CMD_I2C_STM_US 0x40
164 | #define mCH341A_CMD_I2C_STM_MS 0x50
165 | #define mCH341A_CMD_I2C_STM_DLY 0x0F
166 | #define mCH341A_CMD_I2C_STM_END 0x00
167 |
168 | #define mCH341A_CMD_UIO_STM_IN 0x00
169 | #define mCH341A_CMD_UIO_STM_DIR 0x40
170 | #define mCH341A_CMD_UIO_STM_OUT 0x80
171 | #define mCH341A_CMD_UIO_STM_US 0xC0
172 | #define mCH341A_CMD_UIO_STM_END 0x20
173 |
174 | #define mCH341_PARA_MODE_EPP 0x00
175 | #define mCH341_PARA_MODE_EPP17 0x00
176 | #define mCH341_PARA_MODE_EPP19 0x01
177 | #define mCH341_PARA_MODE_MEM 0x02
178 |
179 | #define mStateBitERR 0x00000100
180 | #define mStateBitPEMP 0x00000200
181 | #define mStateBitINT 0x00000400
182 | #define mStateBitSLCT 0x00000800
183 | #define mStateBitWAIT 0x00002000
184 | #define mStateBitDATAS 0x00004000
185 | #define mStateBitADDRS 0x00008000
186 | #define mStateBitRESET 0x00010000
187 | #define mStateBitWRITE 0x00020000
188 | #define mStateBitSDA 0x00800000
189 |
190 | #define MAX_DEVICE_PATH_SIZE 128
191 | #define MAX_DEVICE_ID_SIZE 64
192 |
193 |
194 | typedef VOID ( CALLBACK * mPCH341_INT_ROUTINE ) ( ULONG iStatus );
195 |
196 | HANDLE WINAPI CH341OpenDevice(ULONG iIndex );
197 | VOID WINAPI CH341CloseDevice(ULONG iIndex );
198 | ULONG WINAPI CH341GetVersion( );
199 |
200 | ULONG WINAPI CH341DriverCommand( ULONG iIndex, mPWIN32_COMMAND ioCommand );
201 | ULONG WINAPI CH341GetDrvVersion();
202 | BOOL WINAPI CH341ResetDevice( ULONG iIndex );
203 | BOOL WINAPI CH341GetDeviceDescr(ULONG iIndex, PVOID oBuffer, PULONG ioLength );
204 | BOOL WINAPI CH341GetConfigDescr( ULONG iIndex, PVOID oBuffer, PULONG ioLength );
205 | BOOL WINAPI CH341SetIntRoutine( ULONG iIndex, mPCH341_INT_ROUTINE iIntRoutine );
206 | BOOL WINAPI CH341ReadInter( ULONG iIndex, PULONG iStatus );
207 | BOOL WINAPI CH341AbortInter( ULONG iIndex );
208 | BOOL WINAPI CH341SetParaMode( ULONG iIndex, ULONG iMode );
209 | BOOL WINAPI CH341InitParallel( ULONG iIndex, ULONG iMode );
210 | BOOL WINAPI CH341ReadData0( ULONG iIndex, PVOID oBuffer, PULONG ioLength );
211 | BOOL WINAPI CH341ReadData1( ULONG iIndex, PVOID oBuffer, PULONG ioLength );
212 | BOOL WINAPI CH341AbortRead( ULONG iIndex );
213 | BOOL WINAPI CH341WriteData0( ULONG iIndex, PVOID iBuffer, PULONG ioLength );
214 | BOOL WINAPI CH341WriteData1( ULONG iIndex, PVOID iBuffer, PULONG ioLength );
215 | BOOL WINAPI CH341AbortWrite( ULONG iIndex );
216 |
217 | BOOL WINAPI CH341GetStatus( ULONG iIndex, PULONG iStatus );
218 | BOOL WINAPI CH341ReadI2C( ULONG iIndex, UCHAR iDevice, UCHAR iAddr, PUCHAR oByte );
219 | BOOL WINAPI CH341WriteI2C( ULONG iIndex, UCHAR iDevice, UCHAR iAddr, UCHAR iByte );
220 |
221 | BOOL WINAPI CH341EppReadData( ULONG iIndex, PVOID oBuffer, PULONG ioLength );
222 | BOOL WINAPI CH341EppReadAddr( ULONG iIndex, PVOID oBuffer, PULONG ioLength );
223 | BOOL WINAPI CH341EppWriteData( ULONG iIndex, PVOID iBuffer, PULONG ioLength );
224 | BOOL WINAPI CH341EppWriteAddr( ULONG iIndex, PVOID iBuffer, PULONG ioLength );
225 | BOOL WINAPI CH341EppSetAddr( ULONG iIndex, UCHAR iAddr );
226 |
227 | BOOL WINAPI CH341MemReadAddr0( ULONG iIndex, PVOID oBuffer, PULONG ioLength );
228 | BOOL WINAPI CH341MemReadAddr1( ULONG iIndex, PVOID oBuffer, PULONG ioLength );
229 | BOOL WINAPI CH341MemWriteAddr0( ULONG iIndex, PVOID iBuffer, PULONG ioLength );
230 | BOOL WINAPI CH341MemWriteAddr1( ULONG iIndex, PVOID iBuffer, PULONG ioLength );
231 |
232 | BOOL WINAPI CH341SetExclusive( ULONG iIndex, ULONG iExclusive );
233 | BOOL WINAPI CH341SetTimeout( ULONG iIndex, ULONG iWriteTimeout, ULONG iReadTimeout );
234 | BOOL WINAPI CH341ReadData( ULONG iIndex, PVOID oBuffer, PULONG ioLength );
235 | BOOL WINAPI CH341WriteData( ULONG iIndex, PVOID iBuffer, PULONG ioLength );
236 | PVOID WINAPI CH341GetDeviceName( ULONG iIndex );
237 | ULONG WINAPI CH341GetVerIC( ULONG iIndex );
238 | BOOL WINAPI CH341FlushBuffer( ULONG iIndex );
239 | BOOL WINAPI CH341WriteRead( ULONG iIndex, ULONG iWriteLength, PVOID iWriteBuffer, ULONG iReadStep, ULONG iReadTimes, PULONG oReadLength, PVOID oReadBuffer );
240 | BOOL WINAPI CH341SetStream( ULONG iIndex, ULONG iMode );
241 | BOOL WINAPI CH341SetDelaymS( ULONG iIndex, ULONG iDelay );
242 | BOOL WINAPI CH341StreamI2C( ULONG iIndex, ULONG iWriteLength, PVOID iWriteBuffer, ULONG iReadLength, PVOID oReadBuffer );
243 |
244 | typedef enum _EEPROM_TYPE {
245 | ID_24C01,
246 | ID_24C02,
247 | ID_24C04,
248 | ID_24C08,
249 | ID_24C16,
250 | ID_24C32,
251 | ID_24C64,
252 | ID_24C128,
253 | ID_24C256,
254 | ID_24C512,
255 | ID_24C1024,
256 | ID_24C2048,
257 | ID_24C4096
258 | } EEPROM_TYPE;
259 |
260 |
261 | BOOL WINAPI CH341ReadEEPROM( ULONG iIndex, EEPROM_TYPE iEepromID, ULONG iAddr, ULONG iLength, PUCHAR oBuffer );
262 | BOOL WINAPI CH341WriteEEPROM( ULONG iIndex, EEPROM_TYPE iEepromID, ULONG iAddr, ULONG iLength, PUCHAR iBuffer );
263 | BOOL WINAPI CH341GetInput( ULONG iIndex, PULONG iStatus );
264 | BOOL WINAPI CH341SetOutput( ULONG iIndex, ULONG iEnable, ULONG iSetDirOut, ULONG iSetDataOut );
265 | BOOL WINAPI CH341Set_D5_D0( ULONG iIndex, ULONG iSetDirOut, ULONG iSetDataOut );
266 | BOOL WINAPI CH341StreamSPI3( ULONG iIndex, ULONG iChipSelect, ULONG iLength, PVOID ioBuffer );
267 | BOOL WINAPI CH341StreamSPI4( ULONG iIndex, ULONG iChipSelect, ULONG iLength, PVOID ioBuffer );
268 | BOOL WINAPI CH341StreamSPI5( ULONG iIndex, ULONG iChipSelect, ULONG iLength, PVOID ioBuffer, PVOID ioBuffer2 );
269 | BOOL WINAPI CH341BitStreamSPI( ULONG iIndex, ULONG iLength, PVOID ioBuffer );
270 | BOOL WINAPI CH341SetBufUpload( ULONG iIndex, ULONG iEnableOrClear );
271 | LONG WINAPI CH341QueryBufUpload( ULONG iIndex );
272 | BOOL WINAPI CH341SetBufDownload( ULONG iIndex, ULONG iEnableOrClear );
273 | LONG WINAPI CH341QueryBufDownload( ULONG iIndex );
274 | BOOL WINAPI CH341ResetInter( ULONG iIndex );
275 | BOOL WINAPI CH341ResetRead( ULONG iIndex );
276 | BOOL WINAPI CH341ResetWrite( ULONG iIndex );
277 |
278 | typedef VOID ( CALLBACK * mPCH341_NOTIFY_ROUTINE ) ( ULONG iEventStatus );
279 |
280 | #define CH341_DEVICE_ARRIVAL 3
281 | #define CH341_DEVICE_REMOVE_PEND 1
282 | #define CH341_DEVICE_REMOVE 0
283 |
284 | BOOL WINAPI CH341SetDeviceNotify( ULONG iIndex, PCHAR iDeviceID, mPCH341_NOTIFY_ROUTINE iNotifyRoutine );
285 | BOOL WINAPI CH341SetupSerial( ULONG iIndex, ULONG iParityMode, ULONG iBaudRate );
286 |
287 | #ifdef __cplusplus
288 | }
289 | #endif
290 |
291 | #endif // _CH341_DLL_H
292 |
--------------------------------------------------------------------------------
/ch341eeprom.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | F0A2BA821790A5BB0010957D /* ch341eeprom.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A2BA7E1790A5BB0010957D /* ch341eeprom.c */; };
11 | F0A2BA831790A5BB0010957D /* ch341funcs.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A2BA801790A5BB0010957D /* ch341funcs.c */; };
12 | F0E5C64917933B8000D43390 /* mktestimg.c in Sources */ = {isa = PBXBuildFile; fileRef = F0A2BA811790A5BB0010957D /* mktestimg.c */; };
13 | /* End PBXBuildFile section */
14 |
15 | /* Begin PBXCopyFilesBuildPhase section */
16 | F08B11E11790A58000B4E402 /* CopyFiles */ = {
17 | isa = PBXCopyFilesBuildPhase;
18 | buildActionMask = 2147483647;
19 | dstPath = /usr/share/man/man1/;
20 | dstSubfolderSpec = 0;
21 | files = (
22 | );
23 | runOnlyForDeploymentPostprocessing = 1;
24 | };
25 | F0A2BA871790A60E0010957D /* CopyFiles */ = {
26 | isa = PBXCopyFilesBuildPhase;
27 | buildActionMask = 2147483647;
28 | dstPath = /usr/share/man/man1/;
29 | dstSubfolderSpec = 0;
30 | files = (
31 | );
32 | runOnlyForDeploymentPostprocessing = 1;
33 | };
34 | /* End PBXCopyFilesBuildPhase section */
35 |
36 | /* Begin PBXFileReference section */
37 | F08B11E31790A58000B4E402 /* ch341eeprom */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ch341eeprom; sourceTree = BUILT_PRODUCTS_DIR; };
38 | F0A2BA7E1790A5BB0010957D /* ch341eeprom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ch341eeprom.c; sourceTree = SOURCE_ROOT; };
39 | F0A2BA7F1790A5BB0010957D /* ch341eeprom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ch341eeprom.h; sourceTree = SOURCE_ROOT; };
40 | F0A2BA801790A5BB0010957D /* ch341funcs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ch341funcs.c; sourceTree = SOURCE_ROOT; };
41 | F0A2BA811790A5BB0010957D /* mktestimg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mktestimg.c; sourceTree = SOURCE_ROOT; };
42 | F0A2BA891790A60E0010957D /* mktestimg */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mktestimg; sourceTree = BUILT_PRODUCTS_DIR; };
43 | /* End PBXFileReference section */
44 |
45 | /* Begin PBXFrameworksBuildPhase section */
46 | F08B11E01790A58000B4E402 /* Frameworks */ = {
47 | isa = PBXFrameworksBuildPhase;
48 | buildActionMask = 2147483647;
49 | files = (
50 | );
51 | runOnlyForDeploymentPostprocessing = 0;
52 | };
53 | F0A2BA861790A60E0010957D /* Frameworks */ = {
54 | isa = PBXFrameworksBuildPhase;
55 | buildActionMask = 2147483647;
56 | files = (
57 | );
58 | runOnlyForDeploymentPostprocessing = 0;
59 | };
60 | /* End PBXFrameworksBuildPhase section */
61 |
62 | /* Begin PBXGroup section */
63 | F08B11DA1790A58000B4E402 = {
64 | isa = PBXGroup;
65 | children = (
66 | F08B11E51790A58000B4E402 /* ch341eeprom */,
67 | F0A2BA8A1790A60E0010957D /* mktestimg */,
68 | F08B11E41790A58000B4E402 /* Products */,
69 | );
70 | sourceTree = "";
71 | };
72 | F08B11E41790A58000B4E402 /* Products */ = {
73 | isa = PBXGroup;
74 | children = (
75 | F08B11E31790A58000B4E402 /* ch341eeprom */,
76 | F0A2BA891790A60E0010957D /* mktestimg */,
77 | );
78 | name = Products;
79 | sourceTree = "";
80 | };
81 | F08B11E51790A58000B4E402 /* ch341eeprom */ = {
82 | isa = PBXGroup;
83 | children = (
84 | F0A2BA7E1790A5BB0010957D /* ch341eeprom.c */,
85 | F0A2BA7F1790A5BB0010957D /* ch341eeprom.h */,
86 | F0A2BA801790A5BB0010957D /* ch341funcs.c */,
87 | );
88 | path = ch341eeprom;
89 | sourceTree = "";
90 | };
91 | F0A2BA8A1790A60E0010957D /* mktestimg */ = {
92 | isa = PBXGroup;
93 | children = (
94 | F0A2BA811790A5BB0010957D /* mktestimg.c */,
95 | );
96 | path = mktestimg;
97 | sourceTree = "";
98 | };
99 | /* End PBXGroup section */
100 |
101 | /* Begin PBXNativeTarget section */
102 | F08B11E21790A58000B4E402 /* ch341eeprom */ = {
103 | isa = PBXNativeTarget;
104 | buildConfigurationList = F08B11EC1790A58000B4E402 /* Build configuration list for PBXNativeTarget "ch341eeprom" */;
105 | buildPhases = (
106 | F08B11DF1790A58000B4E402 /* Sources */,
107 | F08B11E01790A58000B4E402 /* Frameworks */,
108 | F08B11E11790A58000B4E402 /* CopyFiles */,
109 | );
110 | buildRules = (
111 | );
112 | dependencies = (
113 | );
114 | name = ch341eeprom;
115 | productName = ch341eeprom;
116 | productReference = F08B11E31790A58000B4E402 /* ch341eeprom */;
117 | productType = "com.apple.product-type.tool";
118 | };
119 | F0A2BA881790A60E0010957D /* mktestimg */ = {
120 | isa = PBXNativeTarget;
121 | buildConfigurationList = F0A2BA8B1790A60E0010957D /* Build configuration list for PBXNativeTarget "mktestimg" */;
122 | buildPhases = (
123 | F0A2BA851790A60E0010957D /* Sources */,
124 | F0A2BA861790A60E0010957D /* Frameworks */,
125 | F0A2BA871790A60E0010957D /* CopyFiles */,
126 | );
127 | buildRules = (
128 | );
129 | dependencies = (
130 | );
131 | name = mktestimg;
132 | productName = mktestimg;
133 | productReference = F0A2BA891790A60E0010957D /* mktestimg */;
134 | productType = "com.apple.product-type.tool";
135 | };
136 | /* End PBXNativeTarget section */
137 |
138 | /* Begin PBXProject section */
139 | F08B11DB1790A58000B4E402 /* Project object */ = {
140 | isa = PBXProject;
141 | attributes = {
142 | LastUpgradeCheck = 0460;
143 | };
144 | buildConfigurationList = F08B11DE1790A58000B4E402 /* Build configuration list for PBXProject "ch341eeprom" */;
145 | compatibilityVersion = "Xcode 3.2";
146 | developmentRegion = English;
147 | hasScannedForEncodings = 0;
148 | knownRegions = (
149 | en,
150 | );
151 | mainGroup = F08B11DA1790A58000B4E402;
152 | productRefGroup = F08B11E41790A58000B4E402 /* Products */;
153 | projectDirPath = "";
154 | projectRoot = "";
155 | targets = (
156 | F08B11E21790A58000B4E402 /* ch341eeprom */,
157 | F0A2BA881790A60E0010957D /* mktestimg */,
158 | );
159 | };
160 | /* End PBXProject section */
161 |
162 | /* Begin PBXSourcesBuildPhase section */
163 | F08B11DF1790A58000B4E402 /* Sources */ = {
164 | isa = PBXSourcesBuildPhase;
165 | buildActionMask = 2147483647;
166 | files = (
167 | F0A2BA821790A5BB0010957D /* ch341eeprom.c in Sources */,
168 | F0A2BA831790A5BB0010957D /* ch341funcs.c in Sources */,
169 | );
170 | runOnlyForDeploymentPostprocessing = 0;
171 | };
172 | F0A2BA851790A60E0010957D /* Sources */ = {
173 | isa = PBXSourcesBuildPhase;
174 | buildActionMask = 2147483647;
175 | files = (
176 | F0E5C64917933B8000D43390 /* mktestimg.c in Sources */,
177 | );
178 | runOnlyForDeploymentPostprocessing = 0;
179 | };
180 | /* End PBXSourcesBuildPhase section */
181 |
182 | /* Begin XCBuildConfiguration section */
183 | F08B11EA1790A58000B4E402 /* Debug */ = {
184 | isa = XCBuildConfiguration;
185 | buildSettings = {
186 | ALWAYS_SEARCH_USER_PATHS = NO;
187 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
188 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
189 | CLANG_CXX_LIBRARY = "libc++";
190 | CLANG_WARN_CONSTANT_CONVERSION = YES;
191 | CLANG_WARN_EMPTY_BODY = YES;
192 | CLANG_WARN_ENUM_CONVERSION = YES;
193 | CLANG_WARN_INT_CONVERSION = YES;
194 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
195 | COPY_PHASE_STRIP = NO;
196 | GCC_C_LANGUAGE_STANDARD = gnu99;
197 | GCC_DYNAMIC_NO_PIC = NO;
198 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
199 | GCC_OPTIMIZATION_LEVEL = 0;
200 | GCC_PREPROCESSOR_DEFINITIONS = (
201 | "DEBUG=1",
202 | "$(inherited)",
203 | );
204 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
205 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
206 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
207 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
208 | GCC_WARN_UNUSED_VARIABLE = YES;
209 | MACOSX_DEPLOYMENT_TARGET = 10.8;
210 | ONLY_ACTIVE_ARCH = YES;
211 | SDKROOT = macosx;
212 | };
213 | name = Debug;
214 | };
215 | F08B11EB1790A58000B4E402 /* Release */ = {
216 | isa = XCBuildConfiguration;
217 | buildSettings = {
218 | ALWAYS_SEARCH_USER_PATHS = NO;
219 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
221 | CLANG_CXX_LIBRARY = "libc++";
222 | CLANG_WARN_CONSTANT_CONVERSION = YES;
223 | CLANG_WARN_EMPTY_BODY = YES;
224 | CLANG_WARN_ENUM_CONVERSION = YES;
225 | CLANG_WARN_INT_CONVERSION = YES;
226 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
227 | COPY_PHASE_STRIP = YES;
228 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
229 | GCC_C_LANGUAGE_STANDARD = gnu99;
230 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
231 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
232 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
233 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
234 | GCC_WARN_UNUSED_VARIABLE = YES;
235 | MACOSX_DEPLOYMENT_TARGET = 10.8;
236 | SDKROOT = macosx;
237 | };
238 | name = Release;
239 | };
240 | F08B11ED1790A58000B4E402 /* Debug */ = {
241 | isa = XCBuildConfiguration;
242 | buildSettings = {
243 | ALWAYS_SEARCH_USER_PATHS = YES;
244 | HEADER_SEARCH_PATHS = (
245 | "/usr/include/**",
246 | "/usr/local/include/**",
247 | );
248 | LIBRARY_SEARCH_PATHS = "/usr/local/lib/**";
249 | OTHER_LDFLAGS = "-lusb-1.0";
250 | PRODUCT_NAME = "$(TARGET_NAME)";
251 | };
252 | name = Debug;
253 | };
254 | F08B11EE1790A58000B4E402 /* Release */ = {
255 | isa = XCBuildConfiguration;
256 | buildSettings = {
257 | ALWAYS_SEARCH_USER_PATHS = YES;
258 | HEADER_SEARCH_PATHS = (
259 | "/usr/include/**",
260 | "/usr/local/include/**",
261 | );
262 | LIBRARY_SEARCH_PATHS = "/usr/local/lib/**";
263 | OTHER_LDFLAGS = "-lusb-1.0";
264 | PRODUCT_NAME = "$(TARGET_NAME)";
265 | };
266 | name = Release;
267 | };
268 | F0A2BA8C1790A60E0010957D /* Debug */ = {
269 | isa = XCBuildConfiguration;
270 | buildSettings = {
271 | PRODUCT_NAME = "$(TARGET_NAME)";
272 | };
273 | name = Debug;
274 | };
275 | F0A2BA8D1790A60E0010957D /* Release */ = {
276 | isa = XCBuildConfiguration;
277 | buildSettings = {
278 | PRODUCT_NAME = "$(TARGET_NAME)";
279 | };
280 | name = Release;
281 | };
282 | /* End XCBuildConfiguration section */
283 |
284 | /* Begin XCConfigurationList section */
285 | F08B11DE1790A58000B4E402 /* Build configuration list for PBXProject "ch341eeprom" */ = {
286 | isa = XCConfigurationList;
287 | buildConfigurations = (
288 | F08B11EA1790A58000B4E402 /* Debug */,
289 | F08B11EB1790A58000B4E402 /* Release */,
290 | );
291 | defaultConfigurationIsVisible = 0;
292 | defaultConfigurationName = Release;
293 | };
294 | F08B11EC1790A58000B4E402 /* Build configuration list for PBXNativeTarget "ch341eeprom" */ = {
295 | isa = XCConfigurationList;
296 | buildConfigurations = (
297 | F08B11ED1790A58000B4E402 /* Debug */,
298 | F08B11EE1790A58000B4E402 /* Release */,
299 | );
300 | defaultConfigurationIsVisible = 0;
301 | defaultConfigurationName = Release;
302 | };
303 | F0A2BA8B1790A60E0010957D /* Build configuration list for PBXNativeTarget "mktestimg" */ = {
304 | isa = XCConfigurationList;
305 | buildConfigurations = (
306 | F0A2BA8C1790A60E0010957D /* Debug */,
307 | F0A2BA8D1790A60E0010957D /* Release */,
308 | );
309 | defaultConfigurationIsVisible = 0;
310 | defaultConfigurationName = Release;
311 | };
312 | /* End XCConfigurationList section */
313 | };
314 | rootObject = F08B11DB1790A58000B4E402 /* Project object */;
315 | }
316 |
--------------------------------------------------------------------------------
/ch341eeprom.c:
--------------------------------------------------------------------------------
1 | //
2 | // ch341eeprom programmer version 0.1 (Beta)
3 | //
4 | // Programming tool for the 24Cxx serial EEPROMs using the Winchiphead CH341A IC
5 | //
6 | // (c) December 2011 asbokid
7 | //
8 | // This program is free software: you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation, either version 3 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program. If not, see .
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include "ch341eeprom.h"
32 |
33 | FILE *debugout, *verbout;
34 | uint8_t *readbuf = NULL;
35 |
36 | int main(int argc, char **argv) {
37 | int i, eepromsize = 0, bytesread = 0;
38 | uint8_t debug = FALSE, verbose = FALSE;
39 | struct libusb_device_handle *devHandle = NULL;
40 | char *filename = NULL, eepromname[12], operation = 0;
41 | uint32_t speed = CH341_I2C_STANDARD_SPEED;
42 | uint8_t *verifybuf;
43 | uint8_t verify_failed = FALSE;
44 | FILE *fp;
45 |
46 | struct EEPROM eeprom_info;
47 |
48 | static char version_msg[] =
49 | "ch341eeprom - an i2c EEPROM programming tool for the WCH CH341a IC\n" \
50 | "Version " CH341TOOLVERSION " copyright (c) 2011 asbokid \n\n" \
51 | "This program comes with absolutely no warranty; This is free software,\n" \
52 | "and you are welcome to redistribute it under certain conditions:\n" \
53 | "GNU GPL v3 License: http://www.gnu.org/licenses/gpl.html\n";
54 |
55 | static char usage_msg[] =
56 | "Usage:\n" \
57 | " -h, --help display this text\n" \
58 | " -v, --verbose verbose output\n" \
59 | " -d, --debug debug output\n" \
60 | " -s, --size size of EEPROM {24c01|24c02|24c04|24c08|24c16|24c32|24c64|24c128|24c256|24c512|24c1024}\n" \
61 | " -e, --erase erase EEPROM (fill with 0xff)\n" \
62 | " -p, --speed i2c speed (low|fast|high) if different than standard which is default\n" \
63 | " -c, --chip-select the part of the i2c address set by the chip select pins (default: 0)\n" \
64 | " -w, --write write EEPROM with image from filename\n" \
65 | " -r, --read read EEPROM and save image to filename\n" \
66 | " -V, --verify verify EEPROM contents against image in filename\n\n" \
67 | "Example: ch341eeprom -v -s 24c64 -w bootrom.bin\n";
68 |
69 | static struct option longopts[] = {
70 | {"help", no_argument, 0, 'h'},
71 | {"verbose", no_argument, 0, 'v'},
72 | {"debug", no_argument, 0, 'd'},
73 | {"erase", no_argument, 0, 'e'},
74 | {"size", required_argument, 0, 's'},
75 | {"speed", required_argument, 0, 'p'},
76 | {"chip-select", required_argument, 0, 'c'},
77 | {"read", required_argument, 0, 'r'},
78 | {"write", required_argument, 0, 'w'},
79 | {"verify", required_argument, 0, 'V'},
80 | {0, 0, 0, 0}
81 | };
82 |
83 | static int speed_table[] = {20, 100, 400, 750};
84 |
85 | while (TRUE) {
86 | int32_t optidx = 0;
87 | int8_t c = getopt_long(argc,argv,"hvdes:p:c:w:r:V:", longopts, &optidx);
88 | if (c == -1)
89 | break;
90 |
91 | switch (c) {
92 | case 'h': fprintf(stdout, "%s\n%s", version_msg, usage_msg);
93 | return 0;
94 | case 'v': verbose = TRUE;
95 | break;
96 | case 'd': debug = TRUE;
97 | break;
98 | case 's': if((eepromsize = parseEEPsize(optarg, &eeprom_info)) > 0)
99 | strncpy(eepromname, optarg, 10);
100 | break;
101 | case 'c':
102 | eeprom_info.addr = (uint8_t) atoi(optarg);
103 | if(eeprom_info.addr > 7) {
104 | fprintf(stderr, "chip select should probably be between 0 and 7 but continuing anyway");
105 | }
106 | case 'p': if(strstr(optarg, "low"))
107 | speed = CH341_I2C_LOW_SPEED;
108 | else if(strstr(optarg, "fast"))
109 | speed = CH341_I2C_FAST_SPEED;
110 | else if(strstr(optarg, "high"))
111 | speed = CH341_I2C_HIGH_SPEED;
112 | else
113 | speed = CH341_I2C_STANDARD_SPEED;
114 | break;
115 | case 'e': if(!operation)
116 | operation = 'e';
117 | else {
118 | fprintf(stderr, "Conflicting command line options\n");
119 | goto shutdown;
120 | }
121 | break;
122 | case 'r': if(!operation) {
123 | operation = 'r';
124 | filename = (char *) malloc(strlen(optarg)+1);
125 | strcpy(filename, optarg);
126 | } else {
127 | fprintf(stderr, "Conflicting command line options\n");
128 | goto shutdown;
129 | }
130 | break;
131 | case 'w': if(!operation) {
132 | operation = 'w';
133 | filename = (char *) malloc(strlen(optarg)+1);
134 | strcpy(filename, optarg);
135 | } else {
136 | fprintf(stderr, "Conflicting command line options\n");
137 | goto shutdown;
138 | }
139 | break;
140 | case 'V': if(!operation) {
141 | operation = 'V';
142 | filename = (char *) malloc(strlen(optarg)+1);
143 | strcpy(filename, optarg);
144 | } else {
145 | fprintf(stderr, "Conflicting command line options\n");
146 | goto shutdown;
147 | }
148 | break;
149 | default :
150 | case '?': fprintf(stdout, "%s", version_msg);
151 | fprintf(stderr, "%s", usage_msg);
152 | goto shutdown;
153 | }
154 | }
155 |
156 | debugout = (debug == TRUE) ? stdout : fopen("/dev/null","w");
157 | verbout = (verbose == TRUE) ? stdout : fopen("/dev/null","w");
158 | fprintf(debugout, "Debug Enabled\n");
159 |
160 | if(!operation) {
161 | fprintf(stderr, "%s\n%s", version_msg, usage_msg);
162 | goto shutdown;
163 | }
164 |
165 | if(eepromsize <= 0) {
166 | fprintf(stderr, "Invalid EEPROM size\n");
167 | goto shutdown;
168 | }
169 |
170 | readbuf = (uint8_t *) malloc(MAX_EEPROM_SIZE); // space to store loaded EEPROM
171 | if(!readbuf) {
172 | fprintf(stderr, "Couldnt malloc space needed for EEPROM image\n");
173 | goto shutdown;
174 | }
175 |
176 | if(!(devHandle = ch341configure(USB_LOCK_VENDOR, USB_LOCK_PRODUCT))) {
177 | fprintf(stderr, "Couldnt configure USB device with vendor ID: %04x product ID: %04x\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT);
178 | goto shutdown;
179 | }
180 | fprintf(verbout, "Configured USB device with vendor ID: %04x product ID: %04x\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT);
181 |
182 | if(ch341setstream(devHandle, speed) < 0) {
183 | fprintf(stderr, "Couldnt set i2c bus speed\n");
184 | goto shutdown;
185 | }
186 | fprintf(verbout, "Set i2c bus speed to [%dkHz]\n", speed_table[speed]);
187 |
188 | switch(operation) {
189 | case 'r': // read
190 | memset(readbuf, 0xff, MAX_EEPROM_SIZE);
191 |
192 | if(ch341readEEPROM(devHandle, readbuf, eepromsize, &eeprom_info) < 0) {
193 | fprintf(stderr, "Couldnt read [%d] bytes from [%s] EEPROM\n", eepromsize, eepromname);
194 | goto shutdown;
195 | }
196 | fprintf(stdout, "Read [%d] bytes from [%s] EEPROM\n", eepromsize, eepromname);
197 | for(i=0;i eepromsize)
281 | fprintf(stdout, "Truncated to [%d] bytes for [%s] EEPROM\n", eepromsize, eepromname);
282 |
283 | if(ch341writeEEPROM(devHandle, readbuf, eepromsize, &eeprom_info) < 0) {
284 | fprintf(stderr,"Failed to write [%d] bytes from [%s] to [%s] EEPROM\n", eepromsize, filename, eepromname);
285 | goto shutdown;
286 | }
287 | fprintf(stdout, "Wrote [%d] bytes to [%s] EEPROM\n", eepromsize, eepromname);
288 | break;
289 | case 'e': // erase
290 | memset(readbuf, 0xff, MAX_EEPROM_SIZE);
291 | if(ch341writeEEPROM(devHandle, readbuf, eepromsize, &eeprom_info) < 0) {
292 | fprintf(stderr,"Failed to erase [%d] bytes of [%s] EEPROM\n", eepromsize, eepromname);
293 | goto shutdown;
294 | }
295 | fprintf(stdout, "Erased [%d] bytes of [%s] EEPROM\n", eepromsize, eepromname);
296 | break;
297 | default:
298 | fprintf(stderr, "Unknown option\n");
299 | goto shutdown;
300 | }
301 |
302 | shutdown:
303 | if(readbuf)
304 | free(readbuf);
305 | if(filename)
306 | free(filename);
307 | if(devHandle) {
308 | libusb_release_interface(devHandle, DEFAULT_INTERFACE);
309 | fprintf(debugout, "Released device interface [%d]\n", DEFAULT_INTERFACE);
310 | libusb_close(devHandle);
311 | fprintf(verbout, "Closed USB device\n");
312 | libusb_exit(NULL);
313 | }
314 | return 0;
315 | }
316 |
317 |
--------------------------------------------------------------------------------
/ch341funcs.c:
--------------------------------------------------------------------------------
1 | //
2 | // ch341eeprom programmer version 0.1 (Beta)
3 | //
4 | // Programming tool for the 24Cxx serial EEPROMs using the Winchiphead CH341A IC
5 | //
6 | // (c) December 2011 asbokid
7 | //
8 | // This program is free software: you can redistribute it and/or modify
9 | // it under the terms of the GNU General Public License as published by
10 | // the Free Software Foundation, either version 3 of the License, or
11 | // (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program. If not, see .
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include "ch341eeprom.h"
29 |
30 | extern FILE *debugout, *verbout;
31 | uint32_t getnextpkt; // set by the callback function
32 | uint32_t syncackpkt; // synch / ack flag used by BULK OUT cb function
33 | uint32_t byteoffset;
34 |
35 | // --------------------------------------------------------------------------
36 | // ch341configure()
37 | // lock USB device for exclusive use
38 | // claim default interface
39 | // set default configuration
40 | // retrieve device descriptor
41 | // identify device revision
42 | // returns *usb device handle
43 |
44 | struct libusb_device_handle *ch341configure(uint16_t vid, uint16_t pid) {
45 |
46 | struct libusb_device *dev;
47 | struct libusb_device_handle *devHandle;
48 | int32_t ret=0; // set to < 0 to indicate USB errors
49 | uint32_t i = 0;
50 | int32_t currentConfig = 0;
51 |
52 | uint8_t ch341DescriptorBuffer[0x12];
53 |
54 | ret = libusb_init(NULL);
55 | if(ret < 0) {
56 | fprintf(stderr, "Couldnt initialise libusb\n");
57 | return NULL;
58 | }
59 |
60 |
61 |
62 | #if LIBUSBX_API_VERSION < 0x01000106
63 | libusb_set_debug(NULL, 3); // maximum debug logging level
64 | #else
65 | libusb_set_option(NULL, LIBUSB_OPTION_LOG_LEVEL, 3);
66 | #endif
67 |
68 | fprintf(verbout, "Searching USB buses for WCH CH341a i2c EEPROM programmer [%04x:%04x]\n",
69 | USB_LOCK_VENDOR, USB_LOCK_PRODUCT);
70 |
71 | if(!(devHandle = libusb_open_device_with_vid_pid(NULL, USB_LOCK_VENDOR, USB_LOCK_PRODUCT))) {
72 | fprintf(stderr, "Couldn't open device [%04x:%04x]\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT);
73 | return NULL;
74 | }
75 |
76 | if(!(dev = libusb_get_device(devHandle))) {
77 | fprintf(stderr, "Couldnt get bus number and address of device\n");
78 | return NULL;
79 | }
80 |
81 | fprintf(verbout, "Found [%04x:%04x] as device [%d] on USB bus [%d]\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT,
82 | libusb_get_device_address(dev), libusb_get_bus_number(dev));
83 |
84 | fprintf(verbout, "Opened device [%04x:%04x]\n", USB_LOCK_VENDOR, USB_LOCK_PRODUCT);
85 |
86 |
87 | if(libusb_kernel_driver_active(devHandle, DEFAULT_INTERFACE)) {
88 | ret = libusb_detach_kernel_driver(devHandle, DEFAULT_INTERFACE);
89 | if(ret) {
90 | fprintf(stderr, "Failed to detach kernel driver: '%s'\n", strerror(-ret));
91 | return NULL;
92 | } else
93 | fprintf(verbout, "Detached kernel driver\n");
94 | }
95 |
96 | ret = libusb_get_configuration(devHandle, ¤tConfig);
97 | if(ret) {
98 | fprintf(stderr, "Failed to get current device configuration: '%s'\n", strerror(-ret));
99 | return NULL;
100 | }
101 |
102 | if(currentConfig != DEFAULT_CONFIGURATION)
103 | ret = libusb_set_configuration(devHandle, currentConfig);
104 |
105 | if(ret) {
106 | fprintf(stderr, "Failed to set device configuration to %d: '%s'\n", DEFAULT_CONFIGURATION, strerror(-ret));
107 | return NULL;
108 | }
109 |
110 | ret = libusb_claim_interface(devHandle, DEFAULT_INTERFACE); // interface 0
111 |
112 | if(ret) {
113 | fprintf(stderr, "Failed to claim interface %d: '%s'\n", DEFAULT_INTERFACE, strerror(-ret));
114 | return NULL;
115 | }
116 |
117 | fprintf(verbout, "Claimed device interface [%d]\n", DEFAULT_INTERFACE);
118 |
119 | ret = libusb_get_descriptor(devHandle, LIBUSB_DT_DEVICE, 0x00, ch341DescriptorBuffer, 0x12);
120 |
121 | if(ret < 0) {
122 | fprintf(stderr, "Failed to get device descriptor: '%s'\n", strerror(-ret));
123 | return NULL;
124 | }
125 |
126 | fprintf(verbout, "Device reported its revision [%d.%02d]\n",
127 | ch341DescriptorBuffer[12], ch341DescriptorBuffer[13]);
128 |
129 | for(i=0;i<0x12;i++)
130 | fprintf(debugout,"%02x ", ch341DescriptorBuffer[i]);
131 | fprintf(debugout,"\n");
132 |
133 | return devHandle;
134 | }
135 |
136 |
137 | // --------------------------------------------------------------------------
138 | // ch341setstream()
139 | // set the i2c bus speed (speed: 0 = 20kHz; 1 = 100kHz, 2 = 400kHz, 3 = 750kHz)
140 | int32_t ch341setstream(struct libusb_device_handle *devHandle, uint32_t speed) {
141 | int32_t ret, i;
142 | uint8_t ch341outBuffer[EEPROM_READ_BULKOUT_BUF_SZ], *outptr;
143 | int32_t actuallen = 0;
144 |
145 | outptr = ch341outBuffer;
146 |
147 | *outptr++ = mCH341A_CMD_I2C_STREAM;
148 | *outptr++ = mCH341A_CMD_I2C_STM_SET | (speed & 0x3);
149 | *outptr = mCH341A_CMD_I2C_STM_END;
150 |
151 | ret = libusb_bulk_transfer(devHandle, BULK_WRITE_ENDPOINT, ch341outBuffer, 3, &actuallen, DEFAULT_TIMEOUT);
152 |
153 | if(ret < 0) {
154 | fprintf(stderr, "ch341setstream(): Failed write %d bytes '%s'\n", 3, strerror(-ret));
155 | return -1;
156 | }
157 |
158 | fprintf(debugout, "ch341setstream(): Wrote %d bytes: ", 3);
159 | for(i=0; i < 3; i++)
160 | fprintf(debugout, "%02x ", ch341outBuffer[i]);
161 | fprintf(debugout, "\n");
162 | return 0;
163 | }
164 |
165 | size_t ch341ReadCmdMarshall(uint8_t *buffer, uint32_t addr, struct EEPROM *eeprom_info) {
166 | uint8_t *ptr = buffer;
167 |
168 | // Frame 1. Program data address, and read 32 bytes.
169 | *ptr++ = mCH341A_CMD_I2C_STREAM; // 0
170 | *ptr++ = mCH341A_CMD_I2C_STM_STA; // 1
171 | // Write address
172 | *ptr++ = mCH341A_CMD_I2C_STM_OUT | ((*eeprom_info).addr_size+1); // 2: I2C bus adddress + EEPROM address
173 | uint8_t msb_addr;
174 | if ((*eeprom_info).addr_size >= 2) {
175 | // 24C32 and more
176 | msb_addr = (addr>>16 & 1) | eeprom_info->addr;
177 | *ptr++ = (EEPROM_I2C_BUS_ADDRESS | msb_addr)<<1; // 3
178 | *ptr++ = (addr>>8 & 0xFF); // 4
179 | *ptr++ = (addr>>0 & 0xFF); // 5
180 | } else {
181 | // 24C16 and less
182 | msb_addr = (addr>>8 & 7) | eeprom_info->addr;
183 | *ptr++ = (EEPROM_I2C_BUS_ADDRESS | msb_addr)<<1; // 3
184 | *ptr++ = (addr>>0 & 0xFF); // 4
185 | }
186 | *ptr++ = mCH341A_CMD_I2C_STM_STA; // 6/5
187 | *ptr++ = mCH341A_CMD_I2C_STM_OUT | 1; // 7/6
188 | *ptr++ = (EEPROM_I2C_BUS_ADDRESS | msb_addr)<<1 | 1; // 8/7: Read command
189 |
190 | // Read 32 bytes
191 | *ptr++ = mCH341A_CMD_I2C_STM_IN | 32; // 9/8
192 | *ptr++ = mCH341A_CMD_I2C_STM_END; // 10/9
193 |
194 | // Frame 2 - read 32 bytes
195 | ptr = &buffer[32];
196 | *ptr++ = mCH341A_CMD_I2C_STREAM;
197 | *ptr++ = mCH341A_CMD_I2C_STM_IN | 32;
198 | *ptr++ = mCH341A_CMD_I2C_STM_END;
199 |
200 | // Frame 3 - read 32 bytes
201 | ptr = &buffer[64];
202 | *ptr++ = mCH341A_CMD_I2C_STREAM;
203 | *ptr++ = mCH341A_CMD_I2C_STM_IN | 32;
204 | *ptr++ = mCH341A_CMD_I2C_STM_END;
205 |
206 | // Finalize - read last 32 bytes
207 | ptr = &buffer[96];
208 | *ptr++ = mCH341A_CMD_I2C_STREAM;
209 | *ptr++ = mCH341A_CMD_I2C_STM_IN | 31;
210 | *ptr++ = mCH341A_CMD_I2C_STM_IN;
211 | *ptr++ = mCH341A_CMD_I2C_STM_STO;
212 | *ptr++ = mCH341A_CMD_I2C_STM_END;
213 |
214 | return ptr - buffer;
215 | }
216 |
217 | // --------------------------------------------------------------------------
218 | // ch341readEEPROM()
219 | // read n bytes from device (in packets of 32 bytes)
220 | int32_t ch341readEEPROM(struct libusb_device_handle *devHandle, uint8_t *buffer, uint32_t bytestoread, struct EEPROM *eeprom_info) {
221 |
222 | uint8_t ch341outBuffer[EEPROM_READ_BULKOUT_BUF_SZ];
223 | uint8_t ch341inBuffer[IN_BUF_SZ]; // 0x100 bytes
224 | int32_t ret = 0, readpktcount = 0;
225 | struct libusb_transfer *xferBulkIn, *xferBulkOut;
226 | struct timeval tv = {0, 100}; // our async polling interval
227 | size_t xfer_size;
228 |
229 | xferBulkIn = libusb_alloc_transfer(0);
230 | xferBulkOut = libusb_alloc_transfer(0);
231 |
232 | if(!xferBulkIn || !xferBulkOut) {
233 | fprintf(stderr, "Couldnt allocate USB transfer structures\n");
234 | return -1;
235 | }
236 |
237 | byteoffset = 0;
238 |
239 | fprintf(debugout, "Allocated USB transfer structures\n");
240 |
241 | memset(ch341inBuffer, 0, EEPROM_READ_BULKIN_BUF_SZ);
242 | xfer_size = ch341ReadCmdMarshall(ch341outBuffer, 0, eeprom_info); // Fill output buffer
243 |
244 | libusb_fill_bulk_transfer(xferBulkIn, devHandle, BULK_READ_ENDPOINT, ch341inBuffer,
245 | EEPROM_READ_BULKIN_BUF_SZ, cbBulkIn, NULL, DEFAULT_TIMEOUT);
246 |
247 | libusb_fill_bulk_transfer(xferBulkOut, devHandle, BULK_WRITE_ENDPOINT,
248 | ch341outBuffer, xfer_size, cbBulkOut, NULL, DEFAULT_TIMEOUT);
249 |
250 | fprintf(debugout, "Filled USB transfer structures\n");
251 |
252 | libusb_submit_transfer(xferBulkIn);
253 | fprintf(debugout, "Submitted BULK IN start packet\n");
254 | libusb_submit_transfer(xferBulkOut);
255 | fprintf(debugout, "Submitted BULK OUT setup packet\n");
256 |
257 | readbuf = buffer;
258 |
259 | while (1) {
260 | fprintf(stdout, "Read %d%% [%d] of [%d] bytes \r", 100*byteoffset/bytestoread, byteoffset, bytestoread);
261 | ret = libusb_handle_events_timeout(NULL, &tv);
262 |
263 | if (ret < 0 || getnextpkt == -1) { // indicates an error
264 | fprintf(stderr, "ret from libusb_handle_timeout = %d\n", ret);
265 | fprintf(stderr, "getnextpkt = %d\n", getnextpkt);
266 | if (ret < 0)
267 | fprintf(stderr, "USB read error : %s\n", strerror(-ret));
268 | libusb_free_transfer(xferBulkIn);
269 | libusb_free_transfer(xferBulkOut);
270 | return -1;
271 | }
272 | if(getnextpkt == 1) { // callback function reports a new BULK IN packet received
273 | getnextpkt = 0; // reset the flag
274 | readpktcount++; // increment the read packet counter
275 | byteoffset += EEPROM_READ_BULKIN_BUF_SZ;
276 | if (byteoffset == bytestoread)
277 | break;
278 |
279 | fprintf(debugout, "\nRe-submitting transfer request to BULK IN endpoint\n");
280 | libusb_submit_transfer(xferBulkIn); // re-submit request for next BULK IN packet of EEPROM data
281 | if(syncackpkt)
282 | syncackpkt = 0;
283 | // if 4th packet received, we are at end of 0x80 byte data block,
284 | // if it is not the last block, then resubmit request for data
285 | if(readpktcount==4) {
286 | fprintf(debugout, "\nSubmitting next transfer request to BULK OUT endpoint\n");
287 | readpktcount = 0;
288 |
289 | ch341ReadCmdMarshall(ch341outBuffer, byteoffset, eeprom_info); // Fill output buffer
290 | libusb_fill_bulk_transfer(xferBulkOut, devHandle, BULK_WRITE_ENDPOINT, ch341outBuffer,
291 | EEPROM_READ_BULKOUT_BUF_SZ, cbBulkOut, NULL, DEFAULT_TIMEOUT);
292 |
293 | libusb_submit_transfer(xferBulkOut);// update transfer struct (with new EEPROM page offset)
294 | // and re-submit next transfer request to BULK OUT endpoint
295 | }
296 | }
297 | }
298 |
299 | libusb_free_transfer(xferBulkIn);
300 | libusb_free_transfer(xferBulkOut);
301 | return 0;
302 | }
303 |
304 | // Callback function for async bulk in comms
305 | void cbBulkIn(struct libusb_transfer *transfer) {
306 | int i;
307 |
308 | switch(transfer->status) {
309 | case LIBUSB_TRANSFER_COMPLETED:
310 | // display the contents of the BULK IN data buffer
311 | fprintf(debugout,"\ncbBulkIn(): status %d - Read %d bytes\n",transfer->status,transfer->actual_length);
312 |
313 | for(i=0; i < transfer->actual_length; i++) {
314 | if(!(i%16))
315 | fprintf(debugout, "\n ");
316 | fprintf(debugout, "%02x ", transfer->buffer[i]);
317 | }
318 | fprintf(debugout, "\n");
319 | // copy read data to our EEPROM buffer
320 | memcpy(readbuf + byteoffset, transfer->buffer, transfer->actual_length);
321 | getnextpkt = 1;
322 | break;
323 | default:
324 | fprintf(stderr, "\ncbBulkIn: error : %d\n", transfer->status);
325 | getnextpkt = -1;
326 | }
327 | return;
328 | }
329 |
330 | // Callback function for async bulk out comms
331 | void cbBulkOut(struct libusb_transfer *transfer) {
332 | syncackpkt = 1;
333 | fprintf(debugout, "\ncbBulkOut(): Sync/Ack received: status %d\n", transfer->status);
334 | return;
335 | }
336 |
337 | // --------------------------------------------------------------------------
338 | // ch341writeEEPROM()
339 | // write n bytes to 24c32/24c64 device (in packets of 32 bytes)
340 | int32_t ch341writeEEPROM(struct libusb_device_handle *devHandle, uint8_t *buffer, uint32_t bytesum, struct EEPROM *eeprom_info) {
341 |
342 | uint8_t ch341outBuffer[512/*EEPROM_WRITE_BUF_SZ*/];
343 | uint8_t *outptr, *bufptr;
344 | uint8_t i2cCmdBuffer[256];
345 | int32_t ret = 0, i;
346 | uint32_t byteoffset = 0;
347 | uint32_t bytes = bytesum;
348 | uint8_t addrbytecount = (*eeprom_info).addr_size+1; // 24c32 and 24c64 (and other 24c??) use 3 bytes for addressing
349 | int32_t actuallen = 0;
350 | uint16_t page_size = (*eeprom_info).page_size;
351 |
352 | bufptr = buffer;
353 |
354 | while(bytes) {
355 | outptr = i2cCmdBuffer;
356 | if ((*eeprom_info).addr_size >= 2) {
357 | *outptr++ = (uint8_t) (0xa0 | (((byteoffset >> 16) & 1) | eeprom_info->addr)<<1); // EEPROM device address
358 | *outptr++ = (uint8_t) (byteoffset >> 8 & 0xff); // MSB (big-endian) byte address
359 | } else {
360 | *outptr++ = (uint8_t) (0xa0 | (((byteoffset >> 8) & 7) | eeprom_info->addr)<<1); // EEPROM device address
361 | }
362 | *outptr++ = (uint8_t) (byteoffset & 0xff); // LSB of 16-bit byte address
363 |
364 | memcpy(outptr, bufptr, page_size); // Copy one page
365 |
366 | byteoffset += page_size;
367 | bufptr += page_size;
368 | bytes -= page_size;
369 |
370 | outptr = ch341outBuffer;
371 | uint16_t page_size_left = page_size + addrbytecount;
372 | uint8_t part_no = 0;
373 | uint8_t *i2cBufPtr = i2cCmdBuffer;
374 | while(page_size_left) {
375 | uint8_t to_write = MIN(page_size_left, 28);
376 | *outptr++ = mCH341A_CMD_I2C_STREAM;
377 | if (part_no == 0) { // Start packet
378 | *outptr++ = mCH341A_CMD_I2C_STM_STA;
379 | }
380 | *outptr++ = mCH341A_CMD_I2C_STM_OUT | to_write;
381 | memcpy(outptr, i2cBufPtr, to_write);
382 | outptr += to_write;
383 | i2cBufPtr += to_write;
384 | page_size_left -= to_write;
385 |
386 | if (page_size_left == 0) { // Stop packet
387 | *outptr++ = mCH341A_CMD_I2C_STM_STO;
388 | }
389 | *outptr++ = mCH341A_CMD_I2C_STM_END;
390 | part_no++;
391 | }
392 | uint32_t payload_size = outptr - ch341outBuffer;
393 |
394 | for(i=0; i < payload_size; i++) {
395 | if(!(i%0x10))
396 | fprintf(debugout, "\n%04x : ", i);
397 | fprintf(debugout, "%02x ", ch341outBuffer[i]);
398 | }
399 | fprintf(debugout, "\n");
400 |
401 | ret = libusb_bulk_transfer(devHandle, BULK_WRITE_ENDPOINT,
402 | ch341outBuffer, payload_size, &actuallen, DEFAULT_TIMEOUT);
403 |
404 | if(ret < 0) {
405 | fprintf(stderr, "Failed to write to EEPROM: '%s'\n", strerror(-ret));
406 | return -1;
407 | }
408 |
409 | fprintf(debugout, "Writing [aa 5a 00] to EEPROM\n"); // Magic CH341a packet! Undocumented, unknown purpose
410 |
411 | outptr = ch341outBuffer;
412 | *outptr++ = mCH341A_CMD_I2C_STREAM;
413 | *outptr++ = mCH341A_CMD_I2C_STM_MS | 10; // Wait 10ms (?)
414 | *outptr++ = mCH341A_CMD_I2C_STM_END;
415 |
416 | ret = libusb_bulk_transfer(devHandle, BULK_WRITE_ENDPOINT, ch341outBuffer, 3, &actuallen, DEFAULT_TIMEOUT);
417 |
418 | if(ret < 0) {
419 | fprintf(stderr, "Failed to write to EEPROM: '%s'\n", strerror(-ret));
420 | return -1;
421 | }
422 |
423 | /*
424 | struct timeval tv = {0, 100}; // our async polling interval
425 | ret = libusb_handle_events_timeout(NULL, &tv);
426 | if (ret < 0) { // indicates an error
427 | fprintf(stderr, "ret from libusb_handle_timeout = %d\n", ret);
428 | fprintf(stderr, "USB read error : %s\n", strerror(-ret));
429 | return -1;
430 | }
431 | */
432 | fprintf(stdout, "Written %d%% [%d] of [%d] bytes \r", 100*(bytesum-bytes)/bytesum, bytesum-bytes, bytesum);
433 | }
434 | return 0;
435 | }
436 |
437 |
438 | // --------------------------------------------------------------------------
439 | // parseEEPsize()
440 | // passed an EEPROM name (case-sensitive), returns its byte size
441 | int32_t parseEEPsize(char* eepromname, struct EEPROM *eeprom) {
442 | int i;
443 |
444 | for(i=0; eepromlist[i].size; i++)
445 | if(strstr(eepromlist[i].name, eepromname)) {
446 | memcpy(eeprom, &(eepromlist[i]), sizeof(struct EEPROM));
447 | return(eepromlist[i].size);
448 | }
449 | return -1;
450 | }
451 |
--------------------------------------------------------------------------------
/ch341docs/ch341_i2c_example_in_english.c:
--------------------------------------------------------------------------------
1 | // V1.1
2 |
3 | # Include
4 | # Include "CH341DLL.H"
5 |
6 | /* This program involves:
7 |
8 | 1, 2-wire interface, some of the custom timing, dealing with IIC bus acknowledge bit, and an example of
9 | the internal 2-wire interface timing analysis
10 | 2, provide examples of procedures, the operation 2-wire interface IIC device X76F640, PCF8574, PCA9554
11 | 3, or MEM with EPP parallel port for a number of multi-bit output or input, analog read-only or write-only SPI timing
12 | 4, with the UIO purpose I / O bit stream order to achieve a custom synchronous serial interface
13 | 5, provide examples of procedures, operations similar to the non-standard serial SPI timing device TLC1549
14 | 6, provides example programs using CH341StreamSPI4 4-wire interface SPI devices 25C512, 25C020
15 | 7, provides example programs using CH341BitStreamSPI, similar non-standard SPI timing device ADC0831
16 | Another set of CH341 can CH341SetOutput I/O direction, and through any pin of CH341 direct output
17 | data, does not provide examples, it is recommended instead of using CH341Set_D5_D0
18 | */
19 |
20 | /* Measurement speed
21 | CH341StreamI2C about 56K bytes
22 | CH341ReadEEPROM about 56K bytes
23 | CH341WriteEEPROM about 5K bytes (RAM instead of flash if it is the same speed with CH341ReadEEPROM)
24 | CH341StreamSPI4 about 68K bytes
25 | CH341StreamSPI5 about 30K bytes per channel * 2 inputs and 2 outputs
26 | CH341BitStreamSPI about 8K-bit per channel * at least 2 inputs and 2 outputs (up to 7 inputs 4 outputs)
27 | */
28 |
29 | /* ***************************************************************************************** */
30 | /* Example: a common IIC bus-compatible operating sequence */
31 |
32 | BOOL WINAPI IIC_IssueStart (ULONG iIndex) // device number designated CH341
33 | {
34 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
35 | ULONG mLength;
36 |
37 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
38 | mBuffer [1] = mCH341A_CMD_I2C_STM_STA; // generate the start bit
39 | mBuffer [2] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
40 | mLength = 3;
41 | return (CH341WriteData (iIndex, mBuffer, & mLength)); // write the data block
42 | }
43 |
44 | BOOL WINAPI IIC_IssueStop (ULONG iIndex) // device number designated CH341
45 | {
46 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
47 | ULONG mLength;
48 |
49 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
50 | mBuffer [1] = mCH341A_CMD_I2C_STM_STO; // stop bit generation
51 | mBuffer [2] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
52 | mLength = 3;
53 | return (CH341WriteData (iIndex, mBuffer, & mLength)); // write the data block
54 | }
55 |
56 | // IIC_OutBlockSkipAck() - output data block, do not check the response is valid
57 | // iIndex is the device number allocated by CH341
58 | // iOutLength ready to write data bytes 29 bytes must be less than a single
59 | // iOutBuffer is a pointer to a buffer, ready to write the data into place
60 | BOOL WINAPI IIC_OutBlockSkipAck (ULONG iIndex, ULONG iOutLength, PVOID iOutBuffer)
61 | {
62 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
63 | ULONG mLength;
64 |
65 | if (iOutLength == 0 | | iOutLength> (mCH341_PACKET_LENGTH - 1 - 1 - 1))
66 | return (FALSE);
67 |
68 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
69 | mBuffer [1] = (UCHAR) (mCH341A_CMD_I2C_STM_OUT | iOutLength); // output data, bit 5 - bit 0 is the length of
70 |
71 | memcpy (& mBuffer [2], iOutBuffer, iOutLength); // data
72 | mBuffer [1 + 1 + iOutLength] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
73 | mLength = 1 + 1 + iOutLength + 1;
74 |
75 | return (CH341WriteData (iIndex, mBuffer, & mLength)); // write the data block
76 | }
77 |
78 |
79 | // IIC_OutByteCheckAck() - output a byte of data and check that the response is valid
80 | // iIndex is te device number designated by CH341
81 | // iOutByte write the data to prepare
82 | BOOL WINAPI IIC_OutByteCheckAck (ULONG iIndex, UCHAR iOutByte) {
83 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
84 | ULONG mLength, mInLen;
85 |
86 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
87 | mBuffer [1] = mCH341A_CMD_I2C_STM_OUT; // output data, bit 5 - bit 0 of length,length 0 bytes;returns only to send a response
88 | mBuffer [2] = iOutByte; // data
89 | mBuffer [3] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
90 | mLength = 4;
91 | mInLen = 0;
92 |
93 | if (CH341WriteRead (iIndex, mLength, mBuffer, mCH341A_CMD_I2C_STM_MAX, 1, & mInLen, mBuffer)) { // execute command stream, and then input first output
94 | if (mInLen & & (mBuffer [mInLen - 1] & 0x80) == 0) return (TRUE); // data returned ACK response on behalf of the bit 7 position, ACK = 0 effective
95 | }
96 | return (FALSE);
97 | }
98 |
99 |
100 | // IIC_InBlockByAck() - input data blocks, each input byte is an effective response
101 | // iIndex is the device number designated by CH341
102 | // iInLength is ready to read data bytes 32 bytes must be less than a single
103 | // oInBuffer is a pointer to a buffer, return the data is read
104 |
105 | BOOL WINAPI IIC_InBlockByAck (ULONG iIndex, ULONG iInLength, PVOID oInBuffer) {
106 |
107 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
108 | ULONG mLength, mInLen;
109 |
110 | if (iInLength == 0 | | iInLength> mCH341A_CMD_I2C_STM_MAX) return (FALSE);
111 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
112 | mBuffer [1] = (UCHAR) (mCH341A_CMD_I2C_STM_IN | iInLength); // input data, bit 5 - bit 0 is the length of
113 | mBuffer [2] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
114 | mLength = 3;
115 | mInLen = 0;
116 | if (CH341WriteRead (iIndex, mLength, mBuffer, mCH341A_CMD_I2C_STM_MAX, 1, & mInLen, mBuffer)) { // execute command stream, and then input first output
117 | if (mInLen == iInLength) {
118 | memcpy (oInBuffer, & mBuffer [0], iInLength); // data
119 | return (TRUE);
120 | }
121 | }
122 | return (FALSE);
123 | }
124 |
125 | // IIC_InByteNoAck() - input a byte of data, but does not produce response
126 | // iIndex is device number designated CH341
127 | // oInByte points to a byte buffer is read back the data after
128 | BOOL WINAPI IIC_InByteNoAck (ULONG iIndex, PUCHAR oInByte) {
129 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
130 | ULONG mLength, mInLen;
131 |
132 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
133 | mBuffer [1] = mCH341A_CMD_I2C_STM_IN; // input data, bit 5 - bit 0 of length, only to receive a length of 0 bytes and sends no response
134 | mBuffer [2] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
135 | mLength = 3;
136 | mInLen = 0;
137 | // execute command stream and then input first output
138 | if (CH341WriteRead (iIndex, mLength, mBuffer, mCH341A_CMD_I2C_STM_MAX, 1, & mInLen, mBuffer)) {
139 | if (mInLen) {
140 | * OInByte = mBuffer [mInLen - 1]; // data
141 | return (TRUE);
142 | }
143 | }
144 | return (FALSE);
145 | }
146 |
147 | /* ********************************************************************************************** */
148 | /* Operation encrypted memory X76F640 */
149 |
150 |
151 | // X76F640_AckPolling() - query X76F640 answer (include: the start bit, a byte of command data output, check the response is valid)
152 |
153 | BOOL WINAPI X76F640_AckPolling (ULONG iIndex) { // iIndex is device number designated CH341
154 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
155 | ULONG mLength, mInLen;
156 |
157 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
158 | mBuffer [1] = mCH341A_CMD_I2C_STM_STA; // generate the start bit
159 | mBuffer [2] = mCH341A_CMD_I2C_STM_OUT; // output data, bit 5 - bit 0 of length, the length of 0 bytes and returns only to send a response
160 | mBuffer [3] = 0xF0; // query command response codes
161 | mBuffer [4] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
162 | mLength = 5;
163 | mInLen = 0;
164 | // execute command stream and then input first output
165 | if (CH341WriteRead (iIndex, mLength, mBuffer, mCH341A_CMD_I2C_STM_MAX, 1, & mInLen, mBuffer)) {
166 | if (mInLen & & (mBuffer [mInLen - 1] & 0x80) == 0)
167 | return (TRUE); // data returned ACK response on behalf of bit 7 position, ACK = 0 effective
168 | }
169 | return (FALSE);
170 | }
171 |
172 | // X76F640_CheckPasswd() - send operation commands and check the specified password (including: output start bit,
173 | // 9 bytes of output data (1 + 8 password command), the query response, the output 2-byte address)
174 | // iIndex is device number designated CH341
175 | // iCommand is operation command code
176 | // iPasswdBuf is pointer to a buffer with 8 bytes of the password data
177 | // iAddress) to specify address or password operation of 2-byte data
178 |
179 | BOOL WINAPI X76F640_CheckPasswd (ULONG iIndex, ULONG iCommand, PVOID iPasswdBuf, ULONG iAddress) {
180 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
181 | ULONG i, mLength;
182 |
183 | i = 0;
184 | mBuffer [i++] = mCH341A_CMD_I2C_STREAM; // command code
185 | mBuffer [i++] = mCH341A_CMD_I2C_STM_STA; // generate the start bit
186 | mBuffer [i++] = (UCHAR) (mCH341A_CMD_I2C_STM_OUT | 9); // output data, bit 5 - bit 0 is the length of 9 bytes
187 | mBuffer [i++] = (UCHAR) iCommand; // operation command code
188 | memcpy (& mBuffer [i], iPasswdBuf, 8); // 8 byte password data
189 | i += 8;
190 | mBuffer [i++] = (UCHAR) (mCH341A_CMD_I2C_STM_MS | 10); // to bo seconds delay, bit 3 - bit 0 value for the delay, delay 10 ms
191 | mBuffer [i++] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
192 | mLength = i;
193 | if (CH341WriteData (iIndex, mBuffer, & mLength)) { // write the data block
194 | if (X76F640_AckPolling (iIndex)) { // query response effective
195 | i = 0;
196 | mBuffer [i++] = mCH341A_CMD_I2C_STREAM; // command code
197 | mBuffer [i++] = (UCHAR) (mCH341A_CMD_I2C_STM_OUT | 2); // output data, bit 5 - bit 0 is the length of
198 | mBuffer [i++] = (UCHAR) (iAddress & 0x00FF); // lower 8-bit address
199 | mBuffer [i++] = (UCHAR) ((iAddress>> 8) & 0x00FF); // 8 bits of address
200 | mBuffer [i++] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
201 | mLength = i;
202 | return (CH341WriteData (iIndex, mBuffer, & mLength)); // write the data block
203 | }
204 | else IIC_IssueStop (iIndex); // invalid response
205 | }
206 | return (FALSE);
207 | }
208 |
209 | // X76F640_WriteWithPasswd() - write X76F640 block, using the specified password
210 | BOOL WINAPI X76F640_WriteWithPasswd (
211 | ULONG iIndex, // device number designated CH341
212 | ULONG iWriteCommand, // block write command code
213 | PVOID iPasswdBuf, // pointer to a buffer, place the 8-byte password data
214 | ULONG iAddress, // address of the specified operation
215 | ULONG iOutLength, // ready to write data bytes must be less than 32 single-byte (one sector)
216 | PVOID iOutBuffer) // point to a buffer, ready to write the data to place
217 | {
218 | UCHAR mBuffer [mDEFAULT_BUFFER_LEN];
219 | ULONG i, mLength;
220 |
221 | if (iOutLength == 0 | | iOutLength> 32)
222 | return (FALSE);
223 | if (X76F640_CheckPasswd (iIndex, iWriteCommand, iPasswdBuf, iAddress)) { // check the password by issuing the command and
224 | if (iOutLength> (mCH341_PACKET_LENGTH - 1 - 1 - 1 - 1 - 1)) { // remove the first 2 byte 3 byte, a packet is not enough
225 | mLength = iOutLength - (mCH341_PACKET_LENGTH - 1 - 1 - 1 - 1 - 1); // length of more
226 | iOutLength -= mLength; // 1st data packet length
227 | }
228 | else
229 | mLength = 0; // 1 is enough to use a package
230 | i = 0;
231 | mBuffer [i++] = mCH341A_CMD_I2C_STREAM; // command code
232 | mBuffer [i++] = (UCHAR) (mCH341A_CMD_I2C_STM_OUT | iOutLength); // output data, bit 5 - bit 0 is the length of
233 | memcpy (& mBuffer [i], iOutBuffer, iOutLength); // data
234 | i += iOutLength;
235 | if (mLength) { // 2 package
236 | mBuffer [i] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
237 | i += mCH341_PACKET_LENGTH - i% mCH341_PACKET_LENGTH;// skip the rest of the current package
238 | mBuffer [i++] = mCH341A_CMD_I2C_STREAM; // the first two packets of the first byte command code is still
239 | mBuffer [i++] = (UCHAR) (mCH341A_CMD_I2C_STM_OUT | mLength); // output data, bit 5 - bit 0 is the length of
240 | memcpy (& mBuffer [i], (PUCHAR) iOutBuffer + iOutLength, mLength); // remaining data
241 | i += mLength;
242 | }
243 | mBuffer [i++] = mCH341A_CMD_I2C_STM_STO; // stop bit generation
244 | mBuffer [i++] = (UCHAR) (mCH341A_CMD_I2C_STM_MS | 10); // to bo seconds delay, bit 3 - bit 0 value for the delay, delay 10 ms
245 | mBuffer [i++] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
246 | return (CH341WriteData (iIndex, mBuffer, & i)); // write the data block
247 | }
248 | return (FALSE);
249 | }
250 |
251 | // X76F640_ReadWithPasswd() - read X76F640 block, using the specified password (including: output start bit,
252 | // 9 bytes of output data (1 + 8 password command), the query response, the output 2-byte address, read data blocks)
253 | BOOL WINAPI X76F640_ReadWithPasswd (
254 | ULONG iIndex, // device number designated CH341
255 | ULONG iReadCommand, // code block read command
256 | PVOID iPasswdBuf, // pointer to a buffer, place the 8-byte password data
257 | ULONG iAddress, // address of the specified operation
258 | ULONG iInLength, // number of bytes ready to read the data, must be less than 512 single-byte (32 * 16 per pack pack = 512 bytes)
259 | PVOID oInBuffer) // point to a buffer, return the data is read
260 | {
261 | UCHAR mBuffer [mDEFAULT_BUFFER_LEN];
262 | ULONG i, mLength, mInLen;
263 |
264 | if (iInLength == 0 | | iInLength> (16 * mCH341_PACKET_LENGTH))
265 | return (FALSE);
266 | if (X76F640_CheckPasswd (iIndex, iReadCommand, iPasswdBuf, iAddress)) { // check the password by issuing the command and
267 | i = 0;
268 | mBuffer [i++] = mCH341A_CMD_I2C_STREAM; // command code
269 | for (mInLen = 1; mInLen = mCH341A_CMD_I2C_STM_MAX? mCH341A_CMD_I2C_STM_MAX: iInLength - mInLen; // The length of valid data input
271 | mBuffer [i++] = (UCHAR) (mCH341A_CMD_I2C_STM_IN | mLength); // input data, bit 5 - bit 0 is the length of
272 | mInLen += mLength;
273 | if (mLength >= mCH341A_CMD_I2C_STM_MAX) { // the current package will be full
274 | mBuffer [i] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
275 | i += mCH341_PACKET_LENGTH - i% mCH341_PACKET_LENGTH; // skip the rest of the current package
276 | mBuffer [i++] = mCH341A_CMD_I2C_STREAM; // new packet command code
277 | }
278 | }
279 | mBuffer [i++] = mCH341A_CMD_I2C_STM_IN; // last byte of input data, and send only one byte received no response
280 | mBuffer [i++] = mCH341A_CMD_I2C_STM_STO; // stop bit generation
281 | mBuffer [i++] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
282 | mLength = 0;
283 | // execute command stream and then input the first output
284 | if (CH341WriteRead (iIndex, i, mBuffer, mCH341A_CMD_I2C_STM_MAX, (iInLength + mCH341A_CMD_I2C_STM_MAX - 1)
285 | / mCH341A_CMD_I2C_STM_MAX, & mLength, oInBuffer)) {
286 | if (mLength == iInLength)
287 | return (TRUE);
288 | }
289 | }
290 | return (FALSE);
291 | }
292 |
293 | /* ************************************************ ********************************************** */
294 | /* Example: operating quasi-bidirectional I / O expansion PCF8574 */
295 |
296 | BOOL WINAPI PCF8574_WriteIO (// output the PCF8574 I / O
297 | ULONG iIndex, // device number designated CH341
298 | ULONG iDeviceAddr, // device address, the lowest order bit of the direction bit
299 | ULONG iOutByte) // prepare to write the I / O data
300 | { // Could directly use CH341StreamI2C (iIndex, 2, mBuffer, 0, NULL) to achieve
301 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
302 | ULONG mLength;
303 |
304 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
305 | mBuffer [1] = mCH341A_CMD_I2C_STM_STA; // generate the start bit
306 | mBuffer [2] = (UCHAR) (mCH341A_CMD_I2C_STM_OUT | 2); // output data, bit 5 - bit 0 is the length of 2 bytes
307 | mBuffer [3] = (UCHAR) (iDeviceAddr & 0xFE); // device address, write
308 | mBuffer [4] = (UCHAR) iOutByte; // I / O data
309 | mBuffer [5] = mCH341A_CMD_I2C_STM_STO; // stop bit generation
310 | mBuffer [6] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
311 | mLength = 7;
312 | return (CH341WriteData (iIndex, mBuffer, & mLength)); // write the data block
313 | }
314 |
315 | // input the PCF8574 I / O
316 | BOOL WINAPI PCF8574_ReadIO (
317 | ULONG iIndex, // device number designated CH341
318 | ULONG iDeviceAddr, // device address, the lowest order bit of the direction bit
319 | PUCHAR oInByte) // points to a byte buffer is read back after the I / O data
320 | { // Could directly use CH341StreamI2C (iIndex, 1, mBuffer, 1, oInByte) to achieve
321 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
322 | ULONG mLength, mInLen;
323 |
324 | mBuffer [0] = mCH341A_CMD_I2C_STREAM; // command code
325 | mBuffer [1] = mCH341A_CMD_I2C_STM_STA; // generate the start bit
326 | mBuffer [2] = (UCHAR) (mCH341A_CMD_I2C_STM_OUT | 1); // output data, bit 5 - bit 0 of length, 1 byte
327 | mBuffer [3] = (UCHAR) (iDeviceAddr | 0x01); // device address, read
328 | mBuffer [4] = (UCHAR) (mCH341A_CMD_I2C_STM_IN | 1); // input data, bit 5 - bit 0 of length, 1 byte
329 | mBuffer [5] = mCH341A_CMD_I2C_STM_STO; // stop bit generation
330 | mBuffer [6] = mCH341A_CMD_I2C_STM_END; // end of the current package in advance
331 | mLength = 7;
332 | mInLen = 0;
333 | // execute the command stream, and then input the first output
334 | if (CH341WriteRead (iIndex, mLength, mBuffer, mCH341A_CMD_I2C_STM_MAX, 1, & mInLen, mBuffer)) {
335 | if (mInLen) {
336 | *OInByte = mBuffer[mInLen - 1]; // return the data
337 | return (TRUE);
338 | }
339 | }
340 | return (FALSE);
341 | }
342 |
343 | /* ************************************************ ********************************************** */
344 | /* Example: two-way operation of I / O expansion PCA9554 */
345 |
346 | BOOL WINAPI PCA9554_SetIO ( // set the PCA9554's I / O direction
347 | ULONG iIndex, // device number designated CH341
348 | ULONG iDeviceAddr, // device address, the lowest order bit of the direction bit
349 | ULONG iSetByte) // direction data
350 | { // Can also be achieved with CH341WriteI2C
351 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
352 |
353 | mBuffer [0] = (UCHAR) (iDeviceAddr & 0xFE); // device address, write
354 | mBuffer [1] = 0x03;
355 | mBuffer [2] = (UCHAR) iSetByte; // I / O direction of the data
356 | return (CH341StreamI2C (iIndex, 3, mBuffer, 0, NULL)); // I2C data stream processing
357 | }
358 |
359 |
360 | BOOL WINAPI PCA9554_WriteIO (// output PCA9554's I / O
361 | ULONG iIndex, // device number designated CH341
362 | ULONG iDeviceAddr, // device address, the lowest order bit of the direction bit
363 | ULONG iOutByte) // prepare to write the I / O data
364 | {// Can also be achieved with CH341WriteI2C
365 |
366 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
367 | mBuffer [0] = (UCHAR) (iDeviceAddr & 0xFE); // device address, write
368 | mBuffer [1] = 0x01;
369 | mBuffer [2] = (UCHAR) iOutByte; // I / O data
370 | return (CH341StreamI2C (iIndex, 3, mBuffer, 0, NULL)); // I2C data stream processing
371 | }
372 |
373 | BOOL WINAPI PCA9554_ReadIO (// input PCA9554's I / O
374 | ULONG iIndex, // device number designated CH341
375 | ULONG iDeviceAddr, // device address, the lowest order bit of the direction bit
376 | PUCHAR oInByte) // points to a byte buffer is read back after the I / O data
377 | {// Can also be achieved with CH341ReadI2C
378 |
379 | UCHAR mBuffer [mCH341_PACKET_LENGTH];
380 |
381 | mBuffer [0] = (UCHAR) (iDeviceAddr & 0xFE); // device address, CH341StreamI2C handled automatically read
382 | mBuffer [1] = 0x00;
383 | return (CH341StreamI2C (iIndex, 2, mBuffer, 1, oInByte)); // I2C data stream processing
384 | }
385 |
386 |
--------------------------------------------------------------------------------
/ch341eeprom.h:
--------------------------------------------------------------------------------
1 | // libUSB driver for the ch341a in i2c mode
2 | //
3 | // Copyright 2011 asbokid
4 |
5 | #define CH341TOOLVERSION "0.5"
6 |
7 | #define USB_LOCK_VENDOR 0x1a86 // Dev : (1a86) QinHeng Electronics
8 | #define USB_LOCK_PRODUCT 0x5512 // (5512) CH341A in i2c mode
9 |
10 |
11 | #define MAX_EEPROM_SIZE 131072 /* For 24c1024*/
12 |
13 | #define EEPROM_I2C_BUS_ADDRESS 0x50
14 |
15 | #define BULK_WRITE_ENDPOINT 0x02 /* bEndpointAddress 0x02 EP 2 OUT (Bulk)*/
16 | #define BULK_READ_ENDPOINT 0x82 /* bEndpointAddress 0x82 EP 2 IN (Bulk)*/
17 | #define DEFAULT_INTERFACE 0x00
18 |
19 | #define DEFAULT_CONFIGURATION 0x01
20 | #define DEFAULT_TIMEOUT 300 // 300mS for USB timeouts
21 |
22 | #define IN_BUF_SZ 0x100
23 | #define EEPROM_WRITE_BUF_SZ 0x2b // only for 24c64 / 24c32 ??
24 | #define EEPROM_READ_BULKIN_BUF_SZ 0x20
25 | #define EEPROM_READ_BULKOUT_BUF_SZ 0x65
26 |
27 | /* Based on (closed-source) DLL V1.9 for USB by WinChipHead (c) 2005.
28 | Supports USB chips: CH341, CH341A
29 | This can be a problem for copyright, sure asbokid can't release this part on any GPL licence*/
30 |
31 | #define mCH341_PACKET_LENGTH 32 /* wMaxPacketSize 0x0020 1x 32 bytes, unused on the source*/
32 | #define mCH341_PKT_LEN_SHORT 8 /* wMaxPacketSize 0x0008 1x 8 bytes, unused on the source*/
33 |
34 | #define mCH341_ENDP_INTER_UP 0x81 /* bEndpointAddress 0x81 EP 1 IN (Interrupt), unused on the source*/
35 | #define mCH341_ENDP_INTER_DOWN 0x01 /* This endpoint isn't list on my lsusb -v output, unused on the source*/
36 | #define mCH341_ENDP_DATA_UP 0x82 /* ==BULK_READ_ENDPOINT Why repeat it?*/
37 | #define mCH341_ENDP_DATA_DOWN 0x02 /* ==BULK_WRITE_ENDPOINT Why repeat it?*/
38 |
39 | #define mCH341_VENDOR_READ 0xC0 /* Unused on the source*/
40 | #define mCH341_VENDOR_WRITE 0x40 /* Unused on the source*/
41 |
42 | #define mCH341_PARA_INIT 0xB1 /* Unused on the source*/
43 | #define mCH341_I2C_STATUS 0x52 /* Unused on the source*/
44 | #define mCH341_I2C_COMMAND 0x53 /* Unused on the source*/
45 |
46 | #define mCH341_PARA_CMD_R0 0xAC /* Unused on the source*/
47 | #define mCH341_PARA_CMD_R1 0xAD /* Unused on the source*/
48 | #define mCH341_PARA_CMD_W0 0xA6 /* Unused on the source*/
49 | #define mCH341_PARA_CMD_W1 0xA7 /* Unused on the source*/
50 | #define mCH341_PARA_CMD_STS 0xA0 /* Unused on the source*/
51 |
52 | #define mCH341A_CMD_SET_OUTPUT 0xA1 /* Unused on the source*/
53 | #define mCH341A_CMD_IO_ADDR 0xA2 /* Unused on the source*/
54 | #define mCH341A_CMD_PRINT_OUT 0xA3 /* Unused on the source*/
55 | #define mCH341A_CMD_SPI_STREAM 0xA8 /* Unused on the source*/
56 | #define mCH341A_CMD_SIO_STREAM 0xA9 /* Unused on the source*/
57 | #define mCH341A_CMD_I2C_STREAM 0xAA
58 | #define mCH341A_CMD_UIO_STREAM 0xAB /* Unused on the source*/
59 |
60 | #define mCH341A_BUF_CLEAR 0xB2 /* Unused on the source*/
61 | #define mCH341A_I2C_CMD_X 0x54 /* Unused on the source*/
62 | #define mCH341A_DELAY_MS 0x5E /* Unused on the source*/
63 | #define mCH341A_GET_VER 0x5F /* Unused on the source*/
64 |
65 | #define mCH341_EPP_IO_MAX ( mCH341_PACKET_LENGTH - 1 ) /* Unused on the source*/
66 | #define mCH341A_EPP_IO_MAX 0xFF /* Unused on the source*/
67 |
68 | #define mCH341A_CMD_IO_ADDR_W 0x00 /* Unused on the source*/
69 | #define mCH341A_CMD_IO_ADDR_R 0x80 /* Unused on the source*/
70 |
71 | #define mCH341A_CMD_I2C_STM_STA 0x74
72 | #define mCH341A_CMD_I2C_STM_STO 0x75
73 | #define mCH341A_CMD_I2C_STM_OUT 0x80
74 | #define mCH341A_CMD_I2C_STM_IN 0xC0
75 | #define mCH341A_CMD_I2C_STM_MAX ( min( 0x3F, mCH341_PACKET_LENGTH ) ) /* Unused on the source*/
76 | #define mCH341A_CMD_I2C_STM_SET 0x60
77 | #define mCH341A_CMD_I2C_STM_US 0x40 /* Unused on the source*/
78 | #define mCH341A_CMD_I2C_STM_MS 0x50 /* Unused on the source*/
79 | #define mCH341A_CMD_I2C_STM_DLY 0x0F /* Unused on the source*/
80 | #define mCH341A_CMD_I2C_STM_END 0x00
81 |
82 | #define mCH341A_CMD_UIO_STM_IN 0x00 /* Unused on the source*/
83 | #define mCH341A_CMD_UIO_STM_DIR 0x40 /* Unused on the source*/
84 | #define mCH341A_CMD_UIO_STM_OUT 0x80 /* Unused on the source*/
85 | #define mCH341A_CMD_UIO_STM_US 0xC0 /* Unused on the source*/
86 | #define mCH341A_CMD_UIO_STM_END 0x20 /* Unused on the source*/
87 |
88 | #define mCH341_PARA_MODE_EPP 0x00 /* Unused on the source*/
89 | #define mCH341_PARA_MODE_EPP17 0x00 /* Unused on the source*/
90 | #define mCH341_PARA_MODE_EPP19 0x01 /* Unused on the source*/
91 | #define mCH341_PARA_MODE_MEM 0x02 /* Unused on the source*/
92 |
93 | /* End of part based on (closed-source) DLL V1.9 for USB by WinChipHead (c) 2005.
94 | Since is largely unused we can replace it*/
95 |
96 |
97 | #define CH341_I2C_LOW_SPEED 0 // low speed - 20kHz
98 | #define CH341_I2C_STANDARD_SPEED 1 // standard speed - 100kHz
99 | #define CH341_I2C_FAST_SPEED 2 // fast speed - 400kHz
100 | #define CH341_I2C_HIGH_SPEED 3 // high speed - 750kHz
101 |
102 | #define CH341_EEPROM_READ_CMD_SZ 0x65 /* Same size for all 24cXX read setup and next packets*/
103 |
104 | /* CH341a READ EEPROM setup packet for the 24c01
105 | this needs putting into a struct to allow convenient access to individual elements*/
106 | #define CH341_EEPROM_24c01_READ_SETUP_CMD "\xaa\x74\x82\xa0\x00\x74\x81\xa1\xe0\x00\x0f\x00\x06\x04\x00\x00" \
107 | "\x00\x00\x00\x00\x01\x00\x00\x00\x11\x4d\x40\x77\xcd\xab\xba\xdc" \
108 | "\xaa\xe0\x00\x00\xc4\xf1\x12\x00\x11\x4d\x40\x77\xf0\xf1\x12\x00" \
109 | "\xd9\x8b\x41\x7e\x00\xd0\xfd\x7f\xf0\xf1\x12\x00\x5a\x88\x41\x7e" \
110 | "\xaa\xe0\x00\x00\x2a\x88\x41\x7e\x06\x04\x00\x00\x11\x4d\x40\x77" \
111 | "\xe8\xf3\x12\x00\x14\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
112 | "\xaa\xdf\xc0\x75\x00"
113 | /* please se file /wiresharkusbsniffing/sniffed.txt
114 | this is the read setup packet for 24c01
115 |
116 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 0f 00 06 04 00 00 .t...t.. ........
117 | 0050 00 00 00 00 01 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
118 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
119 | 0070 d9 8b 41 7e 00 d0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
120 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
121 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
122 | 00a0 aa df c0 75 00 ...u.
123 | */
124 |
125 | /* CH341a READ EEPROM next packet for 24c01 (no packets!!!)*/
126 |
127 |
128 | /* CH341a READ EEPROM setup packet for the 24c02
129 | this needs putting into a struct to allow convenient access to individual elements*/
130 | #define CH341_EEPROM_24c02_READ_SETUP_CMD "\xaa\x74\x82\xa0\x00\x74\x81\xa1\xe0\x00\x10\x00\x06\x04\x00\x00" \
131 | "\x00\x00\x00\x00\x02\x00\x00\x00\x11\x4d\x40\x77\xcd\xab\xba\xdc" \
132 | "\xaa\xe0\x00\x00\xc4\xf1\x12\x00\x11\x4d\x40\x77\xf0\xf1\x12\x00" \
133 | "\xd9\x8b\x41\x7e\x00\xf0\xfd\x7f\xf0\xf1\x12\x00\x5a\x88\x41\x7e" \
134 | "\xaa\xe0\x00\x00\x2a\x88\x41\x7e\x06\x04\x00\x00\x11\x4d\x40\x77" \
135 | "\xe8\xf3\x12\x00\x14\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
136 | "\xaa\xdf\xc0\x75\x00"
137 | /* please se file /wiresharkusbsniffing/sniffed.txt
138 | this is the read setup packet for 24c02
139 |
140 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 10 00 06 04 00 00 .t...t.. ........
141 | 0050 00 00 00 00 02 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
142 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
143 | 0070 d9 8b 41 7e 00 f0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
144 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
145 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
146 | 00a0 aa df c0 75 00 ...u.
147 | */
148 |
149 | /* CH341a READ EEPROM next packet for 24c02 (one packet)*/
150 | #define CH341_EEPROM_24c02_READ_NEXT_CMD "\xaa\x74\x82\xa0\x80\x74\x81\xa1\xe0\x00\x00\x00\x10\x00\x00\x00" \
151 | "\x00\x00\x00\x00\x8c\xf1\x12\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
152 | "\xaa\xe0\x00\x00\x4c\xf1\x12\x00\x5d\x22\xd7\x5a\xdc\xf1\x12\x00" \
153 | "\x8f\x04\x44\x7e\x30\x88\x41\x7e\xff\xff\xff\xff\x2a\x88\x41\x7e" \
154 | "\xaa\xe0\x00\x7e\x00\x00\x00\x00\x69\x0e\x3c\x00\xe4\x00\x18\x00" \
155 | "\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8c\xe8\x67\x00" \
156 | "\xaa\xdf\xc0\x75\x00"
157 | /*please see file /wiresharkusbsniffing/sniffed.txt
158 | this is the read next packet for 24c02 (one packet)
159 |
160 | 0040 aa 74 82 a0 80 74 81 a1 e0 00 00 00 10 00 00 00 .t...t.. ........
161 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
162 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
163 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
164 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 e4 00 18 00 ...~.... i.<.....
165 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
166 | 00a0 aa df c0 75 00 ...u.
167 | */
168 |
169 |
170 | /* CH341a READ EEPROM setup packet for the 24c04
171 | this needs putting into a struct to allow convenient access to individual elements*/
172 | #define CH341_EEPROM_24c04_READ_SETUP_CMD "\xaa\x74\x82\xa0\x00\x74\x81\xa1\xe0\x00\x11\x00\x06\x04\x00\x00" \
173 | "\x00\x00\x00\x00\x04\x00\x00\x00\x11\x4d\x40\x77\xcd\xab\xba\xdc" \
174 | "\xaa\xe0\x00\x00\xc4\xf1\x12\x00\x11\x4d\x40\x77\xf0\xf1\x12\x00" \
175 | "\xd9\x8b\x41\x7e\x00\xd0\xfd\x7f\xf0\xf1\x12\x00\x5a\x88\x41\x7e" \
176 | "\xaa\xe0\x00\x00\x2a\x88\x41\x7e\x06\x04\x00\x00\x11\x4d\x40\x77" \
177 | "\xe8\xf3\x12\x00\x14\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
178 | "\xaa\xdf\xc0\x75\x00"
179 | /* please se file /wiresharkusbsniffing/sniffed.txt
180 | this is the read setup packet for 24c04
181 |
182 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 11 00 06 04 00 00 .t...t.. ........
183 | 0050 00 00 00 00 04 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
184 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
185 | 0070 d9 8b 41 7e 00 d0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
186 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
187 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
188 | 00a0 aa df c0 75 00 ...u.
189 | */
190 |
191 | /* CH341a READ EEPROM next packet for 24c04 (three packets)*/
192 | #define CH341_EEPROM_24c04_READ_NEXT_CMD "\xaa\x74\x82\xa0\x80\x74\x81\xa1\xe0\x00\x00\x00\x10\x00\x00\x00" \
193 | "\x00\x00\x00\x00\x8c\xf1\x12\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
194 | "\xaa\xe0\x00\x00\x4c\xf1\x12\x00\x5d\x22\xd7\x5a\xdc\xf1\x12\x00" \
195 | "\x8f\x04\x44\x7e\x30\x88\x41\x7e\xff\xff\xff\xff\x2a\x88\x41\x7e" \
196 | "\xaa\xe0\x00\x7e\x00\x00\x00\x00\x69\x0e\x3c\x00\xde\x00\x16\x00" \
197 | "\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8c\xe8\x67\x00" \
198 | "\xaa\xdf\xc0\x75\x00"
199 | /*please see file /wiresharkusbsniffing/sniffed.txt
200 | this is the first read next packet for 24c04 (three different packets)
201 |
202 | 0040 aa 74 82 a0 80 74 81 a1 e0 00 00 00 10 00 00 00 .t...t.. ........
203 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
204 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
205 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
206 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 de 00 16 00 ...~.... i.<.....
207 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
208 | 00a0 aa df c0 75 00 ...u.
209 | */
210 |
211 |
212 | /* CH341a READ EEPROM setup packet for the 24c08
213 | this needs putting into a struct to allow convenient access to individual elements*/
214 | #define CH341_EEPROM_24c08_READ_SETUP_CMD "\xaa\x74\x82\xa0\x00\x74\x81\xa1\xe0\x00\x16\x00\x06\x04\x00\x00" \
215 | "\x00\x00\x00\x00\x08\x00\x00\x00\x11\x4d\x40\x77\xcd\xab\xba\xdc" \
216 | "\xaa\xe0\x00\x00\xc4\xf1\x12\x00\x11\x4d\x40\x77\xf0\xf1\x12\x00" \
217 | "\xd9\x8b\x41\x7e\x00\xd0\xfd\x7f\xf0\xf1\x12\x00\x5a\x88\x41\x7e" \
218 | "\xaa\xe0\x00\x00\x2a\x88\x41\x7e\x06\x04\x00\x00\x11\x4d\x40\x77" \
219 | "\xe8\xf3\x12\x00\x14\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
220 | "\xaa\xdf\xc0\x75\x00"
221 | /* please se file /wiresharkusbsniffing/sniffed.txt
222 | this is the read setup packet for 24c08
223 |
224 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 16 00 06 04 00 00 .t...t.. ........
225 | 0050 00 00 00 00 08 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
226 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
227 | 0070 d9 8b 41 7e 00 d0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
228 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
229 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
230 | 00a0 aa df c0 75 00 ...u.
231 | */
232 |
233 | /* CH341a READ EEPROM next packet for 24c08 (seven packets)*/
234 | #define CH341_EEPROM_24c08_READ_NEXT_CMD "\xaa\x74\x82\xa0\x80\x74\x81\xa1\xe0\x00\x00\x00\x10\x00\x00\x00" \
235 | "\x00\x00\x00\x00\x8c\xf1\x12\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
236 | "\xaa\xe0\x00\x00\x4c\xf1\x12\x00\x5d\x22\xd7\x5a\xdc\xf1\x12\x00" \
237 | "\x8f\x04\x44\x7e\x30\x88\x41\x7e\xff\xff\xff\xff\x2a\x88\x41\x7e" \
238 | "\xaa\xe0\x00\x7e\x00\x00\x00\x00\x69\x0e\x3c\x00\x00\x01\x1a\x00" \
239 | "\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8c\xe8\x67\x00" \
240 | "\xaa\xdf\xc0\x75\x00"
241 | /*please see file /wiresharkusbsniffing/sniffed.txt
242 | this is the first read next packet for 24c08 (seven different packets)
243 |
244 | 0040 aa 74 82 a0 80 74 81 a1 e0 00 00 00 10 00 00 00 .t...t.. ........
245 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
246 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
247 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
248 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 00 01 1a 00 ...~.... i.<.....
249 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
250 | 00a0 aa df c0 75 00 ...u.
251 | */
252 |
253 |
254 | /* CH341a READ EEPROM setup packet for the 24c16
255 | this needs putting into a struct to allow convenient access to individual elements*/
256 | #define CH341_EEPROM_24c16_READ_SETUP_CMD "\xaa\x74\x82\xa0\x00\x74\x81\xa1\xe0\x00\x0e\x00\x06\x04\x00\x00" \
257 | "\x00\x00\x00\x00\x10\x00\x00\x00\x11\x4d\x40\x77\xcd\xab\xba\xdc" \
258 | "\xaa\xe0\x00\x00\xc4\xf1\x12\x00\x11\x4d\x40\x77\xf0\xf1\x12\x00" \
259 | "\xd9\x8b\x41\x7e\x00\xe0\xfd\x7f\xf0\xf1\x12\x00\x5a\x88\x41\x7e" \
260 | "\xaa\xe0\x00\x00\x2a\x88\x41\x7e\x06\x04\x00\x00\x11\x4d\x40\x77" \
261 | "\xe8\xf3\x12\x00\x14\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
262 | "\xaa\xdf\xc0\x75\x00"
263 | /* please se file /wiresharkusbsniffing/sniffed.txt
264 | this is the read setup packet for 24c16
265 |
266 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 0e 00 06 04 00 00 .t...t.. ........
267 | 0050 00 00 00 00 10 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
268 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
269 | 0070 d9 8b 41 7e 00 e0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
270 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
271 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
272 | 00a0 aa df c0 75 00 ...u.
273 | */
274 |
275 | /* CH341a READ EEPROM next packet for 24c16*/
276 | #define CH341_EEPROM_24c16_READ_NEXT_CMD "\xaa\x74\x82\xa0\x80\x74\x81\xa1\xe0\x00\x00\x00\x10\x00\x00\x00" \
277 | "\x00\x00\x00\x00\x8c\xf1\x12\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
278 | "\xaa\xe0\x00\x00\x4c\xf1\x12\x00\x5d\x22\xd7\x5a\xdc\xf1\x12\x00" \
279 | "\x8f\x04\x44\x7e\x30\x88\x41\x7e\xff\xff\xff\xff\x2a\x88\x41\x7e" \
280 | "\xaa\xe0\x00\x7e\x00\x00\x00\x00\x69\x0e\x3c\x00\xfa\x00\x31\x00" \
281 | "\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8c\xe8\x67\x00" \
282 | "\xaa\xdf\xc0\x75\x00"
283 | /*please see file /wiresharkusbsniffing/sniffed.txt
284 | this is the first read next packet for 24c16 (fifteen different packets)
285 |
286 | 0040 aa 74 82 a0 80 74 81 a1 e0 00 00 00 10 00 00 00 .t...t.. ........
287 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
288 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
289 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
290 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
291 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
292 | 00a0 aa df c0 75 00 ...u.
293 | */
294 |
295 |
296 | /* CH341a READ EEPROM setup packet for the 24c64
297 | this needs putting into a struct to allow convenient access to individual elements*/
298 | #define CH341_EEPROM_24c64_READ_SETUP_CMD "\xaa\x74\x83\xa0\x00\x00\x74\x81\xa1\xe0\x00\x00\x06\x04\x00\x00" \
299 | "\x00\x00\x00\x00\x40\x00\x00\x00\x11\x4d\x40\x77\xcd\xab\xba\xdc" \
300 | "\xaa\xe0\x00\x00\xc4\xf1\x12\x00\x11\x4d\x40\x77\xf0\xf1\x12\x00" \
301 | "\xd9\x8b\x41\x7e\x00\xf0\xfd\x7f\xf0\xf1\x12\x00\x5a\x88\x41\x7e" \
302 | "\xaa\xe0\x00\x00\x2a\x88\x41\x7e\x06\x04\x00\x00\x11\x4d\x40\x77" \
303 | "\xe8\xf3\x12\x00\x14\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
304 | "\xaa\xdf\xc0\x75\x00"
305 | /* please se file /wiresharkusbsniffing/sniffed.txt
306 | this is the read setup packet for 24c64
307 |
308 | 0040 aa 74 83 a0 00 00 74 81 a1 e0 00 00 06 04 00 00 .t....t. ........
309 | 0050 00 00 00 00 40 00 00 00 11 4d 40 77 cd ab ba dc ....@... .M@w....
310 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
311 | 0070 d9 8b 41 7e 00 e0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
312 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
313 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
314 | 00a0 aa df c0 75 00 ...u.
315 | */
316 |
317 | /* CH341a READ EEPROM next packet for 24c64 (63 packets)*/
318 | #define CH341_EEPROM_24c64_READ_NEXT_CMD "\xaa\x74\x83\xa0\x00\x00\x74\x81\xa1\xe0\x00\x00\x10\x00\x00\x00" \
319 | "\x00\x00\x00\x00\x8c\xf1\x12\x00\x01\x00\x00\x00\x00\x00\x00\x00" \
320 | "\xaa\xe0\x00\x00\x4c\xf1\x12\x00\x5d\x22\xd7\x5a\xdc\xf1\x12\x00" \
321 | "\x8f\x04\x44\x7e\x30\x88\x41\x7e\xff\xff\xff\xff\x2a\x88\x41\x7e" \
322 | "\xaa\xe0\x00\x7e\x00\x00\x00\x00\x69\x0e\x3c\x00\x12\x01\x19\x00" \
323 | "\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9c\x2e\x68\x00" \
324 | "\xaa\xdf\xc0\x75\x00"
325 | /* please see file /wiresharkusbsniffing/sniffed.txt
326 | this is the first read next packet for 24c64 (63 different packets)
327 |
328 | 0040 aa 74 83 a0 00 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
329 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
330 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
331 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
332 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 3a 01 1b 00 ...~.... i.<.:...
333 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
334 | 00a0 aa df c0 75 00 ...u.
335 | */
336 |
337 | #define MIN(a,b) (((a)<(b))?(a):(b))
338 | #define MAX(a,b) (((a)>(b))?(a):(b))
339 |
340 | #define TRUE 1
341 | #define FALSE 0
342 |
343 | struct EEPROM {
344 | char *name;
345 | uint32_t size;
346 | uint16_t page_size;
347 | uint8_t addr_size; // Length of addres in bytes
348 | uint8_t addr; // value of the (up to) three EEPROM address select pins
349 | };
350 |
351 | const static struct EEPROM eepromlist[] = {
352 | { "24c01", 128, 8, 1, 0x00}, // 16 pages of 8 bytes each = 128 bytes
353 | { "24c02", 256, 8, 1, 0x00}, // 32 pages of 8 bytes each = 256 bytes
354 | { "24c04", 512, 16, 1, 0x01}, // 32 pages of 16 bytes each = 512 bytes
355 | { "24c08", 1024, 16, 1, 0x03}, // 64 pages of 16 bytes each = 1024 bytes
356 | { "24c16", 2048, 16, 1, 0x07}, // 128 pages of 16 bytes each = 2048 bytes
357 | { "24c32", 4096, 32, 2, 0x00}, // 32kbit = 4kbyte
358 | { "24c64", 8192, 32, 2, 0x00},
359 | { "24c128", 16384, 32/*64*/, 2, 0x00},
360 | { "24c256", 32768, 32/*64*/, 2, 0x00},
361 | { "24c512", 65536, 32/*128*/, 2, 0x00},
362 | { "24c1024", 131072, 32/*128*/, 2, 0x01},
363 | { 0, 0, 0, 0 }
364 | };
365 |
366 | extern uint8_t *readbuf;
367 |
368 | int32_t ch341readEEPROM(struct libusb_device_handle *devHandle, uint8_t *buf, uint32_t bytes, struct EEPROM* eeprom_info);
369 | int32_t ch341writeEEPROM(struct libusb_device_handle *devHandle, uint8_t *buf, uint32_t bytes, struct EEPROM* eeprom_info);
370 | struct libusb_device_handle *ch341configure(uint16_t vid, uint16_t pid);
371 | int32_t ch341setstream(struct libusb_device_handle *devHandle, uint32_t speed);
372 | int32_t parseEEPsize(char* eepromname, struct EEPROM *eeprom);
373 |
374 | // callback functions for async USB transfers
375 | void cbBulkIn(struct libusb_transfer *transfer);
376 | void cbBulkOut(struct libusb_transfer *transfer);
377 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/wiresharkusbsniffing/sniffed.txt:
--------------------------------------------------------------------------------
1 | The BULK OUT packets with payload of 101 bytes sent during 24c32/24c64 EEPROM READ operations
2 | have the following structure.
3 |
4 | Of those BULK OUT packets, two different types are sent. There is an initial 'SETUP' packet
5 | and then there are repeated packets sent to request the next block of EEPROM data
6 |
7 |
8 | struct READPKT {
9 | uint16_t u16_01_00; // 0x74aa; // start i2c mode / stream
10 | uint8_t u8_02; // 0x83; // three output bytes to follow
11 | uint8_t u8_03; // 0xa0; // device write address
12 | uint16_t u16_05_04; // 0x0000; // byte address (16 bit)
13 | uint8_t u8_06; // 0x74; // i2c stream start
14 | uint8_t u8_07; // 0x81; // one read byte to follow
15 | uint8_t u8_08; // 0xa1; // device read address
16 | uint8_t u8_09; // 0xe0; // (unknown)
17 | uint16_t u16_0b_0a; // 0x0000; // eep size index (0xf=24c01,0x10=24c02,0x11=24c04,0x16=24c08,0xe=24c16,0x00 otherwise)
18 | uint32_t u32_0f_0c; // 0x00000406; // (unknown)
19 | uint32_t u32_13_10; // 0x00000000; // (unknown)
20 | uint32_t u32_17_14; // 0x20000000; // eeprom size index (1=24c01, 2=24c02,.. 0x20=24c32 (as shown), 0x40=24c64, (x 0x80)
21 | uint32_t u32_1b_18; // 0x77404d11; // (unknown)
22 | uint32_t u32_1f_1c; // 0xdcbaabcd; // (unknown)
23 | uint32_t u32_23_20; // 0x0000e0aa; // start i2c mode / e0
24 | uint32_t u32_27_24; // 0x0012f1c4; // (unknown)
25 | uint32_t u32_2b_28; // 0x77404d11; // (unknown)
26 | uint32_t u32_2f_2c; // 0x0012f1f0; // (unknown)
27 | uint32_t u32_33_30; // 0x7e418bd9; // (unknown)
28 | uint32_t u32_37_34; // 0x7ffdd000; // (unknown)
29 | uint32_t u32_3b_38; // 0x0012f1f0; // (unknown)
30 | uint32_t u32_3f_3c; // 0x77404d11; // (unknown)
31 | uint32_t u32_43_40; // 0x0012f3e8; // (unknown)
32 | uint32_t u32_47_44; // 0x00000014; // (unknown)
33 | uint32_t u32_4b_48; // 0x00000001; // (unknown)
34 | uint32_t u32_4f_4c; // 0x00000000; // (unknown)
35 | uint32_t u32_53_50; // 0x7fc0dfaa; // i2c stream end
36 | uint8_t u8_54; // 0x00; // i2c stream stop
37 | };
38 |
39 | /*
40 | struct
41 | uint16_t u16_01_00; = 0x74aa; // start i2c mode / stream
42 | uint8_t u8_02; = 0x83; // three output bytes to follow
43 | uint8_t u8_03; = 0xa0; // device write address
44 | uint16_t u16_05_04; = 0x0000; // byte address (16 bit)
45 | uint8_t u8_06; = 0x74; // i2c stream start
46 | uint8_t u8_07; = 0x81; // one read byte to follow
47 | uint8_t u8_08; = 0xa1; // device read address
48 | uint8_t u8_09; = 0xe0; // (unknown)
49 | uint16_t u16_0b_0a; = 0x0000; // eep size index (0xf=24c01,0x10=24c02,0x11=24c04,0x16=24c08,0xe=24c16,0x00 otherwise)
50 | uint32_t u32_0f_0c; = 0x00000406; // (unknown)
51 | uint32_t u32_13_10; = 0x00000000; // (unknown)
52 | uint32_t u32_17_14; = 0x00000000; // eeprom size index (1=24c01, 2=24c02,.. 0x20=24c32, 0x40=24c64, etc.
53 | uint32_t u32_1b_18; = 0x77404d11; // (unknown)
54 | uint32_t u32_1f_1c; = 0xdcbaabcd; // (unknown)
55 | uint32_t u32_23_20; = 0x0000e0aa; // start i2c mode / e0
56 | uint32_t u32_27_24; = 0x0012f1c4; // (unknown)
57 | uint32_t u32_2b_28; = 0x77404d11; // (unknown)
58 | uint32_t u32_2f_2c; = 0x0012f1f0; // (unknown)
59 | uint32_t u32_33_30; = 0x7e418bd9; // (unknown)
60 | uint32_t u32_37_34; = 0x7ffdd000; // (unknown)
61 | uint32_t u32_3b_38; = 0x0012f1f0; // (unknown)
62 | uint32_t u32_3f_3c; = 0x77404d11; // (unknown)
63 | uint32_t u32_43_40; = 0x0012f3e8; // (unknown)
64 | uint32_t u32_47_44; = 0x00000014; // (unknown)
65 | uint32_t u32_4b_48; = 0x00000001; // (unknown)
66 | uint32_t u32_4f_4c; = 0x00000000; // (unknown)
67 | uint32_t u32_53_50; = 0x7fc0dfaa; // i2c stream end
68 | uint8_t u8_54; = 0x00; // i2c stream stop
69 | */
70 |
71 |
72 |
73 | read setup packet for 24c01
74 |
75 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 0f 00 06 04 00 00 .t...t.. ........
76 | 0050 00 00 00 00 01 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
77 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
78 | 0070 d9 8b 41 7e 00 d0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
79 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
80 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
81 | 00a0 aa df c0 75 00 ...u.
82 |
83 | read setup packet for 24c02
84 |
85 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 10 00 06 04 00 00 .t...t.. ........
86 | 0050 00 00 00 00 02 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
87 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
88 | 0070 d9 8b 41 7e 00 f0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
89 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
90 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
91 | 00a0 aa df c0 75 00 ...u.
92 |
93 | read setup packet for 24c04
94 |
95 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 11 00 06 04 00 00 .t...t.. ........
96 | 0050 00 00 00 00 04 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
97 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
98 | 0070 d9 8b 41 7e 00 d0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
99 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
100 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
101 | 00a0 aa df c0 75 00 ...u.
102 |
103 | read setup packet for 24c08
104 |
105 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 16 00 06 04 00 00 .t...t.. ........
106 | 0050 00 00 00 00 08 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
107 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
108 | 0070 d9 8b 41 7e 00 d0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
109 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
110 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
111 | 00a0 aa df c0 75 00 ...u.
112 |
113 | read setup packet for 24c16
114 |
115 | 0040 aa 74 82 a0 00 74 81 a1 e0 00 0e 00 06 04 00 00 .t...t.. ........
116 | 0050 00 00 00 00 10 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
117 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
118 | 0070 d9 8b 41 7e 00 e0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
119 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
120 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
121 | 00a0 aa df c0 75 00 ...u.
122 |
123 | read setup packet for 24c32
124 |
125 | 0040 aa 74 83 a0 00 00 74 81 a1 e0 00 00 06 04 00 00 .t....t. ........
126 | 0050 00 00 00 00 20 00 00 00 11 4d 40 77 cd ab ba dc .... ... .M@w....
127 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
128 | 0070 d9 8b 41 7e 00 f0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
129 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
130 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
131 | 00a0 aa df c0 75 00 ...u.
132 |
133 | read setup packet for 24c64
134 |
135 | 0040 aa 74 83 a0 00 00 74 81 a1 e0 00 00 06 04 00 00 .t....t. ........
136 | 0050 00 00 00 00 40 00 00 00 11 4d 40 77 cd ab ba dc ....@... .M@w....
137 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
138 | 0070 d9 8b 41 7e 00 e0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
139 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
140 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
141 | 00a0 aa df c0 75 00 ...u.
142 |
143 | read setup packet for 24c128
144 |
145 | 0040 aa 74 83 a0 00 00 74 81 a1 e0 00 00 06 04 00 00 .t....t. ........
146 | 0050 00 00 00 00 80 00 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
147 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
148 | 0070 d9 8b 41 7e 00 e0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
149 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
150 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
151 | 00a0 aa df c0 75 00 ...u.
152 |
153 | read setup packet for 24c256
154 |
155 | 0040 aa 74 83 a0 00 00 74 81 a1 e0 00 00 06 04 00 00 .t....t. ........
156 | 0050 00 00 00 00 00 01 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
157 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
158 | 0070 d9 8b 41 7e 00 e0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
159 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
160 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
161 | 00a0 aa df c0 75 00 ...u.
162 |
163 | read setup packet for 24c512
164 |
165 | 0040 aa 74 83 a0 00 00 74 81 a1 e0 00 00 06 04 00 00 .t....t. ........
166 | 0050 00 00 00 00 00 02 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
167 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
168 | 0070 d9 8b 41 7e 00 d0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
169 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
170 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
171 | 00a0 aa df c0 75 00 ...u.
172 |
173 | read setup packet for 24c1024
174 |
175 | 0040 aa 74 83 a0 00 00 74 81 a1 e0 00 00 06 04 00 00 .t....t. ........
176 | 0050 00 00 00 00 00 04 00 00 11 4d 40 77 cd ab ba dc ........ .M@w....
177 | 0060 aa e0 00 00 c4 f1 12 00 11 4d 40 77 f0 f1 12 00 ........ .M@w....
178 | 0070 d9 8b 41 7e 00 e0 fd 7f f0 f1 12 00 5a 88 41 7e ..A~.... ....Z.A~
179 | 0080 aa e0 00 00 2a 88 41 7e 06 04 00 00 11 4d 40 77 ....*.A~ .....M@w
180 | 0090 e8 f3 12 00 14 00 00 00 01 00 00 00 00 00 00 00 ........ ........
181 | 00a0 aa df c0 75 00 ...u.
182 |
183 |
184 |
185 | ---------------------------------
186 | read next packet for 24c01
187 |
188 | (no packet)
189 |
190 | ---------------------------------
191 | read next packet for 24c02 (one packet)
192 |
193 | 0040 aa 74 82 a0 80 74 81 a1 e0 00 00 00 10 00 00 00 .t...t.. ........
194 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
195 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
196 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
197 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 e4 00 18 00 ...~.... i.<.....
198 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
199 | 00a0 aa df c0 75 00
200 |
201 | ---------------------------------
202 | read next packet for 24c04 (three packets)
203 |
204 | 0040 aa 74 82 a0 80 74 81 a1 e0 00 00 00 10 00 00 00 .t...t.. ........
205 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
206 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
207 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
208 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 de 00 16 00 ...~.... i.<.....
209 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
210 | 00a0 aa df c0 75 00 ...u.
211 |
212 | 0040 aa 74 82 a2 00 74 81 a3 e0 00 00 00 10 00 00 00 .t...t.. ........
213 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
214 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
215 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
216 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 de 00 16 00 ...~.... i.<.....
217 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
218 | 00a0 aa df c0 75 00 ...u.
219 |
220 | 0040 aa 74 82 a2 80 74 81 a3 e0 00 00 00 10 00 00 00 .t...t.. ........
221 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
222 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
223 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
224 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 de 00 16 00 ...~.... i.<.....
225 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
226 | 00a0 aa df c0 75 00
227 |
228 | ---------------------------------
229 | read next packet for 24c08 (seven packets)
230 |
231 | 0040 aa 74 82 a0 80 74 81 a1 e0 00 00 00 10 00 00 00 .t...t.. ........
232 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
233 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
234 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
235 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 00 01 1a 00 ...~.... i.<.....
236 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
237 | 00a0 aa df c0 75 00 ...u.
238 |
239 | 0040 aa 74 82 a2 00 74 81 a3 e0 00 00 00 10 00 00 00 .t...t.. ........
240 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
241 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
242 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
243 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 00 01 1a 00 ...~.... i.<.....
244 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
245 | 00a0 aa df c0 75 00 ...u.
246 |
247 | 0040 aa 74 82 a2 80 74 81 a3 e0 00 00 00 10 00 00 00 .t...t.. ........
248 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
249 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
250 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
251 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 00 01 1a 00 ...~.... i.<.....
252 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
253 | 00a0 aa df c0 75 00 ...u.
254 |
255 | 0040 aa 74 82 a4 00 74 81 a5 e0 00 00 00 10 00 00 00 .t...t.. ........
256 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
257 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
258 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
259 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 00 01 1a 00 ...~.... i.<.....
260 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
261 | 00a0 aa df c0 75 00 ...u.
262 |
263 | 0040 aa 74 82 a4 80 74 81 a5 e0 00 00 00 10 00 00 00 .t...t.. ........
264 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
265 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
266 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
267 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 00 01 1a 00 ...~.... i.<.....
268 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
269 | 00a0 aa df c0 75 00 ...u.
270 |
271 | 0040 aa 74 82 a6 00 74 81 a7 e0 00 00 00 10 00 00 00 .t...t.. ........
272 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
273 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
274 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
275 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 00 01 1a 00 ...~.... i.<.....
276 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
277 | 00a0 aa df c0 75 00 ...u.
278 |
279 | 0040 aa 74 82 a6 80 74 81 a7 e0 00 00 00 10 00 00 00 .t...t.. ........
280 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
281 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
282 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
283 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 00 01 1a 00 ...~.... i.<.....
284 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
285 | 00a0 aa df c0 75 00 ...u.
286 |
287 | ---------------------------------
288 | read next packet for 24c16 (fifteen packets)
289 |
290 | 0040 aa 74 82 a0 80 74 81 a1 e0 00 00 00 10 00 00 00 .t...t.. ........
291 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
292 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
293 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
294 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
295 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
296 | 00a0 aa df c0 75 00 ...u.
297 |
298 | 0040 aa 74 82 a2 00 74 81 a3 e0 00 00 00 10 00 00 00 .t...t.. ........
299 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
300 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
301 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
302 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
303 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
304 | 00a0 aa df c0 75 00 ...u.
305 |
306 | 0040 aa 74 82 a2 80 74 81 a3 e0 00 00 00 10 00 00 00 .t...t.. ........
307 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
308 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
309 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
310 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
311 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
312 | 00a0 aa df c0 75 00 ...u.
313 |
314 | 0040 aa 74 82 a4 00 74 81 a5 e0 00 00 00 10 00 00 00 .t...t.. ........
315 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
316 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
317 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
318 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
319 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
320 | 00a0 aa df c0 75 00 ...u.
321 |
322 | 0040 aa 74 82 a4 80 74 81 a5 e0 00 00 00 10 00 00 00 .t...t.. ........
323 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
324 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
325 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
326 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
327 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
328 | 00a0 aa df c0 75 00 ...u.
329 |
330 | 0040 aa 74 82 a6 00 74 81 a7 e0 00 00 00 10 00 00 00 .t...t.. ........
331 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
332 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
333 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
334 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
335 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
336 | 00a0 aa df c0 75 00 ...u.
337 |
338 | 0040 aa 74 82 a6 80 74 81 a7 e0 00 00 00 10 00 00 00 .t...t.. ........
339 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
340 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
341 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
342 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
343 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
344 | 00a0 aa df c0 75 00 ...u.
345 |
346 | 0040 aa 74 82 a8 00 74 81 a9 e0 00 00 00 10 00 00 00 .t...t.. ........
347 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
348 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
349 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
350 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
351 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
352 | 00a0 aa df c0 75 00 ...u.
353 |
354 | 0040 aa 74 82 a8 80 74 81 a9 e0 00 00 00 10 00 00 00 .t...t.. ........
355 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
356 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
357 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
358 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
359 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
360 | 00a0 aa df c0 75 00 ...u.
361 |
362 | 0040 aa 74 82 aa 00 74 81 ab e0 00 00 00 10 00 00 00 .t...t.. ........
363 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
364 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
365 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
366 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
367 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
368 | 00a0 aa df c0 75 00 ...u.
369 |
370 | 0040 aa 74 82 aa 80 74 81 ab e0 00 00 00 10 00 00 00 .t...t.. ........
371 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
372 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
373 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
374 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
375 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
376 | 00a0 aa df c0 75 00 ...u.
377 |
378 | 0040 aa 74 82 ac 00 74 81 ad e0 00 00 00 10 00 00 00 .t...t.. ........
379 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
380 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
381 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
382 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
383 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
384 | 00a0 aa df c0 75 00 ...u.
385 |
386 | 0040 aa 74 82 ac 80 74 81 ad e0 00 00 00 10 00 00 00 .t...t.. ........
387 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
388 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
389 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
390 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
391 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
392 | 00a0 aa df c0 75 00 ...u.
393 |
394 | 0040 aa 74 82 ae 00 74 81 af e0 00 00 00 10 00 00 00 .t...t.. ........
395 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
396 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
397 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
398 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
399 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
400 | 00a0 aa df c0 75 00 ...u.
401 |
402 | 0040 aa 74 82 ae 80 74 81 af e0 00 00 00 10 00 00 00 .t...t.. ........
403 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
404 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
405 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
406 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 fa 00 31 00 ...~.... i.<...1.
407 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
408 | 00a0 aa df c0 75 00 ...u.
409 |
410 | ---------------------------------
411 | read next packet for 24c32 (31 packets)
412 |
413 | 0040 aa 74 83 a0 00 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
414 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
415 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
416 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
417 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 10 01 1c 00 ...~.... i.<.....
418 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
419 | 00a0 aa df c0 75 00 ...u.
420 |
421 | 0040 aa 74 83 a0 01 00 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
422 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
423 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
424 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
425 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 10 01 1c 00 ...~.... i.<.....
426 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
427 | 00a0 aa df c0 75 00 ...u.
428 |
429 | 0040 aa 74 83 a0 01 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
430 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
431 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
432 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
433 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 10 01 1c 00 ...~.... i.<.....
434 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
435 | 00a0 aa df c0 75 00 ...u.
436 | [...]
437 | 0040 aa 74 83 a0 0f 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
438 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
439 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
440 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
441 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 10 01 1c 00 ...~.... i.<.....
442 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
443 | 00a0 aa df c0 75 00 ...u.
444 |
445 | ---------------------------------
446 | read next packet for 24c64 (63 packets)
447 |
448 | 0040 aa 74 83 a0 00 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
449 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
450 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
451 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
452 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 3a 01 1b 00 ...~.... i.<.:...
453 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
454 | 00a0 aa df c0 75 00 ...u.
455 |
456 | 0040 aa 74 83 a0 01 00 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
457 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
458 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
459 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
460 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 3a 01 1b 00 ...~.... i.<.:...
461 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
462 | 00a0 aa df c0 75 00 ...u.
463 |
464 | 0040 aa 74 83 a0 01 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
465 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
466 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
467 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
468 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 3a 01 1b 00 ...~.... i.<.:...
469 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
470 | 00a0 aa df c0 75 00 ...u.
471 |
472 | 0040 aa 74 83 a0 02 00 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
473 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
474 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
475 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
476 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 3a 01 1b 00 ...~.... i.<.:...
477 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
478 | 00a0 aa df c0 75 00 ...u.
479 | [...]
480 | 0040 aa 74 83 a0 1f 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
481 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
482 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
483 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
484 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 3a 01 1b 00 ...~.... i.<.:...
485 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
486 | 00a0 aa df c0 75 00 ...u.
487 |
488 | ---------------------------------
489 | read next packet for 24c128 (127 packets)
490 |
491 | 0040 aa 74 83 a0 00 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
492 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
493 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
494 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
495 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 14 01 48 00 ...~.... i.<...H.
496 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
497 | 00a0 aa df c0 75 00 ...u.
498 |
499 | 0040 aa 74 83 a0 01 00 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
500 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
501 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
502 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
503 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
504 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
505 | 00a0 aa df c0 75 00 ...u.
506 |
507 | 0040 aa 74 83 a0 01 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
508 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
509 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
510 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
511 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 14 01 48 00 ...~.... i.<...H.
512 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
513 | 00a0 aa df c0 75 00 ...u.
514 | [...]
515 | 0040 aa 74 83 a0 3f 80 74 81 a1 e0 00 00 eb fe aa 00 .t..?.t. ........
516 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
517 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
518 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
519 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
520 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
521 | 00a0 aa df c0 75 00 ...u.
522 |
523 | ---------------------------------
524 | read next packet for 24c256 (255 packets)
525 |
526 | 0040 aa 74 83 a0 00 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
527 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
528 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
529 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
530 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 32 01 1d 00 ...~.... i.<.2...
531 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
532 | 00a0 aa df c0 75 00 ...u.
533 |
534 | 0040 aa 74 83 a0 01 00 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
535 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
536 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
537 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
538 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
539 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
540 | 00a0 aa df c0 75 00 ...u.
541 |
542 | 0040 aa 74 83 a0 01 80 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
543 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
544 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
545 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
546 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
547 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
548 | 00a0 aa df c0 75 00 ...u.
549 |
550 | 0040 aa 74 83 a0 02 00 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
551 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
552 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
553 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
554 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
555 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
556 | 00a0 aa df c0 75 00 ...u.
557 | [...]
558 | 0040 aa 74 83 a0 7f 80 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
559 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
560 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
561 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
562 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
563 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
564 | 00a0 aa df c0 75 00 ...u.
565 |
566 | ---------------------------------
567 | read next packet for 24c512 (511 packets)
568 |
569 | 0040 aa 74 83 a0 00 80 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
570 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
571 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
572 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
573 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 3e 01 1e 00 ...~.... i.<.>...
574 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
575 | 00a0 aa df c0 75 00 ...u.
576 |
577 | 0040 aa 74 83 a0 01 00 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
578 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
579 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
580 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
581 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
582 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
583 | 00a0 aa df c0 75 00 ...u.
584 |
585 | 0040 aa 74 83 a0 01 80 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
586 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
587 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
588 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
589 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
590 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
591 | 00a0 aa df c0 75 00 ...u.
592 | [...]
593 | 0040 aa 74 83 a0 ff 80 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
594 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
595 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
596 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
597 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
598 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
599 | 00a0 aa df c0 75 00 ...u.
600 |
601 | ---------------------------------
602 | read next packet for 24c1024 (1023 packets)
603 |
604 | 0040 aa 74 83 a0 00 80 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
605 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
606 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
607 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
608 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
609 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
610 | 00a0 aa df c0 75 00 ...u.
611 |
612 | 0040 aa 74 83 a0 01 00 74 81 a1 e0 00 00 10 00 00 00 .t....t. ........
613 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
614 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
615 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
616 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 42 01 1f 00 ...~.... i.<.B...
617 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
618 | 00a0 aa df c0 75 00 ...u.
619 |
620 | 0040 aa 74 83 a0 01 80 74 81 a1 e0 00 00 eb fe aa 00 .t....t. ........
621 | 0050 5c 30 a8 00 8c f1 12 00 3d 15 d7 5a c4 3b 37 00 \0...... =..Z.;7.
622 | 0060 aa e0 00 00 94 f1 12 00 5d 22 d7 5a 71 22 d7 5a ........ ]".Zq".Z
623 | 0070 c4 3b 37 00 c4 3b 37 00 bc f1 12 00 1e 22 d7 5a .;7..;7. .....".Z
624 | 0080 aa e0 00 00 00 00 00 00 f6 45 d7 5a 9d 45 d7 5a ........ .E.Z.E.Z
625 | 0090 00 00 00 00 ff ff ff ff 20 f2 12 00 28 54 37 00 ........ ...(T7.
626 | 00a0 aa df c0 75 00 ...u.
627 | [...]
628 | 0040 aa 74 83 a2 ff 80 74 81 a3 e0 00 00 10 00 00 00 .t....t. ........
629 | 0050 00 00 00 00 8c f1 12 00 01 00 00 00 00 00 00 00 ........ ........
630 | 0060 aa e0 00 00 4c f1 12 00 5d 22 d7 5a dc f1 12 00 ....L... ]".Z....
631 | 0070 8f 04 44 7e 30 88 41 7e ff ff ff ff 2a 88 41 7e ..D~0.A~ ....*.A~
632 | 0080 aa e0 00 7e 00 00 00 00 69 0e 3c 00 42 01 1f 00 ...~.... i.<.B...
633 | 0090 0f 00 00 00 00 00 00 00 00 00 00 00 8c e8 67 00 ........ ......g.
634 | 00a0 aa df c0 75 00 ...u.
635 |
636 |
--------------------------------------------------------------------------------