ESP32S3 PTP + CDC Device Class Implementation using Espressif libaries "esp_tinyusb" and "tinyusb"

Job ID: 39633932

Budget: $5,000 – $10,000 AUD

The project target is to implement PTP+CDC device classes in ESP32S3 module. The PTP library can be implemented using Espressif IDF standard USB libraries "esp_tinyusb" and "tinyusb" like other device classes implementations. CDC is already done in USB library and only combining it into the USB interface is enough. The requirements are below.

Requirements
• The ESP32S3 should act as USB PTP+CDC device.
• Use IDF 5.4.x
• Use the latest libraries esp_tinyusb & tiny_usb. Add IDF menuconfig item to enable PTP like others.
• Support Windows, Linux and Mac
• Source code required.
• When USB plugged in, the PC should identify the device as follows
◦ Appear in Windows Explorer as a storage device under Devices and Drivers.
◦ Also, appear as CDC device (COM port) for Serial communication.
◦ The PTP device name as “My Device Name”
◦ The PTP device should show a custom icon on Windows explorer and Device Manager.
◦ When PTP opening the storage device, there should be two sub devices such and "Internal Storage" and "System Firmware" using multiple PTP Storage IDs.
◦ "Internal Storage" is a virtual file system which handle uploading, downloading, deleting, overwriting and renaming with progress bar in spiff file system.
◦ When uploading the file check for
▪ Invalid character “\ / : * ? " < > |”
▪ Supported file lists such as “.png”, “.dif”, “.fon”, etc.
◦ When renaming the file, check for invalid characters “\ / : * ? " < > |”
◦ In "Internal Storage", there is a specific file named "sshot000.png" which behaves differently.
◦ "System Firmware" to update the device firmware. Only uploading callback is required.

CDC Device
Espressif libraries already have this implemented. Combine it with PTP device.

Sub Device "Internal Storage"
“Internal Storage” shows total size and free space like a normal drive. This one act as a normal virtual drive and shows files with name and size. User should be able to download, upload, delete, overwrite and rename. For those file operations, the progress bars should show. The files are going to save in specific folder of the spiffs file system of the flash. The flash is slow. So, having progress bar shows users to get an idea of the file progress. On file upload request, the file name should be checked for invalid naming characters “\ / : * ? " < > |” to avoid non supported features of spiff file system. Also, need to check the file size and stop file copying operation.

In “Internal Storage”, there is a special file called "sshot000.png". This is virtual. User cannot do file operations except copying it into PC. You have to implement a PTP library event for copying this file. Inside this event, I am going create “sshot000.png” file using some parameters and pass the “sshot000.png” memory buffer pointer back into PTP lib to send this file to the PC. Once it is done, the file name should be “sshot001.png”. That means, the virtual file name has been incremented by one. This should happen in each copying of the file.

Sub Device “System Firmware”
System Firmware is not exactly a drive. It shows no volume information. When you open it, it shows no files. The user can drag and drop the .bin or .b1n file into it. When copying, needed to check file validity for .bin or .b1n file extension and file size not more than 750KB or 64KB, otherwise it should stop the copy operation. For this, a file uploading event is required for .bin or .b1n files. In that event, I can put those file chunks in specific places to update the firmware of the device. I can handle firmware update code, only file upload callback event is enough for the implementation.

Required PTP Library Callback Events
• File events for finishing of uploading, downloading, deleting, overwriting, and renaming.
• File event for copying “sshot000.png” file to pass the created png file memory pointer.
• File events for uploading of .bin and .b1n files into “System Firmware” storage device.