# HG changeset patch # User Mychaela Falconia # Date 1695840194 0 # Node ID 0787525a33e23c22388bbbb1f7b117ab0b4d9a2d # Parent b36397a56bdae85ec218211d93e0648049b194b8 cp2102-decode-ee-desc program started diff -r b36397a56bda -r 0787525a33e2 .hgignore --- a/.hgignore Wed Sep 27 18:38:10 2023 +0000 +++ b/.hgignore Wed Sep 27 18:43:14 2023 +0000 @@ -3,6 +3,7 @@ \.[oa]$ ^cp2102/cp2102-decode-baudtab$ +^cp2102/cp2102-decode-ee-desc$ ^cp2102/cp2102-read-baudtab$ ^cp2102/cp2102-read-eeprom$ ^cp2102/cp2102-read-partno$ diff -r b36397a56bda -r 0787525a33e2 cp2102/Makefile --- a/cp2102/Makefile Wed Sep 27 18:38:10 2023 +0000 +++ b/cp2102/Makefile Wed Sep 27 18:43:14 2023 +0000 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 -PROGS= cp2102-decode-baudtab cp2102-read-baudtab cp2102-read-eeprom \ - cp2102-read-partno +PROGS= cp2102-decode-baudtab cp2102-decode-ee-desc cp2102-read-baudtab \ + cp2102-read-eeprom cp2102-read-partno NOINST= file_rw_test LIBS= ../libuwrap/libuwrap.a @@ -13,6 +13,7 @@ INSTDAT=${INSTALL_PREFIX}/cp2102 DECODE_BAUDTAB_OBJS= decode_baudtab.o decode_baudtab_main.o intel_hex_in.o +DECODE_EEDESC_OBJS= decode_usb_desc.o intel_hex_in.o READ_BAUDTAB_OBJS= decode_baudtab.o read_baudtab.o read_eeprom.o READ_EEPROM_OBJS= intel_hex_out.o read_eeprom.o read_eeprom_main.o RW_TEST_OBJS= intel_hex_in.o intel_hex_out.o file_rw_test.o @@ -22,6 +23,9 @@ cp2102-decode-baudtab: ${DECODE_BAUDTAB_OBJS} ${CC} ${CFLAGS} -o $@ ${DECODE_BAUDTAB_OBJS} +cp2102-decode-ee-desc: ${DECODE_EEDESC_OBJS} + ${CC} ${CFLAGS} -o $@ ${DECODE_EEDESC_OBJS} + cp2102-read-baudtab: ${READ_BAUDTAB_OBJS} ${LIBS} ${CC} ${CFLAGS} -o $@ ${READ_BAUDTAB_OBJS} ${LIBS} -lusb diff -r b36397a56bda -r 0787525a33e2 cp2102/decode_usb_desc.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cp2102/decode_usb_desc.c Wed Sep 27 18:43:14 2023 +0000 @@ -0,0 +1,48 @@ +/* + * This program reads a CP2102 EEPROM image from an Intel HEX file + * and decodes the USB descriptors portion thereof. + */ + +#include +#include +#include +#include "cp210x_defs.h" + +u_char eeprom[SIZE_EEPROM]; + +main(argc, argv) + char **argv; +{ + if (argc != 2) { + fprintf(stderr, "usage: %s ihex-file\n", argv[0]); + exit(1); + } + read_intel_hex(argv[1]); + printf("USB device descriptor at 0x3988:\n"); + printf(" bLength: %u", eeprom[0x388]); + if (eeprom[0x388] != 18) + fputs(" (WRONG!)", stdout); + putchar('\n'); + printf(" bDescriptorType: 0x%02X", eeprom[0x389]); + if (eeprom[0x389] != 0x01) + fputs(" (WRONG!)", stdout); + putchar('\n'); + printf(" bcdUSB: 0x%02X%02X\n", + eeprom[0x38B], eeprom[0x38A]); + printf(" bDeviceClass: 0x%02X\n", eeprom[0x38C]); + printf(" bDeviceSubClass: 0x%02X\n", eeprom[0x38D]); + printf(" bDeviceProtocol: 0x%02X\n", eeprom[0x38E]); + printf(" bMaxPacketSize0: 0x%02X\n", eeprom[0x38F]); + printf(" idVendor: 0x%02X%02X\n", + eeprom[0x391], eeprom[0x390]); + printf(" idProduct: 0x%02X%02X\n", + eeprom[0x393], eeprom[0x392]); + printf(" bcdDevice: 0x%02X%02X\n", + eeprom[0x395], eeprom[0x394]); + printf(" iManufacturer: %u\n", eeprom[0x396]); + printf(" iProduct: %u\n", eeprom[0x397]); + printf(" iSerialNumber: %u\n", eeprom[0x398]); + printf(" bNumConfigurations: %u\n", eeprom[0x399]); + /* decoding of other descriptors remains to be implemented */ + exit(0); +}