| 1 | /* LIBFTDI EEPROM access example |
| 2 | |
| 3 | This program is distributed under the GPL, version 2 |
| 4 | */ |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | #include <stdlib.h> |
| 8 | #include <string.h> |
| 9 | #include <ctype.h> |
| 10 | #include <unistd.h> |
| 11 | #include <getopt.h> |
| 12 | #include <ftdi.h>cxx . . $ `<file>/src/ftdi.h`/ |
| 13 | |
| 14 | int read_decode_eepromcxx . . $ read_decode_eeprom(e7991dd2c21df3a2).(struct ftdi_contextcxx . . $ ftdi_context# *ftdi) |
| 15 | { |
| 16 | int i, j, f; |
| 17 | int value; |
| 18 | int size; |
| 19 | unsigned char buf[256]; |
| 20 | |
| 21 | f = ftdi_read_eepromcxx . . $ ftdi_read_eeprom(e7991dd2c21df3a2).(ftdi); |
| 22 | if (f < 0) |
| 23 | { |
| 24 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_read_eeprom: %d (%s)\n", |
| 25 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 26 | return -1; |
| 27 | } |
| 28 | |
| 29 | |
| 30 | ftdi_get_eeprom_valuecxx . . $ ftdi_get_eeprom_value(ca60ac2514832673).(ftdi, CHIP_SIZEcxx . . $ CHIP_SIZE., & value); |
| 31 | if (value <0) |
| 32 | { |
| 33 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "No EEPROM found or EEPROM empty\n"); |
| 34 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "On empty EEPROM, use -w option to write default values\n"); |
| 35 | return -1; |
| 36 | } |
| 37 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Chip type %d ftdi_eeprom_size: %d\n", ftdi->typecxx . . $ ftdi_context#type., value); |
| 38 | if (ftdi->typecxx . . $ ftdi_context#type. == TYPE_Rcxx . . $ TYPE_R.) |
| 39 | size = 0xa0; |
| 40 | else |
| 41 | size = value; |
| 42 | ftdi_get_eeprom_bufcxx . . $ ftdi_get_eeprom_buf(d0399952b505fffc).(ftdi, buf, size); |
| 43 | for (i=0; i < size; i += 16) |
| 44 | { |
| 45 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!,"0x%03x:", i); |
| 46 | |
| 47 | for (j = 0; j< 8; j++) |
| 48 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!," %02x", buf[i+j]); |
| 49 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!," "); |
| 50 | for (; j< 16; j++) |
| 51 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!," %02x", buf[i+j]); |
| 52 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!," "); |
| 53 | for (j = 0; j< 8; j++) |
| 54 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!,"%c", isprintcxx . . $ `<external>/17904084882347303253/ctype.h:195:10`!(buf[i+j])?buf[i+j]:'.'); |
| 55 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!," "); |
| 56 | for (; j< 16; j++) |
| 57 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!,"%c", isprintcxx . . $ `<external>/17904084882347303253/ctype.h:195:10`!(buf[i+j])?buf[i+j]:'.'); |
| 58 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!,"\n"); |
| 59 | } |
| 60 | |
| 61 | f = ftdi_eeprom_decodecxx . . $ ftdi_eeprom_decode(b8d6b357325709d2).(ftdi, 1); |
| 62 | if (f < 0) |
| 63 | { |
| 64 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_eeprom_decode: %d (%s)\n", |
| 65 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 66 | return -1; |
| 67 | } |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 72 | { |
| 73 | struct ftdi_contextcxx . . $ ftdi_context# *ftdi; |
| 74 | int f, i; |
| 75 | int vid = 0; |
| 76 | int pid = 0; |
| 77 | char const *desc = 0; |
| 78 | char const *serial = 0; |
| 79 | int erase = 0; |
| 80 | int use_defaults = 0; |
| 81 | int large_chip = 0; |
| 82 | int do_write = 0; |
| 83 | int retval = 0; |
| 84 | int value; |
| 85 | |
| 86 | if ((ftdi = ftdi_newcxx . . $ ftdi_new(207ff50971a1b30).()) == 0) |
| 87 | { |
| 88 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Failed to allocate ftdi structure :%s \n", |
| 89 | ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 90 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 91 | } |
| 92 | |
| 93 | ftdi->module_detach_modecxx . . $ ftdi_context#module_detach_mode. = AUTO_DETACH_REATACH_SIO_MODULEcxx . . $ AUTO_DETACH_REATACH_SIO_MODULE.; |
| 94 | |
| 95 | while ((i = getoptcxx . . $ getopt(2483c31ff9bab884).(argc, argv, "d::ev:p:l:P:S:w")) != -1) |
| 96 | { |
| 97 | switch (i) |
| 98 | { |
| 99 | case 'd': |
| 100 | use_defaults = 1; |
| 101 | if (optargcxx . . $ optarg.) |
| 102 | large_chip = 0x66; |
| 103 | break; |
| 104 | case 'e': |
| 105 | erase = 1; |
| 106 | break; |
| 107 | case 'v': |
| 108 | vid = strtoulcxx . . $ strtoul(31746e8d6ec49860).(optargcxx . . $ optarg., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0); |
| 109 | break; |
| 110 | case 'p': |
| 111 | pid = strtoulcxx . . $ strtoul(31746e8d6ec49860).(optargcxx . . $ optarg., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0); |
| 112 | break; |
| 113 | case 'P': |
| 114 | desc = optargcxx . . $ optarg.; |
| 115 | break; |
| 116 | case 'S': |
| 117 | serial = optargcxx . . $ optarg.; |
| 118 | break; |
| 119 | case 'w': |
| 120 | do_write = 1; |
| 121 | break; |
| 122 | default: |
| 123 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "usage: %s [options]\n", *argv); |
| 124 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-d[num] Work with default valuesfor 128 Byte " |
| 125 | "EEPROM or for 256 Byte EEPROM if some [num] is given\n"); |
| 126 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-w write\n"); |
| 127 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-e erase\n"); |
| 128 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-v verbose decoding\n"); |
| 129 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-p <number> Search for device with PID == number\n"); |
| 130 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-v <number> Search for device with VID == number\n"); |
| 131 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-P <string? Search for device with given " |
| 132 | "product description\n"); |
| 133 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-S <string? Search for device with given " |
| 134 | "serial number\n"); |
| 135 | retval = -1; |
| 136 | goto done; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | // Select first interface |
| 141 | ftdi_set_interfacecxx . . $ ftdi_set_interface(73d9956508f3a98f).(ftdi, INTERFACE_ANYcxx . . $ INTERFACE_ANY.); |
| 142 | |
| 143 | if (!vid && !pid && desc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! && serial == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 144 | { |
| 145 | struct ftdi_device_listcxx . . $ ftdi_device_list# *devlist, *curdev; |
| 146 | int res; |
| 147 | if ((res = ftdi_usb_find_allcxx . . $ ftdi_usb_find_all(c44df5d38c831626).(ftdi, &devlist, 0, 0)) < 0) |
| 148 | { |
| 149 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "No FTDI with default VID/PID found\n"); |
| 150 | retval = EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 151 | goto do_deinit; |
| 152 | } |
| 153 | if (res > 1) |
| 154 | { |
| 155 | int i = 1; |
| 156 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%d FTDI devices found: Only Readout on EEPROM done. \n",res); |
| 157 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Use VID/PID/desc/serial to select device\n"); |
| 158 | for (curdev = devlist; curdev != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; curdev= curdev->nextcxx . . $ ftdi_device_list#next., i++) |
| 159 | { |
| 160 | f = ftdi_usb_open_devcxx . . $ ftdi_usb_open_dev(adb36a6e32e3138e).(ftdi, curdev->devcxx . . $ ftdi_device_list#dev.); |
| 161 | if (f<0) |
| 162 | { |
| 163 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Unable to open device %d: (%s)\n", |
| 164 | i, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 165 | continue; |
| 166 | } |
| 167 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Decoded values of device %d:\n", i); |
| 168 | read_decode_eepromcxx . . $ read_decode_eeprom(e7991dd2c21df3a2).(ftdi); |
| 169 | ftdi_usb_closecxx . . $ ftdi_usb_close(e7991dd2c21df3a2).(ftdi); |
| 170 | } |
| 171 | ftdi_list_freecxx . . $ ftdi_list_free(1a862d998d78d7c5).(&devlist); |
| 172 | retval = EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!; |
| 173 | goto do_deinit; |
| 174 | } |
| 175 | else if (res == 1) |
| 176 | { |
| 177 | f = ftdi_usb_open_devcxx . . $ ftdi_usb_open_dev(adb36a6e32e3138e).(ftdi, devlist[0].devcxx . . $ ftdi_device_list#dev.); |
| 178 | if (f<0) |
| 179 | { |
| 180 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Unable to open device %d: (%s)\n", |
| 181 | i, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 182 | } |
| 183 | } |
| 184 | else |
| 185 | { |
| 186 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "No devices found\n"); |
| 187 | f = 0; |
| 188 | } |
| 189 | ftdi_list_freecxx . . $ ftdi_list_free(1a862d998d78d7c5).(&devlist); |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | // Open device |
| 194 | f = ftdi_usb_open_desccxx . . $ ftdi_usb_open_desc(667eff1aa87ee6b2).(ftdi, vid, pid, desc, serial); |
| 195 | if (f < 0) |
| 196 | { |
| 197 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Device VID 0x%04x PID 0x%04x", vid, pid); |
| 198 | if (desc) |
| 199 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " Desc %s", desc); |
| 200 | if (serial) |
| 201 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " Serial %s", serial); |
| 202 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n"); |
| 203 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "unable to open ftdi device: %d (%s)\n", |
| 204 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 205 | |
| 206 | retval = -1; |
| 207 | goto done; |
| 208 | } |
| 209 | } |
| 210 | if (erase) |
| 211 | { |
| 212 | f = ftdi_erase_eepromcxx . . $ ftdi_erase_eeprom(e7991dd2c21df3a2).(ftdi); /* needed to determine EEPROM chip type */ |
| 213 | if (f < 0) |
| 214 | { |
| 215 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Erase failed: %s\n", |
| 216 | ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 217 | retval = -2; |
| 218 | goto done; |
| 219 | } |
| 220 | if (ftdi_get_eeprom_valuecxx . . $ ftdi_get_eeprom_value(ca60ac2514832673).(ftdi, CHIP_TYPEcxx . . $ CHIP_TYPE., & value) <0) |
| 221 | { |
| 222 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_get_eeprom_value: %d (%s)\n", |
| 223 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 224 | } |
| 225 | if (value == -1) |
| 226 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "No EEPROM\n"); |
| 227 | else if (value == 0) |
| 228 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Internal EEPROM\n"); |
| 229 | else |
| 230 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Found 93x%02x\n", value); |
| 231 | retval = 0; |
| 232 | goto done; |
| 233 | } |
| 234 | |
| 235 | if (use_defaults) |
| 236 | { |
| 237 | ftdi_eeprom_initdefaultscxx . . $ ftdi_eeprom_initdefaults(5c141c01eb1d5ff8).(ftdi, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 238 | if (ftdi_set_eeprom_valuecxx . . $ ftdi_set_eeprom_value(95f2c0b60e9f8f55).(ftdi, MAX_POWERcxx . . $ MAX_POWER., 500) <0) |
| 239 | { |
| 240 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_set_eeprom_value: %d (%s)\n", |
| 241 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 242 | } |
| 243 | if (large_chip) |
| 244 | if (ftdi_set_eeprom_valuecxx . . $ ftdi_set_eeprom_value(95f2c0b60e9f8f55).(ftdi, CHIP_TYPEcxx . . $ CHIP_TYPE., 0x66) <0) |
| 245 | { |
| 246 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_set_eeprom_value: %d (%s)\n", |
| 247 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 248 | } |
| 249 | f=(ftdi_eeprom_buildcxx . . $ ftdi_eeprom_build(e7991dd2c21df3a2).(ftdi)); |
| 250 | if (f < 0) |
| 251 | { |
| 252 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_eeprom_build: %d (%s)\n", |
| 253 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 254 | retval = -1; |
| 255 | goto done; |
| 256 | } |
| 257 | } |
| 258 | else if (do_write) |
| 259 | { |
| 260 | ftdi_eeprom_initdefaultscxx . . $ ftdi_eeprom_initdefaults(5c141c01eb1d5ff8).(ftdi, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 261 | f = ftdi_erase_eepromcxx . . $ ftdi_erase_eeprom(e7991dd2c21df3a2).(ftdi); |
| 262 | if (ftdi_set_eeprom_valuecxx . . $ ftdi_set_eeprom_value(95f2c0b60e9f8f55).(ftdi, MAX_POWERcxx . . $ MAX_POWER., 500) <0) |
| 263 | { |
| 264 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_set_eeprom_value: %d (%s)\n", |
| 265 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 266 | } |
| 267 | f = ftdi_erase_eepromcxx . . $ ftdi_erase_eeprom(e7991dd2c21df3a2).(ftdi);/* needed to determine EEPROM chip type */ |
| 268 | if (ftdi_get_eeprom_valuecxx . . $ ftdi_get_eeprom_value(ca60ac2514832673).(ftdi, CHIP_TYPEcxx . . $ CHIP_TYPE., & value) <0) |
| 269 | { |
| 270 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_get_eeprom_value: %d (%s)\n", |
| 271 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 272 | } |
| 273 | if (value == -1) |
| 274 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "No EEPROM\n"); |
| 275 | else if (value == 0) |
| 276 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Internal EEPROM\n"); |
| 277 | else |
| 278 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Found 93x%02x\n", value); |
| 279 | f=(ftdi_eeprom_buildcxx . . $ ftdi_eeprom_build(e7991dd2c21df3a2).(ftdi)); |
| 280 | if (f < 0) |
| 281 | { |
| 282 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Erase failed: %s\n", |
| 283 | ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 284 | retval = -2; |
| 285 | goto done; |
| 286 | } |
| 287 | f = ftdi_write_eepromcxx . . $ ftdi_write_eeprom(e7991dd2c21df3a2).(ftdi); |
| 288 | { |
| 289 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "ftdi_eeprom_decode: %d (%s)\n", |
| 290 | f, ftdi_get_error_stringcxx . . $ ftdi_get_error_string(318567b992c3484e).(ftdi)); |
| 291 | retval = 1; |
| 292 | goto done; |
| 293 | } |
| 294 | } |
| 295 | retval = read_decode_eepromcxx . . $ read_decode_eeprom(e7991dd2c21df3a2).(ftdi); |
| 296 | done: |
| 297 | ftdi_usb_closecxx . . $ ftdi_usb_close(e7991dd2c21df3a2).(ftdi); |
| 298 | do_deinit: |
| 299 | ftdi_freecxx . . $ ftdi_free(a4aec54891bac95c).(ftdi); |
| 300 | return retval; |
| 301 | } |