Date: Sun, 27 Oct 2024 01:51:26 +0200 From: Tomek CEDRO <tomek@cedro.info> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: hackers@freebsd.org Subject: Re: pyserial.tools.list_port improvement for FreeBSD Message-ID: <CAFYkXj=mmqKxM4zfZNj=Dv1iWmnLizLLoTEU4MppQdGidFEhxw@mail.gmail.com> In-Reply-To: <CAFYkXj==y352gjD9BrMusp8AvvhLZQo%2B5pCN5JZFYq%2BMrJLFsw@mail.gmail.com> References: <202410210954.49L9s9sD076618@critter.freebsd.dk> <203ADA8C-A4ED-4849-B89D-6D18664D67D0@webweaving.org> <CAFYkXjmzAsxLiRZNM1=A37hXKHrDRud6u0R-odxosmCg0oPMcg@mail.gmail.com> <202410221118.49MBIRSj009090@critter.freebsd.dk> <CAFYkXjk2XUc=N49=XN%2B=VA_G%2BVC4KkYUTdE4G=BQDKD86esUHg@mail.gmail.com> <202410221847.49MIlXEs014246@critter.freebsd.dk> <CAFYkXj=E=wg9q5ZW81rVLMs90hxdazRuc1j4awuCAC0Dgmjx0g@mail.gmail.com> <202410221907.49MJ7BZl014476@critter.freebsd.dk> <CAFYkXj==y352gjD9BrMusp8AvvhLZQo%2B5pCN5JZFYq%2BMrJLFsw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
By the way, most of develkits use USB-TO-UART chip that have unusable serial number because with many boards having the same VID:PID and serial number it is not possible to distinguish them o_O It would be nice to add chip customization to pyserial :-) I found two kinda broken old utilities to update CP2102 USB-TO-UART chips that may serve as reference point :-) C: https://github.com/DiUS/cp210x-cfg Python: https://github.com/cederom/cp210x-program The first one uses LibUSB 1.0. After minor tweaks on FreeBSD I made it to compile, work, and burn the new serial.. maybe I will create a Port for this nice utility :-) >From what I read this is one time only operation but that is okay I will add random stuff :-) % ./cp210x-cfg ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: 0001 % dd if=/dev/random count=1M | md5 1048576+0 records in 1048576+0 records out 76f24aad88225fedf7260bb4f54c525d 536870912 bytes transferred in 3.788303 secs (141718053 bytes/sec) % ./cp210x-cfg -h Syntax: cp210x-cfg [-h ] | [-m vid:pid] [-d bus:dev] [ -l | [-V vid] [-P pid] [-F flush] [-M mode] [-N name] [-S serial]] -h This help -m vid:pid Find and use first device with vid:pid -d bus:dev Find and use device at bus:dev -l List all CP210x devices connected -V vid Program the given Vendor ID -P pid Program the given Product ID -F flush Program the given buffer flush bitmap (CP2105 only) -M mode Program the given SCI/ECI mode (CP2105 only) -N name Program the given product name string -S serial Program the given serial string Unless the -d option is used, the first found CP210x device is used. If no programming options are used, the current values are printed. % ./cp210x-cfg -S 76f24aad88225fedf7260bb4f54c525d ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: 76f24aad88225fedf7260bb4f54c525d % ./cp210x-cfg ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: 76f24aad88225fedf7260bb4f54c525d I would not be myself not to try write serial again knowing it it supposedly one time only operation :-) % ./cp210x-cfg -S CeDeROM76f24aad88225fedf7260bb4f54c525d ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: CeDeROM76f24aad88225fedf7260bb4f54c525d % ./cp210x-cfg ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: CeDeROM76f24aad88225fedf7260bb4f54c525d % ./cp210x-cfg -S ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d % ./cp210x-cfg ID 10c4:ea60 @ bus 000, dev 007: CP2102 USB to UART Bridge Controller Model: CP2102 Vendor ID: 10c4 Product ID: ea60 Name: CP2102 USB to UART Bridge Controller Serial: ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d Very cool, looks like this chip has Flash not the OTP and we can assign whatever serial string we want :-) Have a good weekend folks :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFYkXj=mmqKxM4zfZNj=Dv1iWmnLizLLoTEU4MppQdGidFEhxw>