CDC (Communication Device Class) Serial Class: ACM, OBEX, GSER
Currently, only the ACM function is supported, occupying three EP, of which 2 are BULK (in/out), and one is INT (in)
The BULK EP of the ACM function supports trimming packet size:
driver/usb/gadget/function/f_acm.cacm_bindusb_ep_autoconfig
acm_fs_in_desc.wMaxPacketSize = 64;
acm_fs_out_desc.wMaxPacketSize = 64;
After modification, the ACM function can select a packet size of 64 bytes for the EP (default selected packet size is 1024 bytes for the EP) 1. Kernel configuration config select “ Serial Gadget”, after compilation, it will generate u_serial.ko, usb_f_acm.ko and g_serial.ko
After loading the generated ko, the Device side will generate the corresponding device node /dev/ttyGS0, and the Host side will recognize the corresponding serial device. The testing method is as follows:
On the Linux platform, generate /dev/ttyACM0
Host side: cat /dev/ttyACM0
Device side: echo “hello world” >> /dev/ttyGS0
Host side receives hello world
The reverse is also true
Serial debugging tool
Conduct send and receive tests in a serial terminal (such as xshell)