I imagine that maybe my question is too much of a beginner, but I've researched a lot about it and I haven't found anything enlightening about it.
I use esp32-s2 in my commercial products, my devices have USB for the user to update the devices, and for now I'm only using the USB Serial feature, but I want to start using the real USB protocol, and for that I need the Custom PID for the web software I'm developing to automatically connect to my device. I already requested the PID allocated in the Espressif VID, but I still have no idea how I will enter this into the device when I have the custom PID. I already have the inclusion of the USB API in my code and I've tested codes like the following below.
[Codebox]MSC_Update.onEvent(usbEventCallback);
USB.onEvent(usbEventCallback);
USBSerial.begin();
USB.PID(0x81A4);
USB.VID(0x303A);
USB.begin();[/Codebox]
But when recognizing the device by my computer, I notice that the PID has not been changed, could someone point me out what I'm doing wrong? I want to use all the USB API so that my device is recognized by the computer with the product information (brand name, model, version, etc).
How to implement custom PID and VID?
-
- Posts: 829
- Joined: Mon Jul 22, 2019 3:20 pm
Re: How to implement custom PID and VID?
You need to set the PID & VID before you call begin. I just tested the USBSerial example, and was able to change the VID & PID this way.
Note that you can only assign one device class. If you are using USBSerial (aka USB-CDC), you will not be able to also treat that same device as an MSC. I'm not going to say this would be impossible, but you are not going to find an out of box solution for that (you would pretty much have to write your own device class).
Note that you can only assign one device class. If you are using USBSerial (aka USB-CDC), you will not be able to also treat that same device as an MSC. I'm not going to say this would be impossible, but you are not going to find an out of box solution for that (you would pretty much have to write your own device class).
-
- Posts: 13
- Joined: Tue Nov 01, 2022 8:32 pm
Re: How to implement custom PID and VID?
lbernstone wrote: ↑Thu Aug 31, 2023 8:00 pmYou need to set the PID & VID before you call begin. I just tested the USBSerial example, and was able to change the VID & PID this way.
Note that you can only assign one device class. If you are using USBSerial (aka USB-CDC), you will not be able to also treat that same device as an MSC. I'm not going to say this would be impossible, but you are not going to find an out of box solution for that (you would pretty much have to write your own device class).
I tried again following your instructions but it didn't work. I've attached screenshots so you can check. The device keeps showing up as a COM port and with another VID
- Attachments
-
- Captura de tela 2023-09-04 142422.png (13.41 KiB) Viewed 5499 times
-
- Captura de tela 2023-09-04 142513.png (14.78 KiB) Viewed 5499 times
-
- Posts: 829
- Joined: Mon Jul 22, 2019 3:20 pm
Re: How to implement custom PID and VID?
I started from the USBSerial example. Directly after the HWSerial initialization, I added the lines for VID and PID (before any other USB calls). Make sure the board settings are USB Mode: USB OTG, disable USB-CDC on boot, and upload mode is USB OTG.
Code: Select all
larryb@larryb-IdeaPad:~/esp32/arduino-esp32/libraries/USB/examples$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 0bda:c123 Realtek Semiconductor Corp. Bluetooth Radio
Bus 003 Device 002: ID 27c6:55b4 Shenzhen Goodix Technology Co.,Ltd. Fingerprint Reader
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 5986:212a Acer, Inc Integrated Camera
Bus 001 Device 017: ID dead:beef Espressif Systems ESP32S3_DEV
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
-
- Posts: 829
- Joined: Mon Jul 22, 2019 3:20 pm
Re: How to implement custom PID and VID?
Rereading your post, everything is working for you. VIDs are hex numbers, I recommend you use a 0x for your numbers. 1234 = 0x04D2
Who is online
Users browsing this forum: No registered users and 132 guests