Re: pyserial.tools.list_port improvement for FreeBSD
Date: Sat, 26 Oct 2024 23:51:26 UTC
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