espressif / esptool

Espressif SoC serial bootloader utility
https://docs.espressif.com/projects/esptool
GNU General Public License v2.0
5.6k stars 1.39k forks source link

CP2102 / USB-TO-UART chips customization functionality. (ESPTOOL-949) #1026

Closed cederom closed 3 weeks ago

cederom commented 4 weeks ago

Is your feature request related to a problem?

Describe the solution you'd like

Describe alternatives you've considered

Additional context

% uname -a
FreeBSD octagon 13.3-RELEASE-p7 FreeBSD 13.3-RELEASE-p7 GENERIC amd64

% ./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

% ./cp210x-cfg -N 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: ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d
Serial: ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d

% ./cp210x-cfg -N ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
ID 10c4:ea60 @ bus 000, dev 007:
ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d
Model: CP2102
Vendor ID: 10c4
Product ID: ea60
Name: ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
Serial: ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d

% ./cp210x-cfg
ID 10c4:ea60 @ bus 000, dev 007:
ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
Model: CP2102
Vendor ID: 10c4
Product ID: ea60
Name: ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
Serial: ESP32DEVKITC-CDR-76f24aad88225fedf7260bb4f54c525d

% ./cp210x-cfg -S ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
ID 10c4:ea60 @ bus 000, dev 007:
ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
Model: CP2102
Vendor ID: 10c4
Product ID: ea60
Name: ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
Serial: ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d

% ./cp210x-cfg
ID 10c4:ea60 @ bus 000, dev 007:
ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
Model: CP2102
Vendor ID: 10c4
Product ID: ea60
Name: ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
Serial: ESP32DEVKITC-CeDeROM-76f24aad88225fedf7260bb4f54c525d
radimkarnis commented 3 weeks ago

Hi @cederom, Thank you for the suggestion!

This is an interesting feature, but completely out of the scope of esptool.

Esptool is a utility for working with chips from the ESP family. It is agnostic to DevKit configuration and components, such as USB-to-UART bridges. What's more, this would only work for Silicon Labs cp210x chips. What about FTDI or CH340 chips?

The idea to add a serial number filter option sounds good, we'll most likely include that, but the logic to program cp210x chips has to stay in a separate package.

cederom commented 3 weeks ago

Thank you @radimkarnis :-) I thought so but I had to try this seems mandatory feature when more devices are under test but its not here yet and needs some time/work :-)

I also proposed this idea to PySerial https://github.com/pyserial/pyserial/issues/779 that you use and may leverage this functionality whenever it shows up or from another module :-)

As a big company you have better advantage to convince vendors to create this kind of tool (i.e. python module) whenever it is for CP201X or CH34XX it seems a really useful feature! :-)

zsteva commented 6 days ago

simple use udev rules (at least on linux) to make uniq symlink based on serial number of chip chip.